yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
d61d6b57d
master
1//TEST:SIMPLE(filecheck=CHECK): -target cuda -entry runPointEstimator 2 3// Test for issue #7905: CUDA Backend failure due to type mismatch 4// This test ensures that struct types in ParameterBlock operands are properly 5// legalized and don't create type mismatches in generated CUDA code. 6 7#define ZOMBIE_PROBLEM_DIMENSION 3 8 9public interface IExample<let DIM : int> 10{ 11 // computes the distance to the boundary 12 float compute(vector<float, DIM> x); 13}; 14 15public struct Query<Example,let DIM : int> 16 where Example : IExample<DIM> 17{ 18 // private AbsorbingBoundaryGeometricQueries absorbingBoundaryGeometricQueries; 19 private Example query; 20 private uint hasNonEmptyAbsorbingBoundary; 21 22 public float compute(vector<float, DIM> x) 23 { 24 return query.compute(x); 25 } 26}; 27 28public struct EmptyExample<let DIM : int> : IExample<DIM> 29{ 30 // computes the distance to the boundary 31 public float compute(vector<float, DIM> x) 32 { 33 internal static const float FLT_MAX = 3.402823466e+38F; 34 return FLT_MAX; 35 } 36}; 37 38 39typedef EmptyExample<ZOMBIE_PROBLEM_DIMENSION> ExampleQuery; 40typedef Query<ExampleQuery, ZOMBIE_PROBLEM_DIMENSION> QueryType; 41 42 43uniform ParameterBlock<QueryType> gQuery; 44uniform RWStructuredBuffer<float3> gInput; 45uniform RWStructuredBuffer<float> gOutput; 46 47 48[shader("compute")] 49[numthreads(256, 1, 1)] 50void runPointEstimator(uint3 threadId: SV_DispatchThreadID, 51 uniform uint n) 52{ 53 const uint idx = threadId.x; 54 55 if (idx >= n) { 56 return; 57 } 58 59 float res = gQuery.compute(gInput[idx]); 60 gOutput[idx] = res; 61} 62 63// CHECK-NOT: Query_1