8d1184703748e6c52d846e6747f63376c20bb217
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / spirv_assembly / instruction / spirv1p4 / entrypoint / tess_con_ssbo_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 an ssbo 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(std430, binding = 0) buffer 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 %_arr_float_uint_2 = OpTypeArray %float %uint_2
96 %_arr_float_uint_4 = OpTypeArray %float %uint_4
97   %float_1 = OpConstant %float 1.0
98   %arr_2_1 = OpConstantComposite %_arr_float_uint_2 %float_1 %float_1
99   %arr_4_1 = OpConstantComposite %_arr_float_uint_4 %float_1 %float_1 %float_1 %float_1
100 %_ptr_Output__arr_float_uint_2 = OpTypePointer Output %_arr_float_uint_2
101 %_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4
102 %gl_TessLevelInner = OpVariable %_ptr_Output__arr_float_uint_2 Output %arr_2_1
103 %gl_TessLevelOuter = OpVariable %_ptr_Output__arr_float_uint_4 Output %arr_4_1
104 %gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
105      %uint_3 = OpConstant %uint 3
106 %_arr_gl_PerVertex_uint_3 = OpTypeArray %gl_PerVertex %uint_3
107 %_ptr_Output__arr_gl_PerVertex_uint_3 = OpTypePointer Output %_arr_gl_PerVertex_uint_3
108      %gl_out = OpVariable %_ptr_Output__arr_gl_PerVertex_uint_3 Output
109         %int = OpTypeInt 32 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_StorageBuffer_input_buffer = OpTypePointer StorageBuffer %input_buffer
125           %_ = OpVariable %_ptr_StorageBuffer_input_buffer StorageBuffer
126 %_ptr_StorageBuffer_v4float = OpTypePointer StorageBuffer %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_StorageBuffer_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
150 [tessellation evaluation shader]
151 #version 450
152 #extension GL_ARB_separate_shader_objects : enable
153
154 layout(triangles, equal_spacing, cw) in;
155
156 layout(location = 0) in vec4 tse_color[];
157 layout(location = 0) out vec4 frag_color;
158
159 void main()
160 {
161   vec4 p0 = gl_TessCoord.x * gl_in[0].gl_Position;
162   vec4 p1 = gl_TessCoord.y * gl_in[1].gl_Position;
163   vec4 p2 = gl_TessCoord.z * gl_in[2].gl_Position;
164   gl_Position = p0 + p1 + p2;
165   frag_color = tse_color[0];
166 }
167
168 [fragment shader]
169 #version 450
170
171 layout(location = 0) in vec4 frag_color;
172 layout(location = 0) out vec4 final_color;
173
174 void main() {
175   final_color = frag_color;
176 }
177
178 [vertex data]
179 #        position     vert_color
180      0/R8G8_SNORM 1/R8G8B8_UNORM
181
182 #           Red for entire frame
183 #         R8   G8     R8  G8  B8
184         -128 -128    255   0   0
185          127  127    255   0   0
186         -128  127    255   0   0
187
188         -128 -128    255   0   0
189          127  127    255   0   0
190          127 -128    255   0   0
191
192 [test]
193 ssbo 0:0 subdata float 0 0.0 0.0 0.3 0.0
194 clear
195 draw arrays PATCH_LIST 0 6
196 relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (1.0, 0, 0.3)