[spirv-reader] Parse Invariant decoration on var
Bug: tint:1907
Change-Id: Ia759997f73be52559328dd0a4a5bb75a9dbfc62b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/170541
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/lang/spirv/reader/parser/parser.cc b/src/tint/lang/spirv/reader/parser/parser.cc
index a305660..b2c2518 100644
--- a/src/tint/lang/spirv/reader/parser/parser.cc
+++ b/src/tint/lang/spirv/reader/parser/parser.cc
@@ -587,6 +587,9 @@
case spv::Decoration::BuiltIn:
io_attributes.builtin = Builtin(spv::BuiltIn(deco->GetSingleWordOperand(2)));
break;
+ case spv::Decoration::Invariant:
+ io_attributes.invariant = true;
+ break;
case spv::Decoration::Location:
io_attributes.location = deco->GetSingleWordOperand(2);
break;
diff --git a/src/tint/lang/spirv/reader/parser/var_test.cc b/src/tint/lang/spirv/reader/parser/var_test.cc
index 37fcfe4..f524b23 100644
--- a/src/tint/lang/spirv/reader/parser/var_test.cc
+++ b/src/tint/lang/spirv/reader/parser/var_test.cc
@@ -460,6 +460,30 @@
}),
PrintBuiltinCase);
+TEST_F(SpirvParserTest, Invariant_OnVariable) {
+ EXPECT_IR(R"(
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %main "main"
+ OpExecutionMode %main LocalSize 1 1 1
+ OpDecorate %var BuiltIn Position
+ OpDecorate %var Invariant
+ %void = OpTypeVoid
+ %f32 = OpTypeFloat 32
+ %vec4f = OpTypeVector %f32 4
+ %fn_type = OpTypeFunction %void
+
+%_ptr_Output = OpTypePointer Output %vec4f
+ %var = OpVariable %_ptr_Output Output
+
+ %main = OpFunction %void None %fn_type
+ %main_start = OpLabel
+ OpReturn
+ OpFunctionEnd
+)",
+ "%1:ptr<__out, vec4<f32>, read_write> = var @invariant @builtin(position)");
+}
+
struct LocationCase {
std::string spirv_decorations;
std::string ir;