1#!amber 2 3# Copyright 2021 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: A fragment shader that covers specific LLVM 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 320 es 28# 29# precision highp int; 30# precision highp float; 31# 32# layout(location = 0) out vec4 _GLF_color; 33# 34# // Always returns (1, 0, 0, 1) 35# vec4 func() 36# { 37# switch(0) 38# { 39# case 0: 40# return vec4(1, 0, 0, 1); 41# default: 42# return vec4(0); 43# } 44# } 45# 46# void main() 47# { 48# _GLF_color = func(); 49# } 50SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 51; SPIR-V 52; Version: 1.0 53; Generator: Khronos Glslang Reference Front End; 10 54; Bound: 27 55; Schema: 0 56 OpCapability Shader 57 %1 = OpExtInstImport "GLSL.std.450" 58 OpMemoryModel Logical GLSL450 59 OpEntryPoint Fragment %4 "main" %25 60 OpExecutionMode %4 OriginUpperLeft 61 OpSource ESSL 320 62 OpName %4 "main" 63 OpName %9 "func(" 64 OpName %25 "_GLF_color" 65 OpDecorate %25 Location 0 66 %2 = OpTypeVoid 67 %3 = OpTypeFunction %2 68 %6 = OpTypeFloat 32 69 %7 = OpTypeVector %6 4 70 %8 = OpTypeFunction %7 71 %11 = OpTypeInt 32 1 72 %12 = OpConstant %11 0 73 %16 = OpConstant %6 1 74 %17 = OpConstant %6 0 75 %18 = OpConstantComposite %7 %16 %17 %17 %16 76 %20 = OpConstantComposite %7 %17 %17 %17 %17 77 %24 = OpTypePointer Output %7 78 %25 = OpVariable %24 Output 79 %4 = OpFunction %2 None %3 80 %5 = OpLabel 81 %26 = OpFunctionCall %7 %9 82 OpStore %25 %26 83 OpReturn 84 OpFunctionEnd 85 %9 = OpFunction %7 None %8 86 %10 = OpLabel 87 OpSelectionMerge %15 None 88 OpSwitch %12 %14 0 %13 89 %14 = OpLabel 90 OpReturnValue %20 91 %13 = OpLabel 92 OpReturnValue %18 93 %15 = OpLabel 94 OpUnreachable 95 OpFunctionEnd 96END 97 98 99BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 100 101PIPELINE graphics variant_pipeline 102 ATTACH variant_vertex_shader 103 ATTACH variant_fragment_shader 104 FRAMEBUFFER_SIZE 256 256 105 BIND BUFFER variant_framebuffer AS color LOCATION 0 106END 107CLEAR_COLOR variant_pipeline 0 0 0 255 108 109CLEAR variant_pipeline 110RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 111 112EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 113