From 6912c58538112e75f3c18c749ceabe8f316fcef8 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:30:40 -0700 Subject: Fix incorrect use of pointer in WGSL (#5144) Closes #5143 Recently there was a commit that changed the behavior of the memory pointer for WGSL. This commit fixes some issues came up after the change. --- source/slang/hlsl.meta.slang | 8 ++++---- source/slang/slang-stdlib-textures.cpp | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'source') diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index b0c1ed450..8d1b3202e 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -9039,7 +9039,7 @@ __generic [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; }"; + __intrinsic_asm "{ var s = frexp($0); ($1) = s.fract; ($2) = s.exp; }"; } __generic @@ -9071,7 +9071,7 @@ __generic [require(wgsl)] void __wgsl_frexp(vector x, out vector fract, out vector exp) { - __intrinsic_asm "{ var s = frexp($0); (*($1)) = s.fract; (*($2)) = s.exp; }"; + __intrinsic_asm "{ var s = frexp($0); ($1) = s.fract; ($2) = s.exp; }"; } __generic @@ -11469,7 +11469,7 @@ __generic [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; }"; + __intrinsic_asm "{ var s = modf($0); ($1) = s.fract; ($2) = s.whole; }"; } __generic @@ -11501,7 +11501,7 @@ __generic [require(wgsl)] void __wgsl_modf(vector x, out vector fract, out vector whole) { - __intrinsic_asm "{ var s = modf($0); (*($1)) = s.fract; (*($2)) = s.whole; }"; + __intrinsic_asm "{ var s = modf($0); ($1) = s.fract; ($2) = s.whole; }"; } __generic diff --git a/source/slang/slang-stdlib-textures.cpp b/source/slang/slang-stdlib-textures.cpp index a9f14522b..c9b7598c7 100644 --- a/source/slang/slang-stdlib-textures.cpp +++ b/source/slang/slang-stdlib-textures.cpp @@ -224,7 +224,7 @@ void TextureTypeInfo::writeGetDimensionFunctions() ++paramCount; params << t << "width"; metal << "(*($" << String(paramCount) << ") = $0.get_width(" << String(metalMipLevel) << ")),"; - wgsl << "*($" << String(paramCount) << ") = textureDimensions($0" << (includeMipInfo ? ", $1" : "") << ");"; + wgsl << "($" << String(paramCount) << ") = textureDimensions($0" << (includeMipInfo ? ", $1" : "") << ");"; sizeDimCount = 1; break; @@ -235,12 +235,12 @@ void TextureTypeInfo::writeGetDimensionFunctions() params << t << "width,"; metal << "(*($" << String(paramCount) << ") = $0.get_width(" << String(metalMipLevel) << ")),"; wgsl << "var dim = textureDimensions($0" << (includeMipInfo ? ", $1" : "") << ");"; - wgsl << "(*$" << String(paramCount) << ") = dim.x;"; + wgsl << "($" << String(paramCount) << ") = dim.x;"; ++paramCount; params << t << "height"; metal << "(*($" << String(paramCount) << ") = $0.get_height(" << String(metalMipLevel) << ")),"; - wgsl << "(*$" << String(paramCount) << ") = dim.y;"; + wgsl << "($" << String(paramCount) << ") = dim.y;"; sizeDimCount = 2; break; @@ -250,17 +250,17 @@ void TextureTypeInfo::writeGetDimensionFunctions() params << t << "width,"; metal << "(*($" << String(paramCount) << ") = $0.get_width(" << String(metalMipLevel) << ")),"; wgsl << "var dim = textureDimensions($0" << (includeMipInfo ? ", $1" : "") << ");"; - wgsl << "(*$" << String(paramCount) << ") = dim.x;"; + wgsl << "($" << String(paramCount) << ") = dim.x;"; ++paramCount; params << t << "height,"; metal << "(*($" << String(paramCount) << ") = $0.get_height(" << String(metalMipLevel) << ")),"; - wgsl << "(*$" << String(paramCount) << ") = dim.y;"; + wgsl << "($" << String(paramCount) << ") = dim.y;"; ++paramCount; params << t << "depth"; metal << "(*($" << String(paramCount) << ") = $0.get_depth(" << String(metalMipLevel) << ")),"; - wgsl << "(*$" << String(paramCount) << ") = dim.z;"; + wgsl << "($" << String(paramCount) << ") = dim.z;"; sizeDimCount = 3; break; @@ -276,7 +276,7 @@ void TextureTypeInfo::writeGetDimensionFunctions() ++paramCount; params << ", " << t << "elements"; metal << "(*($" << String(paramCount) << ") = $0.get_array_size()),"; - wgsl << "(*$" << String(paramCount) << ") = textureNumLayers($0);"; + wgsl << "($" << String(paramCount) << ") = textureNumLayers($0);"; } if (isMultisample) @@ -284,7 +284,7 @@ void TextureTypeInfo::writeGetDimensionFunctions() ++paramCount; params << ", " << t << "sampleCount"; metal << "(*($" << String(paramCount) << ") = $0.get_num_samples()),"; - wgsl << "(*$" << String(paramCount) << ") = textureNumSamples($0);"; + wgsl << "($" << String(paramCount) << ") = textureNumSamples($0);"; } if (includeMipInfo) @@ -292,7 +292,7 @@ void TextureTypeInfo::writeGetDimensionFunctions() ++paramCount; params << ", " << t << "numberOfLevels"; metal << "(*($" << String(paramCount) << ") = $0.get_num_mip_levels()),"; - wgsl << "(*$" << String(paramCount) << ") = textureNumLevels($0);"; + wgsl << "($" << String(paramCount) << ") = textureNumLevels($0);"; } metal.reduceLength(metal.getLength() - 1); // drop the last comma -- cgit v1.2.3