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