• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2
3# Copyright 2021 Google LLC
4#
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
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
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.
16
17
18# A test for a coverage-gap found by the GraphicsFuzz project.
19
20# Short description: A fragment shader that covers specific BRW code paths
21
22# The test passes because the shader always writes red.
23
24SHADER vertex variant_vertex_shader PASSTHROUGH
25
26# variant_fragment_shader is derived from the following GLSL:
27# #version 320 es
28# #define _int_1 _GLF_uniform_int_values[0]
29# #define _int_0 _GLF_uniform_int_values[1]
30# #define _int_50 _GLF_uniform_int_values[2]
31#
32# precision highp float;
33# precision highp int;
34#
35# // Contents of _GLF_uniform_int_values: [1, 0, 50]
36# layout(set = 0, binding = 0) uniform buf0
37# {
38#     int _GLF_uniform_int_values[3];
39# };
40#
41# layout(location = 0) out vec4 _GLF_color;
42#
43# void main()
44# {
45#     int a = _int_0;
46#
47#     for(int i = _int_0; i < _int_50; i++)
48#     {
49#         // Always true.
50#         if ((~i) != 0)
51#         {
52#             a++;
53#         }
54#     }
55#
56#     // Always true.
57#     if(a == _int_50)
58#     {
59#         _GLF_color = vec4(_int_1, _int_0, _int_0, _int_1);
60#     }
61#     else
62#     {
63#         _GLF_color = vec4(_int_0);
64#     }
65# }
66SHADER fragment variant_fragment_shader SPIRV-ASM TARGET_ENV spv1.0
67; SPIR-V
68; Version: 1.0
69; Generator: Khronos Glslang Reference Front End; 10
70; Bound: 71
71; Schema: 0
72               OpCapability Shader
73          %1 = OpExtInstImport "GLSL.std.450"
74               OpMemoryModel Logical GLSL450
75               OpEntryPoint Fragment %4 "main" %52
76               OpExecutionMode %4 OriginUpperLeft
77               OpSource ESSL 320
78               OpName %4 "main"
79               OpName %8 "a"
80               OpName %12 "buf0"
81               OpMemberName %12 0 "_GLF_uniform_int_values"
82               OpName %14 ""
83               OpName %20 "i"
84               OpName %52 "_GLF_color"
85               OpDecorate %11 ArrayStride 16
86               OpMemberDecorate %12 0 Offset 0
87               OpDecorate %12 Block
88               OpDecorate %14 DescriptorSet 0
89               OpDecorate %14 Binding 0
90               OpDecorate %52 Location 0
91          %2 = OpTypeVoid
92          %3 = OpTypeFunction %2
93          %6 = OpTypeInt 32 1
94          %7 = OpTypePointer Function %6
95          %9 = OpTypeInt 32 0
96         %10 = OpConstant %9 3
97         %11 = OpTypeArray %6 %10
98         %12 = OpTypeStruct %11
99         %13 = OpTypePointer Uniform %12
100         %14 = OpVariable %13 Uniform
101         %15 = OpConstant %6 0
102         %16 = OpConstant %6 1
103         %17 = OpTypePointer Uniform %6
104         %29 = OpConstant %6 2
105         %32 = OpTypeBool
106         %49 = OpTypeFloat 32
107         %50 = OpTypeVector %49 4
108         %51 = OpTypePointer Output %50
109         %52 = OpVariable %51 Output
110          %4 = OpFunction %2 None %3
111          %5 = OpLabel
112          %8 = OpVariable %7 Function
113         %20 = OpVariable %7 Function
114         %18 = OpAccessChain %17 %14 %15 %16
115         %19 = OpLoad %6 %18
116               OpStore %8 %19
117         %21 = OpAccessChain %17 %14 %15 %16
118         %22 = OpLoad %6 %21
119               OpStore %20 %22
120               OpBranch %23
121         %23 = OpLabel
122               OpLoopMerge %25 %26 None
123               OpBranch %27
124         %27 = OpLabel
125         %28 = OpLoad %6 %20
126         %30 = OpAccessChain %17 %14 %15 %29
127         %31 = OpLoad %6 %30
128         %33 = OpSLessThan %32 %28 %31
129               OpBranchConditional %33 %24 %25
130         %24 = OpLabel
131         %34 = OpLoad %6 %20
132         %35 = OpNot %6 %34
133         %36 = OpINotEqual %32 %35 %15
134               OpSelectionMerge %38 None
135               OpBranchConditional %36 %37 %38
136         %37 = OpLabel
137         %39 = OpLoad %6 %8
138         %40 = OpIAdd %6 %39 %16
139               OpStore %8 %40
140               OpBranch %38
141         %38 = OpLabel
142               OpBranch %26
143         %26 = OpLabel
144         %41 = OpLoad %6 %20
145         %42 = OpIAdd %6 %41 %16
146               OpStore %20 %42
147               OpBranch %23
148         %25 = OpLabel
149         %43 = OpLoad %6 %8
150         %44 = OpAccessChain %17 %14 %15 %29
151         %45 = OpLoad %6 %44
152         %46 = OpIEqual %32 %43 %45
153               OpSelectionMerge %48 None
154               OpBranchConditional %46 %47 %66
155         %47 = OpLabel
156         %53 = OpAccessChain %17 %14 %15 %15
157         %54 = OpLoad %6 %53
158         %55 = OpConvertSToF %49 %54
159         %56 = OpAccessChain %17 %14 %15 %16
160         %57 = OpLoad %6 %56
161         %58 = OpConvertSToF %49 %57
162         %59 = OpAccessChain %17 %14 %15 %16
163         %60 = OpLoad %6 %59
164         %61 = OpConvertSToF %49 %60
165         %62 = OpAccessChain %17 %14 %15 %15
166         %63 = OpLoad %6 %62
167         %64 = OpConvertSToF %49 %63
168         %65 = OpCompositeConstruct %50 %55 %58 %61 %64
169               OpStore %52 %65
170               OpBranch %48
171         %66 = OpLabel
172         %67 = OpAccessChain %17 %14 %15 %16
173         %68 = OpLoad %6 %67
174         %69 = OpConvertSToF %49 %68
175         %70 = OpCompositeConstruct %50 %69 %69 %69 %69
176               OpStore %52 %70
177               OpBranch %48
178         %48 = OpLabel
179               OpReturn
180               OpFunctionEnd
181END
182
183# uniforms for variant
184
185# _GLF_uniform_int_values
186BUFFER variant__GLF_uniform_int_values DATA_TYPE int32[] STD140 DATA
187 1 0 50
188END
189
190BUFFER variant_framebuffer FORMAT B8G8R8A8_UNORM
191
192PIPELINE graphics variant_pipeline
193  ATTACH variant_vertex_shader
194  ATTACH variant_fragment_shader
195  FRAMEBUFFER_SIZE 256 256
196  BIND BUFFER variant_framebuffer AS color LOCATION 0
197  BIND BUFFER variant__GLF_uniform_int_values AS uniform DESCRIPTOR_SET 0 BINDING 0
198END
199CLEAR_COLOR variant_pipeline 0 0 0 255
200
201CLEAR variant_pipeline
202RUN variant_pipeline DRAW_RECT POS 0 0 SIZE 256 256
203
204EXPECT variant_framebuffer IDX 0 0 SIZE 256 256 EQ_RGBA 255 0 0 255
205