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