summaryrefslogtreecommitdiffstats
path: root/tests/compute/matrix-layout-structured-buffer.slang
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2020-01-28 12:35:13 -0800
committerTim Foley <tim.foley.is@gmail.com>2020-01-28 12:35:13 -0800
commit8b3e3beea66d9773adf11ea2e163577d649f3d7c (patch)
tree51b4f3967d5db5494f98f6f9bf870ef2096929f5 /tests/compute/matrix-layout-structured-buffer.slang
parentb3e0b0d491c55bfdc1c40d26a421910103c1b9f2 (diff)
Fix layout for structured buffers of matrices (#1184)
When using row-major layout (via command-line or API option), the following sort of declaration: ```hlsl StructuredBuffer<float4x4> gBuffer; ... gBuffer[i] ... ``` Generates unexpected results when compiled to DXBC via fxc or DXIL via dxc, because the fxc/dxc compilers do not respect the matrix layout mode in this specific case (a structured buffer of matrices). Instead, they always use column-major layout, even if row-major was requested by the user. A user can work around this behavior by wrapping the matrix in a `struct`: ```hlsl struct Wrapper { float4x4 wrapped; } SturcturedBuffer<Wrapper> gBuffer; ... gBuffer[i].wrapped ... ``` This change simply automates that workaround when compiling for an HLSL-based downstream compiler, so that we get the same behavior across all our backends. The change adds a test case to confirm the behavior across multiple targets, but it turns out we also had a test checked in that confirmed the buggy (or at least surprising) fxc/dxc behavior, so that one had its baselines changed and can work as a regression test for this fix as well.
Diffstat (limited to 'tests/compute/matrix-layout-structured-buffer.slang')
-rw-r--r--tests/compute/matrix-layout-structured-buffer.slang17
1 files changed, 4 insertions, 13 deletions
diff --git a/tests/compute/matrix-layout-structured-buffer.slang b/tests/compute/matrix-layout-structured-buffer.slang
index 36596424d..bb7dbb381 100644
--- a/tests/compute/matrix-layout-structured-buffer.slang
+++ b/tests/compute/matrix-layout-structured-buffer.slang
@@ -1,18 +1,9 @@
// matrix-layout-structured-buffer.slang
-// This test is set up to confirm that `StructuredBuffer` types are
-// always laid out column-major by fxc/dxc, even when row-major layout has been
-// requested globally.
-//
-// This behavior should be considered a bug in Slang because either:
-//
-// 1. we should report reflection layout information that acknowledges this behavior, or
-// 2. we should alter our HLSL output passed to fxc/dxc to provide consistent
-// behavior that matches our reflection data.
-//
-// For now this test exists to document the situation. It's output can/should
-// be updated if we decide to fix the underlying problem by taking option (2).
-//
+// This test confirms that we apply the matrix layout
+// mode requested by the user, even in the case of structured
+// buffers of matrices, where fxc/dxc do *not* respect
+// the matrix layout mode by default.
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -xslang -matrix-layout-row-major
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -xslang -matrix-layout-column-major