From 8b3e3beea66d9773adf11ea2e163577d649f3d7c Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 28 Jan 2020 12:35:13 -0800 Subject: 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 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 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. --- ...rix-layout-structured-buffer.slang.expected.txt | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/compute/matrix-layout-structured-buffer.slang.expected.txt') diff --git a/tests/compute/matrix-layout-structured-buffer.slang.expected.txt b/tests/compute/matrix-layout-structured-buffer.slang.expected.txt index 18d8be654..e0bbef746 100644 --- a/tests/compute/matrix-layout-structured-buffer.slang.expected.txt +++ b/tests/compute/matrix-layout-structured-buffer.slang.expected.txt @@ -1,12 +1,12 @@ -80010300 -90111301 -88060B02 -95160C03 -81020404 -910F1405 -86070906 -96170D07 -82000508 -8F101209 -87080A0A -97150E0B +80040100 +91151201 +8A020B02 +8F130C03 +84080504 +950D1605 +82060306 +93171007 +88000908 +8D110E09 +860A070A +970F140B -- cgit v1.2.3