authorgravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2025-05-09 18:08:23+03:30
committergravatar for alichraghi@proton.meAli Chraghi <alichraghi@proton.me> 2025-05-21 13:01:21+03:30
log9209f4b16acc4453f89a06caabf54691f6253f62
treeedd5d21ba49a185eb24bb6c203556d418786818e
parentdacd70fbe41d959bb7b48b5bad8612e74231524b

spirv: recognize builtin extern vars


1 files changed, 40 insertions(+), 0 deletions(-)

src/codegen/spirv.zig+40
......@@ -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 },