diff options
| author | Dietrich Geisler <dag368@cornell.edu> | 2020-06-02 12:12:35 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-02 09:12:35 -0700 |
| commit | 926a0c51071f6cf5718c77958cc801030ce9d404 (patch) | |
| tree | c02e84cd402afc6383db2e169c08d05c2a12fbc6 /tests/language-feature | |
| parent | 8acb704ecabc10c31e664de3814c544572e3945f (diff) | |
Working matrix swizzle (#1354)
* Working matrix swizzle.
Supports one and zero indexing and multiple elements.
Performs semantic checking of the swizzle. Matrix swizzles are
transformed into a vector of indexing operations during lowering to the
IR.
This change does not handle matrix swizzle as lvalues.
* Renaming
* Added missing semicolon
* Initialize variable for gcc
* Added the expect file for diagnostics
* Matrix swizzle updated per PR feedback
* Stylistic fix
* Formatting fixes
* Fix compiling with AST change.
Change indentation.
Co-authored-by: jsmall-nvidia <jsmall@nvidia.com>
Diffstat (limited to 'tests/language-feature')
| -rw-r--r-- | tests/language-feature/swizzles/matrix-swizzles.slang | 34 | ||||
| -rw-r--r-- | tests/language-feature/swizzles/matrix-swizzles.slang.expected.txt | 4 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/language-feature/swizzles/matrix-swizzles.slang b/tests/language-feature/swizzles/matrix-swizzles.slang new file mode 100644 index 000000000..e1a2d7473 --- /dev/null +++ b/tests/language-feature/swizzles/matrix-swizzles.slang @@ -0,0 +1,34 @@ +// matrix-swizzle.slang + +//TEST(compute):COMPARE_COMPUTE: + +// Test that matrix swizzle works correctly +// Matrix swizzles can either be one or zero indexed +// Reference: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-per-component-math + +int test(int val) +{ + float2x2 worldMatrix = float2x2(val + 0, val + 1, val + 2, val + 3); + float2 tempVector1; + float2 tempVector2; + + // TODO: make left-hand side matrix swizzles work + tempVector1 = worldMatrix._m00_m11; + tempVector2 = worldMatrix._12_21; + + // return tempMatrix[0][0] + tempMatrix[0][1] = val + 0 + val + 1 + return tempVector1.x + tempVector2.x; +} + + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<int> outputBuffer; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + int inVal = tid; + int outVal = test(inVal); + outputBuffer[tid] = outVal; +} diff --git a/tests/language-feature/swizzles/matrix-swizzles.slang.expected.txt b/tests/language-feature/swizzles/matrix-swizzles.slang.expected.txt new file mode 100644 index 000000000..9b4237ab1 --- /dev/null +++ b/tests/language-feature/swizzles/matrix-swizzles.slang.expected.txt @@ -0,0 +1,4 @@ +1 +3 +5 +7 |
