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