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