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 uninitialized element cast in loop
22 # The test passes because main always writes the color red.
24 # Optimized using spirv-opt with the following arguments:
25 # '--inline-entry-points-exhaustive'
26 # '--eliminate-local-single-block'
28 # '--eliminate-local-multi-store'
29 # '--inline-entry-points-exhaustive'
30 # '--combine-access-chains'
31 # '--combine-access-chains'
32 # '--reduce-load-size'
33 # '--copy-propagate-arrays'
34 # '--reduce-load-size'
35 # '--eliminate-local-multi-store'
36 # '--scalar-replacement=100'
37 # '--convert-local-access-chains'
38 # '--scalar-replacement=100'
40 # '--eliminate-dead-inserts'
41 # '--scalar-replacement=100'
42 # '--eliminate-dead-inserts'
43 # '--simplify-instructions'
44 # '--eliminate-dead-branches'
47 # '--copy-propagate-arrays'
48 # '--combine-access-chains'
49 # '--eliminate-local-multi-store'
50 # spirv-opt commit hash: 06407250a169c6a03b3765e86619075af1a8c187
54 SHADER vertex variant_vertex_shader PASSTHROUGH
56 # variant_fragment_shader is derived from the following GLSL:
58 # precision highp float;
60 # layout(location = 0) out vec4 _GLF_color;
61 # layout(set = 0, binding = 0) uniform buf0 { vec2 injectionSwitch; };
73 # if (injectionSwitch.x < injectionSwitch.y) // always true
75 # _GLF_color = vec4(1.0, 0.0, 0.0, 1.0);
80 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
83 ; Generator: Khronos Glslang Reference Front End; 7
87 %1 = OpExtInstImport "GLSL.std.450"
88 OpMemoryModel Logical GLSL450
89 OpEntryPoint Fragment %4 "main" %46
90 OpExecutionMode %4 OriginUpperLeft
94 OpMemberName %32 0 "injectionSwitch"
96 OpName %46 "_GLF_color"
97 OpMemberDecorate %32 0 Offset 0
99 OpDecorate %34 DescriptorSet 0
100 OpDecorate %34 Binding 0
101 OpDecorate %46 Location 0
103 %3 = OpTypeFunction %2
105 %12 = OpConstantTrue %11
106 %18 = OpConstantFalse %11
109 %22 = OpConstant %21 1
110 %23 = OpTypeArray %20 %22
111 %24 = OpTypePointer Function %23
113 %27 = OpConstant %26 0
114 %28 = OpTypePointer Function %20
115 %31 = OpTypeVector %20 2
116 %32 = OpTypeStruct %31
117 %33 = OpTypePointer Uniform %32
118 %34 = OpVariable %33 Uniform
119 %35 = OpConstant %21 0
120 %36 = OpTypePointer Uniform %20
121 %44 = OpTypeVector %20 4
122 %45 = OpTypePointer Output %44
123 %46 = OpVariable %45 Output
124 %47 = OpConstant %20 1
125 %48 = OpConstant %20 0
126 %49 = OpConstantComposite %44 %47 %48 %48 %47
128 %4 = OpFunction %2 None %3
130 %51 = OpVariable %28 Function
133 %53 = OpPhi %20 %54 %5 %52 %43
134 OpLoopMerge %8 %43 None
137 %52 = OpPhi %20 %53 %6 %54 %16
138 %37 = OpAccessChain %36 %34 %27 %35
140 %39 = OpAccessChain %36 %34 %27 %22
142 %41 = OpFOrdLessThan %11 %38 %40
143 OpSelectionMerge %55 None
144 OpBranchConditional %41 %42 %43
159 # uniforms for variant
162 BUFFER variant_injectionSwitch DATA_TYPE vec2<float> DATA
166 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
168 PIPELINE graphics variant_pipeline
169 ATTACH variant_vertex_shader
170 ATTACH variant_fragment_shader
171 FRAMEBUFFER_SIZE 256 256
172 BIND BUFFER variant_framebuffer AS color LOCATION 0
173 BIND BUFFER variant_injectionSwitch AS uniform DESCRIPTOR_SET 0 BINDING 0
175 CLEAR_COLOR variant_pipeline 0 0 0 255
177 CLEAR variant_pipeline
178 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
180 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255