blob: 55a517ea1579ad44e517694e7d1980a2e2747152 [file] [log] [blame]
[require]
VK_KHR_spirv_1_4
[vertex shader spirv]
; Test a vertex shader with a push constant on the OpEntryPoint.
;
;#version 450
;
;layout(push_constant) uniform pushConstants {
; vec2 in_val_0;
; vec2 in_val_1;
; vec2 in_val_2;
; vec2 in_val_3;
;} u_pushConstants;
;
;void main()
;{
; switch(gl_VertexIndex)
; {
; case 0:
; {
; gl_Position = vec4(u_pushConstants.in_val_0, 0.0, 1.0);
; break;
; }
; case 1:
; {
; gl_Position = vec4(u_pushConstants.in_val_1, 0.0, 1.0);
; break;
; }
; case 2:
; {
; gl_Position = vec4(u_pushConstants.in_val_2, 0.0, 1.0);
; break;
; }
; case 3:
; {
; gl_Position = vec4(u_pushConstants.in_val_3, 0.0, 1.0);
; break;
; }
; }
;}
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %gl_VertexIndex %gl_Output %u_pushConstants
OpSource GLSL 450
OpName %main "main"
OpName %gl_VertexIndex "gl_VertexIndex"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %gl_Output "gl_Output"
OpName %pushConstants "pushConstants"
OpMemberName %pushConstants 0 "in_val_0"
OpMemberName %pushConstants 1 "in_val_1"
OpMemberName %pushConstants 2 "in_val_2"
OpMemberName %pushConstants 3 "in_val_3"
OpName %u_pushConstants "u_pushConstants"
OpDecorate %gl_VertexIndex BuiltIn VertexIndex
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
OpMemberDecorate %pushConstants 0 Offset 0
OpMemberDecorate %pushConstants 1 Offset 8
OpMemberDecorate %pushConstants 2 Offset 16
OpMemberDecorate %pushConstants 3 Offset 24
OpDecorate %pushConstants Block
%type_void = OpTypeVoid
%type_func_void = OpTypeFunction %type_void
%sint = OpTypeInt 32 1
%ptr_sint_input = OpTypePointer Input %sint
%gl_VertexIndex = OpVariable %ptr_sint_input Input
%float32 = OpTypeFloat 32
%fvec4 = OpTypeVector %float32 4
%uint = OpTypeInt 32 0
%const_uint_1 = OpConstant %uint 1
%type_array_float = OpTypeArray %float32 %const_uint_1
%gl_PerVertex = OpTypeStruct %fvec4 %float32 %type_array_float %type_array_float
%ptr_perVert_out = OpTypePointer Output %gl_PerVertex
%gl_Output = OpVariable %ptr_perVert_out Output
%const_sint_0 = OpConstant %sint 0
%fvec2 = OpTypeVector %float32 2
%pushConstants = OpTypeStruct %fvec2 %fvec2 %fvec2 %fvec2
%ptr_push_const = OpTypePointer PushConstant %pushConstants
%u_pushConstants = OpVariable %ptr_push_const PushConstant
%ptr_pc_fvec2 = OpTypePointer PushConstant %fvec2
%const_float32_0 = OpConstant %float32 0
%const_float32_1 = OpConstant %float32 1
%ptr_output_fvec4 = OpTypePointer Output %fvec4
%const_sint_1 = OpConstant %sint 1
%const_sint_2 = OpConstant %sint 2
%const_sint_3 = OpConstant %sint 3
%main = OpFunction %type_void None %type_func_void
%5 = OpLabel
%9 = OpLoad %sint %gl_VertexIndex
OpSelectionMerge %14 None
OpSwitch %9 %14 0 %10 1 %11 2 %12 3 %13
%10 = OpLabel
%31 = OpAccessChain %ptr_pc_fvec2 %u_pushConstants %const_sint_0
%32 = OpLoad %fvec2 %31
%35 = OpCompositeExtract %float32 %32 0
%36 = OpCompositeExtract %float32 %32 1
%37 = OpCompositeConstruct %fvec4 %35 %36 %const_float32_0 %const_float32_1
%39 = OpAccessChain %ptr_output_fvec4 %gl_Output %const_sint_0
OpStore %39 %37
OpBranch %14
%11 = OpLabel
%42 = OpAccessChain %ptr_pc_fvec2 %u_pushConstants %const_sint_1
%43 = OpLoad %fvec2 %42
%44 = OpCompositeExtract %float32 %43 0
%45 = OpCompositeExtract %float32 %43 1
%46 = OpCompositeConstruct %fvec4 %44 %45 %const_float32_0 %const_float32_1
%47 = OpAccessChain %ptr_output_fvec4 %gl_Output %const_sint_0
OpStore %47 %46
OpBranch %14
%12 = OpLabel
%50 = OpAccessChain %ptr_pc_fvec2 %u_pushConstants %const_sint_2
%51 = OpLoad %fvec2 %50
%52 = OpCompositeExtract %float32 %51 0
%53 = OpCompositeExtract %float32 %51 1
%54 = OpCompositeConstruct %fvec4 %52 %53 %const_float32_0 %const_float32_1
%55 = OpAccessChain %ptr_output_fvec4 %gl_Output %const_sint_0
OpStore %55 %54
OpBranch %14
%13 = OpLabel
%58 = OpAccessChain %ptr_pc_fvec2 %u_pushConstants %const_sint_3
%59 = OpLoad %fvec2 %58
%60 = OpCompositeExtract %float32 %59 0
%61 = OpCompositeExtract %float32 %59 1
%62 = OpCompositeConstruct %fvec4 %60 %61 %const_float32_0 %const_float32_1
%63 = OpAccessChain %ptr_output_fvec4 %gl_Output %const_sint_0
OpStore %63 %62
OpBranch %14
%14 = OpLabel
OpReturn
OpFunctionEnd
[fragment shader]
#version 430
layout(location = 0) out vec4 outColor;
void main() {
outColor = vec4(0.5, 0.5, 0.5, 0.5);
}
[test]
clear
# Draw over bottom left quadrant
uniform float 0 -1.0 -1.0 0.0 -1.0 -1.0 0.0 0.0 0.0
draw rect -1 -1 2 2
probe rect rgba (0, 0, 125, 125) (0.5 0.5 0.5 0.5)
probe rect rgba (125, 125, 125, 125) (0.0 0.0 0.0 0.0)