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: Covers specific combine shifts and combine simplify demanded 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_3 _GLF_uniform_int_values[0] 29# #define _int_1 _GLF_uniform_int_values[1] 30# #define _int_0 _GLF_uniform_int_values[2] 31# #define _int_2 _GLF_uniform_int_values[3] 32# #define _float_0_25 _GLF_uniform_float_values[0] 33# #define _float_0_75 _GLF_uniform_float_values[1] 34# #define _float_0_0 _GLF_uniform_float_values[2] 35# #define _float_127_0 _GLF_uniform_float_values[3] 36# #define _float_64_0 _GLF_uniform_float_values[4] 37# #define _float_1_0 _GLF_uniform_float_values[5] 38# #define _float_65_0 _GLF_uniform_float_values[6] 39# 40# precision highp float; 41# precision highp int; 42# 43# // Contents of _GLF_uniform_int_values: [3, 1, 0, 2] 44# layout(set = 0, binding = 0) uniform buf0 45# { 46# int _GLF_uniform_int_values[4]; 47# }; 48# 49# // Contents of _GLF_uniform_float_values: [0.25, 0.75, 0.0, 127.0, 64.0, 1.0, 65.0] 50# layout(set = 0, binding = 1) uniform buf1 51# { 52# float _GLF_uniform_float_values[7]; 53# }; 54# 55# layout(location = 0) out vec4 _GLF_color; 56# 57# void main() 58# { 59# // Packs the two components into an unsigned integer of 3221176320. 60# uint a = packUnorm2x16(vec2(_float_0_25, _float_0_75)); 61# 62# // Unpacks the integer into values of 0.0, 64.0, -1.0 and -65.0. 63# // Then converts them into floating-point values by dividing with 127.0. 64# vec4 v1 = unpackSnorm4x8(a); 65# 66# float E = 0.01; 67# if ( abs(v1[_int_0] - (_float_0_0 / _float_127_0)) < E 68# && abs(v1[_int_1] - (_float_64_0 / _float_127_0)) < E 69# && abs(v1[_int_2] - (-_float_1_0 / _float_127_0)) < E 70# && abs(v1[_int_3] - (-_float_65_0 / _float_127_0)) < E 71# ) 72# { 73# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); 74# } 75# else 76# { 77# _GLF_color = vec4(_float_1_0); 78# } 79# } 80SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 81; SPIR-V 82; Version: 1.0 83; Generator: Khronos Glslang Reference Front End; 8 84; Bound: 130 85; Schema: 0 86 OpCapability Shader 87 %1 = OpExtInstImport "GLSL.std.450" 88 OpMemoryModel Logical GLSL450 89 OpEntryPoint Fragment %4 "main" %112 90 OpExecutionMode %4 OriginUpperLeft 91 OpSource ESSL 310 92 OpName %4 "main" 93 OpName %8 "a" 94 OpName %12 "buf1" 95 OpMemberName %12 0 "_GLF_uniform_float_values" 96 OpName %14 "" 97 OpName %28 "v1" 98 OpName %32 "E" 99 OpName %37 "buf0" 100 OpMemberName %37 0 "_GLF_uniform_int_values" 101 OpName %39 "" 102 OpName %112 "_GLF_color" 103 OpDecorate %11 ArrayStride 16 104 OpMemberDecorate %12 0 Offset 0 105 OpDecorate %12 Block 106 OpDecorate %14 DescriptorSet 0 107 OpDecorate %14 Binding 1 108 OpDecorate %36 ArrayStride 16 109 OpMemberDecorate %37 0 Offset 0 110 OpDecorate %37 Block 111 OpDecorate %39 DescriptorSet 0 112 OpDecorate %39 Binding 0 113 OpDecorate %112 Location 0 114 %2 = OpTypeVoid 115 %3 = OpTypeFunction %2 116 %6 = OpTypeInt 32 0 117 %7 = OpTypePointer Function %6 118 %9 = OpTypeFloat 32 119 %10 = OpConstant %6 7 120 %11 = OpTypeArray %9 %10 121 %12 = OpTypeStruct %11 122 %13 = OpTypePointer Uniform %12 123 %14 = OpVariable %13 Uniform 124 %15 = OpTypeInt 32 1 125 %16 = OpConstant %15 0 126 %17 = OpTypePointer Uniform %9 127 %20 = OpConstant %15 1 128 %23 = OpTypeVector %9 2 129 %26 = OpTypeVector %9 4 130 %27 = OpTypePointer Function %26 131 %31 = OpTypePointer Function %9 132 %33 = OpConstant %9 0.00999999978 133 %34 = OpTypeBool 134 %35 = OpConstant %6 4 135 %36 = OpTypeArray %15 %35 136 %37 = OpTypeStruct %36 137 %38 = OpTypePointer Uniform %37 138 %39 = OpVariable %38 Uniform 139 %40 = OpConstant %15 2 140 %41 = OpTypePointer Uniform %15 141 %48 = OpConstant %15 3 142 %62 = OpConstant %15 4 143 %79 = OpConstant %15 5 144 %97 = OpConstant %15 6 145 %111 = OpTypePointer Output %26 146 %112 = OpVariable %111 Output 147 %4 = OpFunction %2 None %3 148 %5 = OpLabel 149 %8 = OpVariable %7 Function 150 %28 = OpVariable %27 Function 151 %32 = OpVariable %31 Function 152 %18 = OpAccessChain %17 %14 %16 %16 153 %19 = OpLoad %9 %18 154 %21 = OpAccessChain %17 %14 %16 %20 155 %22 = OpLoad %9 %21 156 %24 = OpCompositeConstruct %23 %19 %22 157 %25 = OpExtInst %6 %1 PackUnorm2x16 %24 158 OpStore %8 %25 159 %29 = OpLoad %6 %8 160 %30 = OpExtInst %26 %1 UnpackSnorm4x8 %29 161 OpStore %28 %30 162 OpStore %32 %33 163 %42 = OpAccessChain %41 %39 %16 %40 164 %43 = OpLoad %15 %42 165 %44 = OpAccessChain %31 %28 %43 166 %45 = OpLoad %9 %44 167 %46 = OpAccessChain %17 %14 %16 %40 168 %47 = OpLoad %9 %46 169 %49 = OpAccessChain %17 %14 %16 %48 170 %50 = OpLoad %9 %49 171 %51 = OpFDiv %9 %47 %50 172 %52 = OpFSub %9 %45 %51 173 %53 = OpExtInst %9 %1 FAbs %52 174 %54 = OpLoad %9 %32 175 %55 = OpFOrdLessThan %34 %53 %54 176 OpSelectionMerge %57 None 177 OpBranchConditional %55 %56 %57 178 %56 = OpLabel 179 %58 = OpAccessChain %41 %39 %16 %20 180 %59 = OpLoad %15 %58 181 %60 = OpAccessChain %31 %28 %59 182 %61 = OpLoad %9 %60 183 %63 = OpAccessChain %17 %14 %16 %62 184 %64 = OpLoad %9 %63 185 %65 = OpAccessChain %17 %14 %16 %48 186 %66 = OpLoad %9 %65 187 %67 = OpFDiv %9 %64 %66 188 %68 = OpFSub %9 %61 %67 189 %69 = OpExtInst %9 %1 FAbs %68 190 %70 = OpLoad %9 %32 191 %71 = OpFOrdLessThan %34 %69 %70 192 OpBranch %57 193 %57 = OpLabel 194 %72 = OpPhi %34 %55 %5 %71 %56 195 OpSelectionMerge %74 None 196 OpBranchConditional %72 %73 %74 197 %73 = OpLabel 198 %75 = OpAccessChain %41 %39 %16 %48 199 %76 = OpLoad %15 %75 200 %77 = OpAccessChain %31 %28 %76 201 %78 = OpLoad %9 %77 202 %80 = OpAccessChain %17 %14 %16 %79 203 %81 = OpLoad %9 %80 204 %82 = OpFNegate %9 %81 205 %83 = OpAccessChain %17 %14 %16 %48 206 %84 = OpLoad %9 %83 207 %85 = OpFDiv %9 %82 %84 208 %86 = OpFSub %9 %78 %85 209 %87 = OpExtInst %9 %1 FAbs %86 210 %88 = OpLoad %9 %32 211 %89 = OpFOrdLessThan %34 %87 %88 212 OpBranch %74 213 %74 = OpLabel 214 %90 = OpPhi %34 %72 %57 %89 %73 215 OpSelectionMerge %92 None 216 OpBranchConditional %90 %91 %92 217 %91 = OpLabel 218 %93 = OpAccessChain %41 %39 %16 %16 219 %94 = OpLoad %15 %93 220 %95 = OpAccessChain %31 %28 %94 221 %96 = OpLoad %9 %95 222 %98 = OpAccessChain %17 %14 %16 %97 223 %99 = OpLoad %9 %98 224 %100 = OpFNegate %9 %99 225 %101 = OpAccessChain %17 %14 %16 %48 226 %102 = OpLoad %9 %101 227 %103 = OpFDiv %9 %100 %102 228 %104 = OpFSub %9 %96 %103 229 %105 = OpExtInst %9 %1 FAbs %104 230 %106 = OpLoad %9 %32 231 %107 = OpFOrdLessThan %34 %105 %106 232 OpBranch %92 233 %92 = OpLabel 234 %108 = OpPhi %34 %90 %74 %107 %91 235 OpSelectionMerge %110 None 236 OpBranchConditional %108 %109 %126 237 %109 = OpLabel 238 %113 = OpAccessChain %41 %39 %16 %20 239 %114 = OpLoad %15 %113 240 %115 = OpConvertSToF %9 %114 241 %116 = OpAccessChain %41 %39 %16 %40 242 %117 = OpLoad %15 %116 243 %118 = OpConvertSToF %9 %117 244 %119 = OpAccessChain %41 %39 %16 %40 245 %120 = OpLoad %15 %119 246 %121 = OpConvertSToF %9 %120 247 %122 = OpAccessChain %41 %39 %16 %20 248 %123 = OpLoad %15 %122 249 %124 = OpConvertSToF %9 %123 250 %125 = OpCompositeConstruct %26 %115 %118 %121 %124 251 OpStore %112 %125 252 OpBranch %110 253 %126 = OpLabel 254 %127 = OpAccessChain %17 %14 %16 %79 255 %128 = OpLoad %9 %127 256 %129 = OpCompositeConstruct %26 %128 %128 %128 %128 257 OpStore %112 %129 258 OpBranch %110 259 %110 = OpLabel 260 OpReturn 261 OpFunctionEnd 262END 263 264# uniforms for variant 265 266# _GLF_uniform_float_values 267BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 268 0.25 0.75 0.0 127.0 64.0 1.0 65.0 269END 270# _GLF_uniform_int_values 271BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 272 3 1 0 2 273END 274 275BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 276 277PIPELINE graphics variant_pipeline 278 ATTACH variant_vertex_shader 279 ATTACH variant_fragment_shader 280 FRAMEBUFFER_SIZE 16 16 281 BIND BUFFER variant_framebuffer AS color LOCATION 0 282 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 1 283 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 284END 285CLEAR_COLOR variant_pipeline 0 0 0 255 286 287CLEAR variant_pipeline 288RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16 289 290EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255 291