3 # Copyright 2020 Google LLC
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 # A test for a coverage-gap found by GraphicsFuzz.
20 # Short description: A fragment shader that covers a specific selection DAG code path
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # precision highp float;
30 # layout(location = 0) out vec4 _GLF_color;
32 # layout(set = 0, binding = 0) uniform buf0
39 # _GLF_color = vec4(0);
42 # if(one < 0.0 && one < 0.0)
44 # _GLF_color = vec4(1);
48 # _GLF_color = vec4(1, 0, 0, 1);
51 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
54 ; Generator: Khronos Glslang Reference Front End; 8
58 %1 = OpExtInstImport "GLSL.std.450"
59 OpMemoryModel Logical GLSL450
60 OpEntryPoint Fragment %4 "main" %9
61 OpExecutionMode %4 OriginUpperLeft
64 OpName %9 "_GLF_color"
66 OpMemberName %13 0 "one"
68 OpDecorate %9 Location 0
69 OpMemberDecorate %13 0 Offset 0
71 OpDecorate %15 DescriptorSet 0
72 OpDecorate %15 Binding 0
74 %3 = OpTypeFunction %2
76 %7 = OpTypeVector %6 4
77 %8 = OpTypePointer Output %7
78 %9 = OpVariable %8 Output
80 %11 = OpConstantComposite %7 %10 %10 %10 %10
83 %14 = OpTypePointer Uniform %13
84 %15 = OpVariable %14 Uniform
86 %17 = OpConstant %16 0
87 %18 = OpTypePointer Uniform %6
89 %31 = OpConstantComposite %7 %30 %30 %30 %30
90 %33 = OpConstantComposite %7 %30 %10 %10 %30
91 %4 = OpFunction %2 None %3
94 %19 = OpAccessChain %18 %15 %17
96 %21 = OpFOrdLessThan %12 %20 %10
97 OpSelectionMerge %23 None
98 OpBranchConditional %21 %22 %23
100 %24 = OpAccessChain %18 %15 %17
102 %26 = OpFOrdLessThan %12 %25 %10
105 %27 = OpPhi %12 %21 %5 %26 %22
106 OpSelectionMerge %29 None
107 OpBranchConditional %27 %28 %32
119 # uniforms for variant
122 BUFFER variant_one DATA_TYPE float DATA
126 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
128 PIPELINE graphics variant_pipeline
129 ATTACH variant_vertex_shader
130 ATTACH variant_fragment_shader
131 FRAMEBUFFER_SIZE 256 256
132 BIND BUFFER variant_framebuffer AS color LOCATION 0
133 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
135 CLEAR_COLOR variant_pipeline 0 0 0 255
137 CLEAR variant_pipeline
138 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
140 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255