summaryrefslogtreecommitdiff
path: root/source/slang/hlsl.meta.slang
diff options
context:
space:
mode:
authorsricker-nvidia <115114531+sricker-nvidia@users.noreply.github.com>2025-05-15 17:01:08 -0700
committerGitHub <noreply@github.com>2025-05-16 00:01:08 +0000
commitb39ec87cccaadebbb9325dd2adb8c0b13b364805 (patch)
tree322660b9f058b1d0e2d9b990573332848529a3b0 /source/slang/hlsl.meta.slang
parentfba75a6f3f3c26b05cf4c826bff4a102972d348c (diff)
Fix broken -emit-spirv-via-glsl test option (#7091)
Fixes issue #6898 The -emit-spirv-via-glsl slang-test option has been broken for some amount of time. Tests that were using it were operating as if using -emit-spirv-directly, leading to many duplicated tests. After fixing the test option, there were an number of errors that appeared as a result. This change fixes the broken test option and the resulting test errors. Some of the test errors revealed some legitimate issues, such as: -The GLSL bitCount instrinsic only supports 32-bit integers and requires emulation for other bit widths. -Emitting GLSL 8-bit and 16-bit glsl integer types did not emit the proper extension requirements -Emitting GLSL and casting for 16-bit integers was missing a closing parenthesis. -Missing profile for GL_EXT_shader_explicit_arithmetic_types -Missing toType cases for UInt8/Int8 for the kIROp_BitCast case in tryEmitInstExprImpl.
Diffstat (limited to 'source/slang/hlsl.meta.slang')
-rw-r--r--source/slang/hlsl.meta.slang27
1 files changed, 23 insertions, 4 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index d7a65c031..6fb3af7fd 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -8084,9 +8084,20 @@ uint countbits(T value)
// 16-bit support dependent on SM6.2 and dxil
__intrinsic_asm "countbits";
case glsl:
- // 64-bit support dependent on GL_ARB_gpu_shader_int64
- // 16-bit support dependent on GL_EXT_shader_16bit_storage
- __intrinsic_asm "bitCount";
+ if(T is int64_t || T is uint64_t)
+ {
+ return __emulatedCountbits64(__intCast<uint64_t>(value));
+ }
+ else if (T is int16_t || T is uint16_t)
+ {
+ // emulate 16-bit
+ return countbits(__intCast<uint32_t>(value));
+ }
+ else
+ {
+ // bitCount only supports 32-bit
+ __intrinsic_asm "bitCount";
+ }
case metal:
if (T is int64_t || T is uint64_t)
{
@@ -8150,7 +8161,15 @@ vector<uint, N> countbits(vector<T, N> value)
case hlsl:
__intrinsic_asm "countbits";
case glsl:
- __intrinsic_asm "bitCount";
+ if(T is int64_t || T is uint64_t || T is int16_t || T is uint16_t)
+ {
+ // Emulate 64-bit and 16-bit
+ VECTOR_MAP_UNARY(uint, N, countbits, value);
+ }
+ else
+ {
+ __intrinsic_asm "bitCount";
+ }
case metal:
if(T is int64_t || T is uint64_t || T is int16_t || T is uint16_t)
{