3 # Copyright 2021 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_1 _GLF_uniform_int_values[0]
29 # #define _int_0 _GLF_uniform_int_values[1]
30 # #define _int_2 _GLF_uniform_int_values[2]
31 # #define _int_3 _GLF_uniform_int_values[3]
33 # precision highp float;
34 # precision highp int;
36 # // Contents of _GLF_uniform_int_values: [1, 0, 2, 3]
37 # layout(set = 0, binding = 0) uniform buf0
39 # int _GLF_uniform_int_values[4];
42 # // Contents of zero: 0
43 # layout(set = 0, binding = 1) uniform buf1
48 # layout(location = 0) out vec4 _GLF_color;
52 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
78 # // This should never be hit.
79 # _GLF_color = vec4(_int_0);
81 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
84 ; Generator: Khronos Glslang Reference Front End; 10
88 %1 = OpExtInstImport "GLSL.std.450"
89 OpMemoryModel Logical GLSL450
90 OpEntryPoint Fragment %4 "main" %9
91 OpExecutionMode %4 OriginUpperLeft
94 OpName %9 "_GLF_color"
96 OpMemberName %14 0 "_GLF_uniform_int_values"
99 OpMemberName %37 0 "zero"
101 OpDecorate %9 Location 0
102 OpDecorate %13 ArrayStride 16
103 OpMemberDecorate %14 0 Offset 0
105 OpDecorate %16 DescriptorSet 0
106 OpDecorate %16 Binding 0
107 OpMemberDecorate %37 0 Offset 0
109 OpDecorate %39 DescriptorSet 0
110 OpDecorate %39 Binding 1
112 %3 = OpTypeFunction %2
114 %7 = OpTypeVector %6 4
115 %8 = OpTypePointer Output %7
116 %9 = OpVariable %8 Output
119 %12 = OpConstant %11 4
120 %13 = OpTypeArray %10 %12
121 %14 = OpTypeStruct %13
122 %15 = OpTypePointer Uniform %14
123 %16 = OpVariable %15 Uniform
124 %17 = OpConstant %10 0
125 %18 = OpTypePointer Uniform %10
126 %22 = OpConstant %10 1
127 %37 = OpTypeStruct %10
128 %38 = OpTypePointer Uniform %37
129 %39 = OpVariable %38 Uniform
131 %51 = OpConstant %10 2
132 %60 = OpConstant %10 3
133 %68 = OpConstantFalse %44
134 %4 = OpFunction %2 None %3
136 %19 = OpAccessChain %18 %16 %17 %17
138 %21 = OpConvertSToF %6 %20
139 %23 = OpAccessChain %18 %16 %17 %22
141 %25 = OpConvertSToF %6 %24
142 %26 = OpAccessChain %18 %16 %17 %22
144 %28 = OpConvertSToF %6 %27
145 %29 = OpAccessChain %18 %16 %17 %17
147 %31 = OpConvertSToF %6 %30
148 %32 = OpCompositeConstruct %7 %21 %25 %28 %31
152 OpLoopMerge %35 %36 None
155 %40 = OpAccessChain %18 %39 %17
157 %42 = OpAccessChain %18 %16 %17 %17
159 %45 = OpIEqual %44 %41 %43
160 OpSelectionMerge %47 None
161 OpBranchConditional %45 %46 %47
165 %49 = OpAccessChain %18 %39 %17
167 %52 = OpAccessChain %18 %16 %17 %51
169 %54 = OpIEqual %44 %50 %53
170 OpSelectionMerge %56 None
171 OpBranchConditional %54 %55 %56
175 %58 = OpAccessChain %18 %39 %17
177 %61 = OpAccessChain %18 %16 %17 %60
179 %63 = OpIEqual %44 %59 %62
180 OpSelectionMerge %65 None
181 OpBranchConditional %63 %64 %65
187 OpBranchConditional %68 %33 %35
189 %69 = OpAccessChain %18 %16 %17 %22
191 %71 = OpConvertSToF %6 %70
192 %72 = OpCompositeConstruct %7 %71 %71 %71 %71
198 # uniforms for variant
201 BUFFER variant_zero DATA_TYPE int32 STD140 DATA
204 # _GLF_uniform_int_values
205 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
209 BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
211 PIPELINE graphics variant_pipeline
212 ATTACH variant_vertex_shader
213 ATTACH variant_fragment_shader
214 FRAMEBUFFER_SIZE 256 256
215 BIND BUFFER variant_framebuffer AS color LOCATION 0
216 BIND BUFFER variant_zero AS uniform DESCRIPTOR_SET 0 BINDING 1
217 BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
219 CLEAR_COLOR variant_pipeline 0 0 0 255
221 CLEAR variant_pipeline
222 RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
224 EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255