Skip to content

Commit

Permalink
Compat:Check interpolate linear/sample validation
Browse files Browse the repository at this point in the history
Both don't exist in GLES 3.1
  • Loading branch information
greggman committed Dec 14, 2023
1 parent 84fae1f commit cd9505d
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,83 @@ Tests that you can not create a render pipeline with a shader module that uses s
!isValid
);
});

g.test('interpolate')
.desc(
`
Tests that you can not create a render pipeline with a shader module that uses interpolate(linear) nor interpolate(...,sample) in compat mode.
- Test that a pipeline with a shader that uses interpolate(linear) or interpolate(sample) fails.
- Test that a pipeline that references a module that has a shader that uses interpolate(linear/sample)
but the pipeline does not reference that shader succeeds.
`
)
.params(u =>
u
.combine('interpolate', [
'',
'@interpolate(linear)',
'@interpolate(linear, sample)',
'@interpolate(perspective, sample)',
] as const)
.combine('entryPoint', [
'fsWithoutInterpolationUsage',
'fsWithInterpolationUsage1',
'fsWithInterpolationUsage2',
'fsWithInterpolationUsage3',
] as const)
)
.fn(t => {
const { entryPoint, interpolate } = t.params;

const module = t.device.createShaderModule({
code: `
struct Vertex {
@builtin(position) pos: vec4f,
@location(0) ${interpolate} color : vec4f,
};
@vertex fn vs() -> Vertex {
var v: Vertex;
v.pos = vec4f(1);
v.color = vec4f(1);
return v;
}
@fragment fn fsWithoutInterpolationUsage() -> @location(0) vec4f {
return vec4f(1);
}
@fragment fn fsWithInterpolationUsage1(v: Vertex) -> @location(0) vec4f {
return vec4f(1);
}
@fragment fn fsWithInterpolationUsage2(v: Vertex) -> @location(0) vec4f {
return v.pos;
}
@fragment fn fsWithInterpolationUsage3(v: Vertex) -> @location(0) vec4f {
return v.color;
}
`,
});

const pipelineDescriptor: GPURenderPipelineDescriptor = {
layout: 'auto',
vertex: {
module,
entryPoint: 'vs',
},
fragment: {
module,
entryPoint,
targets: [
{
format: 'rgba8unorm',
},
],
},
};

const isValid = entryPoint === 'fsWithoutInterpolationUsage' || interpolate === '';
t.expectGPUError(
'validation',
() => t.device.createRenderPipeline(pipelineDescriptor),
!isValid
);
});
1 change: 1 addition & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@
"webgpu:compat,api,validation,encoding,programmable,pipeline_bind_group_compat:twoDifferentTextureViews,render_pass,unused:*": { "subcaseMS": 16.002 },
"webgpu:compat,api,validation,encoding,programmable,pipeline_bind_group_compat:twoDifferentTextureViews,render_pass,used:*": { "subcaseMS": 0.000 },
"webgpu:compat,api,validation,render_pipeline,fragment_state:colorState:*": { "subcaseMS": 32.604 },
"webgpu:compat,api,validation,render_pipeline,shader_module:interpolate:*": { "subcaseMS": 1.502 },
"webgpu:compat,api,validation,render_pipeline,shader_module:sample_mask:*": { "subcaseMS": 14.801 },
"webgpu:compat,api,validation,render_pipeline,vertex_state:maxVertexAttributesVertexIndexInstanceIndex:*": { "subcaseMS": 3.700 },
"webgpu:compat,api,validation,texture,createTexture:depthOrArrayLayers_incompatible_with_textureBindingViewDimension:*": { "subcaseMS": 12.712 },
Expand Down

0 comments on commit cd9505d

Please sign in to comment.