summaryrefslogtreecommitdiff
path: root/tests/language-feature/swizzles/matrix-swizzle-write-array.slang
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-04-13 23:49:00 +0800
committerGitHub <noreply@github.com>2023-04-13 08:49:00 -0700
commitc7e5601bb67d2a5ebadb7f84c6968b5912e7566d (patch)
tree311903d485d42617288198ea45f46c50e150f082 /tests/language-feature/swizzles/matrix-swizzle-write-array.slang
parent6fbd892a0e015fd07d1c41983676713aa6f09333 (diff)
Matrix swizzle writes (#2713)
* Add a bunch of builder emit wrappers for constant indices To avoid cluttering any calling code with int instruction construction * Matrix swizzle stores Closes https://github.com/shader-slang/slang/issues/2512 * Matrix swizzle store tests * Squash vs warnings * Select scalar for singular swizzles * Test singular swizzle materialization * Use IRIntegerValue over UInt for IR wrappers * Correct size of swizzle vector type * Remove variable shadowing
Diffstat (limited to 'tests/language-feature/swizzles/matrix-swizzle-write-array.slang')
-rw-r--r--tests/language-feature/swizzles/matrix-swizzle-write-array.slang36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/language-feature/swizzles/matrix-swizzle-write-array.slang b/tests/language-feature/swizzles/matrix-swizzle-write-array.slang
new file mode 100644
index 000000000..7d266b8cd
--- /dev/null
+++ b/tests/language-feature/swizzles/matrix-swizzle-write-array.slang
@@ -0,0 +1,36 @@
+//TEST(compute):COMPARE_COMPUTE: -compute -shaderobj -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE: -vk -compute -shaderobj -output-using-type
+
+// Test that matrix swizzle writes work 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
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<float2x2> outputBuffer;
+
+struct MySubscriptable
+{
+ float2x2 m;
+ __subscript() -> float2x2
+ {
+ get { return m; }
+ set { m = newValue; }
+ }
+};
+
+[numthreads(1, 1, 1)]
+void computeMain(uint tid : SV_GroupIndex)
+{
+ MySubscriptable s;
+ s.m = float2x2(0,0,0,0);
+
+ // _ 1
+ // 4 5
+ s[]._12_21_22 = float3(1, 4, 5);
+
+ // 2 1
+ // 4 3
+ s[]._m00_m11 = float2(2, 3);
+
+ outputBuffer[tid] = s.m;
+}