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