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 "Device/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 float pointCoordX; 46 float pointCoordY; 47 float pointSizeInv; 48 49 PlaneEquation z; 50 float4 zBias; 51 PlaneEquation w; 52 PlaneEquation V[MAX_INTERFACE_COMPONENTS]; 53 54 PlaneEquation clipDistance[MAX_CLIP_DISTANCES]; 55 PlaneEquation cullDistance[MAX_CULL_DISTANCES]; 56 57 // Masks for two-sided stencil 58 int64_t clockwiseMask; 59 int64_t invClockwiseMask; 60 61 struct Span 62 { 63 unsigned short left; 64 unsigned short right; 65 }; 66 67 // The rasterizer adds a zero length span to the top and bottom of the polygon to allow 68 // for 2x2 pixel processing. We need an even number of spans to keep accesses aligned. 69 Span outlineUnderflow[2]; 70 Span outline[OUTLINE_RESOLUTION]; 71 Span outlineOverflow[2]; 72 }; 73 74 } // namespace sw 75 76 #endif // sw_Primitive_hpp 77