3 # Copyright 2022 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 the GraphicsFuzz project.
20 # Short description: A fragment shader that covers specific LLVM code paths
22 # The test passes because the shader always writes red.
24 # Optimized using spirv-opt with the following arguments:
26 # spirv-opt commit hash: a0370efd589be33d5d9a85cfde2f85841b3755af
30 SHADER vertex variant_vertex_shader PASSTHROUGH
32 # variant_fragment_shader is derived from the following GLSL:
34 # #define _int_1 _GLF_uniform_int_values[0]
35 # #define _int_0 _GLF_uniform_int_values[1]
37 # precision highp float;
38 # precision highp int;
40 # // Contents of _GLF_uniform_int_values: [1, 0]
41 # layout(set = 0, binding = 0) uniform buf0
43 # int _GLF_uniform_int_values[2];
46 # layout(location = 0) out vec4 _GLF_color;
50 # _GLF_color = vec4(0);
53 # for(int i = _int_1 & 1; i > 0; i--)
57 # _GLF_color = vec4(i, _int_0, _int_0, i);
67 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
70 ; Generator: Khronos Glslang Reference Front End; 10
74 %1 = OpExtInstImport "GLSL.std.450"
75 OpMemoryModel Logical GLSL450
76 OpEntryPoint Fragment %4 "main" %9
77 OpExecutionMode %4 OriginUpperLeft
80 OpName %9 "_GLF_color"
82 OpMemberName %18 0 "_GLF_uniform_int_values"
84 OpDecorate %9 Location 0
85 OpDecorate %17 ArrayStride 16
86 OpMemberDecorate %18 0 Offset 0
88 OpDecorate %20 DescriptorSet 0
89 OpDecorate %20 Binding 0
91 %3 = OpTypeFunction %2
93 %7 = OpTypeVector %6 4
94 %8 = OpTypePointer Output %7
95 %9 = OpVariable %8 Output
97 %11 = OpConstantComposite %7 %10 %10 %10 %10
100 %16 = OpConstant %15 2
101 %17 = OpTypeArray %12 %16
102 %18 = OpTypeStruct %17
103 %19 = OpTypePointer Uniform %18
104 %20 = OpVariable %19 Uniform
105 %21 = OpConstant %12 0
106 %22 = OpTypePointer Uniform %12
107 %25 = OpConstant %12 1
109 %4 = OpFunction %2 None %3
112 %23 = OpAccessChain %22 %20 %21 %21
114 %26 = OpBitwiseAnd %12 %24 %25
117 %60 = OpPhi %12 %26 %5 %59 %30
118 %34 = OpSGreaterThan %33 %60 %21
119 OpLoopMerge %29 %30 None
120 OpBranchConditional %34 %28 %29
124 OpLoopMerge %55 %38 None
127 %42 = OpConvertSToF %6 %60
128 %43 = OpAccessChain %22 %20 %21 %25
130 %45 = OpConvertSToF %6 %44
131 %51 = OpCompositeConstruct %7 %42 %45 %45 %42
133 %54 = OpSGreaterThan %33 %24 %21
134 OpSelectionMerge %56 None
135 OpBranchConditional %54 %55 %56
143 %59 = OpISub %12 %60 %25
150 # uniforms for variant
152 # _GLF_uniform_int_values
153 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
157 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
159 PIPELINE graphics variant_pipeline
160 ATTACH variant_vertex_shader
161 ATTACH variant_fragment_shader
162 FRAMEBUFFER_SIZE 32 32
163 BIND BUFFER variant_framebuffer AS color LOCATION 0
164 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
166 CLEAR_COLOR variant_pipeline 0 0 0 255
168 CLEAR variant_pipeline
169 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 32 32
171 EXPECT variant_framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255