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