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: Covers register coalescer, live intervals and target instr info code paths
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]
31 # #define _float_0_0 _GLF_uniform_float_values[0]
32 # #define _float_1_0 _GLF_uniform_float_values[1]
34 # precision highp float;
35 # precision highp int;
37 # // Contents of _GLF_uniform_float_values: [0.0, 1.0]
38 # layout(set = 0, binding = 0) uniform buf0
40 # float _GLF_uniform_float_values[2];
43 # // Contents of _GLF_uniform_int_values: [10, 0, 1]
44 # layout(set = 0, binding = 1) uniform buf1
46 # int _GLF_uniform_int_values[3];
49 # layout(location = 0) out vec4 _GLF_v1;
53 # for (int i = _int_0; i < _int_10; i++)
56 # if (_float_0_0 > _float_1_0)
60 # for (int j = _int_0; j < _int_10; j++)
63 # if (gl_FragCoord.x < _float_0_0)
67 # _GLF_v1 = vec4(_int_1, _int_0, _int_0, _int_1);
71 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
74 ; Generator: Khronos Glslang Reference Front End; 8
78 %1 = OpExtInstImport "GLSL.std.450"
79 OpMemoryModel Logical GLSL450
80 OpEntryPoint Fragment %4 "main" %59 %71
81 OpExecutionMode %4 OriginUpperLeft
86 OpMemberName %12 0 "_GLF_uniform_int_values"
89 OpMemberName %33 0 "_GLF_uniform_float_values"
92 OpName %59 "gl_FragCoord"
94 OpDecorate %11 ArrayStride 16
95 OpMemberDecorate %12 0 Offset 0
97 OpDecorate %14 DescriptorSet 0
98 OpDecorate %14 Binding 1
99 OpDecorate %32 ArrayStride 16
100 OpMemberDecorate %33 0 Offset 0
102 OpDecorate %35 DescriptorSet 0
103 OpDecorate %35 Binding 0
104 OpDecorate %59 BuiltIn FragCoord
105 OpDecorate %71 Location 0
107 %3 = OpTypeFunction %2
109 %7 = OpTypePointer Function %6
111 %10 = OpConstant %9 3
112 %11 = OpTypeArray %6 %10
113 %12 = OpTypeStruct %11
114 %13 = OpTypePointer Uniform %12
115 %14 = OpVariable %13 Uniform
116 %15 = OpConstant %6 0
117 %16 = OpConstant %6 1
118 %17 = OpTypePointer Uniform %6
121 %31 = OpConstant %9 2
122 %32 = OpTypeArray %30 %31
123 %33 = OpTypeStruct %32
124 %34 = OpTypePointer Uniform %33
125 %35 = OpVariable %34 Uniform
126 %36 = OpTypePointer Uniform %30
127 %57 = OpTypeVector %30 4
128 %58 = OpTypePointer Input %57
129 %59 = OpVariable %58 Input
130 %60 = OpConstant %9 0
131 %61 = OpTypePointer Input %30
132 %70 = OpTypePointer Output %57
133 %71 = OpVariable %70 Output
134 %72 = OpConstant %6 2
135 %4 = OpFunction %2 None %3
137 %8 = OpVariable %7 Function
138 %45 = OpVariable %7 Function
139 %18 = OpAccessChain %17 %14 %15 %16
144 OpLoopMerge %22 %23 None
148 %26 = OpAccessChain %17 %14 %15 %15
150 %29 = OpSLessThan %28 %25 %27
151 OpBranchConditional %29 %21 %22
153 %37 = OpAccessChain %36 %35 %15 %15
155 %39 = OpAccessChain %36 %35 %15 %16
157 %41 = OpFOrdGreaterThan %28 %38 %40
158 OpSelectionMerge %43 None
159 OpBranchConditional %41 %42 %43
163 %46 = OpAccessChain %17 %14 %15 %16
168 OpLoopMerge %50 %51 None
172 %54 = OpAccessChain %17 %14 %15 %15
174 %56 = OpSLessThan %28 %53 %55
175 OpBranchConditional %56 %49 %50
177 %62 = OpAccessChain %61 %59 %60
179 %64 = OpAccessChain %36 %35 %15 %15
181 %66 = OpFOrdLessThan %28 %63 %65
182 OpSelectionMerge %68 None
183 OpBranchConditional %66 %67 %68
187 %73 = OpAccessChain %17 %14 %15 %72
189 %75 = OpConvertSToF %30 %74
190 %76 = OpAccessChain %17 %14 %15 %16
192 %78 = OpConvertSToF %30 %77
193 %79 = OpAccessChain %17 %14 %15 %16
195 %81 = OpConvertSToF %30 %80
196 %82 = OpAccessChain %17 %14 %15 %72
198 %84 = OpConvertSToF %30 %83
199 %85 = OpCompositeConstruct %57 %75 %78 %81 %84
204 %87 = OpIAdd %6 %86 %16
211 %89 = OpIAdd %6 %88 %16
219 # uniforms for variant
221 # _GLF_uniform_int_values
222 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
225 # _GLF_uniform_float_values
226 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] STD140 DATA
230 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
232 PIPELINE graphics variant_pipeline
233 ATTACH variant_vertex_shader
234 ATTACH variant_fragment_shader
235 FRAMEBUFFER_SIZE 16 16
236 BIND BUFFER variant_framebuffer AS color LOCATION 0
237 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
238 BIND BUFFER variant__GLF_uniform_float_values AS uniform DESCRIPTOR_SET 0 BINDING 0
240 CLEAR_COLOR variant_pipeline 0 0 0 255
242 CLEAR variant_pipeline
243 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 16 16
245 EXPECT variant_framebuffer IDX 0 0 SIZE 16 16 EQ_RGBA 255 0 0 255