yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
5074c4948
master
1// get-attribute-at-vertex-struct.slang 2 3// Test GetAttributeAtVertex and SV_Barycentrics on struct members 4 5//TEST:SIMPLE(filecheck=CHECK-SPIRV):-target spirv -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric 6//TEST:SIMPLE(filecheck=CHECK-GLSL):-target glsl -entry main -stage fragment -profile glsl_450+GL_EXT_fragment_shader_barycentric 7 8// CHECK-SPIRV: OpCapability FragmentBarycentricKHR 9// CHECK-SPIRV: OpExtension "SPV_KHR_fragment_shader_barycentric" 10 11// CHECK-SPIRV: OpEntryPoint Fragment %main "main" 12// CHECK-SPIRV: OpDecorate %{{.*}} BuiltIn BaryCoordKHR 13// CHECK-SPIRV: OpDecorate %{{.*}} BuiltIn BaryCoordNoPerspKHR 14// CHECK-SPIRV: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_0 15// CHECK-SPIRV: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_1 16// CHECK-SPIRV: %{{.*}} = OpAccessChain %_ptr_Input_{{.*}} %{{.*}} %uint_2 17 18// CHECK-GLSL: #extension GL_EXT_fragment_shader_barycentric : require 19// CHECK-GLSL-DAG: gl_BaryCoordEXT 20// CHECK-GLSL-DAG: gl_BaryCoordNoPerspEXT 21 22struct Input 23{ 24 pervertex float4 color : COLOR; 25 float3 bary : SV_Barycentrics; 26 noperspective float3 baryNoPerspective : SV_Barycentrics; 27} 28 29[shader("fragment")] 30void main( 31 Input input, 32 out float4 result : SV_Target) 33{ 34 result = input.bary.x * GetAttributeAtVertex(input.color, 0) 35 + input.bary.y * GetAttributeAtVertex(input.color, 1) 36 + input.bary.z * GetAttributeAtVertex(input.color, 2) 37 + input.baryNoPerspective.x * 0.1f; 38}