1#!amber 2 3# Copyright 2019 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# 32# void main() 33# { 34# int a = 6; 35# int b = 5; 36# // If condition is always false. 37# if ((a ^ b) != 3) 38# _GLF_color = vec4(0); 39# else 40# _GLF_color = vec4(1, 0, 0, 1); 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: 29 47; Schema: 0 48 OpCapability Shader 49 %1 = OpExtInstImport "GLSL.std.450" 50 OpMemoryModel Logical GLSL450 51 OpEntryPoint Fragment %4 "main" %23 52 OpExecutionMode %4 OriginUpperLeft 53 OpSource ESSL 310 54 OpName %4 "main" 55 OpName %8 "a" 56 OpName %10 "b" 57 OpName %23 "_GLF_color" 58 OpDecorate %8 RelaxedPrecision 59 OpDecorate %10 RelaxedPrecision 60 OpDecorate %12 RelaxedPrecision 61 OpDecorate %13 RelaxedPrecision 62 OpDecorate %14 RelaxedPrecision 63 OpDecorate %23 Location 0 64 %2 = OpTypeVoid 65 %3 = OpTypeFunction %2 66 %6 = OpTypeInt 32 1 67 %7 = OpTypePointer Function %6 68 %9 = OpConstant %6 6 69 %11 = OpConstant %6 5 70 %15 = OpConstant %6 3 71 %16 = OpTypeBool 72 %20 = OpTypeFloat 32 73 %21 = OpTypeVector %20 4 74 %22 = OpTypePointer Output %21 75 %23 = OpVariable %22 Output 76 %24 = OpConstant %20 0 77 %25 = OpConstantComposite %21 %24 %24 %24 %24 78 %27 = OpConstant %20 1 79 %28 = OpConstantComposite %21 %27 %24 %24 %27 80 %4 = OpFunction %2 None %3 81 %5 = OpLabel 82 %8 = OpVariable %7 Function 83 %10 = OpVariable %7 Function 84 OpStore %8 %9 85 OpStore %10 %11 86 %12 = OpLoad %6 %8 87 %13 = OpLoad %6 %10 88 %14 = OpBitwiseXor %6 %12 %13 89 %17 = OpINotEqual %16 %14 %15 90 OpSelectionMerge %19 None 91 OpBranchConditional %17 %18 %26 92 %18 = OpLabel 93 OpStore %23 %25 94 OpBranch %19 95 %26 = OpLabel 96 OpStore %23 %28 97 OpBranch %19 98 %19 = OpLabel 99 OpReturn 100 OpFunctionEnd 101END 102 103 104BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 105 106PIPELINE graphics variant_pipeline 107 ATTACH variant_vertex_shader 108 ATTACH variant_fragment_shader 109 FRAMEBUFFER_SIZE 256 256 110 BIND BUFFER variant_framebuffer AS color LOCATION 0 111END 112CLEAR_COLOR variant_pipeline 0 0 0 255 113 114CLEAR variant_pipeline 115RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 116 117EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 118