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