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 inst combine simplify demanded and inst combine shifts path 21 22# The test passes because the shader always writes red. 23 24# Optimized using spirv-opt with the following arguments: 25# '-O' 26# spirv-opt commit hash: a187dd58a0485988841d325a85c8e6063f53500a 27 28 29 30SHADER vertex variant_vertex_shader PASSTHROUGH 31 32# variant_fragment_shader is derived from the following GLSL: 33# #version 310 es 34# #define _int_1 _GLF_uniform_int_values[0] 35# #define _int_0 _GLF_uniform_int_values[1] 36# #define _float_0_0 _GLF_uniform_float_values[0] 37# #define _float_256_0 _GLF_uniform_float_values[0] 38# 39# precision highp float; 40# precision highp int; 41# 42# // Contents of _GLF_uniform_float_values: [0.0, 256.0] 43# layout(set = 0, binding = 0) uniform buf0 44# { 45# float _GLF_uniform_float_values[2]; 46# }; 47# 48# // Contents of _GLF_uniform_int_values: [1, 0] 49# layout(set = 0, binding = 1) uniform buf1 50# { 51# int _GLF_uniform_int_values[2]; 52# }; 53# 54# layout(location = 0) out vec4 _GLF_color; 55# 56# void main() 57# { 58# vec2 v1 = vec2(_float_256_0); 59# 60# // v1.y becomes undefined. This results in an undefined value, but not in undefined behavior. 61# v1[_int_1] = ldexp(v1.y, -256); 62# 63# vec2 v2 = v1 * mat2(_float_0_0); 64# 65# if (v2.x == _float_0_0) 66# _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1); 67# else 68# _GLF_color = vec4(_int_0); 69# } 70SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 71; SPIR-V 72; Version: 1.0 73; Generator: Khronos Glslang Reference Front End; 10 74; Bound: 78 75; Schema: 0 76 OpCapability Shader 77 %1 = OpExtInstImport "GLSL.std.450" 78 OpMemoryModel Logical GLSL450 79 OpEntryPoint Fragment %4 "main" %58 80 OpExecutionMode %4 OriginUpperLeft 81 OpSource ESSL 310 82 OpName %4 "main" 83 OpName %9 "v1" 84 OpName %13 "buf0" 85 OpMemberName %13 0 "_GLF_uniform_float_values" 86 OpName %15 "" 87 OpName %23 "buf1" 88 OpMemberName %23 0 "_GLF_uniform_int_values" 89 OpName %25 "" 90 OpName %58 "_GLF_color" 91 OpDecorate %12 ArrayStride 16 92 OpMemberDecorate %13 0 Offset 0 93 OpDecorate %13 Block 94 OpDecorate %15 DescriptorSet 0 95 OpDecorate %15 Binding 0 96 OpDecorate %22 ArrayStride 16 97 OpMemberDecorate %23 0 Offset 0 98 OpDecorate %23 Block 99 OpDecorate %25 DescriptorSet 0 100 OpDecorate %25 Binding 1 101 OpDecorate %58 Location 0 102 %2 = OpTypeVoid 103 %3 = OpTypeFunction %2 104 %6 = OpTypeFloat 32 105 %7 = OpTypeVector %6 2 106 %8 = OpTypePointer Function %7 107 %10 = OpTypeInt 32 0 108 %11 = OpConstant %10 2 109 %12 = OpTypeArray %6 %11 110 %13 = OpTypeStruct %12 111 %14 = OpTypePointer Uniform %13 112 %15 = OpVariable %14 Uniform 113 %16 = OpTypeInt 32 1 114 %17 = OpConstant %16 0 115 %18 = OpTypePointer Uniform %6 116 %22 = OpTypeArray %16 %11 117 %23 = OpTypeStruct %22 118 %24 = OpTypePointer Uniform %23 119 %25 = OpVariable %24 Uniform 120 %26 = OpTypePointer Uniform %16 121 %29 = OpConstant %10 1 122 %30 = OpTypePointer Function %6 123 %33 = OpConstant %16 -256 124 %40 = OpTypeMatrix %7 2 125 %42 = OpConstant %6 0 126 %52 = OpTypeBool 127 %56 = OpTypeVector %6 4 128 %57 = OpTypePointer Output %56 129 %58 = OpVariable %57 Output 130 %62 = OpConstant %16 1 131 %4 = OpFunction %2 None %3 132 %5 = OpLabel 133 %9 = OpVariable %8 Function 134 %19 = OpAccessChain %18 %15 %17 %17 135 %20 = OpLoad %6 %19 136 %21 = OpCompositeConstruct %7 %20 %20 137 OpStore %9 %21 138 %27 = OpAccessChain %26 %25 %17 %17 139 %28 = OpLoad %16 %27 140 %31 = OpAccessChain %30 %9 %29 141 %32 = OpLoad %6 %31 142 %34 = OpExtInst %6 %1 Ldexp %32 %33 143 %35 = OpAccessChain %30 %9 %28 144 OpStore %35 %34 145 %37 = OpLoad %7 %9 146 %43 = OpCompositeConstruct %7 %20 %42 147 %44 = OpCompositeConstruct %7 %42 %20 148 %45 = OpCompositeConstruct %40 %43 %44 149 %46 = OpVectorTimesMatrix %7 %37 %45 150 %49 = OpCompositeExtract %6 %46 0 151 %53 = OpFOrdEqual %52 %49 %20 152 OpSelectionMerge %55 None 153 OpBranchConditional %53 %54 %73 154 %54 = OpLabel 155 %61 = OpConvertSToF %6 %28 156 %63 = OpAccessChain %26 %25 %17 %62 157 %64 = OpLoad %16 %63 158 %65 = OpConvertSToF %6 %64 159 %72 = OpCompositeConstruct %56 %61 %65 %65 %61 160 OpStore %58 %72 161 OpBranch %55 162 %73 = OpLabel 163 %74 = OpAccessChain %26 %25 %17 %62 164 %75 = OpLoad %16 %74 165 %76 = OpConvertSToF %6 %75 166 %77 = OpCompositeConstruct %56 %76 %76 %76 %76 167 OpStore %58 %77 168 OpBranch %55 169 %55 = OpLabel 170 OpReturn 171 OpFunctionEnd 172END 173 174# uniforms for variant 175 176# _GLF_uniform_int_values 177BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 178 1 0 179END 180# _GLF_uniform_float_values 181BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA 182 0.0 256.0 183END 184 185BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 186 187PIPELINE graphics variant_pipeline 188 ATTACH variant_vertex_shader 189 ATTACH variant_fragment_shader 190 FRAMEBUFFER_SIZE 256 256 191 BIND BUFFER variant_framebuffer AS color LOCATION 0 192 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1 193 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0 194END 195CLEAR_COLOR variant_pipeline 0 0 0 255 196 197CLEAR variant_pipeline 198RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 199 200EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 201