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