8b45ae7ed83c70403db8bae425e2a42173580993
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / spirv_assembly / instruction / spirv1p4 / entrypoint / tess_con_pc_entry_point.amber
1 [require]
2 VK_KHR_spirv_1_4
3 tessellationShader
4
5 [vertex shader]
6 #version 450
7
8 layout(location = 0) in vec4 position;
9 layout(location = 1) in vec4 vert_color;
10 layout(location = 0) out vec4 tsc_color;
11
12 void main() {
13     gl_Position = position;
14       tsc_color = vert_color;
15 }
16
17 [tessellation control shader spirv]
18 ; Test tessellation control shader with push constant on entry point.
19 ; But also modified to set gl_TessLevelInner gl_TessLevelOuter
20 ; #version 450
21 ; #extension GL_ARB_separate_shader_objects : enable
22 ;
23 ; layout(vertices = 3) out;
24 ;
25 ; layout(location = 0) in vec4 tsc_color[];
26 ; layout(location = 0) out vec4 tse_color[];
27 ;
28 ; layout(push_constant) uniform pushConstants {
29 ;     vec4 in_val;
30 ; } pc;
31 ; #define ID gl_InvocationID
32 ;
33 ; void main()
34 ; {
35 ;   gl_out[ID].gl_Position = gl_in[ID].gl_Position;
36 ;   tse_color[ID] = tsc_color[ID]+pc.in_val;
37 ; }
38                OpCapability Tessellation
39           %1 = OpExtInstImport "GLSL.std.450"
40                OpMemoryModel Logical GLSL450
41                OpEntryPoint TessellationControl %main "main" %gl_out %gl_InvocationID %gl_in %tse_color %pc %tsc_color %gl_TessLevelInner %gl_TessLevelOuter
42                OpExecutionMode %main OutputVertices 3
43                OpSource GLSL 450
44                OpSourceExtension "GL_ARB_separate_shader_objects"
45                OpName %main "main"
46                OpName %gl_PerVertex "gl_PerVertex"
47                OpMemberName %gl_PerVertex 0 "gl_Position"
48                OpMemberName %gl_PerVertex 1 "gl_PointSize"
49                OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
50                OpMemberName %gl_PerVertex 3 "gl_CullDistance"
51                OpName %gl_out "gl_out"
52                OpName %gl_InvocationID "gl_InvocationID"
53                OpName %gl_PerVertex_0 "gl_PerVertex"
54                OpMemberName %gl_PerVertex_0 0 "gl_Position"
55                OpMemberName %gl_PerVertex_0 1 "gl_PointSize"
56                OpMemberName %gl_PerVertex_0 2 "gl_ClipDistance"
57                OpMemberName %gl_PerVertex_0 3 "gl_CullDistance"
58                OpName %gl_in "gl_in"
59                OpName %tse_color "tse_color"
60                OpName %pushConstants "pushConstants"
61                OpMemberName %pushConstants 0 "in_val"
62                OpName %pc "pc"
63                OpName %tsc_color "tsc_color"
64                OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
65                OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
66                OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
67                OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
68                OpDecorate %gl_PerVertex Block
69                OpDecorate %gl_InvocationID BuiltIn InvocationId
70                OpMemberDecorate %gl_PerVertex_0 0 BuiltIn Position
71                OpMemberDecorate %gl_PerVertex_0 1 BuiltIn PointSize
72                OpMemberDecorate %gl_PerVertex_0 2 BuiltIn ClipDistance
73                OpMemberDecorate %gl_PerVertex_0 3 BuiltIn CullDistance
74                OpDecorate %gl_PerVertex_0 Block
75                OpDecorate %tse_color Location 0
76                OpMemberDecorate %pushConstants 0 Offset 0
77                OpDecorate %pushConstants Block
78                OpDecorate %tsc_color Location 0
79                OpDecorate %gl_TessLevelInner BuiltIn TessLevelInner
80                OpDecorate %gl_TessLevelOuter BuiltIn TessLevelOuter
81                OpDecorate %gl_TessLevelInner Patch
82                OpDecorate %gl_TessLevelOuter Patch
83        %void = OpTypeVoid
84           %3 = OpTypeFunction %void
85       %float = OpTypeFloat 32
86     %v4float = OpTypeVector %float 4
87        %uint = OpTypeInt 32 0
88      %uint_1 = OpConstant %uint 1
89      %uint_2 = OpConstant %uint 2
90      %uint_4 = OpConstant %uint 4
91 %_arr_float_uint_1 = OpTypeArray %float %uint_1
92 %_arr_float_uint_2 = OpTypeArray %float %uint_2
93 %_arr_float_uint_4 = OpTypeArray %float %uint_4
94   %float_1 = OpConstant %float 1.0
95   %arr_2_1 = OpConstantComposite %_arr_float_uint_2 %float_1 %float_1
96   %arr_4_1 = OpConstantComposite %_arr_float_uint_4 %float_1 %float_1 %float_1 %float_1
97 %_ptr_Output__arr_float_uint_2 = OpTypePointer Output %_arr_float_uint_2
98 %_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4
99 %gl_TessLevelInner = OpVariable %_ptr_Output__arr_float_uint_2 Output %arr_2_1
100 %gl_TessLevelOuter = OpVariable %_ptr_Output__arr_float_uint_4 Output %arr_4_1
101 %gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
102      %uint_3 = OpConstant %uint 3
103 %_arr_gl_PerVertex_uint_3 = OpTypeArray %gl_PerVertex %uint_3
104 %_ptr_Output__arr_gl_PerVertex_uint_3 = OpTypePointer Output %_arr_gl_PerVertex_uint_3
105      %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_3 Output
106         %int = OpTypeInt 32 1
107 %_ptr_Input_int = OpTypePointer Input %int
108 %gl_InvocationID = OpVariable %_ptr_Input_int Input
109       %int_0 = OpConstant %int 0
110 %gl_PerVertex_0 = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
111     %uint_32 = OpConstant %uint 32
112 %_arr_gl_PerVertex_0_uint_32 = OpTypeArray %gl_PerVertex_0 %uint_32
113 %_ptr_Input__arr_gl_PerVertex_0_uint_32 = OpTypePointer Input %_arr_gl_PerVertex_0_uint_32
114       %gl_in = OpVariable %_ptr_Input__arr_gl_PerVertex_0_uint_32 Input
115 %_ptr_Input_v4float = OpTypePointer Input %v4float
116 %_ptr_Output_v4float = OpTypePointer Output %v4float
117 %_arr_v4float_uint_3 = OpTypeArray %v4float %uint_3
118 %_ptr_Output__arr_v4float_uint_3 = OpTypePointer Output %_arr_v4float_uint_3
119   %tse_color = OpVariable %_ptr_Output__arr_v4float_uint_3 Output
120 %pushConstants = OpTypeStruct %v4float
121 %_ptr_PushConstant_pushConstants = OpTypePointer PushConstant %pushConstants
122          %pc = OpVariable %_ptr_PushConstant_pushConstants PushConstant
123 %_ptr_PushConstant_v4float = OpTypePointer PushConstant %v4float
124 %_arr_v4float_uint_32 = OpTypeArray %v4float %uint_32
125 %_ptr_Input__arr_v4float_uint_32 = OpTypePointer Input %_arr_v4float_uint_32
126   %tsc_color = OpVariable %_ptr_Input__arr_v4float_uint_32 Input
127        %main = OpFunction %void None %3
128           %5 = OpLabel
129          %19 = OpLoad %int %gl_InvocationID
130          %26 = OpLoad %int %gl_InvocationID
131          %28 = OpAccessChain %_ptr_Input_v4float %gl_in %26 %int_0
132          %29 = OpLoad %v4float %28
133          %31 = OpAccessChain %_ptr_Output_v4float %gl_out %19 %int_0
134                OpStore %31 %29
135          %35 = OpLoad %int %gl_InvocationID
136          %36 = OpLoad %int %gl_InvocationID
137          %37 = OpAccessChain %_ptr_Input_v4float %tsc_color %36
138          %38 = OpLoad %v4float %37
139          %43 = OpAccessChain %_ptr_PushConstant_v4float %pc %int_0
140          %44 = OpLoad %v4float %43
141          %45 = OpFAdd %v4float %38 %44
142          %46 = OpAccessChain %_ptr_Output_v4float %tse_color %35
143                OpStore %46 %45
144                OpReturn
145                OpFunctionEnd
146 [tessellation evaluation shader]
147 #version 450
148 #extension GL_ARB_separate_shader_objects : enable
149
150 layout(triangles, equal_spacing, cw) in;
151
152 layout(location = 0) in vec4 tse_color[];
153 layout(location = 0) out vec4 frag_color;
154
155 void main()
156 {
157   vec4 p0 = gl_TessCoord.x * gl_in[0].gl_Position;
158   vec4 p1 = gl_TessCoord.y * gl_in[1].gl_Position;
159   vec4 p2 = gl_TessCoord.z * gl_in[2].gl_Position;
160   gl_Position = p0 + p1 + p2;
161   frag_color = tse_color[0];
162 }
163
164 [fragment shader]
165 #version 450
166
167 layout(location = 0) in vec4 frag_color;
168 layout(location = 0) out vec4 final_color;
169
170 void main() {
171   final_color = frag_color;
172 }
173
174 [vertex data]
175 #        position     vert_color
176      0/R8G8_SNORM 1/R8G8B8_UNORM
177
178 #           Red for entire frame
179 #         R8   G8     R8  G8  B8
180         -128 -128    255   0   0
181          127  127    255   0   0
182         -128  127    255   0   0
183
184         -128 -128    255   0   0
185          127  127    255   0   0
186          127 -128    255   0   0
187
188 [test]
189 uniform float 0 0.0 0.0 0.3 0.0
190 clear
191 draw arrays PATCH_LIST 0 6
192 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (1.0, 0, 0.3)