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