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 _float_5_0 _GLF_uniform_float_values[0]
32 # #define _float_1_0 _GLF_uniform_float_values[1]
34 # precision highp int;
35 # precision highp float;
37 # // Contents of _GLF_uniform_float_values: [5.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: [1, 0]
44 # layout(set = 0, binding = 1) uniform buf1
46 # int _GLF_uniform_int_values[2];
49 # layout(location = 0) out vec4 _GLF_color;
56 # return vec2[3](vec2(_float_1_0), vec2(_float_1_0), v)[a];
61 # if(func().y == _float_5_0)
63 # _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
67 # _GLF_color = vec4(_int_0);
70 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
73 ; Generator: Khronos Glslang Reference Front End; 10
77 %1 = OpExtInstImport "GLSL.std.450"
78 OpMemoryModel Logical GLSL450
79 OpEntryPoint Fragment %4 "main" %58
80 OpExecutionMode %4 OriginUpperLeft
86 OpMemberName %16 0 "_GLF_uniform_float_values"
89 OpName %43 "indexable"
90 OpName %58 "_GLF_color"
92 OpMemberName %60 0 "_GLF_uniform_int_values"
94 OpDecorate %15 ArrayStride 16
95 OpMemberDecorate %16 0 Offset 0
97 OpDecorate %18 DescriptorSet 0
98 OpDecorate %18 Binding 0
99 OpDecorate %58 Location 0
100 OpDecorate %59 ArrayStride 16
101 OpMemberDecorate %60 0 Offset 0
103 OpDecorate %62 DescriptorSet 0
104 OpDecorate %62 Binding 1
106 %3 = OpTypeFunction %2
108 %7 = OpTypeVector %6 2
109 %8 = OpTypeFunction %7
110 %11 = OpTypePointer Function %7
112 %14 = OpConstant %13 2
113 %15 = OpTypeArray %6 %14
114 %16 = OpTypeStruct %15
115 %17 = OpTypePointer Uniform %16
116 %18 = OpVariable %17 Uniform
118 %20 = OpConstant %19 0
119 %21 = OpTypePointer Uniform %6
120 %24 = OpConstant %13 1
121 %25 = OpTypePointer Function %6
122 %27 = OpTypePointer Function %19
123 %29 = OpConstant %19 2
124 %30 = OpConstant %19 1
125 %38 = OpConstant %13 3
126 %39 = OpTypeArray %7 %38
127 %42 = OpTypePointer Function %39
129 %56 = OpTypeVector %6 4
130 %57 = OpTypePointer Output %56
131 %58 = OpVariable %57 Output
132 %59 = OpTypeArray %19 %14
133 %60 = OpTypeStruct %59
134 %61 = OpTypePointer Uniform %60
135 %62 = OpVariable %61 Uniform
136 %63 = OpTypePointer Uniform %19
137 %4 = OpFunction %2 None %3
139 %48 = OpFunctionCall %7 %9
140 %49 = OpCompositeExtract %6 %48 1
141 %50 = OpAccessChain %21 %18 %20 %20
143 %53 = OpFOrdEqual %52 %49 %51
144 OpSelectionMerge %55 None
145 OpBranchConditional %53 %54 %77
147 %64 = OpAccessChain %63 %62 %20 %20
149 %66 = OpConvertSToF %6 %65
150 %67 = OpAccessChain %63 %62 %20 %30
152 %69 = OpConvertSToF %6 %68
153 %70 = OpAccessChain %63 %62 %20 %30
155 %72 = OpConvertSToF %6 %71
156 %73 = OpAccessChain %63 %62 %20 %20
158 %75 = OpConvertSToF %6 %74
159 %76 = OpCompositeConstruct %56 %66 %69 %72 %75
163 %78 = OpAccessChain %63 %62 %20 %30
165 %80 = OpConvertSToF %6 %79
166 %81 = OpCompositeConstruct %56 %80 %80 %80 %80
172 %9 = OpFunction %7 None %8
174 %12 = OpVariable %11 Function
175 %28 = OpVariable %27 Function
176 %43 = OpVariable %42 Function
177 %22 = OpAccessChain %21 %18 %20 %20
179 %26 = OpAccessChain %25 %12 %24
182 %31 = OpAccessChain %21 %18 %20 %30
184 %33 = OpCompositeConstruct %7 %32 %32
185 %34 = OpAccessChain %21 %18 %20 %30
187 %36 = OpCompositeConstruct %7 %35 %35
189 %40 = OpCompositeConstruct %39 %33 %36 %37
192 %44 = OpAccessChain %11 %43 %41
198 # uniforms for variant
200 # _GLF_uniform_int_values
201 BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
204 # _GLF_uniform_float_values
205 BUFFER variant__GLF_uniform_float_values DATA_TYPE float[] 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__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 1
217 BIND BUFFER variant__GLF_uniform_float_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