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