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 specific NIR 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:
29 # #define _int_1 _GLF_uniform_int_values[0]
30 # #define _int_0 _GLF_uniform_int_values[1]
31 # #define _int_4 _GLF_uniform_int_values[2]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [1, 0, 4]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[3];
42 # layout(location = 0) out vec4 _GLF_color;
46 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
49 # if(gl_FragCoord.y < 0.0)
51 # _GLF_color = vec4(_int_0);
54 # for(int i = _int_0; i < _int_4; i++)
57 # if(gl_FragCoord.x > 0.0)
60 # if(gl_FragCoord.y < 0.0)
62 # _GLF_color = vec4(_int_0);
68 # if(gl_FragCoord.x > 0.0)
71 # if(gl_FragCoord.y < 0.0)
73 # _GLF_color = vec4(_int_0);
78 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
81 ; Generator: Khronos Glslang Reference Front End; 10
85 %1 = OpExtInstImport "GLSL.std.450"
86 OpMemoryModel Logical GLSL450
87 OpEntryPoint Fragment %4 "main" %9 %34
88 OpExecutionMode %4 OriginUpperLeft
91 OpName %9 "_GLF_color"
93 OpMemberName %14 0 "_GLF_uniform_int_values"
95 OpName %34 "gl_FragCoord"
97 OpDecorate %9 Location 0
98 OpDecorate %13 ArrayStride 16
99 OpMemberDecorate %14 0 Offset 0
101 OpDecorate %16 DescriptorSet 0
102 OpDecorate %16 Binding 0
103 OpDecorate %34 BuiltIn FragCoord
105 %3 = OpTypeFunction %2
107 %7 = OpTypeVector %6 4
108 %8 = OpTypePointer Output %7
109 %9 = OpVariable %8 Output
112 %12 = OpConstant %11 3
113 %13 = OpTypeArray %10 %12
114 %14 = OpTypeStruct %13
115 %15 = OpTypePointer Uniform %14
116 %16 = OpVariable %15 Uniform
117 %17 = OpConstant %10 0
118 %18 = OpTypePointer Uniform %10
119 %22 = OpConstant %10 1
120 %33 = OpTypePointer Input %7
121 %34 = OpVariable %33 Input
122 %35 = OpConstant %11 1
123 %36 = OpTypePointer Input %6
124 %39 = OpConstant %6 0
126 %48 = OpTypePointer Function %10
127 %58 = OpConstant %10 2
128 %62 = OpConstant %11 0
129 %4 = OpFunction %2 None %3
131 %49 = OpVariable %48 Function
132 %19 = OpAccessChain %18 %16 %17 %17
134 %21 = OpConvertSToF %6 %20
135 %23 = OpAccessChain %18 %16 %17 %22
137 %25 = OpConvertSToF %6 %24
138 %26 = OpAccessChain %18 %16 %17 %22
140 %28 = OpConvertSToF %6 %27
141 %29 = OpAccessChain %18 %16 %17 %17
143 %31 = OpConvertSToF %6 %30
144 %32 = OpCompositeConstruct %7 %21 %25 %28 %31
146 %37 = OpAccessChain %36 %34 %35
148 %41 = OpFOrdLessThan %40 %38 %39
149 OpSelectionMerge %43 None
150 OpBranchConditional %41 %42 %43
152 %44 = OpAccessChain %18 %16 %17 %22
154 %46 = OpConvertSToF %6 %45
155 %47 = OpCompositeConstruct %7 %46 %46 %46 %46
159 %50 = OpAccessChain %18 %16 %17 %22
164 OpLoopMerge %54 %55 None
168 %59 = OpAccessChain %18 %16 %17 %58
170 %61 = OpSLessThan %40 %57 %60
171 OpBranchConditional %61 %53 %54
173 %63 = OpAccessChain %36 %34 %62
175 %65 = OpFOrdGreaterThan %40 %64 %39
176 OpSelectionMerge %67 None
177 OpBranchConditional %65 %66 %67
179 %68 = OpAccessChain %36 %34 %35
181 %70 = OpFOrdLessThan %40 %69 %39
182 OpSelectionMerge %72 None
183 OpBranchConditional %70 %71 %72
185 %73 = OpAccessChain %18 %16 %17 %22
187 %75 = OpConvertSToF %6 %74
188 %76 = OpCompositeConstruct %7 %75 %75 %75 %75
194 %78 = OpAccessChain %36 %34 %62
196 %80 = OpFOrdGreaterThan %40 %79 %39
197 OpSelectionMerge %82 None
198 OpBranchConditional %80 %81 %82
200 %83 = OpAccessChain %36 %34 %35
202 %85 = OpFOrdLessThan %40 %84 %39
203 OpSelectionMerge %87 None
204 OpBranchConditional %85 %86 %87
206 %88 = OpAccessChain %18 %16 %17 %22
208 %90 = OpConvertSToF %6 %89
209 %91 = OpCompositeConstruct %7 %90 %90 %90 %90
218 %93 = OpIAdd %10 %92 %22
226 # uniforms for variant
228 # _GLF_uniform_int_values
229 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
233 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
235 PIPELINE graphics variant_pipeline
236 ATTACH variant_vertex_shader
237 ATTACH variant_fragment_shader
238 FRAMEBUFFER_SIZE 256 256
239 BIND BUFFER variant_framebuffer AS color LOCATION 0
240 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
242 CLEAR_COLOR variant_pipeline 0 0 0 255
244 CLEAR variant_pipeline
245 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
247 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255