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 BRW 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]
31 # #define _float_0_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: [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: [0, 10, 1]
44 # layout(set = 0, binding = 1) uniform buf1
46 # int _GLF_uniform_int_values[3];
49 # layout(location = 0) out vec4 _GLF_color;
53 # float f = _float_1_0;
55 # for (int i = _int_10; i > _int_0; i--)
57 # float a = 1.0 - max(1.0, float(i));
58 # // Always sets f to zero.
59 # f = min(max(a, 0.0), 0.0);
65 # _GLF_color = vec4(_int_1, f, _int_0, 1);
69 # _GLF_color = vec4(0);
72 SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
75 ; Generator: Khronos Glslang Reference Front End; 10
79 %1 = OpExtInstImport "GLSL.std.450"
80 OpMemoryModel Logical GLSL450
81 OpEntryPoint Fragment %4 "main" %61
82 OpExecutionMode %4 OriginUpperLeft
87 OpMemberName %12 0 "_GLF_uniform_float_values"
91 OpMemberName %25 0 "_GLF_uniform_int_values"
94 OpName %61 "_GLF_color"
95 OpDecorate %11 ArrayStride 16
96 OpMemberDecorate %12 0 Offset 0
98 OpDecorate %14 DescriptorSet 0
99 OpDecorate %14 Binding 0
100 OpDecorate %24 ArrayStride 16
101 OpMemberDecorate %25 0 Offset 0
103 OpDecorate %27 DescriptorSet 0
104 OpDecorate %27 Binding 1
105 OpDecorate %61 Location 0
107 %3 = OpTypeFunction %2
109 %7 = OpTypePointer Function %6
111 %10 = OpConstant %9 2
112 %11 = OpTypeArray %6 %10
113 %12 = OpTypeStruct %11
114 %13 = OpTypePointer Uniform %12
115 %14 = OpVariable %13 Uniform
117 %16 = OpConstant %15 0
118 %17 = OpConstant %15 1
119 %18 = OpTypePointer Uniform %6
120 %21 = OpTypePointer Function %15
121 %23 = OpConstant %9 3
122 %24 = OpTypeArray %15 %23
123 %25 = OpTypeStruct %24
124 %26 = OpTypePointer Uniform %25
125 %27 = OpVariable %26 Uniform
126 %28 = OpTypePointer Uniform %15
128 %42 = OpConstant %6 1
129 %48 = OpConstant %6 0
130 %59 = OpTypeVector %6 4
131 %60 = OpTypePointer Output %59
132 %61 = OpVariable %60 Output
133 %62 = OpConstant %15 2
134 %72 = OpConstantComposite %59 %48 %48 %48 %48
135 %4 = OpFunction %2 None %3
137 %8 = OpVariable %7 Function
138 %22 = OpVariable %21 Function
139 %41 = OpVariable %7 Function
140 %19 = OpAccessChain %18 %14 %16 %17
143 %29 = OpAccessChain %28 %27 %16 %17
148 OpLoopMerge %33 %34 None
152 %37 = OpAccessChain %28 %27 %16 %16
154 %40 = OpSGreaterThan %39 %36 %38
155 OpBranchConditional %40 %32 %33
158 %44 = OpConvertSToF %6 %43
159 %45 = OpExtInst %6 %1 FMax %42 %44
160 %46 = OpFSub %6 %42 %45
163 %49 = OpExtInst %6 %1 FMax %47 %48
164 %50 = OpExtInst %6 %1 FMin %49 %48
169 %52 = OpISub %15 %51 %17
174 %54 = OpAccessChain %18 %14 %16 %16
176 %56 = OpFOrdEqual %39 %53 %55
177 OpSelectionMerge %58 None
178 OpBranchConditional %56 %57 %71
180 %63 = OpAccessChain %28 %27 %16 %62
182 %65 = OpConvertSToF %6 %64
184 %67 = OpAccessChain %28 %27 %16 %16
186 %69 = OpConvertSToF %6 %68
187 %70 = OpCompositeConstruct %59 %65 %66 %69 %42
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