diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 7c68a641c1..2df66c1f71 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -8658,10 +8658,21 @@ T frexp(T x, out int exp) case spirv: return spirv_asm { result:$$T = OpExtInst glsl450 Frexp $x &exp }; - case wgsl: __intrinsic_asm "frexp"; + case wgsl: + T fract; + __wgsl_frexp(x, fract, exp); + return fract; } } +__generic +[__readNone] +[require(wgsl)] +void __wgsl_frexp(T x, out T fract, out int exp) +{ + __intrinsic_asm "{ var s = frexp($0); $1 = s.fract; $2 = s.exp; }"; +} + __generic [__readNone] [require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, sm_4_0_version)] @@ -8675,7 +8686,6 @@ vector frexp(vector x, out vector exp) case spirv: return spirv_asm { result:$$vector = OpExtInst glsl450 Frexp $x &exp }; - case wgsl: __intrinsic_asm "frexp"; default: VECTOR_MAP_BINARY(T, N, frexp, x, exp); } @@ -11055,10 +11065,21 @@ T modf(T x, out T ip) case spirv: return spirv_asm { result:$$T = OpExtInst glsl450 Modf $x &ip }; - case wgsl: __intrinsic_asm "modf"; + case wgsl: + T fract; + __wgsl_modf(x, fract, ip); + return fract; } } +__generic +[__readNone] +[require(wgsl)] +void __wgsl_modf(T x, out T fract, out T whole) +{ + __intrinsic_asm "{ var s = modf($0); $1 = s.fract; $2 = s.whole; }"; +} + __generic [__readNone] [require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, sm_4_0_version)] @@ -11072,7 +11093,6 @@ vector modf(vector x, out vector ip) case spirv: return spirv_asm { result:$$vector = OpExtInst glsl450 Modf $x &ip }; - case wgsl: __intrinsic_asm "modf"; default: VECTOR_MAP_BINARY(T, N, modf, x, ip); }