Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat: Fix texture_zero init tests for compat #3152

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions src/webgpu/api/operation/resource_init/check_texture/by_sampling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,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({
Expand All @@ -58,7 +64,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;
Expand Down Expand Up @@ -90,10 +97,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 =
Expand All @@ -104,6 +111,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: [
Expand All @@ -113,11 +128,7 @@ export const checkContentsBySampling: CheckContents = (
},
{
binding: 1,
resource: texture.createView({
baseArrayLayer: layer,
arrayLayerCount: 1,
dimension: params.dimension,
}),
resource: texture.createView(viewDescriptor),
},
{
binding: 3,
Expand Down