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:
29 # precision highp float;
30 # precision highp int;
32 # layout(location = 0) out vec4 _GLF_color;
36 # for (int i = 0; i < 10; ++i)
52 # _GLF_color = vec4(func());
56 # _GLF_color = vec4(1, 0, 0, 1);
59 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
62 ; Generator: Khronos Glslang Reference Front End; 8
66 %1 = OpExtInstImport "GLSL.std.450"
67 OpMemoryModel Logical GLSL450
68 OpEntryPoint Fragment %4 "main" %48
69 OpExecutionMode %4 OriginUpperLeft
74 OpName %48 "_GLF_color"
75 OpDecorate %48 Location 0
77 %3 = OpTypeFunction %2
79 %7 = OpTypeFunction %6
81 %11 = OpTypePointer Function %10
82 %13 = OpConstant %10 0
83 %20 = OpConstant %10 10
85 %24 = OpConstant %10 5
86 %29 = OpConstant %10 1
87 %32 = OpConstant %10 8
90 %43 = OpConstantFalse %21
91 %46 = OpTypeVector %6 4
92 %47 = OpTypePointer Output %46
93 %48 = OpVariable %47 Output
94 %52 = OpConstantComposite %46 %40 %36 %36 %40
95 %4 = OpFunction %2 None %3
97 OpSelectionMerge %45 None
98 OpBranchConditional %43 %44 %51
100 %49 = OpFunctionCall %6 %8
101 %50 = OpCompositeConstruct %46 %49 %49 %49 %49
110 %8 = OpFunction %6 None %7
112 %12 = OpVariable %11 Function
116 OpLoopMerge %16 %17 None
120 %22 = OpSLessThan %21 %19 %20
121 OpBranchConditional %22 %15 %16
124 %25 = OpSGreaterThan %21 %23 %24
125 OpSelectionMerge %27 None
126 OpBranchConditional %25 %26 %27
129 %30 = OpIAdd %10 %28 %29
134 %33 = OpSGreaterThan %21 %31 %32
135 OpSelectionMerge %35 None
136 OpBranchConditional %33 %34 %35
143 %39 = OpIAdd %10 %38 %29
152 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
154 PIPELINE graphics variant_pipeline
155 ATTACH variant_vertex_shader
156 ATTACH variant_fragment_shader
157 FRAMEBUFFER_SIZE 256 256
158 BIND BUFFER variant_framebuffer AS color LOCATION 0
160 CLEAR_COLOR variant_pipeline 0 0 0 255
162 CLEAR variant_pipeline
163 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
165 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255