Skip to content

Commit

Permalink
Add missing tests for adapter capability guarantees (#3107)
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois authored Oct 30, 2023
1 parent 2ef3f32 commit 3dbe4ce
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Tests for capability checking for features enabling optional texture formats.
`;

import { makeTestGroup } from '../../../../../common/framework/test_group.js';
import { getGPU } from '../../../../../common/util/navigator_gpu.js';
import { assert } from '../../../../../common/util/util.js';
import { kAllTextureFormats, kTextureFormatInfo } from '../../../../format_info.js';
import { kAllCanvasTypes, createCanvas } from '../../../../util/create_elements.js';
Expand Down Expand Up @@ -437,3 +438,18 @@ g.test('render_bundle_encoder_descriptor_depth_stencil_format')
});
});
});

g.test('check_capability_guarantees')
.desc(
`check "texture-compression-bc" is supported or both "texture-compression-etc2" and "texture-compression-astc" are supported.`
)
.fn(async t => {
const adapter = await getGPU(t.rec).requestAdapter();
assert(adapter !== null);

const features = adapter.features;
t.expect(
features.has('texture-compression-bc') ||
(features.has('texture-compression-etc2') && features.has('texture-compression-astc'))
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,11 @@ g.test('setBindGroup,at_over')
}
);
});

g.test('validate,maxBindGroupsPlusVertexBuffers')
.desc(`Test that ${limit} <= maxBindGroupsPlusVertexBuffers`)
.fn(t => {
const { adapter, defaultLimit, adapterLimit } = t;
t.expect(defaultLimit <= t.getDefaultLimit('maxBindGroupsPlusVertexBuffers'));
t.expect(adapterLimit <= adapter.limits.maxBindGroupsPlusVertexBuffers);
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ g.test('createComputePipeline,at_over')
const { limitTest, testValueName, async } = t.params;
await t.testMaxComputeWorkgroupSize(limitTest, testValueName, async, 'X');
});

g.test('validate,maxComputeInvocationsPerWorkgroup')
.desc(`Test that ${limit} <= maxComputeInvocationsPerWorkgroup`)
.fn(t => {
const { adapter, defaultLimit, adapterLimit } = t;
t.expect(defaultLimit <= t.getDefaultLimit('maxComputeInvocationsPerWorkgroup'));
t.expect(adapterLimit <= adapter.limits.maxComputeInvocationsPerWorkgroup);
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ g.test('createComputePipeline,at_over')
const { limitTest, testValueName, async } = t.params;
await t.testMaxComputeWorkgroupSize(limitTest, testValueName, async, 'Y');
});

g.test('validate,maxComputeInvocationsPerWorkgroup')
.desc(`Test that ${limit} <= maxComputeInvocationsPerWorkgroup`)
.fn(t => {
const { adapter, defaultLimit, adapterLimit } = t;
t.expect(defaultLimit <= t.getDefaultLimit('maxComputeInvocationsPerWorkgroup'));
t.expect(adapterLimit <= adapter.limits.maxComputeInvocationsPerWorkgroup);
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ g.test('createComputePipeline,at_over')
const { limitTest, testValueName, async } = t.params;
await t.testMaxComputeWorkgroupSize(limitTest, testValueName, async, 'Z');
});

g.test('validate,maxComputeInvocationsPerWorkgroup')
.desc(`Test that ${limit} <= maxComputeInvocationsPerWorkgroup`)
.fn(t => {
const { adapter, defaultLimit, adapterLimit } = t;
t.expect(defaultLimit <= t.getDefaultLimit('maxComputeInvocationsPerWorkgroup'));
t.expect(adapterLimit <= adapter.limits.maxComputeInvocationsPerWorkgroup);
});
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,21 @@ g.test('dispatchWorkgroups,at_over')
}
);
});

g.test('validate')
.desc(
`Test that ${limit} <= maxComputeWorkgroupSizeX x maxComputeWorkgroupSizeY x maxComputeWorkgroupSizeZ`
)
.fn(t => {
const { adapter, defaultLimit, adapterLimit } = t;
const defaultMaxComputeWorkgroupSizeProduct =
t.getDefaultLimit('maxComputeWorkgroupSizeX') *
t.getDefaultLimit('maxComputeWorkgroupSizeY') *
t.getDefaultLimit('maxComputeWorkgroupSizeZ');
const maxComputeWorkgroupSizeProduct =
adapter.limits.maxComputeWorkgroupSizeX *
adapter.limits.maxComputeWorkgroupSizeY *
adapter.limits.maxComputeWorkgroupSizeZ;
t.expect(defaultLimit <= defaultMaxComputeWorkgroupSizeProduct);
t.expect(adapterLimit <= maxComputeWorkgroupSizeProduct);
});
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ g.test('createBindGroup,at_over')
);
});

g.test('validate')
.desc(`Test that ${limit} is a multiple of 4 bytes`)
.fn(t => {
const { defaultLimit, adapterLimit } = t;
t.expect(defaultLimit % 4 === 0);
t.expect(adapterLimit % 4 === 0);
});

g.test('validate,maxBufferSize')
.desc(`Test that ${limit} <= maxBufferSize`)
.fn(t => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,11 @@ g.test('createRenderPipeline,at_over')
}
);
});

g.test('validate')
.desc(`Test that ${limit} is a multiple of 4 bytes`)
.fn(t => {
const { defaultLimit, adapterLimit } = t;
t.expect(defaultLimit % 4 === 0);
t.expect(adapterLimit % 4 === 0);
});
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,11 @@ g.test('setVertexBuffer,at_over')
}
);
});

g.test('validate,maxBindGroupsPlusVertexBuffers')
.desc(`Test that ${limit} <= maxBindGroupsPlusVertexBuffers`)
.fn(t => {
const { adapter, defaultLimit, adapterLimit } = t;
t.expect(defaultLimit <= t.getDefaultLimit('maxBindGroupsPlusVertexBuffers'));
t.expect(adapterLimit <= adapter.limits.maxBindGroupsPlusVertexBuffers);
});
1 change: 1 addition & 0 deletions src/webgpu/capability_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ const [
'maxTextureArrayLayers': [ , 256, 256, ],

'maxBindGroups': [ , 4, 4, ],
'maxBindGroupsPlusVertexBuffers': [ , 24, 24, ],
'maxBindingsPerBindGroup': [ , 1000, 1000, ],
'maxDynamicUniformBuffersPerPipelineLayout': [ , 8, 8, ],
'maxDynamicStorageBuffersPerPipelineLayout': [ , 4, 4, ],
Expand Down
9 changes: 9 additions & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
"webgpu:api,validation,capability_checks,features,query_types:writeTimestamp:*": { "subcaseMS": 1.200 },
"webgpu:api,validation,capability_checks,features,texture_formats:canvas_configuration:*": { "subcaseMS": 4.339 },
"webgpu:api,validation,capability_checks,features,texture_formats:canvas_configuration_view_formats:*": { "subcaseMS": 4.522 },
"webgpu:api,validation,capability_checks,features,texture_formats:check_capability_guarantees:*": { "subcaseMS": 55.901 },
"webgpu:api,validation,capability_checks,features,texture_formats:depth_stencil_state:*": { "subcaseMS": 15.701 },
"webgpu:api,validation,capability_checks,features,texture_formats:render_bundle_encoder_descriptor_depth_stencil_format:*": { "subcaseMS": 0.800 },
"webgpu:api,validation,capability_checks,features,texture_formats:texture_descriptor:*": { "subcaseMS": 3.830 },
Expand All @@ -275,6 +276,7 @@
"webgpu:api,validation,capability_checks,limits,maxBindGroups:createPipeline,at_over:*": { "subcaseMS": 10.990 },
"webgpu:api,validation,capability_checks,limits,maxBindGroups:createPipelineLayout,at_over:*": { "subcaseMS": 9.310 },
"webgpu:api,validation,capability_checks,limits,maxBindGroups:setBindGroup,at_over:*": { "subcaseMS": 9.984 },
"webgpu:api,validation,capability_checks,limits,maxBindGroups:validate,maxBindGroupsPlusVertexBuffers:*": { "subcaseMS": 11.200 },
"webgpu:api,validation,capability_checks,limits,maxBindingsPerBindGroup:createBindGroupLayout,at_over:*": { "subcaseMS": 12.441 },
"webgpu:api,validation,capability_checks,limits,maxBindingsPerBindGroup:createPipeline,at_over:*": { "subcaseMS": 11.179 },
"webgpu:api,validation,capability_checks,limits,maxBindingsPerBindGroup:validate:*": { "subcaseMS": 12.401 },
Expand All @@ -289,10 +291,14 @@
"webgpu:api,validation,capability_checks,limits,maxColorAttachments:validate,maxColorAttachmentBytesPerSample:*": { "subcaseMS": 1.101 },
"webgpu:api,validation,capability_checks,limits,maxComputeInvocationsPerWorkgroup:createComputePipeline,at_over:*": { "subcaseMS": 13.735 },
"webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupSizeX:createComputePipeline,at_over:*": { "subcaseMS": 14.465 },
"webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupSizeX:validate,maxComputeInvocationsPerWorkgroup:*": { "subcaseMS": 2.701 },
"webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupSizeY:createComputePipeline,at_over:*": { "subcaseMS": 14.131 },
"webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupSizeY:validate,maxComputeInvocationsPerWorkgroup:*": { "subcaseMS": 2.700 },
"webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupSizeZ:createComputePipeline,at_over:*": { "subcaseMS": 14.920 },
"webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupSizeZ:validate,maxComputeInvocationsPerWorkgroup:*": { "subcaseMS": 2.601 },
"webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupStorageSize:createComputePipeline,at_over:*": { "subcaseMS": 12.009 },
"webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupsPerDimension:dispatchWorkgroups,at_over:*": { "subcaseMS": 13.310 },
"webgpu:api,validation,capability_checks,limits,maxComputeWorkgroupsPerDimension:validate:*": { "subcaseMS": 138.900 },
"webgpu:api,validation,capability_checks,limits,maxDynamicStorageBuffersPerPipelineLayout:createBindGroupLayout,at_over:*": { "subcaseMS": 15.680 },
"webgpu:api,validation,capability_checks,limits,maxDynamicUniformBuffersPerPipelineLayout:createBindGroupLayout,at_over:*": { "subcaseMS": 10.268 },
"webgpu:api,validation,capability_checks,limits,maxInterStageShaderComponents:createRenderPipeline,at_over:*": { "subcaseMS": 12.916 },
Expand All @@ -305,6 +311,7 @@
"webgpu:api,validation,capability_checks,limits,maxSamplersPerShaderStage:createPipelineLayout,at_over:*": { "subcaseMS": 10.427 },
"webgpu:api,validation,capability_checks,limits,maxStorageBufferBindingSize:createBindGroup,at_over:*": { "subcaseMS": 51.810 },
"webgpu:api,validation,capability_checks,limits,maxStorageBufferBindingSize:validate,maxBufferSize:*": { "subcaseMS": 0.900 },
"webgpu:api,validation,capability_checks,limits,maxStorageBufferBindingSize:validate:*": { "subcaseMS": 132.400 },
"webgpu:api,validation,capability_checks,limits,maxStorageBuffersPerShaderStage:createBindGroupLayout,at_over:*": { "subcaseMS": 4.565 },
"webgpu:api,validation,capability_checks,limits,maxStorageBuffersPerShaderStage:createPipeline,at_over:*": { "subcaseMS": 7.884 },
"webgpu:api,validation,capability_checks,limits,maxStorageBuffersPerShaderStage:createPipelineLayout,at_over:*": { "subcaseMS": 5.007 },
Expand All @@ -324,8 +331,10 @@
"webgpu:api,validation,capability_checks,limits,maxUniformBuffersPerShaderStage:createPipelineLayout,at_over:*": { "subcaseMS": 6.109 },
"webgpu:api,validation,capability_checks,limits,maxVertexAttributes:createRenderPipeline,at_over:*": { "subcaseMS": 9.090 },
"webgpu:api,validation,capability_checks,limits,maxVertexBufferArrayStride:createRenderPipeline,at_over:*": { "subcaseMS": 10.060 },
"webgpu:api,validation,capability_checks,limits,maxVertexBufferArrayStride:validate:*": { "subcaseMS": 139.500 },
"webgpu:api,validation,capability_checks,limits,maxVertexBuffers:createRenderPipeline,at_over:*": { "subcaseMS": 8.903 },
"webgpu:api,validation,capability_checks,limits,maxVertexBuffers:setVertexBuffer,at_over:*": { "subcaseMS": 7.695 },
"webgpu:api,validation,capability_checks,limits,maxVertexBuffers:validate,maxBindGroupsPlusVertexBuffers:*": { "subcaseMS": 153.900 },
"webgpu:api,validation,capability_checks,limits,minStorageBufferOffsetAlignment:createBindGroup,at_over:*": { "subcaseMS": 9.650 },
"webgpu:api,validation,capability_checks,limits,minStorageBufferOffsetAlignment:setBindGroup,at_over:*": { "subcaseMS": 8.931 },
"webgpu:api,validation,capability_checks,limits,minStorageBufferOffsetAlignment:validate,greaterThanOrEqualTo32:*": { "subcaseMS": 31.801 },
Expand Down

0 comments on commit 3dbe4ce

Please sign in to comment.