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:
28 # #define _int_0 _GLF_uniform_int_values[0]
29 # #define _int_10 _GLF_uniform_int_values[1]
30 # #define _int_1 _GLF_uniform_int_values[2]
32 # precision highp float;
33 # precision highp int;
35 # // Contents of _GLF_uniform_int_values: [0, 10, 1]
36 # layout(set = 0, binding = 0) uniform buf0
38 # int _GLF_uniform_int_values[3];
41 # layout(location = 0) out vec4 _GLF_color;
59 # while (i < _int_10);
66 # if (func() == _int_1)
68 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
72 # _GLF_color = vec4(_int_0);
75 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
78 ; Generator: Khronos Glslang Reference Front End; 10
82 %1 = OpExtInstImport "GLSL.std.450"
83 OpMemoryModel Logical GLSL450
84 OpEntryPoint Fragment %4 "main" %56
85 OpExecutionMode %4 OriginUpperLeft
91 OpMemberName %15 0 "_GLF_uniform_int_values"
93 OpName %56 "_GLF_color"
94 OpDecorate %14 ArrayStride 16
95 OpMemberDecorate %15 0 Offset 0
97 OpDecorate %17 DescriptorSet 0
98 OpDecorate %17 Binding 0
99 OpDecorate %56 Location 0
101 %3 = OpTypeFunction %2
103 %7 = OpTypeFunction %6
104 %10 = OpTypePointer Function %6
106 %13 = OpConstant %12 3
107 %14 = OpTypeArray %6 %13
108 %15 = OpTypeStruct %14
109 %16 = OpTypePointer Uniform %15
110 %17 = OpVariable %16 Uniform
111 %18 = OpConstant %6 0
112 %19 = OpTypePointer Uniform %6
113 %27 = OpConstant %6 1
115 %30 = OpConstantTrue %29
116 %35 = OpConstant %6 2
118 %54 = OpTypeVector %53 4
119 %55 = OpTypePointer Output %54
120 %56 = OpVariable %55 Output
121 %4 = OpFunction %2 None %3
123 %47 = OpFunctionCall %6 %8
124 %48 = OpAccessChain %19 %17 %18 %35
126 %50 = OpIEqual %29 %47 %49
127 OpSelectionMerge %52 None
128 OpBranchConditional %50 %51 %70
130 %57 = OpAccessChain %19 %17 %18 %35
132 %59 = OpConvertSToF %53 %58
133 %60 = OpAccessChain %19 %17 %18 %18
135 %62 = OpConvertSToF %53 %61
136 %63 = OpAccessChain %19 %17 %18 %18
138 %65 = OpConvertSToF %53 %64
139 %66 = OpAccessChain %19 %17 %18 %35
141 %68 = OpConvertSToF %53 %67
142 %69 = OpCompositeConstruct %54 %59 %62 %65 %68
146 %71 = OpAccessChain %19 %17 %18 %18
148 %73 = OpConvertSToF %53 %72
149 %74 = OpCompositeConstruct %54 %73 %73 %73 %73
155 %8 = OpFunction %6 None %7
157 %11 = OpVariable %10 Function
158 %20 = OpAccessChain %19 %17 %18 %18
163 OpLoopMerge %24 %25 None
167 %28 = OpIAdd %6 %26 %27
169 OpSelectionMerge %32 None
170 OpBranchConditional %30 %31 %32
172 OpSelectionMerge %34 None
173 OpBranchConditional %30 %33 %34
175 %36 = OpAccessChain %19 %17 %18 %35
184 %40 = OpAccessChain %19 %17 %18 %27
186 %42 = OpSLessThan %29 %39 %41
187 OpBranchConditional %42 %22 %24
189 %43 = OpAccessChain %19 %17 %18 %18
195 # uniforms for variant
197 # _GLF_uniform_int_values
198 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
202 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
204 PIPELINE graphics variant_pipeline
205 ATTACH variant_vertex_shader
206 ATTACH variant_fragment_shader
207 FRAMEBUFFER_SIZE 256 256
208 BIND BUFFER variant_framebuffer AS color LOCATION 0
209 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
211 CLEAR_COLOR variant_pipeline 0 0 0 255
213 CLEAR variant_pipeline
214 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
216 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255