diff options
| author | Yong He <yonghe@outlook.com> | 2023-04-13 10:34:08 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-13 10:34:08 -0700 |
| commit | 3b4a50d74059a26af2ed8c37fb2042f33ba7cf2c (patch) | |
| tree | 75a8337f5821ea30149df5292eb43a81c515498f | |
| parent | 7f091478ec89550483b3cd30b4eb30ffa5e12a62 (diff) | |
Fix scalar swizzle write. (#2801)
Co-authored-by: Yong He <yhe@nvidia.com>
| -rw-r--r-- | source/slang/slang-ir.cpp | 5 | ||||
| -rw-r--r-- | tests/bugs/scalar-swizzle-write.slang | 13 | ||||
| -rw-r--r-- | tests/bugs/scalar-swizzle-write.slang.expected.txt | 5 |
3 files changed, 23 insertions, 0 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index e624ef1fd..92da981ad 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -4690,6 +4690,11 @@ namespace Slang { type = getVectorType(matrixType->getElementType(), matrixType->getColumnCount()); } + else if (auto basicType = as<IRBasicType>(basePtrType->getValueType())) + { + // HLSL support things like float.x, in which case we just return the base pointer. + return basePtr; + } SLANG_RELEASE_ASSERT(type); auto inst = createInst<IRGetElementPtr>( this, diff --git a/tests/bugs/scalar-swizzle-write.slang b/tests/bugs/scalar-swizzle-write.slang new file mode 100644 index 000000000..f11dd0728 --- /dev/null +++ b/tests/bugs/scalar-swizzle-write.slang @@ -0,0 +1,13 @@ +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer +RWStructuredBuffer<float> outputBuffer; + + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) +{ + float v = 0.0; + v.x = float(dispatchThreadID.x); + outputBuffer[dispatchThreadID.x] = v.x; +}
\ No newline at end of file diff --git a/tests/bugs/scalar-swizzle-write.slang.expected.txt b/tests/bugs/scalar-swizzle-write.slang.expected.txt new file mode 100644 index 000000000..985cd7275 --- /dev/null +++ b/tests/bugs/scalar-swizzle-write.slang.expected.txt @@ -0,0 +1,5 @@ +type: float +0.0 +1.0 +2.0 +3.0 |
