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