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

Use the texture view in the texture builtin tests. #4298

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -756,13 +756,14 @@ Parameters:
.combine('format', kPossibleStorageTextureFormats)
.beginSubcases()
.combine('samplePoints', kSamplePointMethods)
.combine('baseMipLevel', [0, 1] as const)
.combine('C', ['i32', 'u32'] as const)
)
.beforeAllSubcases(t =>
t.skipIfLanguageFeatureNotSupported('readonly_and_readwrite_storage_textures')
)
.fn(async t => {
const { format, stage, samplePoints, C } = t.params;
const { format, stage, samplePoints, C, baseMipLevel } = t.params;

t.skipIfTextureFormatNotSupported(format);
t.skipIfTextureFormatNotUsableAsStorageTexture(format);
Expand All @@ -774,12 +775,17 @@ Parameters:
format,
size,
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.STORAGE_BINDING,
mipLevelCount: 3,
};
const viewDescriptor = {
baseMipLevel,
mipLevelCount: 1,
};
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor);

const softwareTexture = { texels, descriptor, viewDescriptor };
const calls: TextureCall<vec2>[] = generateTextureBuiltinInputs2D(50, {
method: samplePoints,
descriptor,
softwareTexture,
hashInputs: [stage, format, samplePoints, C],
}).map(({ coords }) => {
return {
Expand All @@ -789,7 +795,6 @@ Parameters:
};
});
const textureType = `texture_storage_2d<${format}, read>`;
const viewDescriptor = {};
const sampler = undefined;
const results = await doTextureCalls(
t,
Expand All @@ -802,7 +807,7 @@ Parameters:
);
const res = await checkCallResults(
t,
{ texels, descriptor, viewDescriptor },
softwareTexture,
textureType,
sampler,
calls,
Expand Down Expand Up @@ -837,12 +842,20 @@ Parameters:
.combine('C', ['i32', 'u32'] as const)
.combine('A', ['i32', 'u32'] as const)
.combine('depthOrArrayLayers', [1, 8] as const)
.combine('baseMipLevel', [0, 1] as const)
.combine('baseArrayLayer', [0, 1] as const)
.unless(t => t.depthOrArrayLayers === 1 && t.baseArrayLayer !== 0)
)
.beforeAllSubcases(t =>
t.skipIfLanguageFeatureNotSupported('readonly_and_readwrite_storage_textures')
)
.beforeAllSubcases(t => {
t.skipIfLanguageFeatureNotSupported('readonly_and_readwrite_storage_textures');
t.skipIf(
t.isCompatibility && t.params.baseArrayLayer !== 0,
'compatibility mode does not support array layer sub ranges'
);
})
.fn(async t => {
const { format, stage, samplePoints, C, A, depthOrArrayLayers } = t.params;
const { format, stage, samplePoints, C, A, depthOrArrayLayers, baseMipLevel, baseArrayLayer } =
t.params;

t.skipIfTextureFormatNotSupported(format);
t.skipIfTextureFormatNotUsableAsStorageTexture(format);
Expand All @@ -856,13 +869,21 @@ Parameters:
size,
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.STORAGE_BINDING,
...(t.isCompatibility && { textureBindingViewDimension: '2d-array' }),
mipLevelCount: 3,
};
const viewDescriptor: GPUTextureViewDescriptor = {
dimension: '2d-array',
baseMipLevel,
mipLevelCount: 1,
baseArrayLayer,
};
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor);
const softwareTexture = { texels, descriptor, viewDescriptor };

const calls: TextureCall<vec2>[] = generateTextureBuiltinInputs2D(50, {
method: samplePoints,
descriptor,
arrayIndex: { num: texture.depthOrArrayLayers, type: A },
softwareTexture,
arrayIndex: { num: texture.depthOrArrayLayers - baseArrayLayer, type: A },
hashInputs: [stage, format, samplePoints, C, A],
}).map(({ coords, arrayIndex }) => {
return {
Expand All @@ -874,9 +895,6 @@ Parameters:
};
});
const textureType = `texture_storage_2d_array<${format}, read>`;
const viewDescriptor: GPUTextureViewDescriptor = {
dimension: '2d-array',
};
const sampler = undefined;
const results = await doTextureCalls(
t,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ Parameters:
.combine('offset', [false, true] as const)
.beginSubcases()
.combine('samplePoints', kSamplePointMethods)
.combine('baseMipLevel', [0, 1] as const)
)
.fn(async t => {
const { format, samplePoints, modeU, modeV, filt: minFilter, offset } = t.params;
const { format, samplePoints, modeU, modeV, filt: minFilter, offset, baseMipLevel } = t.params;
skipIfTextureFormatNotSupportedOrNeedsFilteringAndIsUnfilterable(t, minFilter, format);

// We want at least 4 blocks or something wide enough for 3 mip levels.
Expand All @@ -168,7 +169,11 @@ Parameters:
usage: GPUTextureUsage.COPY_DST | GPUTextureUsage.TEXTURE_BINDING,
mipLevelCount: 3,
};
const viewDescriptor = {
baseMipLevel,
};
const { texels, texture } = await createTextureWithRandomDataAndGetTexels(t, descriptor);
const softwareTexture = { texels, descriptor, viewDescriptor };
const sampler: GPUSamplerDescriptor = {
addressModeU: kShortAddressModeToAddressMode[modeU],
addressModeV: kShortAddressModeToAddressMode[modeV],
Expand All @@ -180,7 +185,7 @@ Parameters:
const calls: TextureCall<vec2>[] = generateTextureBuiltinInputs2D(50, {
sampler,
method: samplePoints,
descriptor,
softwareTexture,
derivatives: true,
offset,
hashInputs: [format, samplePoints, modeU, modeV, minFilter, offset],
Expand All @@ -193,7 +198,6 @@ Parameters:
offset,
};
});
const viewDescriptor = {};
const textureType = 'texture_2d<f32>';
const results = await doTextureCalls(
t,
Expand Down
Loading