yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
6e5d85efb
master
1// interface-shader-param-legalization.slang 2 3// Test case where concrete type implementing 4// an interface has resource-type fields nested in it. 5 6//DISABLED_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute 7 8interface IModifier 9{ 10 int modify(int val); 11} 12 13// Note: a constant buffer for the global scope gets introduced 14// at this point, since `gModifier` introduces uniform storage 15// for the RTTI, witness table, and "any value" parts of the 16// existential. 17// 18//TEST_INPUT:cbuffer(data=[1 2 3 4 5 6 7 8], stride=4): 19uniform IModifier gModifier; 20 21int test( 22 int val) 23{ 24 return gModifier.modify(val); 25} 26 27 28//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out 29RWStructuredBuffer<int> gOutputBuffer; 30 31[numthreads(4, 1, 1)] 32void computeMain( 33 uint3 dispatchThreadID : SV_DispatchThreadID) 34{ 35 let tid = dispatchThreadID.x; 36 37 let inputVal : int = tid; 38 let outputVal = test(inputVal); 39 40 gOutputBuffer[tid] = outputVal; 41} 42 43// Now that we've define all the logic of the entry point, 44// we will define some concrete types that we can plug 45// in for the interface-type parameters. 46 47struct ConcreteData 48{ 49 int offset; 50} 51 52struct ConcreteModifier : IModifier 53{ 54 ConstantBuffer<ConcreteData> data; 55 56 int modify(int val) { return val + data.offset; } 57} 58 59//TEST_INPUT: globalExistentialType ConcreteModifier 60//TEST_INPUT:cbuffer(data=[256], stride=4):out