1#!amber 2 3# Copyright 2020 Google LLC 4# 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 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 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. 16 17 18# A test for a coverage-gap found by GraphicsFuzz. 19 20# Short description: A fragment shader that covers a specific single block elimination path. 21 22# The test passes because shader always writes red. 23 24SHADER vertex variant_vertex_shader PASSTHROUGH 25 26# variant_fragment_shader is derived from the following GLSL: 27# #version 310 es 28# precision highp float; 29# 30# layout(set = 0, binding = 0) uniform buf0 { 31# vec2 injectionSwitch; 32# }; 33# 34# layout(location = 0) out vec4 _GLF_color; 35# 36# int g = 0; 37# 38# void main() 39# { 40# while(g < int(injectionSwitch.x + 2.0)) { 41# g++; 42# } 43# 44# // g is 2. 45# int a = g; 46# 47# // Always false. 48# while(g < int(injectionSwitch.y)) { 49# g++; 50# } 51# 52# a = a; 53# 54# // Always true. 55# if(a == 2) 56# _GLF_color = vec4(1, 0, 0, 1); 57# else 58# _GLF_color = vec4(0); 59# } 60SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 61; SPIR-V 62; Version: 1.0 63; Generator: Khronos Glslang Reference Front End; 8 64; Bound: 64 65; Schema: 0 66 OpCapability Shader 67 %1 = OpExtInstImport "GLSL.std.450" 68 OpMemoryModel Logical GLSL450 69 OpEntryPoint Fragment %4 "main" %58 70 OpExecutionMode %4 OriginUpperLeft 71 OpSource ESSL 310 72 OpName %4 "main" 73 OpName %8 "g" 74 OpName %18 "buf0" 75 OpMemberName %18 0 "injectionSwitch" 76 OpName %20 "" 77 OpName %35 "a" 78 OpName %58 "_GLF_color" 79 OpDecorate %8 RelaxedPrecision 80 OpDecorate %15 RelaxedPrecision 81 OpMemberDecorate %18 0 Offset 0 82 OpDecorate %18 Block 83 OpDecorate %20 DescriptorSet 0 84 OpDecorate %20 Binding 0 85 OpDecorate %31 RelaxedPrecision 86 OpDecorate %33 RelaxedPrecision 87 OpDecorate %35 RelaxedPrecision 88 OpDecorate %36 RelaxedPrecision 89 OpDecorate %42 RelaxedPrecision 90 OpDecorate %48 RelaxedPrecision 91 OpDecorate %49 RelaxedPrecision 92 OpDecorate %50 RelaxedPrecision 93 OpDecorate %51 RelaxedPrecision 94 OpDecorate %58 Location 0 95 %2 = OpTypeVoid 96 %3 = OpTypeFunction %2 97 %6 = OpTypeInt 32 1 98 %7 = OpTypePointer Private %6 99 %8 = OpVariable %7 Private 100 %9 = OpConstant %6 0 101 %16 = OpTypeFloat 32 102 %17 = OpTypeVector %16 2 103 %18 = OpTypeStruct %17 104 %19 = OpTypePointer Uniform %18 105 %20 = OpVariable %19 Uniform 106 %21 = OpTypeInt 32 0 107 %22 = OpConstant %21 0 108 %23 = OpTypePointer Uniform %16 109 %26 = OpConstant %16 2 110 %29 = OpTypeBool 111 %32 = OpConstant %6 1 112 %34 = OpTypePointer Function %6 113 %43 = OpConstant %21 1 114 %52 = OpConstant %6 2 115 %56 = OpTypeVector %16 4 116 %57 = OpTypePointer Output %56 117 %58 = OpVariable %57 Output 118 %59 = OpConstant %16 1 119 %60 = OpConstant %16 0 120 %61 = OpConstantComposite %56 %59 %60 %60 %59 121 %63 = OpConstantComposite %56 %60 %60 %60 %60 122 %4 = OpFunction %2 None %3 123 %5 = OpLabel 124 %35 = OpVariable %34 Function 125 OpStore %8 %9 126 OpBranch %10 127 %10 = OpLabel 128 OpLoopMerge %12 %13 None 129 OpBranch %14 130 %14 = OpLabel 131 %15 = OpLoad %6 %8 132 %24 = OpAccessChain %23 %20 %9 %22 133 %25 = OpLoad %16 %24 134 %27 = OpFAdd %16 %25 %26 135 %28 = OpConvertFToS %6 %27 136 %30 = OpSLessThan %29 %15 %28 137 OpBranchConditional %30 %11 %12 138 %11 = OpLabel 139 %31 = OpLoad %6 %8 140 %33 = OpIAdd %6 %31 %32 141 OpStore %8 %33 142 OpBranch %13 143 %13 = OpLabel 144 OpBranch %10 145 %12 = OpLabel 146 %36 = OpLoad %6 %8 147 OpStore %35 %36 148 OpBranch %37 149 %37 = OpLabel 150 OpLoopMerge %39 %40 None 151 OpBranch %41 152 %41 = OpLabel 153 %42 = OpLoad %6 %8 154 %44 = OpAccessChain %23 %20 %9 %43 155 %45 = OpLoad %16 %44 156 %46 = OpConvertFToS %6 %45 157 %47 = OpSLessThan %29 %42 %46 158 OpBranchConditional %47 %38 %39 159 %38 = OpLabel 160 %48 = OpLoad %6 %8 161 %49 = OpIAdd %6 %48 %32 162 OpStore %8 %49 163 OpBranch %40 164 %40 = OpLabel 165 OpBranch %37 166 %39 = OpLabel 167 %50 = OpLoad %6 %35 168 OpStore %35 %50 169 %51 = OpLoad %6 %35 170 %53 = OpIEqual %29 %51 %52 171 OpSelectionMerge %55 None 172 OpBranchConditional %53 %54 %62 173 %54 = OpLabel 174 OpStore %58 %61 175 OpBranch %55 176 %62 = OpLabel 177 OpStore %58 %63 178 OpBranch %55 179 %55 = OpLabel 180 OpReturn 181 OpFunctionEnd 182END 183 184# uniforms for variant 185 186# injectionSwitch 187BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA 188 0.0 1.0 189END 190 191BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 192 193PIPELINE graphics variant_pipeline 194 ATTACH variant_vertex_shader 195 ATTACH variant_fragment_shader 196 FRAMEBUFFER_SIZE 256 256 197 BIND BUFFER variant_framebuffer AS color LOCATION 0 198 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0 199END 200CLEAR_COLOR variant_pipeline 0 0 0 255 201 202CLEAR variant_pipeline 203RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 204 205EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 206