Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 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 | |
Ben Clayton | eea9d35 | 2019-08-29 01:05:14 +0100 | [diff] [blame] | 18 | #include "Memset.hpp" |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 19 | #include "Vertex.hpp" |
Nicolas Capens | 1d8c8db | 2018-11-05 16:30:42 -0500 | [diff] [blame] | 20 | #include "Device/Config.hpp" |
Ben Clayton | eea9d35 | 2019-08-29 01:05:14 +0100 | [diff] [blame] | 21 | #include "System/Build.hpp" |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 22 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 23 | namespace sw { |
| 24 | |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 25 | struct Triangle MEMORY_SANITIZER_ONLY( |
| 26 | : Memset<Triangle>) |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 27 | { |
Ben Clayton | eea9d35 | 2019-08-29 01:05:14 +0100 | [diff] [blame] | 28 | #if MEMORY_SANITIZER_ENABLED |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 29 | // Memory sanitizer cannot 'see' writes from JIT'd code, and can raise |
| 30 | // false-positives when read. By clearing the struct in the constructor, |
| 31 | // we can avoid triggering these false-positives. |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 32 | inline Triangle() |
| 33 | : Memset<Triangle>(this, 0) |
| 34 | {} |
| 35 | #endif // MEMORY_SANITIZER_ENABLED |
Ben Clayton | eea9d35 | 2019-08-29 01:05:14 +0100 | [diff] [blame] | 36 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 37 | Vertex v0; |
| 38 | Vertex v1; |
| 39 | Vertex v2; |
| 40 | }; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 41 | |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 42 | struct PlaneEquation // z = A * x + B * y + C |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 43 | { |
| 44 | float4 A; |
| 45 | float4 B; |
| 46 | float4 C; |
| 47 | }; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 48 | |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 49 | struct Primitive MEMORY_SANITIZER_ONLY( |
| 50 | : Memset<Primitive>) |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 51 | { |
Ben Clayton | eea9d35 | 2019-08-29 01:05:14 +0100 | [diff] [blame] | 52 | #if MEMORY_SANITIZER_ENABLED |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 53 | // Memory sanitizer cannot 'see' writes from JIT'd code, and can raise |
| 54 | // false-positives when read. By clearing the struct in the constructor, |
| 55 | // we can avoid triggering these false-positives. |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 56 | inline Primitive() |
| 57 | : Memset<Primitive>(this, 0) |
| 58 | {} |
| 59 | #endif // MEMORY_SANITIZER_ENABLED |
Ben Clayton | eea9d35 | 2019-08-29 01:05:14 +0100 | [diff] [blame] | 60 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 61 | int yMin; |
| 62 | int yMax; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 63 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 64 | float4 xQuad; |
| 65 | float4 yQuad; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 66 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 67 | float pointCoordX; |
| 68 | float pointCoordY; |
Marc-Antoine Desroches | b44162f | 2020-03-05 13:35:43 -0500 | [diff] [blame] | 69 | float pointSizeInv; |
Alexis Hetu | 95b1db9 | 2019-05-27 17:40:39 -0400 | [diff] [blame] | 70 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 71 | PlaneEquation z; |
| 72 | PlaneEquation w; |
| 73 | PlaneEquation V[MAX_INTERFACE_COMPONENTS]; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 74 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 75 | PlaneEquation clipDistance[MAX_CLIP_DISTANCES]; |
| 76 | PlaneEquation cullDistance[MAX_CULL_DISTANCES]; |
Ben Clayton | 9ad035b | 2019-08-09 23:44:09 +0100 | [diff] [blame] | 77 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 78 | // Masks for two-sided stencil |
| 79 | int64_t clockwiseMask; |
| 80 | int64_t invClockwiseMask; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 81 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 82 | struct Span |
| 83 | { |
| 84 | unsigned short left; |
| 85 | unsigned short right; |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 86 | }; |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 87 | |
| 88 | // The rasterizer adds a zero length span to the top and bottom of the polygon to allow |
| 89 | // for 2x2 pixel processing. We need an even number of spans to keep accesses aligned. |
| 90 | Span outlineUnderflow[2]; |
| 91 | Span outline[OUTLINE_RESOLUTION]; |
| 92 | Span outlineOverflow[2]; |
| 93 | }; |
| 94 | |
| 95 | } // namespace sw |
Nicolas Capens | 68a8238 | 2018-10-02 13:16:55 -0400 | [diff] [blame] | 96 | |
Ben Clayton | fccfc56 | 2019-12-17 20:37:31 +0000 | [diff] [blame] | 97 | #endif // sw_Primitive_hpp |