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