1#!amber 2 3# Copyright 2021 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 the GraphicsFuzz project. 19 20# Short description: A fragment shader that covers specific LLVM code paths 21 22# The test passes because the shader always writes red. 23 24SHADER vertex variant_vertex_shader PASSTHROUGH 25 26# variant_fragment_shader is derived from the following GLSL: 27# #version 320 es 28# 29# #define _int_0 _GLF_uniform_int_values[0] 30# #define _int_1 _GLF_uniform_int_values[1] 31# 32# precision highp float; 33# precision highp int; 34# 35# // Contents of _GLF_uniform_int_values: [0, 1] 36# layout(set = 0, binding = 0) uniform buf0 37# { 38# int _GLF_uniform_int_values[2]; 39# }; 40# layout(location = 0) out vec4 _GLF_color; 41# 42# int arr[128] = int[128](1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); 43# 44# void main() 45# { 46# ivec2 p = ivec2(1); 47# 48# for(int i = 1; i < 8; i ++) 49# { 50# for(int j = 1; j < 8; j ++) 51# { 52# // Always true. 53# if(arr[j] == 1) 54# { 55# // Always false. 56# if(gl_FragCoord.x < 0.0) 57# { 58# continue; 59# } 60# 61# p.y = i; 62# } 63# } 64# } 65# 66# // Here p = (1, 7). 67# arr[p.x + p.y] = 0; 68# 69# // Always true. 70# if(arr[8] == 0) 71# { 72# _GLF_color = vec4(1, _int_0, _int_0, _int_1); 73# } 74# else 75# { 76# _GLF_color = vec4(_int_0); 77# } 78# } 79SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 80; SPIR-V 81; Version: 1.0 82; Generator: Khronos Glslang Reference Front End; 10 83; Bound: 100 84; Schema: 0 85 OpCapability Shader 86 %1 = OpExtInstImport "GLSL.std.450" 87 OpMemoryModel Logical GLSL450 88 OpEntryPoint Fragment %4 "main" %47 %77 89 OpExecutionMode %4 OriginUpperLeft 90 OpSource ESSL 320 91 OpName %4 "main" 92 OpName %11 "arr" 93 OpName %16 "p" 94 OpName %19 "i" 95 OpName %29 "j" 96 OpName %47 "gl_FragCoord" 97 OpName %77 "_GLF_color" 98 OpName %81 "buf0" 99 OpMemberName %81 0 "_GLF_uniform_int_values" 100 OpName %83 "" 101 OpDecorate %47 BuiltIn FragCoord 102 OpDecorate %77 Location 0 103 OpDecorate %80 ArrayStride 16 104 OpMemberDecorate %81 0 Offset 0 105 OpDecorate %81 Block 106 OpDecorate %83 DescriptorSet 0 107 OpDecorate %83 Binding 0 108 %2 = OpTypeVoid 109 %3 = OpTypeFunction %2 110 %6 = OpTypeInt 32 1 111 %7 = OpTypeInt 32 0 112 %8 = OpConstant %7 128 113 %9 = OpTypeArray %6 %8 114 %10 = OpTypePointer Private %9 115 %11 = OpVariable %10 Private 116 %12 = OpConstant %6 1 117 %13 = OpConstantComposite %9 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 %12 118 %14 = OpTypeVector %6 2 119 %15 = OpTypePointer Function %14 120 %17 = OpConstantComposite %14 %12 %12 121 %18 = OpTypePointer Function %6 122 %26 = OpConstant %6 8 123 %27 = OpTypeBool 124 %38 = OpTypePointer Private %6 125 %44 = OpTypeFloat 32 126 %45 = OpTypeVector %44 4 127 %46 = OpTypePointer Input %45 128 %47 = OpVariable %46 Input 129 %48 = OpConstant %7 0 130 %49 = OpTypePointer Input %44 131 %52 = OpConstant %44 0 132 %58 = OpConstant %7 1 133 %69 = OpConstant %6 0 134 %76 = OpTypePointer Output %45 135 %77 = OpVariable %76 Output 136 %78 = OpConstant %44 1 137 %79 = OpConstant %7 2 138 %80 = OpTypeArray %6 %79 139 %81 = OpTypeStruct %80 140 %82 = OpTypePointer Uniform %81 141 %83 = OpVariable %82 Uniform 142 %84 = OpTypePointer Uniform %6 143 %4 = OpFunction %2 None %3 144 %5 = OpLabel 145 %16 = OpVariable %15 Function 146 %19 = OpVariable %18 Function 147 %29 = OpVariable %18 Function 148 OpStore %11 %13 149 OpStore %16 %17 150 OpStore %19 %12 151 OpBranch %20 152 %20 = OpLabel 153 OpLoopMerge %22 %23 None 154 OpBranch %24 155 %24 = OpLabel 156 %25 = OpLoad %6 %19 157 %28 = OpSLessThan %27 %25 %26 158 OpBranchConditional %28 %21 %22 159 %21 = OpLabel 160 OpStore %29 %12 161 OpBranch %30 162 %30 = OpLabel 163 OpLoopMerge %32 %33 None 164 OpBranch %34 165 %34 = OpLabel 166 %35 = OpLoad %6 %29 167 %36 = OpSLessThan %27 %35 %26 168 OpBranchConditional %36 %31 %32 169 %31 = OpLabel 170 %37 = OpLoad %6 %29 171 %39 = OpAccessChain %38 %11 %37 172 %40 = OpLoad %6 %39 173 %41 = OpIEqual %27 %40 %12 174 OpSelectionMerge %43 None 175 OpBranchConditional %41 %42 %43 176 %42 = OpLabel 177 %50 = OpAccessChain %49 %47 %48 178 %51 = OpLoad %44 %50 179 %53 = OpFOrdLessThan %27 %51 %52 180 OpSelectionMerge %55 None 181 OpBranchConditional %53 %54 %55 182 %54 = OpLabel 183 OpBranch %33 184 %55 = OpLabel 185 %57 = OpLoad %6 %19 186 %59 = OpAccessChain %18 %16 %58 187 OpStore %59 %57 188 OpBranch %43 189 %43 = OpLabel 190 OpBranch %33 191 %33 = OpLabel 192 %60 = OpLoad %6 %29 193 %61 = OpIAdd %6 %60 %12 194 OpStore %29 %61 195 OpBranch %30 196 %32 = OpLabel 197 OpBranch %23 198 %23 = OpLabel 199 %62 = OpLoad %6 %19 200 %63 = OpIAdd %6 %62 %12 201 OpStore %19 %63 202 OpBranch %20 203 %22 = OpLabel 204 %64 = OpAccessChain %18 %16 %48 205 %65 = OpLoad %6 %64 206 %66 = OpAccessChain %18 %16 %58 207 %67 = OpLoad %6 %66 208 %68 = OpIAdd %6 %65 %67 209 %70 = OpAccessChain %38 %11 %68 210 OpStore %70 %69 211 %71 = OpAccessChain %38 %11 %26 212 %72 = OpLoad %6 %71 213 %73 = OpIEqual %27 %72 %69 214 OpSelectionMerge %75 None 215 OpBranchConditional %73 %74 %95 216 %74 = OpLabel 217 %85 = OpAccessChain %84 %83 %69 %69 218 %86 = OpLoad %6 %85 219 %87 = OpConvertSToF %44 %86 220 %88 = OpAccessChain %84 %83 %69 %69 221 %89 = OpLoad %6 %88 222 %90 = OpConvertSToF %44 %89 223 %91 = OpAccessChain %84 %83 %69 %12 224 %92 = OpLoad %6 %91 225 %93 = OpConvertSToF %44 %92 226 %94 = OpCompositeConstruct %45 %78 %87 %90 %93 227 OpStore %77 %94 228 OpBranch %75 229 %95 = OpLabel 230 %96 = OpAccessChain %84 %83 %69 %69 231 %97 = OpLoad %6 %96 232 %98 = OpConvertSToF %44 %97 233 %99 = OpCompositeConstruct %45 %98 %98 %98 %98 234 OpStore %77 %99 235 OpBranch %75 236 %75 = OpLabel 237 OpReturn 238 OpFunctionEnd 239END 240 241# uniforms for variant 242 243# _GLF_uniform_int_values 244BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 245 0 1 246END 247 248BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 249 250PIPELINE graphics variant_pipeline 251 ATTACH variant_vertex_shader 252 ATTACH variant_fragment_shader 253 FRAMEBUFFER_SIZE 256 256 254 BIND BUFFER variant_framebuffer AS color LOCATION 0 255 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 256END 257CLEAR_COLOR variant_pipeline 0 0 0 255 258 259CLEAR variant_pipeline 260RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 261 262EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 263