1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | #ifndef sw_Primitive_hpp |
16 | #define sw_Primitive_hpp |
17 | |
18 | #include "Vertex.hpp" |
19 | #include "Main/Config.hpp" |
20 | |
21 | namespace sw |
22 | { |
23 | struct Triangle |
24 | { |
25 | Vertex v0; |
26 | Vertex v1; |
27 | Vertex v2; |
28 | }; |
29 | |
30 | struct PlaneEquation // z = A * x + B * y + C |
31 | { |
32 | float4 A; |
33 | float4 B; |
34 | float4 C; |
35 | }; |
36 | |
37 | struct Primitive |
38 | { |
39 | int yMin; |
40 | int yMax; |
41 | |
42 | float4 xQuad; |
43 | float4 yQuad; |
44 | |
45 | PlaneEquation z; |
46 | PlaneEquation w; |
47 | |
48 | union |
49 | { |
50 | struct |
51 | { |
52 | PlaneEquation C[2][4]; |
53 | PlaneEquation T[8][4]; |
54 | PlaneEquation f; |
55 | }; |
56 | |
57 | PlaneEquation V[MAX_FRAGMENT_INPUTS][4]; |
58 | }; |
59 | |
60 | float area; |
61 | |
62 | // Masks for two-sided stencil |
63 | int64_t clockwiseMask; |
64 | int64_t invClockwiseMask; |
65 | |
66 | struct Span |
67 | { |
68 | unsigned short left; |
69 | unsigned short right; |
70 | }; |
71 | |
72 | // The rasterizer adds a zero length span to the top and bottom of the polygon to allow |
73 | // for 2x2 pixel processing. We need an even number of spans to keep accesses aligned. |
74 | Span outlineUnderflow[2]; |
75 | Span outline[OUTLINE_RESOLUTION]; |
76 | Span outlineOverflow[2]; |
77 | }; |
78 | } |
79 | |
80 | #endif // sw_Primitive_hpp |
81 | |