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