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