Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat image copy test depth stencil #3192

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions src/webgpu/api/operation/command_buffer/image_copy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,10 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
copySize
);

const use2DArray = this.isCompatibility && inputTexture.depthOrArrayLayers > 1;
const [textureType, layerCode] = use2DArray
? ['texture_2d_array', ', baseArrayLayer']
: ['texture_2d', ''];
const renderPipeline = this.device.createRenderPipeline({
layout: 'auto',
vertex: {
Expand All @@ -1154,10 +1158,11 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
fragment: {
module: this.device.createShaderModule({
code: `
@group(0) @binding(0) var inputTexture: texture_2d<f32>;
@group(0) @binding(0) var inputTexture: ${textureType}<f32>;
@group(0) @binding(1) var<uniform> baseArrayLayer: u32;
@fragment fn main(@builtin(position) fragcoord : vec4<f32>) ->
@builtin(frag_depth) f32 {
var depthValue : vec4<f32> = textureLoad(inputTexture, vec2<i32>(fragcoord.xy), 0);
var depthValue : vec4<f32> = textureLoad(inputTexture, vec2<i32>(fragcoord.xy)${layerCode}, 0);
return depthValue.x;
}`,
}),
Expand Down Expand Up @@ -1200,19 +1205,26 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
});
renderPass.setPipeline(renderPipeline);

const uniformBufferEntry = use2DArray
? [this.createUniformBufferAndBindGroupEntryForBaseArrayLayer(z)]
: [];

const bindGroup = this.device.createBindGroup({
layout: renderPipeline.getBindGroupLayout(0),
entries: [
{
binding: 0,
resource: inputTexture.createView({
dimension: '2d',
baseArrayLayer: z,
arrayLayerCount: 1,
dimension: use2DArray ? '2d-array' : '2d',
...(use2DArray && {
baseArrayLayer: z,
arrayLayerCount: 1,
}),
baseMipLevel: 0,
mipLevelCount: 1,
}),
},
...uniformBufferEntry,
],
});
renderPass.setBindGroup(0, bindGroup);
Expand All @@ -1223,6 +1235,23 @@ class ImageCopyTest extends TextureTestMixin(GPUTest) {
this.queue.submit([encoder.finish()]);
}

createUniformBufferAndBindGroupEntryForBaseArrayLayer(z: number) {
const buffer = this.device.createBuffer({
usage: GPUBufferUsage.UNIFORM,
size: 4,
mappedAtCreation: true,
});
this.trackForCleanup(buffer);
new Uint32Array(buffer.getMappedRange()).set([z]);
buffer.unmap();
return {
binding: 1,
resource: {
buffer,
},
};
}

DoCopyTextureToBufferWithDepthAspectTest(
format: DepthStencilFormat,
copySize: readonly [number, number, number],
Expand Down Expand Up @@ -1413,7 +1442,6 @@ bytes in copy works for every format.
.beforeAllSubcases(t => {
const info = kTextureFormatInfo[t.params.format];
t.skipIfTextureFormatNotSupported(t.params.format);
t.skipIfCopyTextureToTextureNotSupportedForFormat(t.params.format);
t.selectDeviceOrSkipTestCase(info.feature);
})
.fn(t => {
Expand Down Expand Up @@ -1511,7 +1539,6 @@ works for every format with 2d and 2d-array textures.
.beforeAllSubcases(t => {
const info = kTextureFormatInfo[t.params.format];
t.skipIfTextureFormatNotSupported(t.params.format);
t.skipIfCopyTextureToTextureNotSupportedForFormat(t.params.format);
t.selectDeviceOrSkipTestCase(info.feature);
})
.fn(t => {
Expand Down Expand Up @@ -1592,7 +1619,6 @@ for all formats. We pass origin and copyExtent as [number, number, number].`
.beforeAllSubcases(t => {
const info = kTextureFormatInfo[t.params.format];
t.skipIfTextureFormatNotSupported(t.params.format);
t.skipIfCopyTextureToTextureNotSupportedForFormat(t.params.format);
t.selectDeviceOrSkipTestCase(info.feature);
})
.fn(t => {
Expand Down Expand Up @@ -1793,7 +1819,6 @@ TODO: Make a variant for depth-stencil formats.
.beforeAllSubcases(t => {
const info = kTextureFormatInfo[t.params.format];
t.skipIfTextureFormatNotSupported(t.params.format);
t.skipIfCopyTextureToTextureNotSupportedForFormat(t.params.format);
t.selectDeviceOrSkipTestCase(info.feature);
})
.fn(t => {
Expand Down