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 _float_0_0 _GLF_uniform_float_values[0] 29# 30# precision highp float; 31# precision highp int; 32# 33# // Contents of _GLF_uniform_float_values: 0.0 34# layout(set = 0, binding = 0) uniform buf0 35# { 36# float _GLF_uniform_float_values[1]; 37# }; 38# 39# layout(location = 0) out vec4 _GLF_color; 40# 41# void main() 42# { 43# float f; 44# 45# // f is uninitialized, but 1.0 is selected from the first vector. 46# _GLF_color = mix(vec4(1.0), vec4(f, 0.0, 0.0, 1.0), bvec4(gl_FragCoord.y < _float_0_0, true, true, true)); 47# } 48SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 49; SPIR-V 50; Version: 1.0 51; Generator: Khronos Glslang Reference Front End; 10 52; Bound: 39 53; Schema: 0 54 OpCapability Shader 55 %1 = OpExtInstImport "GLSL.std.450" 56 OpMemoryModel Logical GLSL450 57 OpEntryPoint Fragment %4 "main" %9 %18 58 OpExecutionMode %4 OriginUpperLeft 59 OpSource ESSL 320 60 OpName %4 "main" 61 OpName %9 "_GLF_color" 62 OpName %13 "f" 63 OpName %18 "gl_FragCoord" 64 OpName %25 "buf0" 65 OpMemberName %25 0 "_GLF_uniform_float_values" 66 OpName %27 "" 67 OpDecorate %9 Location 0 68 OpDecorate %18 BuiltIn FragCoord 69 OpDecorate %24 ArrayStride 16 70 OpMemberDecorate %25 0 Offset 0 71 OpDecorate %25 Block 72 OpDecorate %27 DescriptorSet 0 73 OpDecorate %27 Binding 0 74 %2 = OpTypeVoid 75 %3 = OpTypeFunction %2 76 %6 = OpTypeFloat 32 77 %7 = OpTypeVector %6 4 78 %8 = OpTypePointer Output %7 79 %9 = OpVariable %8 Output 80 %10 = OpConstant %6 1 81 %11 = OpConstantComposite %7 %10 %10 %10 %10 82 %12 = OpTypePointer Function %6 83 %15 = OpConstant %6 0 84 %17 = OpTypePointer Input %7 85 %18 = OpVariable %17 Input 86 %19 = OpTypeInt 32 0 87 %20 = OpConstant %19 1 88 %21 = OpTypePointer Input %6 89 %24 = OpTypeArray %6 %20 90 %25 = OpTypeStruct %24 91 %26 = OpTypePointer Uniform %25 92 %27 = OpVariable %26 Uniform 93 %28 = OpTypeInt 32 1 94 %29 = OpConstant %28 0 95 %30 = OpTypePointer Uniform %6 96 %33 = OpTypeBool 97 %35 = OpConstantTrue %33 98 %36 = OpTypeVector %33 4 99 %4 = OpFunction %2 None %3 100 %5 = OpLabel 101 %13 = OpVariable %12 Function 102 %14 = OpLoad %6 %13 103 %16 = OpCompositeConstruct %7 %14 %15 %15 %10 104 %22 = OpAccessChain %21 %18 %20 105 %23 = OpLoad %6 %22 106 %31 = OpAccessChain %30 %27 %29 %29 107 %32 = OpLoad %6 %31 108 %34 = OpFOrdLessThan %33 %23 %32 109 %37 = OpCompositeConstruct %36 %34 %35 %35 %35 110 %38 = OpSelect %7 %37 %16 %11 111 OpStore %9 %38 112 OpReturn 113 OpFunctionEnd 114END 115 116# uniforms for variant 117 118# _GLF_uniform_float_values 119BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 120 0.0 121END 122 123BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 124 125PIPELINE graphics variant_pipeline 126 ATTACH variant_vertex_shader 127 ATTACH variant_fragment_shader 128 FRAMEBUFFER_SIZE 32 32 129 BIND BUFFER variant_framebuffer AS color LOCATION 0 130 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0 131END 132CLEAR_COLOR variant_pipeline 0 0 0 255 133 134CLEAR variant_pipeline 135RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32 136 137EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255 138