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 x86 isel lowering code path
22 # The test passes because the shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
25 # '--eliminate-dead-branches'
27 # '--eliminate-dead-branches'
29 # spirv-opt commit hash: a187dd58a0485988841d325a85c8e6063f53500a
33 SHADER vertex variant_vertex_shader PASSTHROUGH
35 # variant_fragment_shader is derived from the following GLSL:
37 # #define _float_0_0 _GLF_uniform_float_values[0]
38 # #define _float_790_0 _GLF_uniform_float_values[1]
39 # #define _float_2_0 _GLF_uniform_float_values[2]
40 # #define _float_4_0 _GLF_uniform_float_values[3]
41 # #define _float_1_0 _GLF_uniform_float_values[4]
43 # precision highp float;
45 # // Contents of _GLF_uniform_float_values: [0.0, 790.0, 2.0, 4.0, 1.0]
46 # layout(set = 0, binding = 0) uniform buf0
48 # float _GLF_uniform_float_values[5];
51 # layout(location = 0) out vec4 _GLF_color;
56 # float a = determinant(mat2(_float_2_0, _float_4_0, _float_1_0, _float_2_0));
59 # float b = float(mat2(a));
61 # // This results in an undefined value, but not in undefined behavior.
62 # // v1.x becomes undefined and v1.y becomes 0.
63 # vec2 v1 = acos(exp(vec2(_float_790_0, b)));
65 # _GLF_color = vec4(v1.x);
67 # if (v1.y == _float_0_0)
69 # _GLF_color = vec4(_float_1_0, _float_0_0, _float_0_0, _float_1_0);
72 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
75 ; Generator: Khronos Glslang Reference Front End; 10
79 %1 = OpExtInstImport "GLSL.std.450"
80 OpMemoryModel Logical GLSL450
81 OpEntryPoint Fragment %4 "main" %54
82 OpExecutionMode %4 OriginUpperLeft
87 OpMemberName %12 0 "_GLF_uniform_float_values"
91 OpName %54 "_GLF_color"
92 OpDecorate %11 ArrayStride 16
93 OpMemberDecorate %12 0 Offset 0
95 OpDecorate %14 DescriptorSet 0
96 OpDecorate %14 Binding 0
97 OpDecorate %54 Location 0
99 %3 = OpTypeFunction %2
101 %7 = OpTypePointer Function %6
103 %10 = OpConstant %9 5
104 %11 = OpTypeArray %6 %10
105 %12 = OpTypeStruct %11
106 %13 = OpTypePointer Uniform %12
107 %14 = OpVariable %13 Uniform
109 %16 = OpConstant %15 0
110 %17 = OpConstant %15 2
111 %18 = OpTypePointer Uniform %6
112 %21 = OpConstant %15 3
113 %24 = OpConstant %15 4
114 %29 = OpTypeVector %6 2
115 %30 = OpTypeMatrix %29 2
116 %31 = OpConstant %6 1
117 %32 = OpConstant %6 0
118 %43 = OpTypePointer Function %29
119 %45 = OpConstant %15 1
120 %52 = OpTypeVector %6 4
121 %53 = OpTypePointer Output %52
122 %54 = OpVariable %53 Output
123 %55 = OpConstant %9 0
124 %59 = OpConstant %9 1
126 %4 = OpFunction %2 None %3
128 %8 = OpVariable %7 Function
129 %37 = OpVariable %7 Function
130 %44 = OpVariable %43 Function
131 %19 = OpAccessChain %18 %14 %16 %17
133 %22 = OpAccessChain %18 %14 %16 %21
135 %25 = OpAccessChain %18 %14 %16 %24
137 %27 = OpAccessChain %18 %14 %16 %17
139 %33 = OpCompositeConstruct %29 %20 %23
140 %34 = OpCompositeConstruct %29 %26 %28
141 %35 = OpCompositeConstruct %30 %33 %34
142 %36 = OpExtInst %6 %1 Determinant %35
145 %39 = OpCompositeConstruct %29 %38 %32
146 %40 = OpCompositeConstruct %29 %32 %38
147 %41 = OpCompositeConstruct %30 %39 %40
148 %42 = OpCompositeExtract %6 %41 0 0
150 %46 = OpAccessChain %18 %14 %16 %45
153 %49 = OpCompositeConstruct %29 %47 %48
154 %50 = OpExtInst %29 %1 Exp %49
155 %51 = OpExtInst %29 %1 Acos %50
157 %56 = OpAccessChain %7 %44 %55
159 %58 = OpCompositeConstruct %52 %57 %57 %57 %57
161 %60 = OpAccessChain %7 %44 %59
163 %62 = OpAccessChain %18 %14 %16 %16
165 %65 = OpFOrdEqual %64 %61 %63
166 OpSelectionMerge %67 None
167 OpBranchConditional %65 %66 %67
169 %68 = OpAccessChain %18 %14 %16 %24
171 %70 = OpAccessChain %18 %14 %16 %16
173 %72 = OpAccessChain %18 %14 %16 %16
175 %74 = OpAccessChain %18 %14 %16 %24
177 %76 = OpCompositeConstruct %52 %69 %71 %73 %75
185 # uniforms for variant
187 # _GLF_uniform_float_values
188 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
189 0.0 790.0 2.0 4.0 1.0
192 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
194 PIPELINE graphics variant_pipeline
195 ATTACH variant_vertex_shader
196 ATTACH variant_fragment_shader
197 FRAMEBUFFER_SIZE 256 256
198 BIND BUFFER variant_framebuffer AS color LOCATION 0
199 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
201 CLEAR_COLOR variant_pipeline 0 0 0 255
203 CLEAR variant_pipeline
204 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
206 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255