diff --git a/src/webgpu/shader/execution/shader_io/fragment_builtins.spec.ts b/src/webgpu/shader/execution/shader_io/fragment_builtins.spec.ts index 587c753f10d9..d42eeb4389b7 100644 --- a/src/webgpu/shader/execution/shader_io/fragment_builtins.spec.ts +++ b/src/webgpu/shader/execution/shader_io/fragment_builtins.spec.ts @@ -326,6 +326,7 @@ function generateFragmentInputs({ frontFace, clipSpacePoints, interpolateFn, + isSampleShading, }: { width: number; height: number; @@ -334,6 +335,7 @@ function generateFragmentInputs({ frontFace?: GPUFrontFace; clipSpacePoints: readonly number[][]; interpolateFn: (fragData: FragData) => number[]; + isSampleShading: boolean; }) { const expected = new Float32Array(width * height * sampleCount * 4); @@ -382,6 +384,11 @@ function generateFragmentInputs({ const inside = isInsideTriangle(sampleBarycentricCoords); if (inside) { + // When Sample Shading (ie MSAA super sampling) we should only get the one sample for this fragment. + // See webgpu wgls issue 5457 + const fragmentLocalSampleMask = isSampleShading + ? sampleMask & (1 << sampleIndex) + : sampleMask; const output = interpolateFn({ baseVertexIndex: vertexIndex, fragmentPoint, @@ -391,7 +398,7 @@ function generateFragmentInputs({ ndcPoints, windowPoints, sampleIndex, - sampleMask, + sampleMask: fragmentLocalSampleMask, frontFacing, }); @@ -845,6 +852,7 @@ g.test('inputs,position') sampleCount, clipSpacePoints, interpolateFn: computeFragmentPosition, + isSampleShading: t.params.interpolation.sampling === 'sample', }); showExpected(t, width, height, sampleCount, expected); @@ -936,6 +944,7 @@ g.test('inputs,interStage') sampleCount, clipSpacePoints, interpolateFn: await createInterStageInterpolationFn(t, interStagePoints, type, sampling), + isSampleShading: t.params.interpolation.sampling === 'sample', }); showExpected(t, width, height, sampleCount, expected); @@ -1077,6 +1086,7 @@ g.test('inputs,interStage,centroid') type, sampling ), + isSampleShading: false, }); showExpected(t, width, height, sampleCount, expected); @@ -1158,6 +1168,7 @@ g.test('inputs,sample_index') sampleCount, clipSpacePoints, interpolateFn: computeFragmentSampleIndex, + isSampleShading: t.params.interpolation.sampling === 'sample', }); showExpected(t, width, height, sampleCount, expected); @@ -1275,6 +1286,7 @@ g.test('inputs,front_facing') clipSpacePoints, frontFace, interpolateFn: computeFragmentFrontFacing, + isSampleShading: t.params.interpolation.sampling === 'sample', }); showExpected(t, width, height, sampleCount, expected); @@ -1451,6 +1463,7 @@ g.test('inputs,sample_mask') sampleCount, clipSpacePoints, interpolateFn: computeSampleMask, + isSampleShading: t.params.interpolation.sampling === 'sample', }); showExpected(t, width, height, sampleCount, expected);