From 777ac2bdde2db8ec3f24034022acfb893924de5a Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 24 Feb 2020 11:46:59 -0800 Subject: Fix support for SV_Coverage on GLSL path (#1239) There were two overlapping issues here: 1. We always mapped `SV_Coverage` to `gl_SampleMask`, even though `gl_SampleMaskIn` is the correct built-in variable to use for an input varying. 2. We treated `gl_SampleMask` like it was a scalar shader input, when it and `gl_SampleMaskIn` are actually arrays of indeterminate size (as a byproduct of trying to future-proof for implementations that might support hundreds or thousands of samples per pixel...) The fix here is simple: map to either `gl_SampleMask[0]` or `gl_SampleMaskIn[0]` as appropriate. I suppose that this approach doesn't handle the possibility of eventually supporting >32 samples per pixel by having something like `uint2 coverage : SV_Coverage`, but I think we can cross that bridge when we come to it. --- tests/cross-compile/sv-coverage.slang | 13 +++++++++++++ tests/cross-compile/sv-coverage.slang.glsl | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 tests/cross-compile/sv-coverage.slang create mode 100644 tests/cross-compile/sv-coverage.slang.glsl (limited to 'tests') diff --git a/tests/cross-compile/sv-coverage.slang b/tests/cross-compile/sv-coverage.slang new file mode 100644 index 000000000..3bae3ea8a --- /dev/null +++ b/tests/cross-compile/sv-coverage.slang @@ -0,0 +1,13 @@ +// sv-coverage.slang + +//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage fragment + +float4 main( + in float4 color : COLOR, + in uint inputCoverage : SV_Coverage, + out uint outputCoverage : SV_Coverage) + : SV_Target +{ + outputCoverage = inputCoverage ^ 1; + return color; +} diff --git a/tests/cross-compile/sv-coverage.slang.glsl b/tests/cross-compile/sv-coverage.slang.glsl new file mode 100644 index 000000000..04728e81b --- /dev/null +++ b/tests/cross-compile/sv-coverage.slang.glsl @@ -0,0 +1,19 @@ +// sv-coverage.slang.glsl +#version 450 + +layout(location = 0) +out vec4 _S1; + +layout(location = 0) +in vec4 _S2; + +void main() +{ + uint _S3 = uint(gl_SampleMaskIn[0]); + uint _S4; + + _S4 = _S3 ^ uint(1); + _S1 = _S2; + gl_SampleMask[0] = int(_S4); + return; +} -- cgit v1.2.3