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