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 constant 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# precision highp int; 30# 31# layout(location = 0) out vec4 _GLF_color; 32# 33# void main() 34# { 35# int i = 0, j = 1; 36# 37# while(i < clamp(j, 5, 9)) 38# { 39# i++; 40# j++; 41# } 42# 43# if (i == 9 && j == 10) 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: 45 53; Schema: 0 54 OpCapability Shader 55 %1 = OpExtInstImport "GLSL.std.450" 56 OpMemoryModel Logical GLSL450 57 OpEntryPoint Fragment %4 "main" %39 58 OpExecutionMode %4 OriginUpperLeft 59 OpSource ESSL 310 60 OpName %4 "main" 61 OpName %8 "i" 62 OpName %10 "j" 63 OpName %39 "_GLF_color" 64 OpDecorate %39 Location 0 65 %2 = OpTypeVoid 66 %3 = OpTypeFunction %2 67 %6 = OpTypeInt 32 1 68 %7 = OpTypePointer Function %6 69 %9 = OpConstant %6 0 70 %11 = OpConstant %6 1 71 %19 = OpConstant %6 5 72 %20 = OpConstant %6 9 73 %22 = OpTypeBool 74 %31 = OpConstant %6 10 75 %36 = OpTypeFloat 32 76 %37 = OpTypeVector %36 4 77 %38 = OpTypePointer Output %37 78 %39 = OpVariable %38 Output 79 %40 = OpConstant %36 1 80 %41 = OpConstant %36 0 81 %42 = OpConstantComposite %37 %40 %41 %41 %40 82 %44 = OpConstantComposite %37 %41 %41 %41 %41 83 %4 = OpFunction %2 None %3 84 %5 = OpLabel 85 %8 = OpVariable %7 Function 86 %10 = OpVariable %7 Function 87 OpStore %8 %9 88 OpStore %10 %11 89 OpBranch %12 90 %12 = OpLabel 91 OpLoopMerge %14 %15 None 92 OpBranch %16 93 %16 = OpLabel 94 %17 = OpLoad %6 %8 95 %18 = OpLoad %6 %10 96 %21 = OpExtInst %6 %1 SClamp %18 %19 %20 97 %23 = OpSLessThan %22 %17 %21 98 OpBranchConditional %23 %13 %14 99 %13 = OpLabel 100 %24 = OpLoad %6 %8 101 %25 = OpIAdd %6 %24 %11 102 OpStore %8 %25 103 %26 = OpLoad %6 %10 104 %27 = OpIAdd %6 %26 %11 105 OpStore %10 %27 106 OpBranch %15 107 %15 = OpLabel 108 OpBranch %12 109 %14 = OpLabel 110 %28 = OpLoad %6 %8 111 %29 = OpIEqual %22 %28 %20 112 %30 = OpLoad %6 %10 113 %32 = OpIEqual %22 %30 %31 114 %33 = OpLogicalAnd %22 %29 %32 115 OpSelectionMerge %35 None 116 OpBranchConditional %33 %34 %43 117 %34 = OpLabel 118 OpStore %39 %42 119 OpBranch %35 120 %43 = OpLabel 121 OpStore %39 %44 122 OpBranch %35 123 %35 = OpLabel 124 OpReturn 125 OpFunctionEnd 126END 127 128 129BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 130 131PIPELINE graphics variant_pipeline 132 ATTACH variant_vertex_shader 133 ATTACH variant_fragment_shader 134 FRAMEBUFFER_SIZE 256 256 135 BIND BUFFER variant_framebuffer AS color LOCATION 0 136END 137CLEAR_COLOR variant_pipeline 0 0 0 255 138 139CLEAR variant_pipeline 140RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 141 142EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 143