Skip to content

Commit 9209f4b

Browse files
committed
spirv: recognize builtin extern vars
1 parent dacd70f commit 9209f4b

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/codegen/spirv.zig

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,6 +2972,46 @@ const NavGen = struct {
29722972
.storage_class = storage_class,
29732973
});
29742974

2975+
if (nav.fqn.eqlSlice("position", ip)) {
2976+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .Position } });
2977+
} else if (nav.fqn.eqlSlice("point_size", ip)) {
2978+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .PointSize } });
2979+
} else if (nav.fqn.eqlSlice("vertex_id", ip)) {
2980+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .VertexId } });
2981+
} else if (nav.fqn.eqlSlice("instance_id", ip)) {
2982+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .InstanceId } });
2983+
} else if (nav.fqn.eqlSlice("invocation_id", ip)) {
2984+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .InvocationId } });
2985+
} else if (nav.fqn.eqlSlice("frag_coord", ip)) {
2986+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .FragCoord } });
2987+
} else if (nav.fqn.eqlSlice("point_coord", ip)) {
2988+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .PointCoord } });
2989+
} else if (nav.fqn.eqlSlice("front_facing", ip)) {
2990+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .FrontFacing } });
2991+
} else if (nav.fqn.eqlSlice("sample_mask", ip)) {
2992+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .SampleMask } });
2993+
} else if (nav.fqn.eqlSlice("sample_mask", ip)) {
2994+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .SampleMask } });
2995+
} else if (nav.fqn.eqlSlice("frag_depth", ip)) {
2996+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .FragDepth } });
2997+
} else if (nav.fqn.eqlSlice("num_workgroups", ip)) {
2998+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .NumWorkgroups } });
2999+
} else if (nav.fqn.eqlSlice("workgroup_size", ip)) {
3000+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .WorkgroupSize } });
3001+
} else if (nav.fqn.eqlSlice("workgroup_id", ip)) {
3002+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .WorkgroupId } });
3003+
} else if (nav.fqn.eqlSlice("local_invocation_id", ip)) {
3004+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .LocalInvocationId } });
3005+
} else if (nav.fqn.eqlSlice("global_invocation_id", ip)) {
3006+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .GlobalInvocationId } });
3007+
} else if (nav.fqn.eqlSlice("local_invocation_index", ip)) {
3008+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .LocalInvocationIndex } });
3009+
} else if (nav.fqn.eqlSlice("vertex_index", ip)) {
3010+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .VertexIndex } });
3011+
} else if (nav.fqn.eqlSlice("instance_index", ip)) {
3012+
try self.spv.decorate(result_id, .{ .BuiltIn = .{ .built_in = .InstanceIndex } });
3013+
}
3014+
29753015
try self.spv.debugName(result_id, nav.fqn.toSlice(ip));
29763016
try self.spv.declareDeclDeps(spv_decl_index, &.{});
29773017
},

0 commit comments

Comments
 (0)