Merge vk-gl-cts/vk_khr_ray_tracing into vk-gl-cts/master
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-inst-peephole-optimizer-acosh.amber
1 #!amber
2
3 # Copyright 2020 Google LLC
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17
18 # A test for a coverage-gap found by the GraphicsFuzz project.
19
20 # Short description: A fragment shader that covers a specific peephole optimizer code path
21
22 # The test passes because the shader always writes red.
23
24 SHADER vertex variant_vertex_shader PASSTHROUGH
25
26 # variant_fragment_shader is derived from the following GLSL:
27 # #version 310 es
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _float_1_2 _GLF_uniform_float_values[0]
30 # #define _float_0_0 _GLF_uniform_float_values[1]
31 # #define _float_1_0 _GLF_uniform_float_values[2]
32 #
33 # precision highp float;
34 #
35 # precision highp int;
36 #
37 # // Contents of _GLF_uniform_int_values: 1
38 # layout(set = 0, binding = 0) uniform buf0
39 # {
40 #     int _GLF_uniform_int_values[1];
41 # };
42 #
43 # // Contents of _GLF_uniform_float_values: [1.2, 0.0, 1.0]
44 # layout(set = 0, binding = 1) uniform buf1
45 # {
46 #     float _GLF_uniform_float_values[3];
47 # };
48 #
49 # layout(location = 0) out vec4 _GLF_color;
50 #
51 # void main()
52 # {
53 #     float a = _float_1_2;
54 #
55 #     // Always true.
56 #     if (!(gl_FragCoord.x < _float_0_0))
57 #     {
58 #         // Always true.
59 #         if (!(gl_FragCoord.x < _float_0_0))
60 #         {
61 #             // Always false.
62 #             if (!(gl_FragCoord.x > _float_0_0))
63 #             {
64 #                 discard;
65 #             }
66 #             a = _float_1_0;
67 #         }
68 #     }
69 #     _GLF_color = vec4(_int_1, acosh(a), acosh(a), _int_1);
70 # }
71 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
72 ; SPIR-V
73 ; Version: 1.0
74 ; Generator: Khronos Glslang Reference Front End; 8
75 ; Bound: 74
76 ; Schema: 0
77                OpCapability Shader
78           %1 = OpExtInstImport "GLSL.std.450"
79                OpMemoryModel Logical GLSL450
80                OpEntryPoint Fragment %4 "main" %22 %56
81                OpExecutionMode %4 OriginUpperLeft
82                OpSource ESSL 310
83                OpName %4 "main"
84                OpName %8 "a"
85                OpName %12 "buf1"
86                OpMemberName %12 0 "_GLF_uniform_float_values"
87                OpName %14 ""
88                OpName %22 "gl_FragCoord"
89                OpName %56 "_GLF_color"
90                OpName %59 "buf0"
91                OpMemberName %59 0 "_GLF_uniform_int_values"
92                OpName %61 ""
93                OpDecorate %11 ArrayStride 16
94                OpMemberDecorate %12 0 Offset 0
95                OpDecorate %12 Block
96                OpDecorate %14 DescriptorSet 0
97                OpDecorate %14 Binding 1
98                OpDecorate %22 BuiltIn FragCoord
99                OpDecorate %56 Location 0
100                OpDecorate %58 ArrayStride 16
101                OpMemberDecorate %59 0 Offset 0
102                OpDecorate %59 Block
103                OpDecorate %61 DescriptorSet 0
104                OpDecorate %61 Binding 0
105           %2 = OpTypeVoid
106           %3 = OpTypeFunction %2
107           %6 = OpTypeFloat 32
108           %7 = OpTypePointer Function %6
109           %9 = OpTypeInt 32 0
110          %10 = OpConstant %9 3
111          %11 = OpTypeArray %6 %10
112          %12 = OpTypeStruct %11
113          %13 = OpTypePointer Uniform %12
114          %14 = OpVariable %13 Uniform
115          %15 = OpTypeInt 32 1
116          %16 = OpConstant %15 0
117          %17 = OpTypePointer Uniform %6
118          %20 = OpTypeVector %6 4
119          %21 = OpTypePointer Input %20
120          %22 = OpVariable %21 Input
121          %23 = OpConstant %9 0
122          %24 = OpTypePointer Input %6
123          %27 = OpConstant %15 1
124          %30 = OpTypeBool
125          %52 = OpConstant %15 2
126          %55 = OpTypePointer Output %20
127          %56 = OpVariable %55 Output
128          %57 = OpConstant %9 1
129          %58 = OpTypeArray %15 %57
130          %59 = OpTypeStruct %58
131          %60 = OpTypePointer Uniform %59
132          %61 = OpVariable %60 Uniform
133          %62 = OpTypePointer Uniform %15
134           %4 = OpFunction %2 None %3
135           %5 = OpLabel
136           %8 = OpVariable %7 Function
137          %18 = OpAccessChain %17 %14 %16 %16
138          %19 = OpLoad %6 %18
139                OpStore %8 %19
140          %25 = OpAccessChain %24 %22 %23
141          %26 = OpLoad %6 %25
142          %28 = OpAccessChain %17 %14 %16 %27
143          %29 = OpLoad %6 %28
144          %31 = OpFOrdLessThan %30 %26 %29
145          %32 = OpLogicalNot %30 %31
146                OpSelectionMerge %34 None
147                OpBranchConditional %32 %33 %34
148          %33 = OpLabel
149          %35 = OpAccessChain %24 %22 %23
150          %36 = OpLoad %6 %35
151          %37 = OpAccessChain %17 %14 %16 %27
152          %38 = OpLoad %6 %37
153          %39 = OpFOrdLessThan %30 %36 %38
154          %40 = OpLogicalNot %30 %39
155                OpSelectionMerge %42 None
156                OpBranchConditional %40 %41 %42
157          %41 = OpLabel
158          %43 = OpAccessChain %24 %22 %23
159          %44 = OpLoad %6 %43
160          %45 = OpAccessChain %17 %14 %16 %27
161          %46 = OpLoad %6 %45
162          %47 = OpFOrdGreaterThan %30 %44 %46
163          %48 = OpLogicalNot %30 %47
164                OpSelectionMerge %50 None
165                OpBranchConditional %48 %49 %50
166          %49 = OpLabel
167                OpKill
168          %50 = OpLabel
169          %53 = OpAccessChain %17 %14 %16 %52
170          %54 = OpLoad %6 %53
171                OpStore %8 %54
172                OpBranch %42
173          %42 = OpLabel
174                OpBranch %34
175          %34 = OpLabel
176          %63 = OpAccessChain %62 %61 %16 %16
177          %64 = OpLoad %15 %63
178          %65 = OpConvertSToF %6 %64
179          %66 = OpLoad %6 %8
180          %67 = OpExtInst %6 %1 Acosh %66
181          %68 = OpLoad %6 %8
182          %69 = OpExtInst %6 %1 Acosh %68
183          %70 = OpAccessChain %62 %61 %16 %16
184          %71 = OpLoad %15 %70
185          %72 = OpConvertSToF %6 %71
186          %73 = OpCompositeConstruct %20 %65 %67 %69 %72
187                OpStore %56 %73
188                OpReturn
189                OpFunctionEnd
190 END
191
192 # uniforms for variant
193
194 # _GLF_uniform_float_values
195 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
196  1.2 0.0 1.0
197 END
198 # _GLF_uniform_int_values
199 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
200  1
201 END
202
203 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
204
205 PIPELINE graphics variant_pipeline
206   ATTACH variant_vertex_shader
207   ATTACH variant_fragment_shader
208   FRAMEBUFFER_SIZE 256 256
209   BIND BUFFER variant_framebuffer AS color LOCATION 0
210   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
211   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
212 END
213 CLEAR_COLOR variant_pipeline 0 0 0 255
214
215 CLEAR variant_pipeline
216 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
217
218 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255