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 the GraphicsFuzz project.
20 # Short description: A fragment shader that covers a specific selection DAG code path
22 # The test passes because the shader always writes red.
24 SHADER vertex variant_vertex_shader PASSTHROUGH
26 # variant_fragment_shader is derived from the following GLSL:
28 # #define _int_10 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_1 _GLF_uniform_int_values[2]
32 # precision highp int;
34 # precision highp float;
36 # // Contents of _GLF_uniform_int_values: [10, 0, 1]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[3];
42 # layout(location = 0) out vec4 _GLF_color;
48 # for (int i = _int_1; i < _int_10; i++)
55 # _GLF_color = vec4(_int_0);
59 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
62 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
65 ; Generator: Khronos Glslang Reference Front End; 10
69 %1 = OpExtInstImport "GLSL.std.450"
70 OpMemoryModel Logical GLSL450
71 OpEntryPoint Fragment %4 "main" %44
72 OpExecutionMode %4 OriginUpperLeft
77 OpMemberName %12 0 "_GLF_uniform_int_values"
80 OpName %44 "_GLF_color"
81 OpDecorate %11 ArrayStride 16
82 OpMemberDecorate %12 0 Offset 0
84 OpDecorate %14 DescriptorSet 0
85 OpDecorate %14 Binding 0
86 OpDecorate %44 Location 0
88 %3 = OpTypeFunction %2
90 %7 = OpTypePointer Function %6
93 %11 = OpTypeArray %6 %10
94 %12 = OpTypeStruct %11
95 %13 = OpTypePointer Uniform %12
96 %14 = OpVariable %13 Uniform
99 %17 = OpTypePointer Uniform %6
101 %36 = OpConstant %6 3
102 %39 = OpConstant %6 1
104 %42 = OpTypeVector %41 4
105 %43 = OpTypePointer Output %42
106 %44 = OpVariable %43 Output
107 %4 = OpFunction %2 None %3
109 %8 = OpVariable %7 Function
110 %20 = OpVariable %7 Function
111 %18 = OpAccessChain %17 %14 %15 %16
114 %21 = OpAccessChain %17 %14 %15 %16
119 OpLoopMerge %25 %26 None
123 %29 = OpAccessChain %17 %14 %15 %15
125 %32 = OpSLessThan %31 %28 %30
126 OpBranchConditional %32 %24 %25
132 %37 = OpExtInst %6 %1 SClamp %35 %15 %36
137 %40 = OpIAdd %6 %38 %39
141 %45 = OpAccessChain %17 %14 %15 %39
143 %47 = OpConvertSToF %41 %46
144 %48 = OpCompositeConstruct %42 %47 %47 %47 %47
147 %50 = OpAccessChain %17 %14 %15 %39
149 %52 = OpIEqual %31 %49 %51
150 OpSelectionMerge %54 None
151 OpBranchConditional %52 %53 %54
153 %55 = OpAccessChain %17 %14 %15 %16
155 %57 = OpConvertSToF %41 %56
156 %58 = OpAccessChain %17 %14 %15 %39
158 %60 = OpConvertSToF %41 %59
159 %61 = OpAccessChain %17 %14 %15 %39
161 %63 = OpConvertSToF %41 %62
162 %64 = OpAccessChain %17 %14 %15 %16
164 %66 = OpConvertSToF %41 %65
165 %67 = OpCompositeConstruct %42 %57 %60 %63 %66
173 # uniforms for variant
175 # _GLF_uniform_int_values
176 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
180 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
182 PIPELINE graphics variant_pipeline
183 ATTACH variant_vertex_shader
184 ATTACH variant_fragment_shader
185 FRAMEBUFFER_SIZE 16 16
186 BIND BUFFER variant_framebuffer AS color LOCATION 0
187 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
189 CLEAR_COLOR variant_pipeline 0 0 0 255
191 CLEAR variant_pipeline
192 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
194 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255