summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/resource_usages/texture/in_render_common.spec.ts
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
commit59203c63bb777a3bacec32fb8830fba33540e809 (patch)
tree58298e711c0ff0575818c30485b44a2f21bf28a0 /dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/resource_usages/texture/in_render_common.spec.ts
parentAdding upstream version 126.0.1. (diff)
downloadfirefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz
firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/resource_usages/texture/in_render_common.spec.ts')
-rw-r--r--dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/resource_usages/texture/in_render_common.spec.ts101
1 files changed, 69 insertions, 32 deletions
diff --git a/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/resource_usages/texture/in_render_common.spec.ts b/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/resource_usages/texture/in_render_common.spec.ts
index 0c41098556..120aadfb07 100644
--- a/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/resource_usages/texture/in_render_common.spec.ts
+++ b/dom/webgpu/tests/cts/checkout/src/webgpu/api/validation/resource_usages/texture/in_render_common.spec.ts
@@ -6,6 +6,21 @@ import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { assert, unreachable } from '../../../../../common/util/util.js';
import { ValidationTest } from '../../validation_test.js';
+export type TextureBindingType =
+ | 'sampled-texture'
+ | 'writeonly-storage-texture'
+ | 'readonly-storage-texture'
+ | 'readwrite-storage-texture';
+export const kTextureBindingTypes = [
+ 'sampled-texture',
+ 'writeonly-storage-texture',
+ 'readonly-storage-texture',
+ 'readwrite-storage-texture',
+] as const;
+export function IsReadOnlyTextureBindingType(t: TextureBindingType): boolean {
+ return t === 'sampled-texture' || t === 'readonly-storage-texture';
+}
+
class F extends ValidationTest {
getColorAttachment(
texture: GPUTexture,
@@ -23,21 +38,35 @@ class F extends ValidationTest {
createBindGroupForTest(
textureView: GPUTextureView,
- textureUsage: 'texture' | 'storage',
- sampleType: 'float' | 'depth' | 'uint'
+ textureUsage: TextureBindingType,
+ sampleType: 'unfilterable-float' | 'depth' | 'uint'
) {
const bindGroupLayoutEntry: GPUBindGroupLayoutEntry = {
binding: 0,
visibility: GPUShaderStage.FRAGMENT,
};
switch (textureUsage) {
- case 'texture':
+ case 'sampled-texture':
bindGroupLayoutEntry.texture = { viewDimension: '2d-array', sampleType };
break;
- case 'storage':
+ case 'readonly-storage-texture':
+ bindGroupLayoutEntry.storageTexture = {
+ access: 'read-only',
+ format: 'r32float',
+ viewDimension: '2d-array',
+ };
+ break;
+ case 'readwrite-storage-texture':
+ bindGroupLayoutEntry.storageTexture = {
+ access: 'read-write',
+ format: 'r32float',
+ viewDimension: '2d-array',
+ };
+ break;
+ case 'writeonly-storage-texture':
bindGroupLayoutEntry.storageTexture = {
access: 'write-only',
- format: 'rgba8unorm',
+ format: 'r32float',
viewDimension: '2d-array',
};
break;
@@ -89,7 +118,7 @@ g.test('subresources,color_attachments')
const { layer0, level0, layer1, level1, inSamePass } = t.params;
const texture = t.device.createTexture({
- format: 'rgba8unorm',
+ format: 'r32float',
usage: GPUTextureUsage.RENDER_ATTACHMENT,
size: [kTextureSize, kTextureSize, kTextureLayers],
mipLevelCount: kTextureLevels,
@@ -152,8 +181,8 @@ g.test('subresources,color_attachment_and_bind_group')
{ bgLayer: 1, bgLayerCount: 1 },
{ bgLayer: 1, bgLayerCount: 2 },
])
- .combine('bgUsage', ['texture', 'storage'] as const)
- .unless(t => t.bgUsage === 'storage' && t.bgLevelCount > 1)
+ .combine('bgUsage', kTextureBindingTypes)
+ .unless(t => t.bgUsage !== 'sampled-texture' && t.bgLevelCount > 1)
.combine('inSamePass', [true, false])
)
.fn(t => {
@@ -169,7 +198,7 @@ g.test('subresources,color_attachment_and_bind_group')
} = t.params;
const texture = t.device.createTexture({
- format: 'rgba8unorm',
+ format: 'r32float',
usage:
GPUTextureUsage.RENDER_ATTACHMENT |
GPUTextureUsage.TEXTURE_BINDING |
@@ -184,7 +213,7 @@ g.test('subresources,color_attachment_and_bind_group')
baseMipLevel: bgLevel,
mipLevelCount: bgLevelCount,
});
- const bindGroup = t.createBindGroupForTest(bindGroupView, bgUsage, 'float');
+ const bindGroup = t.createBindGroupForTest(bindGroupView, bgUsage, 'unfilterable-float');
const colorAttachment = t.getColorAttachment(texture, {
dimension: '2d',
@@ -205,7 +234,7 @@ g.test('subresources,color_attachment_and_bind_group')
renderPass.end();
const texture2 = t.device.createTexture({
- format: 'rgba8unorm',
+ format: 'r32float',
usage: GPUTextureUsage.RENDER_ATTACHMENT,
size: [kTextureSize, kTextureSize, 1],
mipLevelCount: 1,
@@ -261,7 +290,8 @@ g.test('subresources,depth_stencil_attachment_and_bind_group')
{ bgLayer: 1, bgLayerCount: 2 },
])
.beginSubcases()
- .combine('dsReadOnly', [true, false])
+ .combine('depthReadOnly', [true, false])
+ .combine('stencilReadOnly', [true, false])
.combine('bgAspect', ['depth-only', 'stencil-only'] as const)
.combine('inSamePass', [true, false])
)
@@ -273,7 +303,8 @@ g.test('subresources,depth_stencil_attachment_and_bind_group')
bgLevelCount,
bgLayer,
bgLayerCount,
- dsReadOnly,
+ depthReadOnly,
+ stencilReadOnly,
bgAspect,
inSamePass,
} = t.params;
@@ -293,7 +324,7 @@ g.test('subresources,depth_stencil_attachment_and_bind_group')
aspect: bgAspect,
});
const sampleType = bgAspect === 'depth-only' ? 'depth' : 'uint';
- const bindGroup = t.createBindGroupForTest(bindGroupView, 'texture', sampleType);
+ const bindGroup = t.createBindGroupForTest(bindGroupView, 'sampled-texture', sampleType);
const attachmentView = texture.createView({
dimension: '2d',
@@ -304,12 +335,12 @@ g.test('subresources,depth_stencil_attachment_and_bind_group')
});
const depthStencilAttachment: GPURenderPassDepthStencilAttachment = {
view: attachmentView,
- depthReadOnly: dsReadOnly,
- depthLoadOp: dsReadOnly ? undefined : 'load',
- depthStoreOp: dsReadOnly ? undefined : 'store',
- stencilReadOnly: dsReadOnly,
- stencilLoadOp: dsReadOnly ? undefined : 'load',
- stencilStoreOp: dsReadOnly ? undefined : 'store',
+ depthReadOnly,
+ depthLoadOp: depthReadOnly ? undefined : 'load',
+ depthStoreOp: depthReadOnly ? undefined : 'store',
+ stencilReadOnly,
+ stencilLoadOp: stencilReadOnly ? undefined : 'load',
+ stencilStoreOp: stencilReadOnly ? undefined : 'store',
};
const encoder = t.device.createCommandEncoder();
@@ -350,8 +381,11 @@ g.test('subresources,depth_stencil_attachment_and_bind_group')
bgLayer + bgLayerCount - 1
);
const isNotOverlapped = isMipLevelNotOverlapped || isArrayLayerNotOverlapped;
+ const readonly =
+ (bgAspect === 'stencil-only' && stencilReadOnly) ||
+ (bgAspect === 'depth-only' && depthReadOnly);
- const success = !inSamePass || isNotOverlapped || dsReadOnly;
+ const success = !inSamePass || isNotOverlapped || readonly;
t.expectValidationError(() => {
encoder.finish();
}, !success);
@@ -388,20 +422,21 @@ g.test('subresources,multiple_bind_groups')
{ base: 1, count: 1 },
{ base: 1, count: 2 },
])
- .combine('bgUsage0', ['texture', 'storage'] as const)
- .combine('bgUsage1', ['texture', 'storage'] as const)
+ .combine('bgUsage0', kTextureBindingTypes)
+ .combine('bgUsage1', kTextureBindingTypes)
.unless(
t =>
- (t.bgUsage0 === 'storage' && t.bg0Levels.count > 1) ||
- (t.bgUsage1 === 'storage' && t.bg1Levels.count > 1)
+ (t.bgUsage0 !== 'sampled-texture' && t.bg0Levels.count > 1) ||
+ (t.bgUsage1 !== 'sampled-texture' && t.bg1Levels.count > 1)
)
+ .beginSubcases()
.combine('inSamePass', [true, false])
)
.fn(t => {
const { bg0Levels, bg0Layers, bg1Levels, bg1Layers, bgUsage0, bgUsage1, inSamePass } = t.params;
const texture = t.device.createTexture({
- format: 'rgba8unorm',
+ format: 'r32float',
usage: GPUTextureUsage.STORAGE_BINDING | GPUTextureUsage.TEXTURE_BINDING,
size: [kTextureSize, kTextureSize, kTextureLayers],
mipLevelCount: kTextureLevels,
@@ -420,11 +455,11 @@ g.test('subresources,multiple_bind_groups')
baseMipLevel: bg1Levels.base,
mipLevelCount: bg1Levels.count,
});
- const bindGroup0 = t.createBindGroupForTest(bg0, bgUsage0, 'float');
- const bindGroup1 = t.createBindGroupForTest(bg1, bgUsage1, 'float');
+ const bindGroup0 = t.createBindGroupForTest(bg0, bgUsage0, 'unfilterable-float');
+ const bindGroup1 = t.createBindGroupForTest(bg1, bgUsage1, 'unfilterable-float');
const colorTexture = t.device.createTexture({
- format: 'rgba8unorm',
+ format: 'r32float',
usage: GPUTextureUsage.RENDER_ATTACHMENT,
size: [kTextureSize, kTextureSize, 1],
mipLevelCount: 1,
@@ -449,6 +484,8 @@ g.test('subresources,multiple_bind_groups')
renderPass2.end();
}
+ const bothReadOnly =
+ IsReadOnlyTextureBindingType(bgUsage0) && IsReadOnlyTextureBindingType(bgUsage1);
const isMipLevelNotOverlapped = t.isRangeNotOverlapped(
bg0Levels.base,
bg0Levels.base + bg0Levels.count - 1,
@@ -463,7 +500,7 @@ g.test('subresources,multiple_bind_groups')
);
const isNotOverlapped = isMipLevelNotOverlapped || isArrayLayerNotOverlapped;
- const success = !inSamePass || isNotOverlapped || bgUsage0 === bgUsage1;
+ const success = !inSamePass || bothReadOnly || isNotOverlapped || bgUsage0 === bgUsage1;
t.expectValidationError(() => {
encoder.finish();
}, !success);
@@ -531,8 +568,8 @@ g.test('subresources,depth_stencil_texture_in_bind_groups')
const sampleType0 = aspect0 === 'depth-only' ? 'depth' : 'uint';
const sampleType1 = aspect1 === 'depth-only' ? 'depth' : 'uint';
- const bindGroup0 = t.createBindGroupForTest(bindGroupView0, 'texture', sampleType0);
- const bindGroup1 = t.createBindGroupForTest(bindGroupView1, 'texture', sampleType1);
+ const bindGroup0 = t.createBindGroupForTest(bindGroupView0, 'sampled-texture', sampleType0);
+ const bindGroup1 = t.createBindGroupForTest(bindGroupView1, 'sampled-texture', sampleType1);
const colorTexture = t.device.createTexture({
format: 'rgba8unorm',