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