From cd9505da1d631c46cc38b7218c54a4598a4fd802 Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Wed, 13 Dec 2023 16:50:38 -0800 Subject: [PATCH] Compat:Check interpolate linear/sample validation Both don't exist in GLES 3.1 --- .../render_pipeline/shader_module.spec.ts | 80 +++++++++++++++++++ src/webgpu/listing_meta.json | 1 + 2 files changed, 81 insertions(+) diff --git a/src/webgpu/compat/api/validation/render_pipeline/shader_module.spec.ts b/src/webgpu/compat/api/validation/render_pipeline/shader_module.spec.ts index abe2b063e7ba..b89559b6fd10 100644 --- a/src/webgpu/compat/api/validation/render_pipeline/shader_module.spec.ts +++ b/src/webgpu/compat/api/validation/render_pipeline/shader_module.spec.ts @@ -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 + ); + }); diff --git a/src/webgpu/listing_meta.json b/src/webgpu/listing_meta.json index 6c677ebdb320..392150a97807 100644 --- a/src/webgpu/listing_meta.json +++ b/src/webgpu/listing_meta.json @@ -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 },