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 single store elimination path.
22 # The test passes because shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
26 # '--eliminate-local-single-block'
27 # '--redundancy-elimination'
28 # '--reduce-load-size'
29 # spirv-opt commit hash: 9215c1b7df0029f27807e8c8d7ec80532ce90a87
33 SHADER vertex variant_vertex_shader PASSTHROUGH
35 # variant_fragment_shader is derived from the following GLSL:
37 # precision highp float;
38 # precision highp int;
40 # layout(location = 0) out vec4 _GLF_color;
41 # layout(set = 0, binding = 0) uniform buf0
48 # ivec2 v0 = ivec2(0);
49 # ivec2 v1 = ivec2(2);
57 # _GLF_color = vec4(0);
61 # v0 = v1.x > a ? ivec2(0) : ivec2(1);
65 # // After the loop v0 == (1, 1).
71 # _GLF_color = vec4(1, 0, 0, 1);
73 # _GLF_color = vec4(0);
75 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
78 ; Generator: Khronos Glslang Reference Front End; 8
82 %1 = OpExtInstImport "GLSL.std.450"
83 OpMemoryModel Logical GLSL450
84 OpEntryPoint Fragment %4 "main" %36
85 OpExecutionMode %4 OriginUpperLeft
92 OpMemberName %17 0 "one"
94 OpName %36 "_GLF_color"
95 OpMemberDecorate %17 0 Offset 0
97 OpDecorate %19 DescriptorSet 0
98 OpDecorate %19 Binding 0
99 OpDecorate %36 Location 0
101 %3 = OpTypeFunction %2
103 %7 = OpTypeVector %6 2
104 %8 = OpTypePointer Function %7
105 %10 = OpConstant %6 0
106 %11 = OpConstantComposite %7 %10 %10
107 %13 = OpConstant %6 2
108 %14 = OpConstantComposite %7 %13 %13
109 %15 = OpTypePointer Function %6
110 %17 = OpTypeStruct %6
111 %18 = OpTypePointer Uniform %17
112 %19 = OpVariable %18 Uniform
113 %20 = OpTypePointer Uniform %6
114 %28 = OpConstant %6 10
117 %34 = OpTypeVector %33 4
118 %35 = OpTypePointer Output %34
119 %36 = OpVariable %35 Output
120 %37 = OpConstant %33 0
121 %38 = OpConstantComposite %34 %37 %37 %37 %37
123 %41 = OpConstant %40 0
124 %46 = OpConstant %6 1
125 %47 = OpConstantComposite %7 %46 %46
126 %48 = OpTypeVector %29 2
127 %54 = OpConstant %6 9
128 %68 = OpConstant %33 1
129 %69 = OpConstantComposite %34 %68 %37 %37 %68
130 %4 = OpFunction %2 None %3
132 %9 = OpVariable %8 Function
133 %12 = OpVariable %8 Function
134 %16 = OpVariable %15 Function
137 %21 = OpAccessChain %20 %19 %10
142 OpLoopMerge %25 %26 None
146 %30 = OpSGreaterThan %29 %27 %28
147 OpSelectionMerge %32 None
148 OpBranchConditional %30 %31 %32
153 %42 = OpAccessChain %15 %12 %41
156 %45 = OpSGreaterThan %29 %43 %44
157 %49 = OpCompositeConstruct %48 %45 %45
158 %50 = OpSelect %7 %49 %11 %47
160 %52 = OpIAdd %6 %44 %46
165 %55 = OpSLessThan %29 %53 %54
166 OpBranchConditional %55 %23 %25
169 %58 = OpSGreaterThan %29 %57 %46
170 OpSelectionMerge %60 None
171 OpBranchConditional %58 %59 %60
174 %62 = OpIAdd %7 %61 %47
179 %64 = OpIEqual %48 %63 %14
181 OpSelectionMerge %67 None
182 OpBranchConditional %65 %66 %70
194 # uniforms for variant
197 BUFFER variant_one DATA_TYPE int32 DATA
201 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
203 PIPELINE graphics variant_pipeline
204 ATTACH variant_vertex_shader
205 ATTACH variant_fragment_shader
206 FRAMEBUFFER_SIZE 256 256
207 BIND BUFFER variant_framebuffer AS color LOCATION 0
208 BIND BUFFER variant_one AS uniform DESCRIPTOR_SET 0 BINDING 0
210 CLEAR_COLOR variant_pipeline 0 0 0 255
212 CLEAR variant_pipeline
213 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
215 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255