From 36742ae0ad8b11e5ae6c2c0c7531b272800e5ff6 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Fri, 26 Oct 2018 10:58:08 -0700 Subject: Work around dxc matrix layout behavior (#694) The Slang compiler allows the default matrix layout convention (row-major vs. column-major) to be specified via the command line or API. When generating output HLSL, Slang emits a `#pragma pack_matrix` directive for the chosen default convention, so that a user can generate plain HLSL output and still have it encode their desired defaults. The problem that has arisen is that many released versions of dxc (including those in the most recent Windows SDK at this time) *ignore* the `#pragma pack_matrix` directive (the feature has since been added to top-of-tree dxc). The main fix here is to instead pass the `-Zpr` option in to dxc when invoking it if the row-major (non-default) convention is requested. This will solve the problem for clients that use Slang to generate DXIL, but not for clients who use Slang to generate plain HLSL that they then pass into dxc (those clients are assumed to be able to work around the problem for themselves). In order to test the change, I added a test that fills a constant buffer with sequential integers, and then reads out the rows/columns of an `int3x4` matrix with both row- and column-major layout, as well as an integer placed *after* the matrix, so we can see the offset it was given. The `render-test` application did not yet support generating code via dxc/DXIL, so I added an option for that. This ends up assuming that anybody who is running the D3D12 tests will also have a version of dxc available. --- tools/render-test/options.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools/render-test/options.cpp') diff --git a/tools/render-test/options.cpp b/tools/render-test/options.cpp index ec0bc0844..d99ba355e 100644 --- a/tools/render-test/options.cpp +++ b/tools/render-test/options.cpp @@ -139,6 +139,10 @@ SlangResult parseOptions(int* argc, char** argv) { gOptions.rendererType = RendererType::DirectX11; } + else if( strcmp(arg, "-use-dxil") == 0 ) + { + gOptions.useDXIL = true; + } else { fprintf(stderr, "unknown option '%s'\n", arg); -- cgit v1.2.3