diff options
| -rw-r--r-- | source/slang/dxc-support.cpp | 10 | ||||
| -rw-r--r-- | tests/compute/matrix-layout.hlsl | 66 | ||||
| -rw-r--r-- | tests/compute/matrix-layout.hlsl.expected.txt | 12 | ||||
| -rw-r--r-- | tools/render-test/main.cpp | 6 | ||||
| -rw-r--r-- | tools/render-test/options.cpp | 4 | ||||
| -rw-r--r-- | tools/render-test/options.h | 2 |
6 files changed, 100 insertions, 0 deletions
diff --git a/source/slang/dxc-support.cpp b/source/slang/dxc-support.cpp index 30817d31c..b86330f20 100644 --- a/source/slang/dxc-support.cpp +++ b/source/slang/dxc-support.cpp @@ -122,6 +122,16 @@ namespace Slang args[argCount++] = L"-WX"; } + switch( targetReq->getDefaultMatrixLayoutMode() ) + { + default: + break; + + case kMatrixLayoutMode_RowMajor: + args[argCount++] = L"-Zpr"; + break; + } + String entryPointName = getText(entryPoint->name); OSString wideEntryPointName = entryPointName.ToWString(); diff --git a/tests/compute/matrix-layout.hlsl b/tests/compute/matrix-layout.hlsl new file mode 100644 index 000000000..68366fc5b --- /dev/null +++ b/tests/compute/matrix-layout.hlsl @@ -0,0 +1,66 @@ +// dxc-matrix-layout.hlsl + +// This test tries to ensure that a `row_major` layout default specified on +// the command line makes it through to affect code generation on all targets. +// The test was created because it was found that released versions of dxc +// were ignoring the `#pragma pack_matrix` directive. + +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -xslang -matrix-layout-row-major +//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -xslang -matrix-layout-row-major + +// Not testing on Vulkan because of lack of support +// for integer matrices in GLSL. Slang needs to +// supporting lowering of such matrix before we +// can run this test. +// +//NO_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -xslang -matrix-layout-row-major + +struct S +{ + int3x4 a; + int b; +}; + +//TEST_INPUT:cbuffer(data=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]):dxbinding(0),glbinding(0) +cbuffer C0 +{ + S s; +}; + +//TEST_INPUT:cbuffer(data=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]):dxbinding(1),glbinding(1) +cbuffer C1 +{ + column_major + int3x4 cc; + int dd; +}; + +int test(int val) +{ + int N = 256; + + // Note: using `val %3` here instead of `val %4` in order + // to work around a code generation issue in dxc. + + int a = s.a[val / 4][val % 3]; + int b = s.b; + + int c = cc[val / 4][val % 4]; + int d = dd; + + return ((a*N + b) * N + c) * N + d; +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0], stride=4):dxbinding(0),glbinding(2),out +RWStructuredBuffer<int> buffer; + +[numthreads(12, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint tid = dispatchThreadID.x; + + int val = tid; + val = test(val); + + buffer[tid] = val; +} diff --git a/tests/compute/matrix-layout.hlsl.expected.txt b/tests/compute/matrix-layout.hlsl.expected.txt new file mode 100644 index 000000000..cb8e2cae7 --- /dev/null +++ b/tests/compute/matrix-layout.hlsl.expected.txt @@ -0,0 +1,12 @@ +10D0111 +20D0511 +30D0911 +10D0D11 +60D0211 +70D0611 +50D0A11 +60D0E11 +B0D0311 +90D0711 +A0D0B11 +B0D0F11 diff --git a/tools/render-test/main.cpp b/tools/render-test/main.cpp index 77e077b6c..9dfcbe29e 100644 --- a/tools/render-test/main.cpp +++ b/tools/render-test/main.cpp @@ -460,6 +460,12 @@ SlangResult innerMain(int argc, char** argv) nativeLanguage = SLANG_SOURCE_LANGUAGE_HLSL; slangPassThrough = SLANG_PASS_THROUGH_FXC; profileName = "sm_5_0"; + if( gOptions.useDXIL ) + { + slangTarget = SLANG_DXIL; + slangPassThrough = SLANG_PASS_THROUGH_DXC; + profileName = "sm_6_0"; + } break; case RendererType::OpenGl: 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); diff --git a/tools/render-test/options.h b/tools/render-test/options.h index 78f673796..76fdf95af 100644 --- a/tools/render-test/options.h +++ b/tools/render-test/options.h @@ -46,6 +46,8 @@ struct Options char const* slangArgs[kMaxSlangArgs]; int slangArgCount = 0; + + bool useDXIL = false; }; extern Options gOptions; |
