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(void) 33# { 34# int i = 2; 35# 36# do 37# { 38# i++; 39# } 40# while(gl_FragCoord.x >= 0.0 && false); 41# 42# // If condition is always true. 43# if (i == 3) 44# _GLF_color = vec4(1, 0, 0, 1); 45# else 46# _GLF_color = vec4(0); 47# } 48SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 49; SPIR-V 50; Version: 1.0 51; Generator: Khronos Glslang Reference Front End; 8 52; Bound: 42 53; Schema: 0 54 OpCapability Shader 55 %1 = OpExtInstImport "GLSL.std.450" 56 OpMemoryModel Logical GLSL450 57 OpEntryPoint Fragment %4 "main" %20 %37 58 OpExecutionMode %4 OriginUpperLeft 59 OpSource ESSL 310 60 OpName %4 "main" 61 OpName %8 "i" 62 OpName %20 "gl_FragCoord" 63 OpName %37 "_GLF_color" 64 OpDecorate %8 RelaxedPrecision 65 OpDecorate %14 RelaxedPrecision 66 OpDecorate %16 RelaxedPrecision 67 OpDecorate %20 BuiltIn FragCoord 68 OpDecorate %31 RelaxedPrecision 69 OpDecorate %37 Location 0 70 %2 = OpTypeVoid 71 %3 = OpTypeFunction %2 72 %6 = OpTypeInt 32 1 73 %7 = OpTypePointer Function %6 74 %9 = OpConstant %6 2 75 %15 = OpConstant %6 1 76 %17 = OpTypeFloat 32 77 %18 = OpTypeVector %17 4 78 %19 = OpTypePointer Input %18 79 %20 = OpVariable %19 Input 80 %21 = OpTypeInt 32 0 81 %22 = OpConstant %21 0 82 %23 = OpTypePointer Input %17 83 %26 = OpConstant %17 0 84 %27 = OpTypeBool 85 %29 = OpConstantFalse %27 86 %32 = OpConstant %6 3 87 %36 = OpTypePointer Output %18 88 %37 = OpVariable %36 Output 89 %38 = OpConstant %17 1 90 %39 = OpConstantComposite %18 %38 %26 %26 %38 91 %41 = OpConstantComposite %18 %26 %26 %26 %26 92 %4 = OpFunction %2 None %3 93 %5 = OpLabel 94 %8 = OpVariable %7 Function 95 OpStore %8 %9 96 OpBranch %10 97 %10 = OpLabel 98 OpLoopMerge %12 %13 None 99 OpBranch %11 100 %11 = OpLabel 101 %14 = OpLoad %6 %8 102 %16 = OpIAdd %6 %14 %15 103 OpStore %8 %16 104 OpBranch %13 105 %13 = OpLabel 106 %24 = OpAccessChain %23 %20 %22 107 %25 = OpLoad %17 %24 108 %28 = OpFOrdGreaterThanEqual %27 %25 %26 109 %30 = OpLogicalAnd %27 %28 %29 110 OpBranchConditional %30 %10 %12 111 %12 = OpLabel 112 %31 = OpLoad %6 %8 113 %33 = OpIEqual %27 %31 %32 114 OpSelectionMerge %35 None 115 OpBranchConditional %33 %34 %40 116 %34 = OpLabel 117 OpStore %37 %39 118 OpBranch %35 119 %40 = OpLabel 120 OpStore %37 %41 121 OpBranch %35 122 %35 = OpLabel 123 OpReturn 124 OpFunctionEnd 125END 126 127# uniforms for variant 128 129# resolution 130BUFFER variant_resolution DATA_TYPE vec2<float> DATA 131 256.0 256.0 132END 133 134BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 135 136PIPELINE graphics variant_pipeline 137 ATTACH variant_vertex_shader 138 ATTACH variant_fragment_shader 139 FRAMEBUFFER_SIZE 256 256 140 BIND BUFFER variant_framebuffer AS color LOCATION 0 141 BIND BUFFER variant_resolution AS uniform DESCRIPTOR_SET 0 BINDING 0 142END 143CLEAR_COLOR variant_pipeline 0 0 0 255 144 145CLEAR variant_pipeline 146RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 147 148EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 149