[glsl][ir] Add `SampleMask` to ShaderIO.
This CL updates the ShaderIO polyfill for GLSL IR to support the needed
SampleMask conversions. In GLSL, the `in` mask is named
`gl_SampleMaskIn` and is an array of `i32` values. The output mask is
`gl_SampleMask` and is an array of `i32` values. The ShaderIO code is
updated to access the given arrays and bitcast the values to/from the
WGSL `u32` sample mask values.
Bug: 42251044
Change-Id: I9498a988f00d8fa8f2f4aca3a0de443643b34b56
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/208334
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/glsl/writer/raise/shader_io_test.cc b/src/tint/lang/glsl/writer/raise/shader_io_test.cc
index a258636..638540f 100644
--- a/src/tint/lang/glsl/writer/raise/shader_io_test.cc
+++ b/src/tint/lang/glsl/writer/raise/shader_io_test.cc
@@ -979,7 +979,7 @@
EXPECT_EQ(expect, str());
}
-// Test that we change the type of the sample mask builtin to an array for SPIR-V.
+// Test that we change the type of the sample mask builtin to an array for GLSL
TEST_F(GlslWriter_ShaderIOTest, SampleMask) {
auto* str_ty = ty.Struct(mod.symbols.New("Outputs"),
{
@@ -1042,9 +1042,9 @@
}
$B1: { # root
- %gl_SampleMaskIn:ptr<__in, u32, read> = var @builtin(sample_mask)
+ %gl_SampleMaskIn:ptr<__in, array<i32, 1>, read> = var @builtin(sample_mask)
%foo_loc0_Output:ptr<__out, f32, write> = var @location(0)
- %gl_SampleMask:ptr<__out, u32, write> = var @builtin(sample_mask)
+ %gl_SampleMask:ptr<__out, array<i32, 1>, write> = var @builtin(sample_mask)
}
%foo_inner = func(%mask_in:u32):Outputs {
@@ -1055,12 +1055,16 @@
}
%foo = @fragment func():void {
$B3: {
- %8:u32 = load %gl_SampleMaskIn
- %9:Outputs = call %foo_inner, %8
- %10:f32 = access %9, 0u
- store %foo_loc0_Output, %10
- %11:u32 = access %9, 1u
- store %gl_SampleMask, %11
+ %8:array<i32, 1> = load %gl_SampleMaskIn
+ %9:i32 = access %8, 0u
+ %10:u32 = convert %9
+ %11:Outputs = call %foo_inner, %10
+ %12:f32 = access %11, 0u
+ store %foo_loc0_Output, %12
+ %13:u32 = access %11, 1u
+ %14:ptr<__out, i32, write> = access %gl_SampleMask, 0u
+ %15:i32 = convert %13
+ store %14, %15
ret
}
}