Skip to content

Commit

Permalink
Separate bound check test
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxli committed Jan 5, 2024
1 parent 67598e0 commit 9236d60
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class F extends ValidationTest {
}

export const g = makeTestGroup(F);
const kArrayLayerCount = 4;

g.test('attachments,one_color_attachment')
.desc(`Test that a render pass works with only one color attachment.`)
Expand Down Expand Up @@ -284,50 +285,71 @@ g.test('color_attachments,limits,maxColorAttachmentBytesPerSample,unaligned')
g.test('color_attachments,depthSlice,definedness')
.desc(
`
Test that depthSlice must be set correctly in color attachments.
- must be undefined for 2d color attachments.
- must be defined for 3d color attachments and less than the depthOrArrayLayers of texture's subresource.
Test that depthSlice must be undefined for 2d color attachments and defined for 3d color attachments."
`
)
.params(u =>
u
.combine('depthSlice', [undefined, 0, 1, 0xffffffff])
.beginSubcases()
.combine('dimension', ['2d', '3d'] as GPUTextureDimension[])
.expand('mipLevel', ({ depthSlice, dimension }) => {
// Only need to test defined depthSlice with non-zero mipLevel for 3d color attachments
return depthSlice !== undefined && dimension === '3d' ? [0, 1] : [0];
})
.beginSubcases()
.combine('depthSlice', [undefined, 0])
)
.fn(t => {
const { depthSlice, dimension, mipLevel } = t.params;
const arrayLayerCount = 2;
const { dimension, depthSlice } = t.params;
const texture = t.createTexture({ dimension });

const colorAttachment = t.getColorAttachment(texture);
if (depthSlice !== undefined) {
colorAttachment.depthSlice = depthSlice;
}

const descriptor: GPURenderPassDescriptor = {
colorAttachments: [colorAttachment],
};

const success =
(dimension === '2d' && depthSlice === undefined) ||
(dimension === '3d' && depthSlice !== undefined);

t.tryRenderPass(success, descriptor);
});

g.test('color_attachments,depthSlice,bound_check')
.desc(
`
Test that depthSlice must be less than the depthOrArrayLayers of 3d texture's subresource at mip levels.
`
)
.params(u =>
u
.combine('mipLevel', [0, 1, 2])
.beginSubcases()
.combine('depthSlice', [0, 1, kArrayLayerCount - 1, kArrayLayerCount, 0xffffffff])
)
.fn(t => {
const { mipLevel, depthSlice } = t.params;

const texture = t.createTexture({
arrayLayerCount,
dimension,
mipLevelCount: mipLevel + 1,
dimension: '3d',
arrayLayerCount: kArrayLayerCount,
mipLevelCount: 3,
});

const viewDescriptor: GPUTextureViewDescriptor = {
dimension,
baseMipLevel: mipLevel,
mipLevelCount: 1,
baseArrayLayer: 0,
arrayLayerCount: 1,
};

const colorAttachment = t.getColorAttachment(texture, viewDescriptor);
if (depthSlice !== undefined) {
colorAttachment.depthSlice = depthSlice;
}
colorAttachment.depthSlice = depthSlice;

const passDescriptor: GPURenderPassDescriptor = {
colorAttachments: [colorAttachment],
};

const success =
(dimension === '2d' && depthSlice === undefined) ||
(dimension === '3d' && depthSlice !== undefined && depthSlice < arrayLayerCount >> mipLevel);
const success = depthSlice < kArrayLayerCount >> mipLevel;

t.tryRenderPass(success, passDescriptor);
});
Expand Down
3 changes: 2 additions & 1 deletion src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,8 @@
"webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,empty:*": { "subcaseMS": 0.400 },
"webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,limits,maxColorAttachmentBytesPerSample,aligned:*": { "subcaseMS": 1.825 },
"webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,limits,maxColorAttachmentBytesPerSample,unaligned:*": { "subcaseMS": 17.151 },
"webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,depthSlice,base:*": { "subcaseMS": 5.800 },
"webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,depthSlice,definedness:*": { "subcaseMS": 5.601 },
"webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,depthSlice,bound_check:*": { "subcaseMS": 9.400 },
"webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,depthSlice,overlaps,same_miplevel:*": { "subcaseMS": 6.400 },
"webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,depthSlice,overlaps,diff_miplevel:*": { "subcaseMS": 3.901 },
"webgpu:api,validation,render_pass,render_pass_descriptor:color_attachments,limits,maxColorAttachments:*": { "subcaseMS": 0.950 },
Expand Down

0 comments on commit 9236d60

Please sign in to comment.