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