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 GraphicsFuzz. 19 20# Short description: A fragment shader that covers a specific folding path 21 22# The test passes because shader always writes red. 23 24SHADER vertex variant_vertex_shader PASSTHROUGH 25 26# variant_fragment_shader is derived from the following GLSL: 27# #version 310 es 28# precision highp float; 29# precision highp int; 30# 31# layout(location = 0) out vec4 _GLF_color; 32# 33# layout(set = 0, binding = 0) uniform buf0 34# { 35# int one; 36# }; 37# 38# int func() 39# { 40# int ret = 0; 41# 42# for(int i = 3; i > (i & 1); i -= one) 43# ret++; 44# 45# return ret; 46# } 47# 48# void main() 49# { 50# if (func() == 2) 51# _GLF_color = vec4(1, 0, 0, 1); 52# else 53# _GLF_color = vec4(0); 54# } 55SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 56; SPIR-V 57; Version: 1.0 58; Generator: Khronos Glslang Reference Front End; 8 59; Bound: 53 60; Schema: 0 61 OpCapability Shader 62 %1 = OpExtInstImport "GLSL.std.450" 63 OpMemoryModel Logical GLSL450 64 OpEntryPoint Fragment %4 "main" %47 65 OpExecutionMode %4 OriginUpperLeft 66 OpSource ESSL 310 67 OpName %4 "main" 68 OpName %8 "func(" 69 OpName %11 "ret" 70 OpName %13 "i" 71 OpName %28 "buf0" 72 OpMemberName %28 0 "one" 73 OpName %30 "" 74 OpName %47 "_GLF_color" 75 OpMemberDecorate %28 0 Offset 0 76 OpDecorate %28 Block 77 OpDecorate %30 DescriptorSet 0 78 OpDecorate %30 Binding 0 79 OpDecorate %47 Location 0 80 %2 = OpTypeVoid 81 %3 = OpTypeFunction %2 82 %6 = OpTypeInt 32 1 83 %7 = OpTypeFunction %6 84 %10 = OpTypePointer Function %6 85 %12 = OpConstant %6 0 86 %14 = OpConstant %6 3 87 %22 = OpConstant %6 1 88 %24 = OpTypeBool 89 %28 = OpTypeStruct %6 90 %29 = OpTypePointer Uniform %28 91 %30 = OpVariable %29 Uniform 92 %31 = OpTypePointer Uniform %6 93 %40 = OpConstant %6 2 94 %44 = OpTypeFloat 32 95 %45 = OpTypeVector %44 4 96 %46 = OpTypePointer Output %45 97 %47 = OpVariable %46 Output 98 %48 = OpConstant %44 1 99 %49 = OpConstant %44 0 100 %50 = OpConstantComposite %45 %48 %49 %49 %48 101 %52 = OpConstantComposite %45 %49 %49 %49 %49 102 %4 = OpFunction %2 None %3 103 %5 = OpLabel 104 %39 = OpFunctionCall %6 %8 105 %41 = OpIEqual %24 %39 %40 106 OpSelectionMerge %43 None 107 OpBranchConditional %41 %42 %51 108 %42 = OpLabel 109 OpStore %47 %50 110 OpBranch %43 111 %51 = OpLabel 112 OpStore %47 %52 113 OpBranch %43 114 %43 = OpLabel 115 OpReturn 116 OpFunctionEnd 117 %8 = OpFunction %6 None %7 118 %9 = OpLabel 119 %11 = OpVariable %10 Function 120 %13 = OpVariable %10 Function 121 OpStore %11 %12 122 OpStore %13 %14 123 OpBranch %15 124 %15 = OpLabel 125 OpLoopMerge %17 %18 None 126 OpBranch %19 127 %19 = OpLabel 128 %20 = OpLoad %6 %13 129 %21 = OpLoad %6 %13 130 %23 = OpBitwiseAnd %6 %21 %22 131 %25 = OpSGreaterThan %24 %20 %23 132 OpBranchConditional %25 %16 %17 133 %16 = OpLabel 134 %26 = OpLoad %6 %11 135 %27 = OpIAdd %6 %26 %22 136 OpStore %11 %27 137 OpBranch %18 138 %18 = OpLabel 139 %32 = OpAccessChain %31 %30 %12 140 %33 = OpLoad %6 %32 141 %34 = OpLoad %6 %13 142 %35 = OpISub %6 %34 %33 143 OpStore %13 %35 144 OpBranch %15 145 %17 = OpLabel 146 %36 = OpLoad %6 %11 147 OpReturnValue %36 148 OpFunctionEnd 149END 150 151# uniforms for variant 152 153# one 154BUFFER variant_one DATA_TYPE int32 DATA 155 1 156END 157 158BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 159 160PIPELINE graphics variant_pipeline 161 ATTACH variant_vertex_shader 162 ATTACH variant_fragment_shader 163 FRAMEBUFFER_SIZE 256 256 164 BIND BUFFER variant_framebuffer AS color LOCATION 0 165 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0 166END 167CLEAR_COLOR variant_pipeline 0 0 0 255 168 169CLEAR variant_pipeline 170RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 171 172EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 173