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

Fix rg11b10ufloat filter_mode tests #4293

Merged
merged 2 commits into from
Mar 13, 2025
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
43 changes: 28 additions & 15 deletions src/webgpu/api/operation/sampling/filter_mode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { kAddressModes, kMipmapFilterModes } from '../../../capability_info.js';
import {
EncodableTextureFormat,
getTextureFormatType,
isTextureFormatColorRenderable,
kPossibleColorRenderableTextureFormats,
} from '../../../format_info.js';
import { AllFeaturesMaxLimitsGPUTest, TextureTestMixin } from '../../../gpu_test.js';
Expand Down Expand Up @@ -46,6 +47,12 @@ class FilterModeTest extends TextureTestMixin(AllFeaturesMaxLimitsGPUTest) {
vertexCount: number,
instanceCount: number
) {
let renderTargetFormat = format;
if (!isTextureFormatColorRenderable(this.device, format)) {
// If the format is not renderable, we use rgba32float as the render target format
// to verify the result, which is always renderable.
renderTargetFormat = 'rgba32float';
}
const sampleTexture = this.createTextureFromTexelView(
TexelView.fromTexelsAsColors(format, coord => {
const id = coord.x + coord.y * kCheckerTextureSize;
Expand All @@ -57,7 +64,7 @@ class FilterModeTest extends TextureTestMixin(AllFeaturesMaxLimitsGPUTest) {
}
);
const renderTexture = this.createTextureTracked({
format,
format: renderTargetFormat,
size: renderSize,
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
});
Expand All @@ -70,7 +77,7 @@ class FilterModeTest extends TextureTestMixin(AllFeaturesMaxLimitsGPUTest) {
fragment: {
module,
entryPoint: 'fs_main',
targets: [{ format }],
targets: [{ format: renderTargetFormat }],
},
});
const bindgroup = this.device.createBindGroup({
Expand All @@ -96,7 +103,7 @@ class FilterModeTest extends TextureTestMixin(AllFeaturesMaxLimitsGPUTest) {
renderPass.draw(vertexCount, instanceCount);
renderPass.end();
this.device.queue.submit([commandEncoder.finish()]);
return renderTexture;
return { texture: renderTexture, format: renderTargetFormat };
}
}

Expand Down Expand Up @@ -548,8 +555,8 @@ g.test('magFilter,nearest')
instanceCount
);
t.expectTexelViewComparisonIsOkInTexture(
{ texture: render },
expectedColors(format, 'nearest', addressModeU, addressModeV),
{ texture: render.texture },
expectedColors(render.format, 'nearest', addressModeU, addressModeV),
kNearestRenderDim
);
});
Expand Down Expand Up @@ -663,8 +670,8 @@ g.test('magFilter,linear')
instanceCount
);
t.expectTexelViewComparisonIsOkInTexture(
{ texture: render },
expectedColors(format, 'linear', addressModeU, addressModeV),
{ texture: render.texture },
expectedColors(render.format, 'linear', addressModeU, addressModeV),
kLinearRenderDim
);
});
Expand Down Expand Up @@ -790,8 +797,8 @@ g.test('minFilter,nearest')
instanceCount
);
t.expectTexelViewComparisonIsOkInTexture(
{ texture: render },
expectedColors(format, 'nearest', addressModeU, addressModeV),
{ texture: render.texture },
expectedColors(render.format, 'nearest', addressModeU, addressModeV),
kNearestRenderDim
);
});
Expand Down Expand Up @@ -915,8 +922,8 @@ g.test('minFilter,linear')
instanceCount
);
t.expectTexelViewComparisonIsOkInTexture(
{ texture: render },
expectedColors(format, 'linear', addressModeU, addressModeV),
{ texture: render.texture },
expectedColors(render.format, 'linear', addressModeU, addressModeV),
kLinearRenderDim
);
});
Expand All @@ -939,6 +946,12 @@ g.test('mipmapFilter')
const { format, filterMode } = t.params;
t.skipIfTextureFormatNotSupported(format);
t.skipIfTextureFormatNotFilterable(format);
let renderTargetFormat = format;
if (!isTextureFormatColorRenderable(t.device, format)) {
// If the format is not renderable, we use rgba32float as the render target format
// to verify the result, which is always renderable.
renderTargetFormat = 'rgba32float';
}
// Takes a 8x8/4x4 mipmapped texture and renders it on multiple quads with different UVs such
// that each instanced quad from left to right emulates moving the quad further and further from
// the camera. Each quad is then rendered to a single pixel in a 1-dimensional texture. Since
Expand Down Expand Up @@ -966,7 +979,7 @@ g.test('mipmapFilter')
}
);
const renderTexture = t.createTextureTracked({
format,
format: renderTargetFormat,
size: [kRenderSize, 1],
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.COPY_SRC,
});
Expand Down Expand Up @@ -1016,7 +1029,7 @@ g.test('mipmapFilter')
fragment: {
module,
entryPoint: 'fs_main',
targets: [{ format }],
targets: [{ format: renderTargetFormat }],
},
});
const bindgroup = t.device.createBindGroup({
Expand Down Expand Up @@ -1050,8 +1063,8 @@ g.test('mipmapFilter')
buffer,
actual => {
// Convert the buffer to texel view so we can do comparisons.
const layout = getTextureCopyLayout(format, '2d', [kRenderSize, 1, 1]);
const view = TexelView.fromTextureDataByReference(format, actual, {
const layout = getTextureCopyLayout(renderTargetFormat, '2d', [kRenderSize, 1, 1]);
const view = TexelView.fromTextureDataByReference(renderTargetFormat, actual, {
bytesPerRow: layout.bytesPerRow,
rowsPerImage: layout.rowsPerImage,
subrectOrigin: [0, 0, 0],
Expand Down