3 # Copyright 2019 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;
36 # // If condition is always false.
38 # _GLF_color = vec4(0);
40 # _GLF_color = vec4(1, 0, 0, 1);
42 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
45 ; Generator: Khronos Glslang Reference Front End; 8
49 %1 = OpExtInstImport "GLSL.std.450"
50 OpMemoryModel Logical GLSL450
51 OpEntryPoint Fragment %4 "main" %23
52 OpExecutionMode %4 OriginUpperLeft
57 OpName %23 "_GLF_color"
58 OpDecorate %8 RelaxedPrecision
59 OpDecorate %10 RelaxedPrecision
60 OpDecorate %12 RelaxedPrecision
61 OpDecorate %13 RelaxedPrecision
62 OpDecorate %14 RelaxedPrecision
63 OpDecorate %23 Location 0
65 %3 = OpTypeFunction %2
67 %7 = OpTypePointer Function %6
73 %21 = OpTypeVector %20 4
74 %22 = OpTypePointer Output %21
75 %23 = OpVariable %22 Output
76 %24 = OpConstant %20 0
77 %25 = OpConstantComposite %21 %24 %24 %24 %24
78 %27 = OpConstant %20 1
79 %28 = OpConstantComposite %21 %27 %24 %24 %27
80 %4 = OpFunction %2 None %3
82 %8 = OpVariable %7 Function
83 %10 = OpVariable %7 Function
88 %14 = OpBitwiseXor %6 %12 %13
89 %17 = OpINotEqual %16 %14 %15
90 OpSelectionMerge %19 None
91 OpBranchConditional %17 %18 %26
104 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
106 PIPELINE graphics variant_pipeline
107 ATTACH variant_vertex_shader
108 ATTACH variant_fragment_shader
109 FRAMEBUFFER_SIZE 256 256
110 BIND BUFFER variant_framebuffer AS color LOCATION 0
112 CLEAR_COLOR variant_pipeline 0 0 0 255
114 CLEAR variant_pipeline
115 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
117 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255