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 inlining optimization 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;
35 # if (gl_FragCoord.x == 12.0)
37 # if (gl_FragCoord.y == 13.0)
51 # _GLF_color = vec4(func());
55 # _GLF_color = vec4(1, 0, 0, 1);
58 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
61 ; Generator: Khronos Glslang Reference Front End; 8
65 %1 = OpExtInstImport "GLSL.std.450"
66 OpMemoryModel Logical GLSL450
67 OpEntryPoint Fragment %4 "main" %15 %44
68 OpExecutionMode %4 OriginUpperLeft
73 OpName %15 "gl_FragCoord"
74 OpName %44 "_GLF_color"
75 OpDecorate %15 BuiltIn FragCoord
76 OpDecorate %44 Location 0
78 %3 = OpTypeFunction %2
80 %7 = OpTypeFunction %6
81 %10 = OpTypePointer Function %6
83 %13 = OpTypeVector %6 4
84 %14 = OpTypePointer Input %13
85 %15 = OpVariable %14 Input
87 %17 = OpConstant %16 0
88 %18 = OpTypePointer Input %6
89 %21 = OpConstant %6 12
91 %26 = OpConstant %16 1
92 %29 = OpConstant %6 13
94 %40 = OpConstantFalse %22
95 %43 = OpTypePointer Output %13
96 %44 = OpVariable %43 Output
98 %49 = OpConstantComposite %13 %33 %48 %48 %33
99 %4 = OpFunction %2 None %3
101 OpSelectionMerge %42 None
102 OpBranchConditional %40 %41 %47
104 %45 = OpFunctionCall %6 %8
105 %46 = OpCompositeConstruct %13 %45 %45 %45 %45
114 %8 = OpFunction %6 None %7
116 %11 = OpVariable %10 Function
118 %19 = OpAccessChain %18 %15 %17
120 %23 = OpFOrdEqual %22 %20 %21
121 OpSelectionMerge %25 None
122 OpBranchConditional %23 %24 %25
124 %27 = OpAccessChain %18 %15 %26
126 %30 = OpFOrdEqual %22 %28 %29
127 OpSelectionMerge %32 None
128 OpBranchConditional %30 %31 %32
131 %35 = OpFAdd %6 %34 %33
143 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
145 PIPELINE graphics variant_pipeline
146 ATTACH variant_vertex_shader
147 ATTACH variant_fragment_shader
148 FRAMEBUFFER_SIZE 256 256
149 BIND BUFFER variant_framebuffer AS color LOCATION 0
151 CLEAR_COLOR variant_pipeline 0 0 0 255
153 CLEAR variant_pipeline
154 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
156 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255