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

Separate tests for target format supporting usage and being a color format #3393

Merged
merged 4 commits into from
Feb 13, 2024
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
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
Loading