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 instruction folding path.
22 # The test passes because 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;
38 # if (v == vec4(1, 1, 2, 2))
39 # _GLF_color = vec4(1, 0, 0, 1);
41 # _GLF_color = vec4(0);
43 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
46 ; Generator: Khronos Glslang Reference Front End; 8
50 %1 = OpExtInstImport "GLSL.std.450"
51 OpMemoryModel Logical GLSL450
52 OpEntryPoint Fragment %4 "main" %28
53 OpExecutionMode %4 OriginUpperLeft
57 OpName %28 "_GLF_color"
58 OpDecorate %28 Location 0
60 %3 = OpTypeFunction %2
62 %7 = OpTypeVector %6 4
63 %8 = OpTypePointer Function %7
64 %10 = OpTypeVector %6 2
66 %12 = OpConstantComposite %10 %11 %11
68 %16 = OpConstantComposite %10 %15 %15
69 %20 = OpConstantComposite %7 %11 %11 %15 %15
71 %22 = OpTypeVector %21 4
72 %27 = OpTypePointer Output %7
73 %28 = OpVariable %27 Output
75 %30 = OpConstantComposite %7 %11 %29 %29 %11
76 %32 = OpConstantComposite %7 %29 %29 %29 %29
77 %4 = OpFunction %2 None %3
79 %9 = OpVariable %8 Function
81 %14 = OpVectorShuffle %7 %13 %12 4 5 2 3
84 %18 = OpVectorShuffle %7 %17 %16 0 1 4 5
87 %23 = OpFOrdEqual %22 %19 %20
89 OpSelectionMerge %26 None
90 OpBranchConditional %24 %25 %31
103 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
105 PIPELINE graphics variant_pipeline
106 ATTACH variant_vertex_shader
107 ATTACH variant_fragment_shader
108 FRAMEBUFFER_SIZE 256 256
109 BIND BUFFER variant_framebuffer AS color LOCATION 0
111 CLEAR_COLOR variant_pipeline 0 0 0 255
113 CLEAR variant_pipeline
114 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
116 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255