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 # Optimized using spirv-opt with the following arguments:
25 # '--reduce-load-size'
26 # '--convert-local-access-chains'
27 # '--eliminate-local-single-store'
28 # '--simplify-instructions'
29 # '--combine-access-chains'
30 # '--eliminate-dead-branches'
32 # '--convert-local-access-chains'
33 # '--convert-local-access-chains'
34 # spirv-opt commit hash: 9215c1b7df0029f27807e8c8d7ec80532ce90a87
38 SHADER vertex variant_vertex_shader PASSTHROUGH
40 # variant_fragment_shader is derived from the following GLSL:
42 # precision highp float;
44 # layout(location = 0) out vec4 _GLF_color;
51 # if (gl_FragCoord.x < 0.0)
54 # return vec4(x, 0, 0, 1);
59 # _GLF_color = vec4(0);
63 # _GLF_color = func();
67 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
70 ; Generator: Khronos Glslang Reference Front End; 8
74 %1 = OpExtInstImport "GLSL.std.450"
75 OpMemoryModel Logical GLSL450
76 OpEntryPoint Fragment %4 "main" %15 %32
77 OpExecutionMode %4 OriginUpperLeft
82 OpName %15 "gl_FragCoord"
83 OpName %32 "_GLF_color"
84 OpDecorate %15 BuiltIn FragCoord
85 OpDecorate %32 Location 0
87 %3 = OpTypeFunction %2
89 %7 = OpTypeVector %6 4
90 %8 = OpTypeFunction %7
91 %11 = OpTypePointer Function %6
93 %14 = OpTypePointer Input %7
94 %15 = OpVariable %14 Input
96 %17 = OpConstant %16 0
97 %18 = OpTypePointer Input %6
100 %26 = OpConstant %6 0.5
101 %31 = OpTypePointer Output %7
102 %32 = OpVariable %31 Output
103 %33 = OpConstantComposite %7 %21 %21 %21 %21
104 %39 = OpConstantFalse %22
105 %4 = OpFunction %2 None %3
110 %38 = OpFunctionCall %7 %9
112 OpLoopMerge %36 %34 None
113 OpBranchConditional %39 %34 %36
117 %9 = OpFunction %7 None %8
119 %12 = OpVariable %11 Function
121 %19 = OpAccessChain %18 %15 %17
123 %23 = OpFOrdLessThan %22 %20 %21
124 OpSelectionMerge %25 None
125 OpBranchConditional %23 %24 %25
131 %28 = OpCompositeConstruct %7 %27 %21 %21 %13
137 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
139 PIPELINE graphics variant_pipeline
140 ATTACH variant_vertex_shader
141 ATTACH variant_fragment_shader
142 FRAMEBUFFER_SIZE 256 256
143 BIND BUFFER variant_framebuffer AS color LOCATION 0
145 CLEAR_COLOR variant_pipeline 0 0 0 255
147 CLEAR variant_pipeline
148 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
150 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255