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# layout(location = 0) out vec4 _GLF_color; 41# 42# // This function returns 0. 43# int func() 44# { 45# return findLSB(ivec2(1)).g; 46# } 47# 48# void main() 49# { 50# // Always true. 51# if(func() == _int_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: 58 65; Schema: 0 66 OpCapability Shader 67 %1 = OpExtInstImport "GLSL.std.450" 68 OpMemoryModel Logical GLSL450 69 OpEntryPoint Fragment %4 "main" %39 70 OpExecutionMode %4 OriginUpperLeft 71 OpSource ESSL 320 72 OpName %4 "main" 73 OpName %8 "func(" 74 OpName %25 "buf0" 75 OpMemberName %25 0 "_GLF_uniform_int_values" 76 OpName %27 "" 77 OpName %39 "_GLF_color" 78 OpDecorate %13 RelaxedPrecision 79 OpDecorate %16 RelaxedPrecision 80 OpDecorate %24 ArrayStride 16 81 OpMemberDecorate %25 0 Offset 0 82 OpDecorate %25 Block 83 OpDecorate %27 DescriptorSet 0 84 OpDecorate %27 Binding 0 85 OpDecorate %39 Location 0 86 %2 = OpTypeVoid 87 %3 = OpTypeFunction %2 88 %6 = OpTypeInt 32 1 89 %7 = OpTypeFunction %6 90 %10 = OpTypeVector %6 2 91 %11 = OpConstant %6 1 92 %12 = OpConstantComposite %10 %11 %11 93 %14 = OpTypeInt 32 0 94 %15 = OpConstant %14 1 95 %17 = OpTypePointer Function %6 96 %23 = OpConstant %14 2 97 %24 = OpTypeArray %6 %23 98 %25 = OpTypeStruct %24 99 %26 = OpTypePointer Uniform %25 100 %27 = OpVariable %26 Uniform 101 %28 = OpConstant %6 0 102 %29 = OpTypePointer Uniform %6 103 %32 = OpTypeBool 104 %36 = OpTypeFloat 32 105 %37 = OpTypeVector %36 4 106 %38 = OpTypePointer Output %37 107 %39 = OpVariable %38 Output 108 %4 = OpFunction %2 None %3 109 %5 = OpLabel 110 %22 = OpFunctionCall %6 %8 111 %30 = OpAccessChain %29 %27 %28 %28 112 %31 = OpLoad %6 %30 113 %33 = OpIEqual %32 %22 %31 114 OpSelectionMerge %35 None 115 OpBranchConditional %33 %34 %53 116 %34 = OpLabel 117 %40 = OpAccessChain %29 %27 %28 %11 118 %41 = OpLoad %6 %40 119 %42 = OpConvertSToF %36 %41 120 %43 = OpAccessChain %29 %27 %28 %28 121 %44 = OpLoad %6 %43 122 %45 = OpConvertSToF %36 %44 123 %46 = OpAccessChain %29 %27 %28 %28 124 %47 = OpLoad %6 %46 125 %48 = OpConvertSToF %36 %47 126 %49 = OpAccessChain %29 %27 %28 %11 127 %50 = OpLoad %6 %49 128 %51 = OpConvertSToF %36 %50 129 %52 = OpCompositeConstruct %37 %42 %45 %48 %51 130 OpStore %39 %52 131 OpBranch %35 132 %53 = OpLabel 133 %54 = OpAccessChain %29 %27 %28 %28 134 %55 = OpLoad %6 %54 135 %56 = OpConvertSToF %36 %55 136 %57 = OpCompositeConstruct %37 %56 %56 %56 %56 137 OpStore %39 %57 138 OpBranch %35 139 %35 = OpLabel 140 OpReturn 141 OpFunctionEnd 142 %8 = OpFunction %6 None %7 143 %9 = OpLabel 144 %18 = OpVariable %17 Function 145 %13 = OpExtInst %10 %1 FindILsb %12 146 %16 = OpCompositeExtract %6 %13 1 147 OpStore %18 %16 148 %19 = OpLoad %6 %18 149 OpReturnValue %19 150 OpFunctionEnd 151END 152 153# uniforms for variant 154 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__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 168END 169CLEAR_COLOR variant_pipeline 0 0 0 255 170 171CLEAR variant_pipeline 172RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 173 174EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 175