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 IR builder, constant fold, inst combine calls and value tracking 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_3 _GLF_uniform_int_values[0]
29 # #define _int_1 _GLF_uniform_int_values[1]
30 # #define _int_0 _GLF_uniform_int_values[2]
31 # #define _int_2 _GLF_uniform_int_values[3]
33 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_int_values: [3, 1, 0, 2]
38 # layout(set = 0, binding = 0) uniform buf0
40 # int _GLF_uniform_int_values[4];
42 # layout(location = 0) out vec4 _GLF_color;
49 # if (mix(vec2(1), vec2(2), bvec2(true, _int_1 == _int_2)) == vec2(1))
51 # for (int i = _int_1; findMSB(i) < 5; i++)
58 # for (int i = _int_1; findMSB(i) < _int_3; i++)
65 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
69 # _GLF_color = vec4(_int_0);
72 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
75 ; Generator: Khronos Glslang Reference Front End; 8
79 %1 = OpExtInstImport "GLSL.std.450"
80 OpMemoryModel Logical GLSL450
81 OpEntryPoint Fragment %4 "main" %80
82 OpExecutionMode %4 OriginUpperLeft
87 OpMemberName %21 0 "_GLF_uniform_int_values"
91 OpName %80 "_GLF_color"
92 OpDecorate %20 ArrayStride 16
93 OpMemberDecorate %21 0 Offset 0
95 OpDecorate %23 DescriptorSet 0
96 OpDecorate %23 Binding 0
97 OpDecorate %80 Location 0
99 %3 = OpTypeFunction %2
101 %7 = OpTypePointer Function %6
104 %11 = OpTypeVector %10 2
105 %12 = OpConstant %10 1
106 %13 = OpConstantComposite %11 %12 %12
107 %14 = OpConstant %10 2
108 %15 = OpConstantComposite %11 %14 %14
110 %17 = OpConstantTrue %16
112 %19 = OpConstant %18 4
113 %20 = OpTypeArray %6 %19
114 %21 = OpTypeStruct %20
115 %22 = OpTypePointer Uniform %21
116 %23 = OpVariable %22 Uniform
117 %24 = OpConstant %6 1
118 %25 = OpTypePointer Uniform %6
119 %28 = OpConstant %6 3
120 %32 = OpTypeVector %16 2
121 %49 = OpConstant %6 5
122 %74 = OpConstant %6 7
123 %78 = OpTypeVector %10 4
124 %79 = OpTypePointer Output %78
125 %80 = OpVariable %79 Output
126 %84 = OpConstant %6 2
127 %4 = OpFunction %2 None %3
129 %8 = OpVariable %7 Function
130 %39 = OpVariable %7 Function
131 %56 = OpVariable %7 Function
133 %26 = OpAccessChain %25 %23 %9 %24
135 %29 = OpAccessChain %25 %23 %9 %28
137 %31 = OpIEqual %16 %27 %30
138 %33 = OpCompositeConstruct %32 %17 %31
139 %34 = OpSelect %11 %33 %15 %13
140 %35 = OpFOrdEqual %32 %34 %13
142 OpSelectionMerge %38 None
143 OpBranchConditional %36 %37 %55
145 %40 = OpAccessChain %25 %23 %9 %24
150 OpLoopMerge %44 %45 None
154 %48 = OpExtInst %6 %1 FindSMsb %47
155 %50 = OpSLessThan %16 %48 %49
156 OpBranchConditional %50 %43 %44
159 %52 = OpIAdd %6 %51 %24
164 %54 = OpIAdd %6 %53 %24
170 %57 = OpAccessChain %25 %23 %9 %24
175 OpLoopMerge %61 %62 None
179 %65 = OpExtInst %6 %1 FindSMsb %64
180 %66 = OpAccessChain %25 %23 %9 %9
182 %68 = OpSLessThan %16 %65 %67
183 OpBranchConditional %68 %60 %61
186 %70 = OpIAdd %6 %69 %24
191 %72 = OpIAdd %6 %71 %24
198 %75 = OpIEqual %16 %73 %74
199 OpSelectionMerge %77 None
200 OpBranchConditional %75 %76 %95
202 %81 = OpAccessChain %25 %23 %9 %24
204 %83 = OpConvertSToF %10 %82
205 %85 = OpAccessChain %25 %23 %9 %84
207 %87 = OpConvertSToF %10 %86
208 %88 = OpAccessChain %25 %23 %9 %84
210 %90 = OpConvertSToF %10 %89
211 %91 = OpAccessChain %25 %23 %9 %24
213 %93 = OpConvertSToF %10 %92
214 %94 = OpCompositeConstruct %78 %83 %87 %90 %93
218 %96 = OpAccessChain %25 %23 %9 %84
220 %98 = OpConvertSToF %10 %97
221 %99 = OpCompositeConstruct %78 %98 %98 %98 %98
229 # uniforms for variant
231 # _GLF_uniform_int_values
232 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
236 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
238 PIPELINE graphics variant_pipeline
239 ATTACH variant_vertex_shader
240 ATTACH variant_fragment_shader
241 FRAMEBUFFER_SIZE 256 256
242 BIND BUFFER variant_framebuffer AS color LOCATION 0
243 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
245 CLEAR_COLOR variant_pipeline 0 0 0 255
247 CLEAR variant_pipeline
248 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
250 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255