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