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