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 GraphicsFuzz.
20 # Short description: A fragment shader that covers a specific basic block code path
22 # The test passes because shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
26 # '--combine-access-chains'
27 # '--eliminate-local-multi-store'
28 # '--scalar-replacement=100'
29 # '--simplify-instructions'
30 # '--eliminate-dead-branches'
32 # '--combine-access-chains'
33 # '--simplify-instructions'
34 # '--eliminate-dead-branches'
36 # spirv-opt commit hash: 9215c1b7df0029f27807e8c8d7ec80532ce90a87
40 SHADER vertex variant_vertex_shader PASSTHROUGH
42 # variant_fragment_shader is derived from the following GLSL:
44 # precision highp float;
45 # precision highp int;
47 # layout(set = 0, binding = 0) uniform buf0
52 # layout(location = 0) out vec4 _GLF_color;
56 # if (x == 10) // Always false.
75 # _GLF_color = vec4(1, 0, 0, 1);
77 # _GLF_color = vec4(0);
79 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
82 ; Generator: Khronos Glslang Reference Front End; 8
86 %1 = OpExtInstImport "GLSL.std.450"
87 OpMemoryModel Logical GLSL450
88 OpEntryPoint Fragment %4 "main" %52
89 OpExecutionMode %4 OriginUpperLeft
97 OpMemberName %25 0 "zero"
100 OpName %52 "_GLF_color"
101 OpMemberDecorate %25 0 Offset 0
103 OpDecorate %27 DescriptorSet 0
104 OpDecorate %27 Binding 0
105 OpDecorate %52 Location 0
107 %3 = OpTypeFunction %2
109 %7 = OpTypePointer Function %6
110 %8 = OpTypeFunction %6 %7
111 %13 = OpConstant %6 10
113 %23 = OpConstant %6 0
114 %25 = OpTypeStruct %6
115 %26 = OpTypePointer Uniform %25
116 %27 = OpVariable %26 Uniform
117 %28 = OpTypePointer Uniform %6
118 %39 = OpConstant %6 1
119 %42 = OpConstant %6 4
120 %45 = OpConstant %6 3
122 %50 = OpTypeVector %49 4
123 %51 = OpTypePointer Output %50
124 %52 = OpVariable %51 Output
125 %53 = OpConstant %49 1
126 %54 = OpConstant %49 0
127 %55 = OpConstantComposite %50 %53 %54 %54 %53
128 %57 = OpConstantComposite %50 %54 %54 %54 %54
129 %4 = OpFunction %2 None %3
131 %22 = OpVariable %7 Function
132 %24 = OpVariable %7 Function
133 %35 = OpVariable %7 Function
135 %29 = OpAccessChain %28 %27 %23
140 %58 = OpPhi %6 %30 %5 %40 %31
142 %37 = OpFunctionCall %6 %10 %35
144 %40 = OpIAdd %6 %58 %39
146 %43 = OpSLessThan %14 %40 %42
147 OpLoopMerge %33 %31 None
148 OpBranchConditional %43 %31 %33
150 %46 = OpIEqual %14 %37 %45
151 OpSelectionMerge %48 None
152 OpBranchConditional %46 %47 %56
162 %10 = OpFunction %6 None %8
163 %9 = OpFunctionParameter %7
166 %15 = OpIEqual %14 %12 %13
167 OpSelectionMerge %17 None
168 OpBranchConditional %15 %16 %17
177 # uniforms for variant
180 BUFFER variant_zero DATA_TYPE int32 DATA
184 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
186 PIPELINE graphics variant_pipeline
187 ATTACH variant_vertex_shader
188 ATTACH variant_fragment_shader
189 FRAMEBUFFER_SIZE 256 256
190 BIND BUFFER variant_framebuffer AS color LOCATION 0
191 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 0
193 CLEAR_COLOR variant_pipeline 0 0 0 255
195 CLEAR variant_pipeline
196 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
198 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255