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