[vertex shader spirv]
; Test a vertex shader with a push constant on the OpEntryPoint.
;
-; #version 450
+;#version 450
;
-; layout(push_constant) uniform pushConstants {
-; vec2 in_val[4];
-; } u_pushConstants;
+;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() {
-; gl_Position = vec4(u_pushConstants.in_val[gl_VertexIndex], 0.0, 1.0);
-; }
- OpCapability Shader
- %1 = OpExtInstImport "GLSL.std.450"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Vertex %main "main" %_ %u_pushConstants %gl_VertexIndex
- OpSource GLSL 450
- OpName %main "main"
- 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 %_ ""
- OpName %pushConstants "pushConstants"
- OpMemberName %pushConstants 0 "in_val"
- OpName %u_pushConstants "u_pushConstants"
- OpName %gl_VertexIndex "gl_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
- OpDecorate %_arr_v2float_uint_4 ArrayStride 8
- OpMemberDecorate %pushConstants 0 Offset 0
- OpDecorate %pushConstants Block
- OpDecorate %gl_VertexIndex BuiltIn VertexIndex
- %void = OpTypeVoid
- %3 = OpTypeFunction %void
- %float = OpTypeFloat 32
- %v4float = OpTypeVector %float 4
- %uint = OpTypeInt 32 0
- %uint_1 = OpConstant %uint 1
-%_arr_float_uint_1 = OpTypeArray %float %uint_1
-%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
-%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
- %_ = OpVariable %_ptr_Output_gl_PerVertex Output
- %int = OpTypeInt 32 1
- %int_0 = OpConstant %int 0
- %v2float = OpTypeVector %float 2
- %uint_4 = OpConstant %uint 4
-%_arr_v2float_uint_4 = OpTypeArray %v2float %uint_4
-%pushConstants = OpTypeStruct %_arr_v2float_uint_4
-%_ptr_PushConstant_pushConstants = OpTypePointer PushConstant %pushConstants
-%u_pushConstants = OpVariable %_ptr_PushConstant_pushConstants PushConstant
-%_ptr_Input_int = OpTypePointer Input %int
-%gl_VertexIndex = OpVariable %_ptr_Input_int Input
-%_ptr_PushConstant_v2float = OpTypePointer PushConstant %v2float
- %float_0 = OpConstant %float 0
- %float_1 = OpConstant %float 1
-%_ptr_Output_v4float = OpTypePointer Output %v4float
- %main = OpFunction %void None %3
- %5 = OpLabel
- %24 = OpLoad %int %gl_VertexIndex
- %26 = OpAccessChain %_ptr_PushConstant_v2float %u_pushConstants %int_0 %24
- %27 = OpLoad %v2float %26
- %30 = OpCompositeExtract %float %27 0
- %31 = OpCompositeExtract %float %27 1
- %32 = OpCompositeConstruct %v4float %30 %31 %float_0 %float_1
- %34 = OpAccessChain %_ptr_Output_v4float %_ %int_0
- OpStore %34 %32
- OpReturn
- OpFunctionEnd
+;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;