yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Yong HeMetal: misc fixes and enable more tests. (#4374)cfef0c6f6

master
1.6 KiB42 linesraw
1// structured-buffer-of-matrices.slang
2
3// This test confirms that we have implemented a workaround
4// for the issue where the Microsoft HLSL compilers (fxc and dxc)
5// ignore matrix layout settings (like `#pragma pack_matrx`)
6// in the case where a matrix type is used directly in a
7// structured buffer (e.g., `StructuredBuffer<float4x4>`),
8// and instead always use column-major layout.
9//
10// With our fix in place, this test should produce the same
11// output on all targets, correctly respecting the user's
12// request for row-major layout via command-line option.
13
14//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -compile-arg -O3 -xslang -matrix-layout-row-major -shaderobj
15//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -xslang -matrix-layout-row-major -shaderobj
16//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -xslang -matrix-layout-row-major -shaderobj
17//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -xslang -matrix-layout-row-major -shaderobj
18
19
20// Note: we are using a buffer of floating-point matrices, but fill it with integer
21// data, to allow this test to work on the Vulkan targets, which do not currently
22// support integer matrices, because of GLSL limitations.
23
24//TEST_INPUT:ubuffer(data=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15], stride=64):name gInput
25RWStructuredBuffer<float4x4> gInput;
26
27
28//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name gOutput
29RWStructuredBuffer<int> gOutput;
30
31int test(int val)
32{
33	return asint(gInput[0][(val+1)&3][(val+3)&3]);
34}
35
36[numthreads(4, 1, 1)]
37void computeMain(int3 tid : SV_DispatchThreadID)
38{
39	int value = tid.x;
40	value = test(value);
41	gOutput[tid.x] = value;
42}