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 bug found by GraphicsFuzz.
20 # Short description: A fragment shader with returned boolean in vector
22 # The test passes because the shader always writes the color red.
24 # Optimized using spirv-opt with the following arguments:
25 # '--eliminate-dead-branches'
27 # '--inline-entry-points-exhaustive'
29 # '--simplify-instructions'
30 # '--eliminate-dead-branches'
32 # '--eliminate-dead-code-aggressive'
33 # '--scalar-replacement=100'
34 # '--eliminate-dead-branches'
35 # '--reduce-load-size'
36 # '--eliminate-local-multi-store'
38 # spirv-opt commit hash: ad7f2c5c4c7f51360e9e079109a9217aa5ba5cc0
42 SHADER vertex variant_vertex_shader PASSTHROUGH
44 # variant_fragment_shader is derived from the following GLSL:
46 # precision highp float;
48 # layout(location = 0) out vec4 _GLF_color;
50 # layout(set = 0, binding = 0) uniform buf0
52 # vec2 injectionSwitch;
57 # for (int i = 0; i < 1; i++)
69 # if (injectionSwitch.y < 0.0)
74 # _GLF_color = vec4(color, 1.0) + vec4(puzzlelize());
76 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
78 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
81 ; Generator: Khronos Glslang Reference Front End; 7
85 %1 = OpExtInstImport "GLSL.std.450"
86 OpMemoryModel Logical GLSL450
87 OpEntryPoint Fragment %4 "main" %53
88 OpExecutionMode %4 OriginUpperLeft
92 OpMemberName %33 0 "injectionSwitch"
95 OpName %53 "_GLF_color"
96 OpMemberDecorate %33 0 Offset 0
98 OpDecorate %35 DescriptorSet 0
99 OpDecorate %35 Binding 0
100 OpDecorate %53 Location 0
101 OpDecorate %76 RelaxedPrecision
103 %3 = OpTypeFunction %2
106 %11 = OpTypePointer Function %10
107 %13 = OpConstant %10 0
108 %20 = OpConstant %10 1
109 %22 = OpConstantTrue %6
111 %32 = OpTypeVector %31 2
112 %33 = OpTypeStruct %32
113 %34 = OpTypePointer Uniform %33
114 %35 = OpVariable %34 Uniform
116 %37 = OpConstant %36 1
117 %38 = OpTypePointer Uniform %31
118 %41 = OpConstant %31 0
119 %45 = OpTypeVector %31 3
120 %46 = OpTypePointer Function %45
121 %48 = OpConstant %31 1
122 %49 = OpConstantComposite %45 %48 %48 %48
123 %50 = OpConstantFalse %6
124 %51 = OpTypeVector %31 4
125 %52 = OpTypePointer Output %51
126 %53 = OpVariable %52 Output
127 %63 = OpConstantComposite %51 %48 %41 %41 %48
128 %65 = OpTypePointer Function %6
132 %4 = OpFunction %2 None %3
134 %74 = OpVariable %65 Function %50
135 %75 = OpVariable %65 Function
136 %76 = OpVariable %11 Function
137 %77 = OpVariable %65 Function
138 %47 = OpVariable %46 Function
141 %105 = OpPhi %6 %106 %5 %105 %30
142 %94 = OpPhi %45 %95 %5 %93 %30
143 OpLoopMerge %29 %30 None
146 %39 = OpAccessChain %38 %35 %13 %37
148 %42 = OpFOrdLessThan %6 %40 %41
149 OpSelectionMerge %44 None
150 OpBranchConditional %42 %43 %44
155 %93 = OpPhi %45 %94 %28 %49 %43
158 OpBranchConditional %50 %27 %29
160 %55 = OpCompositeExtract %31 %93 0
161 %56 = OpCompositeExtract %31 %93 1
162 %57 = OpCompositeExtract %31 %93 2
163 %58 = OpCompositeConstruct %51 %55 %56 %57 %48
167 %103 = OpPhi %6 %105 %29 %106 %80
168 %99 = OpPhi %6 %50 %29 %106 %80
169 OpLoopMerge %79 %80 None
175 %102 = OpPhi %6 %103 %81 %106 %84
176 %98 = OpPhi %6 %50 %81 %106 %84
177 %96 = OpPhi %10 %13 %81 %107 %84
178 OpLoopMerge %83 %84 None
181 %87 = OpSLessThan %6 %13 %20
182 OpBranchConditional %22 %88 %83
190 %101 = OpPhi %6 %102 %85 %22 %88
191 %97 = OpPhi %6 %50 %85 %22 %88
192 OpSelectionMerge %90 None
193 OpBranchConditional %22 %79 %90
201 %60 = OpSelect %31 %22 %48 %41
202 %61 = OpCompositeConstruct %51 %60 %60 %60 %60
203 %62 = OpFAdd %51 %58 %61
210 # uniforms for variant
213 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
217 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
219 PIPELINE graphics variant_pipeline
220 ATTACH variant_vertex_shader
221 ATTACH variant_fragment_shader
222 FRAMEBUFFER_SIZE 256 256
223 BIND BUFFER variant_framebuffer AS color LOCATION 0
224 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
226 CLEAR_COLOR variant_pipeline 0 0 0 255
228 CLEAR variant_pipeline
229 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
231 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255