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