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