summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2024-11-26 19:02:59 +0200
committerGitHub <noreply@github.com>2024-11-26 12:02:59 -0500
commit915e05dcc4c03492087c2d3126ba01dff9ebe1be (patch)
treee69ff25b99a179ffc98c9b2037fb658788af4c94 /source
parent9e21cd4a7552390aff9a1421f2c7f6666876d0bc (diff)
WGSL: Fix issue where swizzle L-values are generated (#5682)
* wgsl: Do not generate L-value swizzle expressions * Enable tests/language-feature/swizzles/matrix-swizzle-write-*.slang The following tests are enabled - tests/language-feature/swizzles/matrix-swizzle-write-swizzle.slang - tests/language-feature/swizzles/matrix-swizzle-write-array.slang This closes #5603.
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-emit-c-like.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp
index 790162c5b..f10147f0d 100644
--- a/source/slang/slang-emit-c-like.cpp
+++ b/source/slang/slang-emit-c-like.cpp
@@ -1661,7 +1661,7 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst)
}
}
- // For cuda and cpu targets don't support swizzle on the left-hand-side
+ // The cpp, cuda and wgsl targets don't support swizzle on the left-hand-side
// variable, e.g. vec4.xy = vec2 is not allowed.
// Therefore, we don't want to fold the right-hand-side expression.
// Instead, the right-hand-side expression should be generated as a separable
@@ -1669,7 +1669,8 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst)
// variable per element. E.g. vec4.x = vec2.x; vec4.y = vec2.y.
if (as<IRSwizzledStore>(user))
{
- if (isCPUTarget(getTargetReq()) || isCUDATarget(getTargetReq()))
+ if (isCPUTarget(getTargetReq()) || isCUDATarget(getTargetReq()) ||
+ isWGPUTarget(getTargetReq()))
return false;
}
@@ -3123,9 +3124,10 @@ void CLikeSourceEmitter::_emitInst(IRInst* inst)
case kIROp_SwizzledStore:
{
- // cpp and cuda target don't support swizzle on the left handside, so we
+ // cpp, cuda and wgsl targets don't support swizzle on the left handside, so we
// have to assign the element one by one.
- if (isCPUTarget(getTargetReq()) || isCUDATarget(getTargetReq()))
+ if (isCPUTarget(getTargetReq()) || isCUDATarget(getTargetReq()) ||
+ isWGPUTarget(getTargetReq()))
{
_emitSwizzleStorePerElement(inst);
}