Skip to content

Commit 09793fc

Browse files
authored
Test zero levels or layers is invalid in render_pass,resolve:resolve_attachment (gpuweb#1600)
This PR adds test cases that check mipsLevelCount: 0 and arrayLayerCount: 0 to the render_pass,resolve:resolve_attachment test. A validation error should be generated if resolveTargetViewMipCount or resolveTargetViewArrayLayerCount is 0. Issue: 1599
1 parent daf0dab commit 09793fc

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/webgpu/api/validation/render_pass/resolve.spec.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Test various validation behaviors when a resolveTarget is provided.
2222
- resolve target must have exactly one subresource:
2323
- base mip level {0, >0}, mip level count {1, >1}.
2424
- base array layer {0, >0}, array layer count {1, >1}.
25-
- TODO: test zero subresources
25+
- resolve target GPUTextureView is invalid
2626
- resolve source and target have different formats.
2727
- rgba8unorm -> {bgra8unorm, rgba8unorm-srgb}
2828
- {bgra8unorm, rgba8unorm-srgb} -> rgba8unorm
@@ -46,6 +46,8 @@ Test various validation behaviors when a resolveTarget is provided.
4646
resolveTargetWidth: 4,
4747
_valid: true,
4848
},
49+
// a validation error should be created when resolveTarget is invalid.
50+
{ resolveTargetInvalid: true, _valid: false },
4951
// a validation error should be created when mip count > 1
5052
{ resolveTargetViewMipCount: 2, _valid: false },
5153
{
@@ -81,6 +83,7 @@ Test various validation behaviors when a resolveTarget is provided.
8183
colorAttachmentSamples = 4,
8284
resolveTargetSamples = 1,
8385
resolveTargetUsage = GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
86+
resolveTargetInvalid = false,
8487
resolveTargetViewMipCount = 1,
8588
resolveTargetViewBaseMipLevel = 0,
8689
resolveTargetViewArrayLayerCount = 1,
@@ -101,8 +104,8 @@ Test various validation behaviors when a resolveTarget is provided.
101104
colorAttachmentSlot < kNumColorAttachments;
102105
colorAttachmentSlot++
103106
) {
104-
// resolveSlot === colorAttachmentSlot denotes the color attachment slot that contains the color attachment with resolve
105-
// target.
107+
// resolveSlot === colorAttachmentSlot denotes the color attachment slot that contains the
108+
// color attachment with resolve target.
106109
if (resolveSlot === colorAttachmentSlot) {
107110
// Create the color attachment with resolve target with the configurable parameters.
108111
const resolveSourceColorAttachment = t.device.createTexture({
@@ -133,13 +136,15 @@ Test various validation behaviors when a resolveTarget is provided.
133136
view: resolveSourceColorAttachment.createView(),
134137
loadOp: 'load',
135138
storeOp: 'discard',
136-
resolveTarget: resolveTarget.createView({
137-
dimension: resolveTargetViewArrayLayerCount === 1 ? '2d' : '2d-array',
138-
mipLevelCount: resolveTargetViewMipCount,
139-
arrayLayerCount: resolveTargetViewArrayLayerCount,
140-
baseMipLevel: resolveTargetViewBaseMipLevel,
141-
baseArrayLayer: resolveTargetViewBaseArrayLayer,
142-
}),
139+
resolveTarget: resolveTargetInvalid
140+
? t.getErrorTextureView()
141+
: resolveTarget.createView({
142+
dimension: resolveTargetViewArrayLayerCount === 1 ? '2d' : '2d-array',
143+
mipLevelCount: resolveTargetViewMipCount,
144+
arrayLayerCount: resolveTargetViewArrayLayerCount,
145+
baseMipLevel: resolveTargetViewBaseMipLevel,
146+
baseArrayLayer: resolveTargetViewBaseArrayLayer,
147+
}),
143148
});
144149
} else {
145150
// Create a basic texture to fill other color attachment slots. This texture's dimensions

0 commit comments

Comments
 (0)