yum-mirror/slang

Making it easier to work with shaders

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

Yong HeRewriting the lower-buffer-element-type pass to avoid unnecessary packing/unpacking. (#8526)a6deb5ed8

master
1.1 KiB33 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly -profile glsl_460
2//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type -xslang -g0
3//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-d3d12 -compute -output-using-type
4//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-cpu -compute -output-using-type
5
6// Check that when generating spirv directly, we do not load the entire big array
7// from the constant buffer into registers.
8
9struct WorkData
10{
11    float A[2*2];
12    float B[1024];
13    
14    float Foo(uint i) { return A[i] * B[i]; }
15};
16
17//TEST_INPUT:set input = new WorkData{[1.0, 2.0, 3.0, 4.0], [10.0, 20.0, 30.0, 40.0]}
18ConstantBuffer<WorkData> input;
19
20//TEST_INPUT:set resultBuffer = out ubuffer(data=[0 0 0 0], stride=4)
21RWStructuredBuffer<float> resultBuffer;
22
23// CHECK-NOT: OpLoopMerge
24// CHECK-NOT: OpCompositeConstruct
25// CHECK-COUNT-1: OpStore
26
27[numthreads(2, 1, 1)]
28void computeMain(uint3 tid: SV_DispatchThreadID)
29{
30    // BUF: 10.0
31    // BUF: 40.0
32    resultBuffer[tid.x] = input.Foo(tid.x);
33}