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