diff options
| author | Yong He <yonghe@outlook.com> | 2025-02-27 16:57:52 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-27 16:57:52 -0800 |
| commit | 6f2ce72b038b34e84819ddfc5d658166ed879eaa (patch) | |
| tree | 486a85523114a428ccf4deee05bcbab0d4b9528b /source/slang/glsl.meta.slang | |
| parent | 90b3817498d9cf664346f04dcea71f48ce81993e (diff) | |
Map `SV_InstanceID` to `gl_InstanceIndex-gl_BaseInstance` (#6468)
* Map `SV_InstanceID` to `gl_InstanceIndex-gl_BaseInstance`
* Fix ci.
Diffstat (limited to 'source/slang/glsl.meta.slang')
| -rw-r--r-- | source/slang/glsl.meta.slang | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source/slang/glsl.meta.slang b/source/slang/glsl.meta.slang index 6f0ca1bf3..eed6cc690 100644 --- a/source/slang/glsl.meta.slang +++ b/source/slang/glsl.meta.slang @@ -136,7 +136,27 @@ public property uint3 gl_WorkGroupSize // TODO: define overload for tessellation control stage. public in int gl_InvocationID : SV_GSInstanceID; -public in int gl_InstanceIndex : SV_InstanceID; +internal in int __sv_InstanceIndex : SV_InstanceID; + +// SPIRV InstanceIndex builtin for vertex shader +public property int gl_InstanceIndex +{ + [require(vertex)] + get + { + __target_switch + { + default: + return __sv_InstanceIndex; + case glsl: + __intrinsic_asm "gl_InstanceIndex"; + case spirv: + return spirv_asm { + result:$$int = OpLoad builtin(InstanceIndex:int); + }; + } + } +} public in bool gl_FrontFacing : SV_IsFrontFace; // TODO: define overload for geometry stage. |
