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( 26 : Memset<Triangle>) 27 { 28 #if MEMORY_SANITIZER_ENABLED 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. Trianglesw::MEMORY_SANITIZER_ONLY32 inline Triangle() 33 : Memset<Triangle>(this, 0) 34 {} 35 #endif // MEMORY_SANITIZER_ENABLED 36 37 Vertex v0; 38 Vertex v1; 39 Vertex v2; 40 }; 41 42 struct PlaneEquation // z = A * x + B * y + C 43 { 44 float4 A; 45 float4 B; 46 float4 C; 47 }; 48 49 struct Primitive MEMORY_SANITIZER_ONLY( 50 : Memset<Primitive>) 51 { 52 #if MEMORY_SANITIZER_ENABLED 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. Primitivesw::MEMORY_SANITIZER_ONLY56 inline Primitive() 57 : Memset<Primitive>(this, 0) 58 {} 59 #endif // MEMORY_SANITIZER_ENABLED 60 61 int yMin; 62 int yMax; 63 64 float4 xQuad; 65 float4 yQuad; 66 67 float pointCoordX; 68 float pointCoordY; 69 70 PlaneEquation z; 71 PlaneEquation w; 72 PlaneEquation V[MAX_INTERFACE_COMPONENTS]; 73 74 PlaneEquation clipDistance[MAX_CLIP_DISTANCES]; 75 PlaneEquation cullDistance[MAX_CULL_DISTANCES]; 76 77 // Masks for two-sided stencil 78 int64_t clockwiseMask; 79 int64_t invClockwiseMask; 80 81 struct Span 82 { 83 unsigned short left; 84 unsigned short right; 85 }; 86 87 // The rasterizer adds a zero length span to the top and bottom of the polygon to allow 88 // for 2x2 pixel processing. We need an even number of spans to keep accesses aligned. 89 Span outlineUnderflow[2]; 90 Span outline[OUTLINE_RESOLUTION]; 91 Span outlineOverflow[2]; 92 }; 93 94 } // namespace sw 95 96 #endif // sw_Primitive_hpp 97