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