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