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