3 # Copyright 2020 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by the GraphicsFuzz project.
20 # Short description: A fragment shader that covers a specific inst combine compares code path
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _float_2_3503 _GLF_uniform_float_values[0]
31 # #define _float_2_3505 _GLF_uniform_float_values[1]
32 # #define _float_1_0 _GLF_uniform_float_values[2]
33 # #define _float_800_0 _GLF_uniform_float_values[3]
35 # precision highp int;
37 # precision highp float;
39 # // Contents of _GLF_uniform_int_values: [1, 0]
40 # layout(set = 0, binding = 0) uniform buf0
42 # int _GLF_uniform_int_values[2];
45 # // Contents of _GLF_uniform_float_values: [2.3503, 2.3505, 1.0, 800.0]
46 # layout(set = 0, binding = 1) uniform buf1
48 # float _GLF_uniform_float_values[4];
51 # layout(location = 0) out vec4 _GLF_color;
55 # // This results in an undefined value, but not in undefined behavior.
56 # // v1.x becomes approximately 1.1752 and v1.y becomes undefined.
57 # vec2 v1 = sinh(vec2(_float_1_0, _float_800_0));
59 # ivec2 v2 = ivec2(_int_1, -3000);
61 # // This results in an undefined value, but not in undefined behavior.
62 # // v3.x becomes approximately 2.3504 and v3.y becomes undefined.
63 # vec2 v3 = ldexp(v1, v2);
65 # // Assigning an undefined value doesn't matter since the variable will be
66 # // reassigned later with a sensible value.
67 # _GLF_color = vec4(v3.y);
69 # if (v3.x > _float_2_3503 && v3.x < _float_2_3505)
71 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
75 # _GLF_color = vec4(_int_0);
78 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
81 ; Generator: Khronos Glslang Reference Front End; 10
85 %1 = OpExtInstImport "GLSL.std.450"
86 OpMemoryModel Logical GLSL450
87 OpEntryPoint Fragment %4 "main" %46
88 OpExecutionMode %4 OriginUpperLeft
93 OpMemberName %13 0 "_GLF_uniform_float_values"
97 OpMemberName %32 0 "_GLF_uniform_int_values"
100 OpName %46 "_GLF_color"
101 OpDecorate %12 ArrayStride 16
102 OpMemberDecorate %13 0 Offset 0
104 OpDecorate %15 DescriptorSet 0
105 OpDecorate %15 Binding 1
106 OpDecorate %31 ArrayStride 16
107 OpMemberDecorate %32 0 Offset 0
109 OpDecorate %34 DescriptorSet 0
110 OpDecorate %34 Binding 0
111 OpDecorate %46 Location 0
113 %3 = OpTypeFunction %2
115 %7 = OpTypeVector %6 2
116 %8 = OpTypePointer Function %7
118 %11 = OpConstant %10 4
119 %12 = OpTypeArray %6 %11
120 %13 = OpTypeStruct %12
121 %14 = OpTypePointer Uniform %13
122 %15 = OpVariable %14 Uniform
124 %17 = OpConstant %16 0
125 %18 = OpConstant %16 2
126 %19 = OpTypePointer Uniform %6
127 %22 = OpConstant %16 3
128 %27 = OpTypeVector %16 2
129 %28 = OpTypePointer Function %27
130 %30 = OpConstant %10 2
131 %31 = OpTypeArray %16 %30
132 %32 = OpTypeStruct %31
133 %33 = OpTypePointer Uniform %32
134 %34 = OpVariable %33 Uniform
135 %35 = OpTypePointer Uniform %16
136 %38 = OpConstant %16 -3000
137 %44 = OpTypeVector %6 4
138 %45 = OpTypePointer Output %44
139 %46 = OpVariable %45 Output
140 %47 = OpConstant %10 1
141 %48 = OpTypePointer Function %6
143 %53 = OpConstant %10 0
144 %63 = OpConstant %16 1
145 %4 = OpFunction %2 None %3
147 %9 = OpVariable %8 Function
148 %29 = OpVariable %28 Function
149 %40 = OpVariable %8 Function
150 %20 = OpAccessChain %19 %15 %17 %18
152 %23 = OpAccessChain %19 %15 %17 %22
154 %25 = OpCompositeConstruct %7 %21 %24
155 %26 = OpExtInst %7 %1 Sinh %25
157 %36 = OpAccessChain %35 %34 %17 %17
159 %39 = OpCompositeConstruct %27 %37 %38
163 %43 = OpExtInst %7 %1 Ldexp %41 %42
165 %49 = OpAccessChain %48 %40 %47
167 %51 = OpCompositeConstruct %44 %50 %50 %50 %50
169 %54 = OpAccessChain %48 %40 %53
171 %56 = OpAccessChain %19 %15 %17 %17
173 %58 = OpFOrdGreaterThan %52 %55 %57
174 OpSelectionMerge %60 None
175 OpBranchConditional %58 %59 %60
177 %61 = OpAccessChain %48 %40 %53
179 %64 = OpAccessChain %19 %15 %17 %63
181 %66 = OpFOrdLessThan %52 %62 %65
184 %67 = OpPhi %52 %58 %5 %66 %59
185 OpSelectionMerge %69 None
186 OpBranchConditional %67 %68 %83
188 %70 = OpAccessChain %35 %34 %17 %17
190 %72 = OpConvertSToF %6 %71
191 %73 = OpAccessChain %35 %34 %17 %63
193 %75 = OpConvertSToF %6 %74
194 %76 = OpAccessChain %35 %34 %17 %63
196 %78 = OpConvertSToF %6 %77
197 %79 = OpAccessChain %35 %34 %17 %17
199 %81 = OpConvertSToF %6 %80
200 %82 = OpCompositeConstruct %44 %72 %75 %78 %81
204 %84 = OpAccessChain %35 %34 %17 %63
206 %86 = OpConvertSToF %6 %85
207 %87 = OpCompositeConstruct %44 %86 %86 %86 %86
215 # uniforms for variant
217 # _GLF_uniform_float_values
218 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
219 2.3503 2.3505 1.0 800.0
221 # _GLF_uniform_int_values
222 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
226 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
228 PIPELINE graphics variant_pipeline
229 ATTACH variant_vertex_shader
230 ATTACH variant_fragment_shader
231 FRAMEBUFFER_SIZE 256 256
232 BIND BUFFER variant_framebuffer AS color LOCATION 0
233 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
234 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
236 CLEAR_COLOR variant_pipeline 0 0 0 255
238 CLEAR variant_pipeline
239 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
241 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255