yum-mirror/slang

Making it easier to work with shaders

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

Yong HeFix spirv emit that leads to pathological downstream time. (#3546)6dca7e392

master
931 B34 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target spirv -entry computeMain -stage compute -emit-spirv-directly
2
3// Check that we are not generating spirv that loads a global resource array into a SSA register,
4// instead, these arrays should always be accessed via direct OpAccessChain operations to avoid
5// creating a lot of local load/stores in the driver compiler.
6
7struct Scene
8{
9    SamplerState samplers[256];
10    Texture2D textures[100];
11}
12
13ParameterBlock<Scene> scene;
14struct Material
15{
16    int sampler;
17    int texture;
18}
19
20RWStructuredBuffer<float4> result;
21
22float4 shade(Scene scene, Material mat)
23{
24    return scene.textures[mat.texture].SampleLevel(scene.samplers[mat.sampler], float2(0,0), 0);
25}
26
27[numthreads(1,1,1)]
28void computeMain(uniform Material mat)
29{
30    // CHECK: OpEntryPoint
31    // CHECK-NOT: OpLoad {{.*}} %scene{{.*}}samplers
32    // CHECK-NOT: OpLoad {{.*}} %scene{{.*}}textures
33    result[0] = shade(scene, mat);
34}