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