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