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 "Memset.hpp" |
19 | #include "Vertex.hpp" |
20 | #include "Device/Config.hpp" |
21 | #include "System/Build.hpp" |
22 | |
23 | namespace sw |
24 | { |
25 | struct Triangle MEMORY_SANITIZER_ONLY(: Memset<Triangle>) |
26 | { |
27 | #if MEMORY_SANITIZER_ENABLED |
28 | // Memory sanitizer cannot 'see' writes from JIT'd code, and can raise |
29 | // false-positives when read. By clearing the struct in the constructor, |
30 | // we can avoid triggering these false-positives. |
31 | inline Triangle() : Memset<Triangle>(this, 0) {} |
32 | #endif // MEMORY_SANITIZER_ENABLED |
33 | |
34 | Vertex v0; |
35 | Vertex v1; |
36 | Vertex v2; |
37 | }; |
38 | |
39 | struct PlaneEquation // z = A * x + B * y + C |
40 | { |
41 | float4 A; |
42 | float4 B; |
43 | float4 C; |
44 | }; |
45 | |
46 | struct Primitive MEMORY_SANITIZER_ONLY(: Memset<Primitive>) |
47 | { |
48 | #if MEMORY_SANITIZER_ENABLED |
49 | // Memory sanitizer cannot 'see' writes from JIT'd code, and can raise |
50 | // false-positives when read. By clearing the struct in the constructor, |
51 | // we can avoid triggering these false-positives. |
52 | inline Primitive() : Memset<Primitive>(this, 0) {} |
53 | #endif // MEMORY_SANITIZER_ENABLED |
54 | |
55 | int yMin; |
56 | int yMax; |
57 | |
58 | float4 xQuad; |
59 | float4 yQuad; |
60 | |
61 | float pointCoordX; |
62 | float pointCoordY; |
63 | |
64 | PlaneEquation z; |
65 | PlaneEquation w; |
66 | PlaneEquation V[MAX_INTERFACE_COMPONENTS]; |
67 | |
68 | // Masks for two-sided stencil |
69 | int64_t clockwiseMask; |
70 | int64_t invClockwiseMask; |
71 | |
72 | struct Span |
73 | { |
74 | unsigned short left; |
75 | unsigned short right; |
76 | }; |
77 | |
78 | // The rasterizer adds a zero length span to the top and bottom of the polygon to allow |
79 | // for 2x2 pixel processing. We need an even number of spans to keep accesses aligned. |
80 | Span outlineUnderflow[2]; |
81 | Span outline[OUTLINE_RESOLUTION]; |
82 | Span outlineOverflow[2]; |
83 | }; |
84 | } |
85 | |
86 | #endif // sw_Primitive_hpp |
87 | |