[glsl][ir] Fix types for GLSL builtins
Several of the GLSL builtins are `i32` where in WGSL they are `u32`.
This CL fixes the `var` creation to have the correct types so the
subsequent bitcast calls do not get removed.
Bug: 42251044
Change-Id: I51e4fe08cb7a0d41e75041b89756746a9a4649ff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/208395
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.cc b/src/tint/lang/glsl/writer/raise/shader_io.cc
index a13a9c6..bf1bf7a 100644
--- a/src/tint/lang/glsl/writer/raise/shader_io.cc
+++ b/src/tint/lang/glsl/writer/raise/shader_io.cc
@@ -128,10 +128,18 @@
if (io.attributes.builtin) {
name << GLSLBuiltinToString(*io.attributes.builtin, addrspace);
- if (io.attributes.builtin == core::BuiltinValue::kSampleMask) {
- ptr = ty.ptr(addrspace, ty.array(ty.i32(), 1), access);
- } else {
- ptr = ty.ptr(addrspace, io.type, access);
+ switch (io.attributes.builtin.value()) {
+ case core::BuiltinValue::kSampleMask:
+ ptr = ty.ptr(addrspace, ty.array(ty.i32(), 1), access);
+ break;
+ case core::BuiltinValue::kVertexIndex:
+ case core::BuiltinValue::kInstanceIndex:
+ case core::BuiltinValue::kSampleIndex:
+ ptr = ty.ptr(addrspace, ty.i32(), access);
+ break;
+ default:
+ ptr = ty.ptr(addrspace, io.type, access);
+ break;
}
} else {
name << ir.NameOf(func).Name();