Skip to content

Commit

Permalink
Add missing tests for adapter capability guarantees
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois committed Oct 30, 2023
1 parent 36a23bf commit 4e44d4f
Show file tree
Hide file tree
Showing 10 changed files with 91 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

0 comments on commit 4e44d4f

Please sign in to comment.