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 the GraphicsFuzz project. 19 20# Short description: A fragment shader that covers a specific inst combine select code 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# #define _int_0 _GLF_uniform_int_values[0] 29# #define _int_1 _GLF_uniform_int_values[1] 30# 31# precision highp float; 32# 33# precision highp int; 34# 35# // Contents of _GLF_uniform_int_values: [0, 1] 36# layout(set = 0, binding = 0) uniform buf0 37# { 38# int _GLF_uniform_int_values[2]; 39# }; 40# layout(location = 0) out vec4 _GLF_color; 41# 42# void main() 43# { 44# // a becomes 1. 45# int a = max(1, min(1, int(gl_FragCoord.x))); 46# 47# if (a < 2) 48# { 49# _GLF_color = vec4(1, _int_0, _int_0, _int_1); 50# } 51# else 52# { 53# _GLF_color = vec4(_int_1); 54# } 55# } 56SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0 57; SPIR-V 58; Version: 1.0 59; Generator: Khronos Glslang Reference Front End; 10 60; Bound: 53 61; Schema: 0 62 OpCapability Shader 63 %1 = OpExtInstImport "GLSL.std.450" 64 OpMemoryModel Logical GLSL450 65 OpEntryPoint Fragment %4 "main" %13 %29 66 OpExecutionMode %4 OriginUpperLeft 67 OpSource ESSL 310 68 OpName %4 "main" 69 OpName %8 "a" 70 OpName %13 "gl_FragCoord" 71 OpName %29 "_GLF_color" 72 OpName %33 "buf0" 73 OpMemberName %33 0 "_GLF_uniform_int_values" 74 OpName %35 "" 75 OpDecorate %13 BuiltIn FragCoord 76 OpDecorate %29 Location 0 77 OpDecorate %32 ArrayStride 16 78 OpMemberDecorate %33 0 Offset 0 79 OpDecorate %33 Block 80 OpDecorate %35 DescriptorSet 0 81 OpDecorate %35 Binding 0 82 %2 = OpTypeVoid 83 %3 = OpTypeFunction %2 84 %6 = OpTypeInt 32 1 85 %7 = OpTypePointer Function %6 86 %9 = OpConstant %6 1 87 %10 = OpTypeFloat 32 88 %11 = OpTypeVector %10 4 89 %12 = OpTypePointer Input %11 90 %13 = OpVariable %12 Input 91 %14 = OpTypeInt 32 0 92 %15 = OpConstant %14 0 93 %16 = OpTypePointer Input %10 94 %23 = OpConstant %6 2 95 %24 = OpTypeBool 96 %28 = OpTypePointer Output %11 97 %29 = OpVariable %28 Output 98 %30 = OpConstant %10 1 99 %31 = OpConstant %14 2 100 %32 = OpTypeArray %6 %31 101 %33 = OpTypeStruct %32 102 %34 = OpTypePointer Uniform %33 103 %35 = OpVariable %34 Uniform 104 %36 = OpConstant %6 0 105 %37 = OpTypePointer Uniform %6 106 %4 = OpFunction %2 None %3 107 %5 = OpLabel 108 %8 = OpVariable %7 Function 109 %17 = OpAccessChain %16 %13 %15 110 %18 = OpLoad %10 %17 111 %19 = OpConvertFToS %6 %18 112 %20 = OpExtInst %6 %1 SMin %9 %19 113 %21 = OpExtInst %6 %1 SMax %9 %20 114 OpStore %8 %21 115 %22 = OpLoad %6 %8 116 %25 = OpSLessThan %24 %22 %23 117 OpSelectionMerge %27 None 118 OpBranchConditional %25 %26 %48 119 %26 = OpLabel 120 %38 = OpAccessChain %37 %35 %36 %36 121 %39 = OpLoad %6 %38 122 %40 = OpConvertSToF %10 %39 123 %41 = OpAccessChain %37 %35 %36 %36 124 %42 = OpLoad %6 %41 125 %43 = OpConvertSToF %10 %42 126 %44 = OpAccessChain %37 %35 %36 %9 127 %45 = OpLoad %6 %44 128 %46 = OpConvertSToF %10 %45 129 %47 = OpCompositeConstruct %11 %30 %40 %43 %46 130 OpStore %29 %47 131 OpBranch %27 132 %48 = OpLabel 133 %49 = OpAccessChain %37 %35 %36 %9 134 %50 = OpLoad %6 %49 135 %51 = OpConvertSToF %10 %50 136 %52 = OpCompositeConstruct %11 %51 %51 %51 %51 137 OpStore %29 %52 138 OpBranch %27 139 %27 = OpLabel 140 OpReturn 141 OpFunctionEnd 142END 143 144# uniforms for variant 145 146# _GLF_uniform_int_values 147BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA 148 0 1 149END 150 151BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM 152 153PIPELINE graphics variant_pipeline 154 ATTACH variant_vertex_shader 155 ATTACH variant_fragment_shader 156 FRAMEBUFFER_SIZE 256 256 157 BIND BUFFER variant_framebuffer AS color LOCATION 0 158 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0 159END 160CLEAR_COLOR variant_pipeline 0 0 0 255 161 162CLEAR variant_pipeline 163RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256 164 165EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255 166