yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
9a23a9aab
master
1// unknown-image-format.slang 2 3//TEST:SIMPLE(filecheck=CHECK):-target spirv-assembly -entry main -stage fragment -default-image-format-unknown 4 5// Ensure that we can emit R/W images with an unknown format, when required. 6 7// CHECK: OpTypeImage %float 2D 2 0 0 2 Unknown 8// CHECK: OpTypeImage %float 2D 2 0 0 2 R32f 9// CHECK: OpTypeImage %float 2D 2 0 0 2 Rgba8 10// CHECK: OpTypeImage %float 2D 2 0 0 2 Rgba16f 11 12// Global Scope: 13 14RWTexture2D<float> gNoFormat; 15 16[format("r32f")] 17RWTexture2D<float> gExplicitFormat; 18 19// Nested in a Parameter Block 20 21struct PB 22{ 23 RWTexture2D<float4> noFormat; 24 25 [format("rgba8")] 26 RWTexture2D<float4> explicitFormat; 27} 28ParameterBlock<PB> gBlock; 29 30cbuffer C 31{ 32 uint2 index; 33} 34 35float4 main( 36 37 // In entry-point parameter list 38 39 uniform RWTexture2D<float4> noFormat, 40 41 [format("rgba16f")] 42 uniform RWTexture2D<float4> explicitFormat 43 ) : SV_Target 44{ 45 float4 result = 0; 46 47#define USE(NAME) result += NAME[index] 48 49 USE(gNoFormat); 50 USE(gExplicitFormat); 51 52 USE(gBlock.noFormat); 53 USE(gBlock.explicitFormat); 54 55 USE(noFormat); 56 USE(explicitFormat); 57 58#undef USE 59 60 return result; 61}