yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
8086adc90
master
1//TEST:SIMPLE(filecheck=METAL): -target metal 2//TEST:SIMPLE(filecheck=METALLIB): -target metallib 3//TEST:REFLECTION(filecheck=REFLECT):-target metal -entry computeMain -stage compute 4//TEST(compute, metal):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-metal -compute -output-using-type 5//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=BUF):-vk -compute -output-using-type 6 7//TEST_INPUT:ubuffer(data=[0 0 0], stride=1):out,name=outputBuffer 8uniform RWStructuredBuffer<float> outputBuffer; 9 10struct MyBlock 11{ 12 StructuredBuffer<float> b1; 13 StructuredBuffer<float> b2; 14} 15//TEST_INPUT: set block = new MyBlock{ ubuffer(data=[7.0]), ubuffer(data=[0.0]) } 16ParameterBlock<MyBlock> block; 17//TEST_INPUT: set block2 = new MyBlock{ ubuffer(data=[0.0]), ubuffer(data=[5.0]) } 18ParameterBlock<MyBlock> block2; 19 20// METAL: {{\[\[}}kernel{{\]\]}} void computeMain(float device* {{.*}} {{\[\[}}buffer(0){{\]\]}}, MyBlock{{.*}} constant* block{{.*}} {{\[\[}}buffer(1){{\]\]}}, MyBlock{{.*}} constant* block2{{.*}} {{\[\[}}buffer(2){{\]\]}}) 21 22// METALLIB: define void @computeMain 23 24// REFLECT: "elementVarLayout": { 25// REFLECT: "name": "b1", 26// REFLECT: "binding": {"kind": "uniform", "offset": 0, "size": 8, "elementStride": 0} 27 28// REFLECT: "name": "b2", 29// REFLECT: "binding": {"kind": "uniform", "offset": 8, "size": 8, "elementStride": 0} 30 31// REFLECT: "binding": {"kind": "metalArgumentBufferElement", "index": 0, "count": 2} 32 33// REFLECT: "name": "outputBuffer", 34// REFLECT-NEXT: "binding": {"kind": "constantBuffer", "index": 0{{.*}}} 35 36// REFLECT: "name": "block", 37// REFLECT-NEXT: "binding": {"kind": "constantBuffer", "index": 1{{.*}}} 38 39void func(float v) 40{ 41 // BUF: 3.0 42 outputBuffer[0] = v; 43 // BUF: 3.0 44 outputBuffer[1] = outputBuffer.Load(0); 45 // BUF: 12.0 46 outputBuffer[2] = block.b1[0] + block2.b2[0]; 47} 48 49[numthreads(1,1,1)] 50void computeMain() 51{ 52 func(3.0f); 53}