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