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: Covers peephole optimizer and instr info code paths
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 _int_10 _GLF_uniform_int_values[2]
31 # #define _float_0_0 _GLF_uniform_float_values[0]
32 # #define _float_1_0 _GLF_uniform_float_values[1]
34 # precision highp float;
36 # precision highp int;
38 # // Contents of _GLF_uniform_int_values: [1, 0, 10]
39 # layout(set = 0, binding = 0) uniform buf0
41 # int _GLF_uniform_int_values[3];
44 # // Contents of _GLF_uniform_float_values: [0.0, 1.0]
45 # layout(set = 0, binding = 1) uniform buf1
47 # float _GLF_uniform_float_values[2];
50 # layout(location = 0) out vec4 _GLF_color;
54 # _GLF_color = vec4(_int_0);
55 # for (int i = _int_0; i < _int_10; i++)
58 # if (gl_FragCoord.y < _float_0_0)
61 # if (gl_FragCoord.x < _float_0_0)
67 # if (_float_1_0 > _float_1_0)
75 # if (_float_1_0 > _float_0_0)
77 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
82 # if (_float_0_0 < 0.0)
88 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
91 ; Generator: Khronos Glslang Reference Front End; 8
95 %1 = OpExtInstImport "GLSL.std.450"
96 OpMemoryModel Logical GLSL450
97 OpEntryPoint Fragment %4 "main" %9 %40
98 OpExecutionMode %4 OriginUpperLeft
101 OpName %9 "_GLF_color"
103 OpMemberName %14 0 "_GLF_uniform_int_values"
106 OpName %40 "gl_FragCoord"
108 OpMemberName %47 0 "_GLF_uniform_float_values"
110 OpDecorate %9 Location 0
111 OpDecorate %13 ArrayStride 16
112 OpMemberDecorate %14 0 Offset 0
114 OpDecorate %16 DescriptorSet 0
115 OpDecorate %16 Binding 0
116 OpDecorate %40 BuiltIn FragCoord
117 OpDecorate %46 ArrayStride 16
118 OpMemberDecorate %47 0 Offset 0
120 OpDecorate %49 DescriptorSet 0
121 OpDecorate %49 Binding 1
123 %3 = OpTypeFunction %2
125 %7 = OpTypeVector %6 4
126 %8 = OpTypePointer Output %7
127 %9 = OpVariable %8 Output
130 %12 = OpConstant %11 3
131 %13 = OpTypeArray %10 %12
132 %14 = OpTypeStruct %13
133 %15 = OpTypePointer Uniform %14
134 %16 = OpVariable %15 Uniform
135 %17 = OpConstant %10 0
136 %18 = OpConstant %10 1
137 %19 = OpTypePointer Uniform %10
138 %24 = OpTypePointer Function %10
139 %34 = OpConstant %10 2
141 %39 = OpTypePointer Input %7
142 %40 = OpVariable %39 Input
143 %41 = OpConstant %11 1
144 %42 = OpTypePointer Input %6
145 %45 = OpConstant %11 2
146 %46 = OpTypeArray %6 %45
147 %47 = OpTypeStruct %46
148 %48 = OpTypePointer Uniform %47
149 %49 = OpVariable %48 Uniform
150 %50 = OpTypePointer Uniform %6
151 %56 = OpConstant %11 0
152 %97 = OpConstant %6 0
153 %4 = OpFunction %2 None %3
155 %25 = OpVariable %24 Function
156 %20 = OpAccessChain %19 %16 %17 %18
158 %22 = OpConvertSToF %6 %21
159 %23 = OpCompositeConstruct %7 %22 %22 %22 %22
161 %26 = OpAccessChain %19 %16 %17 %18
166 OpLoopMerge %30 %31 None
170 %35 = OpAccessChain %19 %16 %17 %34
172 %38 = OpSLessThan %37 %33 %36
173 OpBranchConditional %38 %29 %30
175 %43 = OpAccessChain %42 %40 %41
177 %51 = OpAccessChain %50 %49 %17 %17
179 %53 = OpFOrdLessThan %37 %44 %52
180 OpSelectionMerge %55 None
181 OpBranchConditional %53 %54 %55
183 %57 = OpAccessChain %42 %40 %56
185 %59 = OpAccessChain %50 %49 %17 %17
187 %61 = OpFOrdLessThan %37 %58 %60
188 OpSelectionMerge %63 None
189 OpBranchConditional %61 %62 %63
193 %65 = OpAccessChain %50 %49 %17 %18
195 %67 = OpAccessChain %50 %49 %17 %18
197 %69 = OpFOrdGreaterThan %37 %66 %68
198 OpSelectionMerge %71 None
199 OpBranchConditional %69 %70 %71
205 %74 = OpAccessChain %50 %49 %17 %18
207 %76 = OpAccessChain %50 %49 %17 %17
209 %78 = OpFOrdGreaterThan %37 %75 %77
210 OpSelectionMerge %80 None
211 OpBranchConditional %78 %79 %80
213 %81 = OpAccessChain %19 %16 %17 %17
215 %83 = OpConvertSToF %6 %82
216 %84 = OpAccessChain %19 %16 %17 %18
218 %86 = OpConvertSToF %6 %85
219 %87 = OpAccessChain %19 %16 %17 %18
221 %89 = OpConvertSToF %6 %88
222 %90 = OpAccessChain %19 %16 %17 %17
224 %92 = OpConvertSToF %6 %91
225 %93 = OpCompositeConstruct %7 %83 %86 %89 %92
229 %95 = OpAccessChain %50 %49 %17 %17
231 %98 = OpFOrdLessThan %37 %96 %97
232 OpSelectionMerge %100 None
233 OpBranchConditional %98 %99 %100
239 %102 = OpLoad %10 %25
240 %103 = OpIAdd %10 %102 %18
248 # uniforms for variant
250 # _GLF_uniform_float_values
251 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
254 # _GLF_uniform_int_values
255 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
259 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
261 PIPELINE graphics variant_pipeline
262 ATTACH variant_vertex_shader
263 ATTACH variant_fragment_shader
264 FRAMEBUFFER_SIZE 256 256
265 BIND BUFFER variant_framebuffer AS color LOCATION 0
266 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1
267 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
269 CLEAR_COLOR variant_pipeline 0 0 0 255
271 CLEAR variant_pipeline
272 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
274 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255