diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 525b666ab0..6ac0b7fb9e 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -9498,7 +9498,8 @@ T ldexp(T x, T exp) __target_switch { case hlsl: __intrinsic_asm "ldexp"; - case wgsl: __intrinsic_asm "ldexp"; + // In WGSL spec, ldexp can only take integer as the exponent. + case wgsl: __intrinsic_asm "($0 * exp2($1))"; default: return x * exp2(exp); } @@ -9512,7 +9513,8 @@ vector ldexp(vector x, vector exp) __target_switch { case hlsl: __intrinsic_asm "ldexp"; - case wgsl: __intrinsic_asm "ldexp"; + // In WGSL spec, ldexp can only take integer as the exponent. + case wgsl: __intrinsic_asm "($0 * exp2($1))"; default: return x * exp2(exp); } @@ -9737,13 +9739,14 @@ matrix log(matrix x) /// @category math __generic [__readNone] -[require(cpp_cuda_glsl_hlsl_metal_spirv, sm_4_0_version)] +[require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, sm_4_0_version)] T log10(T x) { __target_switch { case hlsl: __intrinsic_asm "log10"; case metal: __intrinsic_asm "log10"; + case wgsl: __intrinsic_asm "(log( $0 ) * $S0( 0.43429448190325182765112891891661) )"; case glsl: __intrinsic_asm "(log( $0 ) * $S0( 0.43429448190325182765112891891661) )"; case cuda: __intrinsic_asm "$P_log10($0)"; case cpp: __intrinsic_asm "$P_log10($0)"; @@ -9760,13 +9763,14 @@ T log10(T x) __generic [__readNone] -[require(cpp_cuda_glsl_hlsl_metal_spirv, sm_4_0_version)] +[require(cpp_cuda_glsl_hlsl_metal_spirv_wgsl, sm_4_0_version)] vector log10(vector x) { __target_switch { case hlsl: __intrinsic_asm "log10"; case metal: __intrinsic_asm "log10"; + case wgsl: __intrinsic_asm "(log( $0 ) * $S0(0.43429448190325182765112891891661) )"; case glsl: __intrinsic_asm "(log( $0 ) * $S0(0.43429448190325182765112891891661) )"; case spirv: { diff --git a/tests/expected-failure-github.txt b/tests/expected-failure-github.txt index b064af9ad8..3c318993a1 100644 --- a/tests/expected-failure-github.txt +++ b/tests/expected-failure-github.txt @@ -69,8 +69,6 @@ tests/hlsl-intrinsic/classify-float.slang.5 syn (wgpu) tests/hlsl-intrinsic/matrix-float.slang.6 syn (wgpu) tests/hlsl-intrinsic/matrix-int.slang.6 syn (wgpu) tests/hlsl-intrinsic/scalar-double-simple.slang.7 syn (wgpu) -tests/hlsl-intrinsic/scalar-float.slang.5 syn (wgpu) -tests/hlsl-intrinsic/vector-float.slang.5 syn (wgpu) tests/ir/string-literal-hash.slang.2 syn (wgpu) tests/language-feature/anonymous-struct.slang.1 syn (wgpu) tests/language-feature/constants/constexpr-loop.slang.2 syn (wgpu) diff --git a/tests/hlsl-intrinsic/scalar-float.slang b/tests/hlsl-intrinsic/scalar-float.slang index 148e1b6960..a32fe8f6cf 100644 --- a/tests/hlsl-intrinsic/scalar-float.slang +++ b/tests/hlsl-intrinsic/scalar-float.slang @@ -4,7 +4,7 @@ //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj //DISABLED_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -shaderobj -//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu +//TEST(compute):COMPARE_COMPUTE_EX:-wgpu -compute -shaderobj //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer outputBuffer; diff --git a/tests/hlsl-intrinsic/vector-float.slang b/tests/hlsl-intrinsic/vector-float.slang index de5decfecf..380131a895 100644 --- a/tests/hlsl-intrinsic/vector-float.slang +++ b/tests/hlsl-intrinsic/vector-float.slang @@ -3,7 +3,7 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -output-using-type -shaderobj //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -shaderobj //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj -//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu +//TEST(compute):COMPARE_COMPUTE_EX:-wgpu -compute -output-using-type -shaderobj //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer outputBuffer;