Merge vk-gl-cts/opengl-es-cts-3.2.6 into vk-gl-cts/opengl-es-cts-3.2.7
[platform/upstream/VK-GL-CTS.git] / external / vulkancts / data / vulkan / amber / graphicsfuzz / cov-instruction-simplify-mod-sqrt-undefined.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 instruction simplification 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 _int_0 _GLF_uniform_int_values[1]
30 # #define _float_0_0 _GLF_uniform_float_values[0]
31 # #define _float_1_0 _GLF_uniform_float_values[1]
32 #
33 # precision highp float;
34 #
35 # // Contents of _GLF_uniform_int_values: [1, 0]
36 # layout(set = 0, binding = 0) uniform buf0
37 # {
38 #     int _GLF_uniform_int_values[2];
39 # };
40 #
41 # // Contents of _GLF_uniform_float_values: [0.0, 1.0]
42 # layout(set = 0, binding = 1) uniform buf1
43 # {
44 #     float _GLF_uniform_float_values[2];
45 # };
46 # layout(location = 0) out vec4 _GLF_color;
47 #
48 # void main()
49 # {
50 #     _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
51 #
52 #     float a = mod(sqrt(-1.), _float_1_0);
53 #     if (a != _float_0_0)
54 #     {
55 #         _GLF_color.g = _float_0_0;
56 #     }
57 # }
58 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
59 ; SPIR-V
60 ; Version: 1.0
61 ; Generator: Khronos Glslang Reference Front End; 8
62 ; Bound: 56
63 ; Schema: 0
64                OpCapability Shader
65           %1 = OpExtInstImport "GLSL.std.450"
66                OpMemoryModel Logical GLSL450
67                OpEntryPoint Fragment %4 "main" %9
68                OpExecutionMode %4 OriginUpperLeft
69                OpSource ESSL 310
70                OpName %4 "main"
71                OpName %9 "_GLF_color"
72                OpName %14 "buf0"
73                OpMemberName %14 0 "_GLF_uniform_int_values"
74                OpName %16 ""
75                OpName %34 "a"
76                OpName %37 "buf1"
77                OpMemberName %37 0 "_GLF_uniform_float_values"
78                OpName %39 ""
79                OpDecorate %9 Location 0
80                OpDecorate %13 ArrayStride 16
81                OpMemberDecorate %14 0 RelaxedPrecision
82                OpMemberDecorate %14 0 Offset 0
83                OpDecorate %14 Block
84                OpDecorate %16 DescriptorSet 0
85                OpDecorate %16 Binding 0
86                OpDecorate %20 RelaxedPrecision
87                OpDecorate %24 RelaxedPrecision
88                OpDecorate %27 RelaxedPrecision
89                OpDecorate %30 RelaxedPrecision
90                OpDecorate %36 ArrayStride 16
91                OpMemberDecorate %37 0 Offset 0
92                OpDecorate %37 Block
93                OpDecorate %39 DescriptorSet 0
94                OpDecorate %39 Binding 1
95           %2 = OpTypeVoid
96           %3 = OpTypeFunction %2
97           %6 = OpTypeFloat 32
98           %7 = OpTypeVector %6 4
99           %8 = OpTypePointer Output %7
100           %9 = OpVariable %8 Output
101          %10 = OpTypeInt 32 1
102          %11 = OpTypeInt 32 0
103          %12 = OpConstant %11 2
104          %13 = OpTypeArray %10 %12
105          %14 = OpTypeStruct %13
106          %15 = OpTypePointer Uniform %14
107          %16 = OpVariable %15 Uniform
108          %17 = OpConstant %10 0
109          %18 = OpTypePointer Uniform %10
110          %22 = OpConstant %10 1
111          %33 = OpTypePointer Function %6
112          %35 = OpConstant %6 -0x1.8p+128
113          %36 = OpTypeArray %6 %12
114          %37 = OpTypeStruct %36
115          %38 = OpTypePointer Uniform %37
116          %39 = OpVariable %38 Uniform
117          %40 = OpTypePointer Uniform %6
118          %47 = OpTypeBool
119          %53 = OpConstant %11 1
120          %54 = OpTypePointer Output %6
121           %4 = OpFunction %2 None %3
122           %5 = OpLabel
123          %34 = OpVariable %33 Function
124          %19 = OpAccessChain %18 %16 %17 %17
125          %20 = OpLoad %10 %19
126          %21 = OpConvertSToF %6 %20
127          %23 = OpAccessChain %18 %16 %17 %22
128          %24 = OpLoad %10 %23
129          %25 = OpConvertSToF %6 %24
130          %26 = OpAccessChain %18 %16 %17 %22
131          %27 = OpLoad %10 %26
132          %28 = OpConvertSToF %6 %27
133          %29 = OpAccessChain %18 %16 %17 %17
134          %30 = OpLoad %10 %29
135          %31 = OpConvertSToF %6 %30
136          %32 = OpCompositeConstruct %7 %21 %25 %28 %31
137                OpStore %9 %32
138          %41 = OpAccessChain %40 %39 %17 %22
139          %42 = OpLoad %6 %41
140          %43 = OpFMod %6 %35 %42
141                OpStore %34 %43
142          %44 = OpLoad %6 %34
143          %45 = OpAccessChain %40 %39 %17 %17
144          %46 = OpLoad %6 %45
145          %48 = OpFOrdNotEqual %47 %44 %46
146                OpSelectionMerge %50 None
147                OpBranchConditional %48 %49 %50
148          %49 = OpLabel
149          %51 = OpAccessChain %40 %39 %17 %17
150          %52 = OpLoad %6 %51
151          %55 = OpAccessChain %54 %9 %53
152                OpStore %55 %52
153                OpBranch %50
154          %50 = OpLabel
155                OpReturn
156                OpFunctionEnd
157 END
158
159 # uniforms for variant
160
161 # _GLF_uniform_float_values
162 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
163  0.0 1.0
164 END
165 # _GLF_uniform_int_values
166 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
167  1 0
168 END
169
170 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
171
172 PIPELINE graphics variant_pipeline
173   ATTACH variant_vertex_shader
174   ATTACH variant_fragment_shader
175   FRAMEBUFFER_SIZE 256 256
176   BIND BUFFER variant_framebuffer AS color LOCATION 0
177   BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
178   BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
179 END
180 CLEAR_COLOR variant_pipeline 0 0 0 255
181
182 CLEAR variant_pipeline
183 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
184
185 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255