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