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