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 add sub 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_0 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_2 _GLF_uniform_int_values[2]
31 # #define _float_0_0 _GLF_uniform_float_values[0]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_float_values: 0.0
37 # layout(set = 0, binding = 0) uniform buf0
39 # float _GLF_uniform_float_values[1];
42 # // Contents of _GLF_uniform_int_values: [0, 1, 2]
43 # layout(set = 0, binding = 1) uniform buf1
45 # int _GLF_uniform_int_values[3];
48 # layout(location = 0) out vec4 _GLF_color;
53 # for (int i = _int_0; i < _int_2; i++)
61 # if (!(gl_FragCoord.y < _float_0_0))
68 # // Checks arr[0] == 1. Always true.
69 # if (arr[_int_0] == _int_1)
71 # _GLF_color = vec4(a, _int_0, _int_0, a);
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; 8
85 %1 = OpExtInstImport "GLSL.std.450"
86 OpMemoryModel Logical GLSL450
87 OpEntryPoint Fragment %4 "main" %46 %82
88 OpExecutionMode %4 OriginUpperLeft
93 OpMemberName %12 0 "_GLF_uniform_int_values"
97 OpName %46 "gl_FragCoord"
99 OpMemberName %52 0 "_GLF_uniform_float_values"
101 OpName %82 "_GLF_color"
102 OpDecorate %11 ArrayStride 16
103 OpMemberDecorate %12 0 Offset 0
105 OpDecorate %14 DescriptorSet 0
106 OpDecorate %14 Binding 1
107 OpDecorate %46 BuiltIn FragCoord
108 OpDecorate %51 ArrayStride 16
109 OpMemberDecorate %52 0 Offset 0
111 OpDecorate %54 DescriptorSet 0
112 OpDecorate %54 Binding 0
113 OpDecorate %82 Location 0
115 %3 = OpTypeFunction %2
117 %7 = OpTypePointer Function %6
119 %10 = OpConstant %9 3
120 %11 = OpTypeArray %6 %10
121 %12 = OpTypeStruct %11
122 %13 = OpTypePointer Uniform %12
123 %14 = OpVariable %13 Uniform
124 %15 = OpConstant %6 0
125 %16 = OpTypePointer Uniform %6
126 %25 = OpConstant %6 2
128 %30 = OpConstant %9 2
129 %31 = OpTypeArray %6 %30
130 %32 = OpTypePointer Function %31
131 %39 = OpConstant %6 1
132 %42 = OpConstant %6 -1
134 %44 = OpTypeVector %43 4
135 %45 = OpTypePointer Input %44
136 %46 = OpVariable %45 Input
137 %47 = OpConstant %9 1
138 %48 = OpTypePointer Input %43
139 %51 = OpTypeArray %43 %47
140 %52 = OpTypeStruct %51
141 %53 = OpTypePointer Uniform %52
142 %54 = OpVariable %53 Uniform
143 %55 = OpTypePointer Uniform %43
144 %81 = OpTypePointer Output %44
145 %82 = OpVariable %81 Output
146 %4 = OpFunction %2 None %3
148 %8 = OpVariable %7 Function
149 %33 = OpVariable %32 Function
150 %41 = OpVariable %7 Function
151 %17 = OpAccessChain %16 %14 %15 %15
156 OpLoopMerge %21 %22 None
160 %26 = OpAccessChain %16 %14 %15 %25
162 %29 = OpSLessThan %28 %24 %27
163 OpBranchConditional %29 %20 %21
166 %35 = OpAccessChain %16 %14 %15 %15
168 %37 = OpAccessChain %7 %33 %34
173 %40 = OpIAdd %6 %38 %39
178 %49 = OpAccessChain %48 %46 %47
180 %56 = OpAccessChain %55 %54 %15 %15
182 %58 = OpFOrdLessThan %28 %50 %57
183 %59 = OpLogicalNot %28 %58
184 OpSelectionMerge %61 None
185 OpBranchConditional %59 %60 %61
188 %63 = OpIAdd %6 %62 %39
190 %64 = OpAccessChain %16 %14 %15 %39
192 %66 = OpAccessChain %7 %33 %63
197 %68 = OpIAdd %6 %67 %39
199 %69 = OpAccessChain %16 %14 %15 %25
201 %71 = OpAccessChain %7 %33 %68
203 %72 = OpAccessChain %16 %14 %15 %15
205 %74 = OpAccessChain %7 %33 %73
207 %76 = OpAccessChain %16 %14 %15 %39
209 %78 = OpIEqual %28 %75 %77
210 OpSelectionMerge %80 None
211 OpBranchConditional %78 %79 %94
214 %84 = OpConvertSToF %43 %83
215 %85 = OpAccessChain %16 %14 %15 %15
217 %87 = OpConvertSToF %43 %86
218 %88 = OpAccessChain %16 %14 %15 %15
220 %90 = OpConvertSToF %43 %89
222 %92 = OpConvertSToF %43 %91
223 %93 = OpCompositeConstruct %44 %84 %87 %90 %92
227 %95 = OpAccessChain %16 %14 %15 %15
229 %97 = OpConvertSToF %43 %96
230 %98 = OpCompositeConstruct %44 %97 %97 %97 %97
238 # uniforms for variant
240 # _GLF_uniform_float_values
241 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
244 # _GLF_uniform_int_values
245 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
249 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
251 PIPELINE graphics variant_pipeline
252 ATTACH variant_vertex_shader
253 ATTACH variant_fragment_shader
254 FRAMEBUFFER_SIZE 256 256
255 BIND BUFFER variant_framebuffer AS color LOCATION 0
256 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
257 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
259 CLEAR_COLOR variant_pipeline 0 0 0 255
261 CLEAR variant_pipeline
262 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
264 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255