yum-mirror/slang

Making it easier to work with shaders

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

Yong HeImmutable access qualifier for pointers and use `__ldg` on cuda. (#8710)01510f2c9

master
489 B21 linesraw
1// Test that we can use ImmutablePtr<T> to result in more optimized buffer loads
2// in SPIR-V and CUDA.
3
4//TEST:SIMPLE(filecheck=PTX): -target ptx -entry computeMain -stage compute
5//TEST:SIMPLE(filecheck=SPV): -target spirv -O0
6uniform ImmutablePtr<float4> data;
7
8uniform float4* result;
9
10float4 work(ImmutablePtr<float4> ptr)
11{
12    return *ptr;
13}
14
15[numthreads(1,1,1)]
16void computeMain()
17{
18    // SPV: Restrict
19    // PTX: ld.global.nc.v4.f32
20    *result = work(data) + float4(1,2,3,4);
21}