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