Skip to content

Commit

Permalink
Support nonuniformEXT for GLSL (shader-slang#5695)
Browse files Browse the repository at this point in the history
Adding nonuniformEXT intrinsic for GLSL

Co-authored-by: Ellie Hermaszewska <[email protected]>
  • Loading branch information
jkwak-work and expipiplus1 authored Nov 29, 2024
1 parent 55bea7d commit e53ca98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/slang/glsl.meta.slang
Original file line number Diff line number Diff line change
Expand Up @@ -9601,3 +9601,14 @@ public bool allInvocationsEqual(bool value)
{
return WaveActiveAllEqual(value);
}


/// extensions
/// https://github.com/KhronosGroup/GLSL/blob/main/extensions/ext/GL_EXT_nonuniform_qualifier.txt

__generic<T:__BuiltinArithmeticType>
__intrinsic_op($(kIROp_NonUniformResourceIndex))
[require(cpp_cuda_glsl_hlsl_spirv, nonuniformqualifier)]
public T nonuniformEXT(T index);


5 changes: 5 additions & 0 deletions tests/cross-compile/non-uniform-indexing.slang
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//TEST:SIMPLE(filecheck=CHECK):-target spirv-assembly -entry main -stage fragment -verify-debug-serial-ir
//TEST:SIMPLE(filecheck=CHECK):-target spirv-assembly -entry main -stage fragment -verify-debug-serial-ir -DGLSL -allow-glsl

// Confirm that `NonUniformResourceIndex` translates to SPIR-V as expected

Expand All @@ -11,5 +12,9 @@ float4 main(
float3 uv : UV)
: SV_Target
{
#if defined(GLSL)
return t[nonuniformEXT(int(uv.z))].Sample(s, uv.xy);
#else
return t[NonUniformResourceIndex(int(uv.z))].Sample(s, uv.xy);
#endif
}

0 comments on commit e53ca98

Please sign in to comment.