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