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