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