blob: 52daa1849d6f90fb83672d43717e7f7c98cc0e13 [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// 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 Capens708c24b2017-10-26 13:07:10 -040019#include "Main/Config.hpp"
Nicolas Capens0bac2852016-05-07 06:09:58 -040020
21namespace 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 Capens3b4c93f2016-05-18 12:51:37 -040054 PlaneEquation f;
Nicolas Capens0bac2852016-05-07 06:09:58 -040055 };
56
Nicolas Capens3b4c93f2016-05-18 12:51:37 -040057 PlaneEquation V[MAX_FRAGMENT_INPUTS][4];
Nicolas Capens0bac2852016-05-07 06:09:58 -040058 };
59
Nicolas Capens0bac2852016-05-07 06:09:58 -040060 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 Capensac6e7512017-04-28 12:50:58 -040072 // 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 Capens0bac2852016-05-07 06:09:58 -040075 Span outline[OUTLINE_RESOLUTION];
Nicolas Capensac6e7512017-04-28 12:50:58 -040076 Span outlineOverflow[2];
Nicolas Capens0bac2852016-05-07 06:09:58 -040077 };
78}
79
80#endif // sw_Primitive_hpp