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 GraphicsFuzz. 19 20# Short description: A fragment shader that covers a specific instruction folding path. 21 22# The test passes because 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# precision highp float; 29# 30# layout(location = 0) out vec4 _GLF_color; 31# layout(set = 0, binding = 0) uniform buf0 32# { 33# vec2 threeandfour; // (3.0, 4.0) 34# }; 35# 36# void main() 37# { 38# vec4 v = vec4(2, 3, 4, 5); 39# // mix returns (1.0, 6.0) 40# v.xy = mix(vec2(2, 6), vec2(1.0, threeandfour.y), bvec2(true, false)); 41# if (v == vec4(1, 6, 4, 5)) 42# _GLF_color = vec4(1, 0, 0, 1); 43# else 44# _GLF_color = vec4(0); 45# } 46SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 47; SPIR-V 48; Version: 1.0 49; Generator: Khronos Glslang Reference Front End; 8 50; Bound: 51 51; Schema: 0 52 OpCapability Shader 53 %1 = OpExtInstImport "GLSL.std.450" 54 OpMemoryModel Logical GLSL450 55 OpEntryPoint Fragment %4 "main" %46 56 OpExecutionMode %4 OriginUpperLeft 57 OpSource ESSL 310 58 OpName %4 "main" 59 OpName %9 "v" 60 OpName %19 "buf0" 61 OpMemberName %19 0 "threeandfour" 62 OpName %21 "" 63 OpName %46 "_GLF_color" 64 OpMemberDecorate %19 0 Offset 0 65 OpDecorate %19 Block 66 OpDecorate %21 DescriptorSet 0 67 OpDecorate %21 Binding 0 68 OpDecorate %46 Location 0 69 %2 = OpTypeVoid 70 %3 = OpTypeFunction %2 71 %6 = OpTypeFloat 32 72 %7 = OpTypeVector %6 4 73 %8 = OpTypePointer Function %7 74 %10 = OpConstant %6 2 75 %11 = OpConstant %6 3 76 %12 = OpConstant %6 4 77 %13 = OpConstant %6 5 78 %14 = OpConstantComposite %7 %10 %11 %12 %13 79 %15 = OpTypeVector %6 2 80 %16 = OpConstant %6 6 81 %17 = OpConstantComposite %15 %10 %16 82 %18 = OpConstant %6 1 83 %19 = OpTypeStruct %15 84 %20 = OpTypePointer Uniform %19 85 %21 = OpVariable %20 Uniform 86 %22 = OpTypeInt 32 1 87 %23 = OpConstant %22 0 88 %24 = OpTypeInt 32 0 89 %25 = OpConstant %24 1 90 %26 = OpTypePointer Uniform %6 91 %30 = OpTypeBool 92 %31 = OpTypeVector %30 2 93 %32 = OpConstantTrue %30 94 %33 = OpConstantFalse %30 95 %34 = OpConstantComposite %31 %32 %33 96 %39 = OpConstantComposite %7 %18 %16 %12 %13 97 %40 = OpTypeVector %30 4 98 %45 = OpTypePointer Output %7 99 %46 = OpVariable %45 Output 100 %47 = OpConstant %6 0 101 %48 = OpConstantComposite %7 %18 %47 %47 %18 102 %50 = OpConstantComposite %7 %47 %47 %47 %47 103 %4 = OpFunction %2 None %3 104 %5 = OpLabel 105 %9 = OpVariable %8 Function 106 OpStore %9 %14 107 %27 = OpAccessChain %26 %21 %23 %25 108 %28 = OpLoad %6 %27 109 %29 = OpCompositeConstruct %15 %18 %28 110 %35 = OpSelect %15 %34 %29 %17 111 %36 = OpLoad %7 %9 112 %37 = OpVectorShuffle %7 %36 %35 4 5 2 3 113 OpStore %9 %37 114 %38 = OpLoad %7 %9 115 %41 = OpFOrdEqual %40 %38 %39 116 %42 = OpAll %30 %41 117 OpSelectionMerge %44 None 118 OpBranchConditional %42 %43 %49 119 %43 = OpLabel 120 OpStore %46 %48 121 OpBranch %44 122 %49 = OpLabel 123 OpStore %46 %50 124 OpBranch %44 125 %44 = OpLabel 126 OpReturn 127 OpFunctionEnd 128END 129 130# uniforms for variant 131 132# threeandfour 133BUFFER variant_threeandfour DATA_TYPE vec2<float> DATA 134 3.0 4.0 135END 136 137BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 138 139PIPELINE graphics variant_pipeline 140 ATTACH variant_vertex_shader 141 ATTACH variant_fragment_shader 142 FRAMEBUFFER_SIZE 256 256 143 BIND BUFFER variant_framebuffer AS color LOCATION 0 144 BIND BUFFER variant_threeandfour AS uniform DESCRIPTOR_SET 0 BINDING 0 145END 146CLEAR_COLOR variant_pipeline 0 0 0 255 147 148CLEAR variant_pipeline 149RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 150 151EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 152