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