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 value tracking 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# precision highp float; 29# 30# layout(location = 0) out vec4 _GLF_color; 31# 32# void main() 33# { 34# // Constant vector doesn't change between fragments. 35# vec4 diff = dFdy(acosh(vec4(8.0, 2.0, 3.5, 3.4))); 36# 37# if (diff == vec4(0)) 38# _GLF_color = vec4(1, 0, 0, 1); 39# else 40# _GLF_color = diff; 41# } 42SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 43; SPIR-V 44; Version: 1.0 45; Generator: Khronos Glslang Reference Front End; 8 46; Bound: 32 47; Schema: 0 48 OpCapability Shader 49 %1 = OpExtInstImport "GLSL.std.450" 50 OpMemoryModel Logical GLSL450 51 OpEntryPoint Fragment %4 "main" %27 52 OpExecutionMode %4 OriginUpperLeft 53 OpSource ESSL 310 54 OpName %4 "main" 55 OpName %9 "diff" 56 OpName %27 "_GLF_color" 57 OpDecorate %27 Location 0 58 %2 = OpTypeVoid 59 %3 = OpTypeFunction %2 60 %6 = OpTypeFloat 32 61 %7 = OpTypeVector %6 4 62 %8 = OpTypePointer Function %7 63 %10 = OpConstant %6 8 64 %11 = OpConstant %6 2 65 %12 = OpConstant %6 3.5 66 %13 = OpConstant %6 3.4000001 67 %14 = OpConstantComposite %7 %10 %11 %12 %13 68 %18 = OpConstant %6 0 69 %19 = OpConstantComposite %7 %18 %18 %18 %18 70 %20 = OpTypeBool 71 %21 = OpTypeVector %20 4 72 %26 = OpTypePointer Output %7 73 %27 = OpVariable %26 Output 74 %28 = OpConstant %6 1 75 %29 = OpConstantComposite %7 %28 %18 %18 %28 76 %4 = OpFunction %2 None %3 77 %5 = OpLabel 78 %9 = OpVariable %8 Function 79 %15 = OpExtInst %7 %1 Acosh %14 80 %16 = OpDPdy %7 %15 81 OpStore %9 %16 82 %17 = OpLoad %7 %9 83 %22 = OpFOrdEqual %21 %17 %19 84 %23 = OpAll %20 %22 85 OpSelectionMerge %25 None 86 OpBranchConditional %23 %24 %30 87 %24 = OpLabel 88 OpStore %27 %29 89 OpBranch %25 90 %30 = OpLabel 91 %31 = OpLoad %7 %9 92 OpStore %27 %31 93 OpBranch %25 94 %25 = OpLabel 95 OpReturn 96 OpFunctionEnd 97END 98 99 100BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 101 102PIPELINE graphics variant_pipeline 103 ATTACH variant_vertex_shader 104 ATTACH variant_fragment_shader 105 FRAMEBUFFER_SIZE 256 256 106 BIND BUFFER variant_framebuffer AS color LOCATION 0 107END 108CLEAR_COLOR variant_pipeline 0 0 0 255 109 110CLEAR variant_pipeline 111RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 112 113EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 114