Skip to content

Commit

Permalink
Add format capability checks for createRenderPipelineAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Oct 28, 2023
1 parent 90d4193 commit 8500b12
Showing 1 changed file with 49 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ g.test('color_target_state')
fail if the required optional feature is not enabled.
Note: This test has no cases if there are no optional texture formats supporting color rendering.
TODO: also test createRenderPipelineAsync
`
)
.params(u =>
u
.combine('isAsync', [false, true])
.combine('format', kOptionalTextureFormats)
.filter(t => !!kTextureFormatInfo[t.format].colorRender)
.combine('enable_required_feature', [true, false])
Expand All @@ -311,37 +311,36 @@ g.test('color_target_state')
}
})
.fn(t => {
const { format, enable_required_feature } = t.params;

t.shouldThrow(
enable_required_feature ? false : 'TypeError',
() => {
t.device.createRenderPipeline({
layout: 'auto',
vertex: {
module: t.device.createShaderModule({
code: `
const { isAsync, format, enable_required_feature } = t.params;

t.doCreateRenderPipelineTest(
isAsync,
enable_required_feature,
{
layout: 'auto',
vertex: {
module: t.device.createShaderModule({
code: `
@vertex
fn main()-> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
}`,
}),
entryPoint: 'main',
},
fragment: {
module: t.device.createShaderModule({
code: `
}),
entryPoint: 'main',
},
fragment: {
module: t.device.createShaderModule({
code: `
@fragment
fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
}`,
}),
entryPoint: 'main',
targets: [{ format }],
},
});
}),
entryPoint: 'main',
targets: [{ format }],
},
},
{ checkForStackProperty: true }
'TypeError'
);
});

Expand All @@ -350,11 +349,11 @@ g.test('depth_stencil_state')
`
Test creating a render pipeline with an optional texture format set in GPUColorTargetState will
fail if the required optional feature is not enabled.
TODO: also test createRenderPipelineAsync
`
)
.params(u =>
u
.combine('isAsync', [false, true])
.combine('format', kOptionalTextureFormats)
.filter(t => !!(kTextureFormatInfo[t.format].depth || kTextureFormatInfo[t.format].stencil))
.combine('enable_required_feature', [true, false])
Expand All @@ -368,42 +367,41 @@ g.test('depth_stencil_state')
}
})
.fn(t => {
const { format, enable_required_feature } = t.params;

t.shouldThrow(
enable_required_feature ? false : 'TypeError',
() => {
t.device.createRenderPipeline({
layout: 'auto',
vertex: {
module: t.device.createShaderModule({
code: `
const { isAsync, format, enable_required_feature } = t.params;

t.doCreateRenderPipelineTest(
isAsync,
enable_required_feature,
{
layout: 'auto',
vertex: {
module: t.device.createShaderModule({
code: `
@vertex
fn main()-> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
}`,
}),
entryPoint: 'main',
},
depthStencil: {
format,
depthCompare: 'always',
depthWriteEnabled: false,
},
fragment: {
module: t.device.createShaderModule({
code: `
}),
entryPoint: 'main',
},
depthStencil: {
format,
depthCompare: 'always',
depthWriteEnabled: false,
},
fragment: {
module: t.device.createShaderModule({
code: `
@fragment
fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
}`,
}),
entryPoint: 'main',
targets: [{ format: 'rgba8unorm' }],
},
});
}),
entryPoint: 'main',
targets: [{ format: 'rgba8unorm' }],
},
},
{ checkForStackProperty: true }
'TypeError'
);
});

Expand Down

0 comments on commit 8500b12

Please sign in to comment.