diff options
Diffstat (limited to 'dom/webgpu/tests/cts/checkout/src/webgpu/api/operation/resource_init/check_texture/by_sampling.ts')
-rw-r--r-- | dom/webgpu/tests/cts/checkout/src/webgpu/api/operation/resource_init/check_texture/by_sampling.ts | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/dom/webgpu/tests/cts/checkout/src/webgpu/api/operation/resource_init/check_texture/by_sampling.ts b/dom/webgpu/tests/cts/checkout/src/webgpu/api/operation/resource_init/check_texture/by_sampling.ts index 64b4f73b34..fd268be3b9 100644 --- a/dom/webgpu/tests/cts/checkout/src/webgpu/api/operation/resource_init/check_texture/by_sampling.ts +++ b/dom/webgpu/tests/cts/checkout/src/webgpu/api/operation/resource_init/check_texture/by_sampling.ts @@ -6,7 +6,8 @@ import { getSingleDataType, getComponentReadbackTraits, } from '../../../../util/texture/texel_data.js'; -import { CheckContents } from '../texture_zero.spec.js'; + +import { CheckContents } from './texture_zero_init_test.js'; export const checkContentsBySampling: CheckContents = ( t, @@ -41,14 +42,20 @@ export const checkContentsBySampling: CheckContents = ( ? componentOrder[0].toLowerCase() : componentOrder.map(c => c.toLowerCase()).join('') + '[i]'; - const _xd = '_' + params.dimension; + const viewDimension = + t.isCompatibility && params.dimension === '2d' && texture.depthOrArrayLayers > 1 + ? '2d-array' + : params.dimension; + const _xd = `_${viewDimension.replace('-', '_')}`; const _multisampled = params.sampleCount > 1 ? '_multisampled' : ''; const texelIndexExpression = - params.dimension === '2d' + viewDimension === '2d' ? 'vec2<i32>(GlobalInvocationID.xy)' - : params.dimension === '3d' + : viewDimension === '2d-array' + ? 'vec2<i32>(GlobalInvocationID.xy), constants.layer' + : viewDimension === '3d' ? 'vec3<i32>(GlobalInvocationID.xyz)' - : params.dimension === '1d' + : viewDimension === '1d' ? 'i32(GlobalInvocationID.x)' : unreachable(); const computePipeline = t.device.createComputePipeline({ @@ -58,7 +65,8 @@ export const checkContentsBySampling: CheckContents = ( module: t.device.createShaderModule({ code: ` struct Constants { - level : i32 + level : i32, + layer : i32, }; @group(0) @binding(0) var<uniform> constants : Constants; @@ -90,10 +98,10 @@ export const checkContentsBySampling: CheckContents = ( for (const layer of layers) { const ubo = t.device.createBuffer({ mappedAtCreation: true, - size: 4, + size: 8, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, }); - new Int32Array(ubo.getMappedRange(), 0, 1)[0] = level; + new Int32Array(ubo.getMappedRange()).set([level, layer]); ubo.unmap(); const byteLength = @@ -104,6 +112,14 @@ export const checkContentsBySampling: CheckContents = ( }); t.trackForCleanup(resultBuffer); + const viewDescriptor: GPUTextureViewDescriptor = { + ...(!t.isCompatibility && { + baseArrayLayer: layer, + arrayLayerCount: 1, + }), + dimension: viewDimension, + }; + const bindGroup = t.device.createBindGroup({ layout: computePipeline.getBindGroupLayout(0), entries: [ @@ -113,11 +129,7 @@ export const checkContentsBySampling: CheckContents = ( }, { binding: 1, - resource: texture.createView({ - baseArrayLayer: layer, - arrayLayerCount: 1, - dimension: params.dimension, - }), + resource: texture.createView(viewDescriptor), }, { binding: 3, |