yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1// dxc-matrix-layout.hlsl 2 3// This test tries to ensure that a `row_major` layout default specified on 4// the command line makes it through to affect code generation on all targets. 5// The test was created because it was found that released versions of dxc 6// were ignoring the `#pragma pack_matrix` directive. 7 8// This has a compatibility issue on Windows 10.0.10586 on Dx12 - dxcompiler will crash (can remove form tests with -exclude compatibility-issue) 9 10//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx11 -xslang -matrix-layout-row-major -shaderobj 11//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -xslang -matrix-layout-row-major -shaderobj 12//TEST(compute,compatibility-issue):COMPARE_COMPUTE_EX:-slang -compute -dx12 -xslang -matrix-layout-row-major -shaderobj 13//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl 14 15// Not testing on Vulkan because of lack of support 16// for integer matrices in GLSL. Slang needs to 17// supporting lowering of such matrix before we 18// can run this test. 19// 20//NO_TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -xslang -matrix-layout-row-major 21 22struct S 23{ 24int3x4 a ; 25int b ; 26}; 27 28//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]):name=C0 29cbuffer C0 30{ 31S s ; 32}; 33 34//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]):name=C1 35cbuffer C1 36{ 37 38// Note: support for the explicit `row_major` and `column_major` modifiers is being 39// disabled for now, since our current Vulkan output strategy cannot possibly match the 40// semantics of these modifiers in D3D. Once we do a more complete implementation of 41// matrix layout (see GitHub issue #695) we can add a directed test for all the 42// corners cases of explicit matrix layout. 43// 44// column_major 45int3x4 cc ; 46int dd ; 47}; 48 49int test ( int val ) 50{ 51int N = 256 ; 52 53// Note: using `val %3` here instead of `val %4` in order 54// to work around a code generation issue in dxc. 55// 56int a = s . a [ val / 4 ][ val % 3 ]; 57int b = s . b ; 58 59int c = cc [ val / 4 ][ val % 3 ]; 60int d = dd ; 61 62return (( a * N + b ) * N + c ) * N + d ; 63} 64 65//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name=buffer 66RWStructuredBuffer < int > buffer ; 67 68[ numthreads ( 12 , 1 , 1 )] 69void computeMain ( int3 dispatchThreadID : SV_DispatchThreadID ) 70{ 71int tid = dispatchThreadID . x ; 72 73int val = tid ; 74val = test ( val ); 75 76buffer [ tid ] = val ; 77}