Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -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 | |
| 18 | #include "Vertex.hpp" |
Nicolas Capens | 708c24b | 2017-10-26 13:07:10 -0400 | [diff] [blame] | 19 | #include "Main/Config.hpp" |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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]; |
Nicolas Capens | 3b4c93f | 2016-05-18 12:51:37 -0400 | [diff] [blame] | 54 | PlaneEquation f; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 55 | }; |
| 56 | |
Nicolas Capens | 3b4c93f | 2016-05-18 12:51:37 -0400 | [diff] [blame] | 57 | PlaneEquation V[MAX_FRAGMENT_INPUTS][4]; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 58 | }; |
| 59 | |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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 | |
Nicolas Capens | ac6e751 | 2017-04-28 12:50:58 -0400 | [diff] [blame] | 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]; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 75 | Span outline[OUTLINE_RESOLUTION]; |
Nicolas Capens | ac6e751 | 2017-04-28 12:50:58 -0400 | [diff] [blame] | 76 | Span outlineOverflow[2]; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 77 | }; |
| 78 | } |
| 79 | |
| 80 | #endif // sw_Primitive_hpp |