yum-mirror/slang

Making it easier to work with shaders

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

CopilotFix unnecessary Int64 SPIRV capability usage in pointer marshalling (#7717)704d0c710

master
879 B61 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target spirv
2
3// CHECK-NOT: Int64
4
5RWStructuredBuffer<uint> result;
6
7struct Data
8{
9    uint *index_buffer;
10    uint type;
11};
12
13ConstantBuffer<Data> global_data;
14
15interface IIndexFetcher
16{
17    uint get_index();
18};
19
20struct IndexFetcherU32 : IIndexFetcher
21{
22    uint *m_ptr;
23
24    __init(uint *ptr) 
25    {
26        m_ptr = ptr;
27    }
28    
29    uint get_index()
30    {
31        return 42; // Simplified to avoid dereference issues
32    }
33};
34
35struct IndexFetcherSimple : IIndexFetcher
36{
37    uint value;
38
39    __init(uint val) 
40    {
41        value = val;
42    }
43
44    uint get_index()
45    {
46        return value;
47    }
48};
49
50[shader("compute")]
51void main()
52{
53    IIndexFetcher pf;
54    if (global_data.type == 0) {
55        pf = IndexFetcherU32(global_data.index_buffer);
56    } else {
57        pf = IndexFetcherSimple(100);
58    } 
59  
60    result[0] = pf.get_index();
61}