yum-mirror/slang

Making it easier to work with shaders

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

Yong HeInitial implementation of SP#015 `DescriptorHandle<T>`. (#6028)5290c5806

master
1.3 KiB35 linesraw
1//TEST:SIMPLE(filecheck=MTL): -target metal
2//TEST:SIMPLE(filecheck=MTLLIB): -target metallib
3//TEST:SIMPLE(filecheck=CUDA): -target cuda -entry computeMain -stage compute
4//TEST:SIMPLE(filecheck=PTX): -target ptx -entry computeMain -stage compute 
5//TEST:SIMPLE(filecheck=SPV): -target spirv -entry computeMain -stage compute -emit-spirv-via-glsl
6//TEST:SIMPLE(filecheck=GLSL): -target glsl -entry computeMain -stage compute
7//TEST:SIMPLE(filecheck=HLSL): -target hlsl -entry computeMain -profile cs_6_6
8//TEST:SIMPLE(filecheck=DXIL): -target dxil -entry computeMain -profile cs_6_6
9//TEST:SIMPLE(filecheck=SPV): -target spirv
10
11// SPV-DAG: %[[REG:[A-Za-z_0-9]+]] = OpAccessChain{{.*}}NonUniform
12// SPV-DAG: %[[TEX:[A-Za-z_0-9]+]] = OpLoad {{.*}} %[[REG]]
13// SPV-DAG: OpImageSampleExplicitLod {{.*}} %[[TEX]]
14
15// HLSL: ResourceDescriptorHeap[NonUniformResourceIndex
16// HLSL: SamplerDescriptorHeap[NonUniformResourceIndex(
17
18// DXIL: define void @computeMain()
19
20// GLSL: _slang_resource_heap{{[0-9_]+}}[nonuniformEXT
21
22// MTL: void computeMain
23// MTLLIB: @computeMain
24
25// CUDA: tex2DLod
26// PTX: computeMain
27
28uniform StructuredBuffer<Sampler2D.Handle> t;
29uniform RWStructuredBuffer<float4>.Handle buffer;
30
31[numthreads(4,1,1)]
32void computeMain(int3 id : SV_DispatchThreadID)
33{
34    (*buffer)[0] = nonuniform(t[id.x]).SampleLevel(float2(0.0), 0.0);
35}