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