Skip to content

Commit 0dd5a91

Browse files
Test view is default if texture is used instead of view
1 parent 5b47767 commit 0dd5a91

File tree

3 files changed

+63
-26
lines changed

3 files changed

+63
-26
lines changed

src/webgpu/api/operation/render_pass/clear_value.spec.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,17 @@ g.test('stencil_clear_value')
3232
.combine('stencilFormat', kStencilTextureFormats)
3333
.combine('stencilClearValue', [0, 1, 0xff, 0x100 + 2, 0x10000 + 3])
3434
.combine('applyStencilClearValueAsStencilReferenceValue', [true, false])
35+
.combine('createStencilTextureView', [false, true] as const)
36+
.combine('createColorTextureView', [false, true] as const)
3537
)
3638
.fn(t => {
37-
const { stencilFormat, stencilClearValue, applyStencilClearValueAsStencilReferenceValue } =
38-
t.params;
39+
const {
40+
stencilFormat,
41+
stencilClearValue,
42+
applyStencilClearValueAsStencilReferenceValue,
43+
createStencilTextureView,
44+
createColorTextureView,
45+
} = t.params;
3946

4047
t.skipIfTextureFormatNotSupported(stencilFormat);
4148

@@ -112,7 +119,7 @@ g.test('stencil_clear_value')
112119
const encoder = t.device.createCommandEncoder();
113120

114121
const depthStencilAttachment: GPURenderPassDepthStencilAttachment = {
115-
view: stencilTexture.createView(),
122+
view: createStencilTextureView ? stencilTexture.createView() : stencilTexture,
116123
depthClearValue: 0,
117124
stencilLoadOp: 'clear',
118125
stencilStoreOp: 'store',
@@ -126,7 +133,7 @@ g.test('stencil_clear_value')
126133
const renderPassEncoder = encoder.beginRenderPass({
127134
colorAttachments: [
128135
{
129-
view: colorTexture.createView(),
136+
view: createColorTextureView ? colorTexture.createView() : colorTexture,
130137
loadOp: 'clear',
131138
storeOp: 'store',
132139
clearValue: [1, 0, 0, 1] as const,

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

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ Test basic render pass resolve behavior for combinations of:
4444
.combine('slotsToResolve', kSlotsToResolve)
4545
.combine('resolveTargetBaseMipLevel', [0, 1] as const)
4646
.combine('resolveTargetBaseArrayLayer', [0, 1] as const)
47+
.combine('createColorAttachmentView', [false, true] as const)
48+
.combine('createResolveTargetTextureView', [false, true] as const)
49+
.unless(
50+
p =>
51+
!p.createResolveTargetTextureView &&
52+
(p.resolveTargetBaseMipLevel !== 0 || p.resolveTargetBaseArrayLayer !== 0)
53+
)
4754
)
4855
.fn(t => {
4956
const targets: GPUColorTargetState[] = [];
@@ -108,18 +115,23 @@ Test basic render pass resolve behavior for combinations of:
108115
const kResolveTargetSize = kSize << t.params.resolveTargetBaseMipLevel;
109116

110117
for (let i = 0; i < t.params.numColorAttachments; i++) {
111-
const colorAttachment = t
112-
.createTextureTracked({
113-
format: kFormat,
114-
size: [kSize, kSize, 1],
115-
sampleCount: 4,
116-
mipLevelCount: 1,
117-
usage:
118-
GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
119-
})
120-
.createView();
121-
122-
let resolveTarget: GPUTextureView | undefined;
118+
const colorAttachmentTexture = t.createTextureTracked({
119+
format: kFormat,
120+
size: [kSize, kSize, 1],
121+
sampleCount: 4,
122+
mipLevelCount: 1,
123+
usage:
124+
GPUTextureUsage.COPY_DST | GPUTextureUsage.COPY_SRC | GPUTextureUsage.RENDER_ATTACHMENT,
125+
});
126+
127+
let colorAttachment: GPUTexture | GPUTextureView;
128+
if (t.params.createResolveTargetTextureView) {
129+
colorAttachment = colorAttachmentTexture.createView();
130+
} else {
131+
colorAttachment = colorAttachmentTexture;
132+
}
133+
134+
let resolveTarget: GPUTexture | GPUTextureView | undefined;
123135
if (t.params.slotsToResolve.includes(i)) {
124136
const resolveTargetTexture = t.createTextureTracked({
125137
format: kFormat,
@@ -130,10 +142,14 @@ Test basic render pass resolve behavior for combinations of:
130142
});
131143
resolveTargets.push(resolveTargetTexture);
132144

133-
resolveTarget = resolveTargetTexture.createView({
134-
baseMipLevel: t.params.resolveTargetBaseMipLevel,
135-
baseArrayLayer: t.params.resolveTargetBaseArrayLayer,
136-
});
145+
if (t.params.createResolveTargetTextureView) {
146+
resolveTarget = resolveTargetTexture.createView({
147+
baseMipLevel: t.params.resolveTargetBaseMipLevel,
148+
baseArrayLayer: t.params.resolveTargetBaseArrayLayer,
149+
});
150+
} else {
151+
resolveTarget = resolveTargetTexture;
152+
}
137153
}
138154

139155
// Clear to black for the load operation. After the draw, the top left half of the attachment

src/webgpu/api/operation/texture_view/write.spec.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const kTextureSize = 16;
7272
function writeTextureAndGetExpectedTexelView(
7373
t: GPUTest,
7474
method: TextureViewWriteMethod,
75-
view: GPUTextureView,
75+
view: GPUTexture | GPUTextureView,
7676
format: RegularTextureFormat,
7777
sampleCount: number
7878
) {
@@ -334,10 +334,19 @@ TODO: Test rgb10a2uint when TexelRepresentation.numericRange is made per-compone
334334

335335
return true;
336336
})
337-
.combine('viewUsageMethod', kTextureViewUsageMethods)
337+
.combine('bindTextureResource', [false, true] as const)
338+
.expand('viewUsageMethod', function* ({ bindTextureResource }) {
339+
if (bindTextureResource) {
340+
yield;
341+
} else {
342+
for (const method of kTextureViewUsageMethods) {
343+
yield method;
344+
}
345+
}
346+
})
338347
)
339348
.fn(t => {
340-
const { format, method, sampleCount, viewUsageMethod } = t.params;
349+
const { format, method, sampleCount, bindTextureResource, viewUsageMethod } = t.params;
341350
t.skipIfTextureFormatNotSupported(format);
342351
if (sampleCount > 1) {
343352
t.skipIfTextureFormatNotMultisampled(format);
@@ -377,9 +386,14 @@ TODO: Test rgb10a2uint when TexelRepresentation.numericRange is made per-compone
377386
sampleCount,
378387
});
379388

380-
const view = texture.createView({
381-
usage: getTextureViewUsage(viewUsageMethod, textureUsageForMethod),
382-
});
389+
let view: GPUTexture | GPUTextureView;
390+
if (bindTextureResource) {
391+
view = texture;
392+
} else {
393+
view = texture.createView({
394+
usage: getTextureViewUsage(viewUsageMethod!, textureUsageForMethod),
395+
});
396+
}
383397
const expectedTexelView = writeTextureAndGetExpectedTexelView(
384398
t,
385399
method,

0 commit comments

Comments
 (0)