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 float A; 33 float B; 34 float C; 35 }; 36 37 struct Primitive 38 { 39 int yMin; 40 int yMax; 41 42 float x0; 43 float y0; 44 45 float pointSizeInv; 46 47 PlaneEquation z; 48 float zBias; 49 PlaneEquation w; 50 PlaneEquation V[MAX_INTERFACE_COMPONENTS]; 51 52 PlaneEquation clipDistance[MAX_CLIP_DISTANCES]; 53 PlaneEquation cullDistance[MAX_CULL_DISTANCES]; 54 55 // Masks for two-sided stencil 56 int64_t clockwiseMask; 57 int64_t invClockwiseMask; 58 59 struct Span 60 { 61 unsigned short left; 62 unsigned short right; 63 }; 64 65 // The rasterizer adds a zero length span to the top and bottom of the polygon to allow 66 // for 2x2 pixel processing. We need an even number of spans to keep accesses aligned. 67 Span outlineUnderflow[2]; 68 Span outline[OUTLINE_RESOLUTION]; 69 Span outlineOverflow[2]; 70 }; 71 72 } // namespace sw 73 74 #endif // sw_Primitive_hpp 75