yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
9ec6b9168
master
1//TEST:SIMPLE(filecheck=CHK): -target spirv -entry computeMain 2 3extern static const int flag; 4 5struct None 6{ 7 int a; 8 int b; 9 10 __init() 11 { 12 a = 0; 13 b = 0; 14 } 15} 16 17struct Simple 18{ 19 int value; 20 Simple *next; 21 22 __init(int v, Simple* ptr) 23 { 24 value = v; 25 //CHK-DAG: warning 41020: exiting constructor without initializing field 'next' 26 } 27} 28 29struct Conditional 30{ 31 int field; 32 int another_field; 33 34 __init() 35 { 36 field = 0; 37 if (flag == 0) 38 //CHK-DAG: warning 41020: exiting constructor without initializing field 'another_field' 39 return; 40 41 another_field = 0; 42 } 43}; 44 45struct Partial 46{ 47 int inline = 0; 48 int body = 0; 49 50 __init(int x) 51 { 52 body = x; 53 } 54} 55 56// Warnings here should be a bit different 57struct Implicit 58{ 59 int a; 60 int b = 1; 61 int c; 62 int d = 1 + 1; 63} 64 65int using_implicit(int x) 66{ 67 // no default constructor will be called, because there is no __init() synthesized for `Implicit` 68 // so no warnings will be reported on members of `Implicit` 69 Implicit impl; 70 impl.a = x; 71 return impl.c; 72} 73 74struct UnusedImplicit 75{ 76 // Shouldn't warn here, since its never used 77 int a; 78 int b = 1; 79 int c; 80 int d = 1 + 1; 81} 82 83struct Pass 84{ 85 int x = 0; 86 int y = 0; 87} 88 89//CHK-NOT: warning 41020 90//CHK-NOT: warning 41021 91 92[Shader("compute")] 93[NumThreads(4, 1, 1)] 94void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 95{ 96} 97