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