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