yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
3f4081d85
master
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -shaderobj -emit-spirv-directly 2//DIAGNOSTIC_TEST:SIMPLE(filecheck=DIAG): 3 4//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):out,name=outputBuffer 5RWStructuredBuffer<int> outputBuffer; 6 7// CHECK: 1 8// CHECK-NEXT: 1 9// CHECK-NEXT: 1 10// CHECK-NEXT: 1 11 12//TEST_INPUT: Texture2D(size=4, content = one):name t2D 13Texture2D<float> t2D; 14//TEST_INPUT: Sampler:name samplerState 15SamplerState samplerState; 16 17// 18// This test tests that we don't emit a warning for the variadic operand list 19// to OpImageSample. The reason to test for this is that "ImageOperands" aren't 20// specified as variadic in the json SPIR-V instruction descriptions. 21// 22[numthreads(4, 1, 1)] 23void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 24{ 25 int i = dispatchThreadID.x; 26 float2 loc = float2(0.5, 0.5); 27 float lod = 0; 28 float r = spirv_asm 29 { 30 // The type of our sampled image 31 %sampledImageType = OpTypeSampledImage $$Texture2D<float>; 32 // Combine the image with the sampler 33 %sampledImage : %sampledImageType = OpSampledImage $t2D $samplerState; 34 // Perform a sample 35 %sampled : __sampledType(float) = OpImageSampleExplicitLod %sampledImage $loc 36 // Put some sampling operands in here to check that they don't warn 37 // DIAG-NOT: warning{{.*}}too many operands 38 Lod $lod; 39 // Samples in SPIR-V always return a 4-vector of the component type, 40 // the __truncate function will drop elements so it fits into the 41 // desired output type 42 __truncate $$float result __sampledType(float) %sampled; 43 }; 44 outputBuffer[i] = int(r); 45}