Skip to content

Commit

Permalink
Separate tests for target format supporting usage and being a color f…
Browse files Browse the repository at this point in the history
…ormat (#3393)

This splits two logically separate tests that were part of the same test before. This will make it easier to fix usage of the texture info table: Previously, it would access certain members of the info table assuming they were color, but would actually get the depth component of depth and depth-stencil formats. This wasn't really a problem because those formats were already expected to fail. But cleaner to instead just scope that test to only color formats.
  • Loading branch information
kainino0x authored Feb 13, 2024
1 parent f6337a4 commit 559c806
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
53 changes: 51 additions & 2 deletions src/webgpu/api/validation/render_pipeline/fragment_state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import {
kRenderableColorTextureFormats,
kTextureFormatInfo,
computeBytesPerSampleFromFormats,
kColorTextureFormats,
} from '../../../format_info.js';
import {
getFragmentShaderCodeWithOutput,
getPlainTypeInfo,
kDefaultFragmentShaderCode,
kDefaultVertexShaderCode,
} from '../../../util/shader.js';
import { kTexelRepresentationInfo } from '../../../util/texture/texel_data.js';

Expand Down Expand Up @@ -49,12 +51,59 @@ g.test('color_target_exists')
t.doCreateRenderPipelineTest(isAsync, false, badDescriptor);
});

g.test('targets_format_is_color_format')
.desc(
`Tests that color target state format must be a color format, regardless of how the
fragment shader writes to it.`
)
.params(u =>
u
// Test all non-color texture formats, plus 'rgba8unorm' as a control case.
.combine('format', kAllTextureFormats)
.filter(({ format }) => {
return format === 'rgba8unorm' || !kTextureFormatInfo[format].color;
})
.combine('isAsync', [false, true])
.beginSubcases()
.combine('fragOutType', ['f32', 'u32', 'i32'] as const)
)
.beforeAllSubcases(t => {
const { format } = t.params;
const info = kTextureFormatInfo[format];
t.skipIfTextureFormatNotSupported(t.params.format);
t.selectDeviceOrSkipTestCase(info.feature);
})
.fn(t => {
const { isAsync, format, fragOutType } = t.params;

const fragmentShaderCode = getFragmentShaderCodeWithOutput([
{ values, plainType: fragOutType, componentCount: 4 },
]);

const success = format === 'rgba8unorm' && fragOutType === 'f32';
t.doCreateRenderPipelineTest(isAsync, success, {
vertex: {
module: t.device.createShaderModule({ code: kDefaultVertexShaderCode }),
entryPoint: 'main',
},
fragment: {
module: t.device.createShaderModule({ code: fragmentShaderCode }),
entryPoint: 'main',
targets: [{ format }],
},
layout: 'auto',
});
});

g.test('targets_format_renderable')
.desc(`Tests that color target state format must have RENDER_ATTACHMENT capability.`)
.desc(
`Tests that color target state format must have RENDER_ATTACHMENT capability
(tests only color formats).`
)
.params(u =>
u //
.combine('isAsync', [false, true])
.combine('format', kAllTextureFormats)
.combine('format', kColorTextureFormats)
)
.beforeAllSubcases(t => {
const { format } = t.params;
Expand Down
1 change: 1 addition & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@
"webgpu:api,validation,render_pipeline,fragment_state:pipeline_output_targets:*": { "subcaseMS": 0.497 },
"webgpu:api,validation,render_pipeline,fragment_state:targets_blend:*": { "subcaseMS": 1.203 },
"webgpu:api,validation,render_pipeline,fragment_state:targets_format_filterable:*": { "subcaseMS": 2.143 },
"webgpu:api,validation,render_pipeline,fragment_state:targets_format_is_color_format:*": { "subcaseMS": 2.000 },
"webgpu:api,validation,render_pipeline,fragment_state:targets_format_renderable:*": { "subcaseMS": 3.339 },
"webgpu:api,validation,render_pipeline,fragment_state:targets_write_mask:*": { "subcaseMS": 12.272 },
"webgpu:api,validation,render_pipeline,inter_stage:interpolation_sampling:*": { "subcaseMS": 3.126 },
Expand Down

0 comments on commit 559c806

Please sign in to comment.