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 # '--eliminate-dead-branches'
27 # '--eliminate-dead-inserts'
28 # '--eliminate-local-single-store'
29 # '--scalar-replacement=100'
30 # '--eliminate-dead-branches'
32 # '--scalar-replacement=100'
33 # '--eliminate-dead-branches'
36 # '--eliminate-dead-branches'
39 # '--eliminate-dead-branches'
40 # '--scalar-replacement=100'
41 # '--eliminate-local-single-store'
42 # '--combine-access-chains'
43 # '--redundancy-elimination'
45 # '--eliminate-dead-code-aggressive'
46 # '--private-to-local'
47 # '--eliminate-local-single-block'
48 # '--eliminate-local-multi-store'
49 # '--eliminate-local-single-block'
51 # spirv-opt commit hash: 96354f5047bf35765af49657304357e00264e5f9
55 SHADER vertex variant_vertex_shader PASSTHROUGH
57 # variant_fragment_shader is derived from the following GLSL:
59 # precision highp float;
60 # precision highp int;
62 # layout(location = 0) out vec4 _GLF_color;
63 # layout(set = 0, binding = 0) uniform buf0
75 # return vec4(1, 0, 0, 1);
79 # return vec4(1, 0, 0, 1);
86 # _GLF_color = returnRed();
90 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
93 ; Generator: Khronos Glslang Reference Front End; 8
97 %1 = OpExtInstImport "GLSL.std.450"
98 OpMemoryModel Logical GLSL450
99 OpEntryPoint Fragment %4 "main" %40
100 OpExecutionMode %4 OriginUpperLeft
103 OpName %9 "returnRed("
105 OpMemberName %16 0 "zero"
107 OpName %40 "_GLF_color"
108 OpMemberDecorate %16 0 Offset 0
110 OpDecorate %18 DescriptorSet 0
111 OpDecorate %18 Binding 0
112 OpDecorate %40 Location 0
114 %3 = OpTypeFunction %2
116 %7 = OpTypeVector %6 4
117 %8 = OpTypeFunction %7
119 %16 = OpTypeStruct %15
120 %17 = OpTypePointer Uniform %16
121 %18 = OpVariable %17 Uniform
122 %19 = OpConstant %15 0
123 %20 = OpTypePointer Uniform %15
124 %23 = OpConstant %15 1
126 %28 = OpConstant %6 1
127 %29 = OpConstant %6 0
128 %30 = OpConstantComposite %7 %28 %29 %29 %28
129 %32 = OpConstantFalse %24
130 %39 = OpTypePointer Output %7
131 %40 = OpVariable %39 Output
132 %43 = OpTypePointer Function %7
133 %49 = OpTypePointer Function %24
134 %51 = OpConstantTrue %24
137 %4 = OpFunction %2 None %3
141 %41 = OpFunctionCall %7 %9
143 OpLoopMerge %37 %35 None
144 OpBranchConditional %32 %35 %37
148 %9 = OpFunction %7 None %8
150 %50 = OpVariable %49 Function %32
151 %44 = OpVariable %43 Function
154 %56 = OpPhi %24 %32 %10 %62 %48
155 OpLoopMerge %42 %48 None
158 OpLoopMerge %13 %14 None
161 %21 = OpAccessChain %20 %18 %19
163 %25 = OpIEqual %24 %22 %23
164 OpSelectionMerge %27 None
165 OpBranchConditional %25 %26 %27
173 OpBranchConditional %32 %11 %13
175 %58 = OpPhi %7 %30 %26 %61 %14
176 %54 = OpPhi %24 %51 %26 %32 %14
177 OpSelectionMerge %52 None
178 OpBranchConditional %54 %42 %52
186 %57 = OpPhi %7 %58 %13 %30 %52
191 # uniforms for variant
194 BUFFER variant_zero DATA_TYPE int32 DATA
198 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
200 PIPELINE graphics variant_pipeline
201 ATTACH variant_vertex_shader
202 ATTACH variant_fragment_shader
203 FRAMEBUFFER_SIZE 256 256
204 BIND BUFFER variant_framebuffer AS color LOCATION 0
205 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 0
207 CLEAR_COLOR variant_pipeline 0 0 0 255
209 CLEAR variant_pipeline
210 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
212 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255