blob: 9ae8d14346265a53afe08e42ea448e873aa338c0 [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 Vertex_hpp
16#define Vertex_hpp
17
18#include "Color.hpp"
Nicolas Capens0bac2852016-05-07 06:09:58 -040019#include "Common/Types.hpp"
Nicolas Capensec0936c2016-05-18 12:32:02 -040020#include "Main/Config.hpp"
Nicolas Capens0bac2852016-05-07 06:09:58 -040021
22namespace sw
23{
Nicolas Capensec0936c2016-05-18 12:32:02 -040024 enum Out
Nicolas Capens0bac2852016-05-07 06:09:58 -040025 {
Nicolas Capensec0936c2016-05-18 12:32:02 -040026 // Default vertex output semantics
Nicolas Capens0bac2852016-05-07 06:09:58 -040027 Pos = 0,
Nicolas Capens995ddea2016-05-17 11:48:56 -040028 C0 = 1, // Diffuse
29 C1 = 2, // Specular
Nicolas Capens0bac2852016-05-07 06:09:58 -040030 T0 = 3,
31 T1 = 4,
32 T2 = 5,
33 T3 = 6,
34 T4 = 7,
35 T5 = 8,
36 T6 = 9,
37 T7 = 10,
38 Fog = 11, // x component
39 Pts = Fog, // y component
Nicolas Capensec0936c2016-05-18 12:32:02 -040040
41 // Variable semantics
42 V0 = 0,
43 Vn_1 = MAX_VERTEX_OUTPUTS - 1,
44
45 Unused,
46 VERTEX_OUTPUT_LAST = Unused,
Nicolas Capens0bac2852016-05-07 06:09:58 -040047 };
48
49 struct UVWQ
50 {
51 float u;
52 float v;
53 float w;
54 float q;
55
56 float &operator[](int i)
57 {
58 return (&u)[i];
59 }
60 };
61
62 ALIGN(16, struct Vertex
63 {
64 union
65 {
66 struct // Fixed semantics
67 {
Nicolas Capens2543bd72016-05-17 13:04:01 -040068 // Position
69 float x;
70 float y;
71 float z;
72 float w;
Nicolas Capens0bac2852016-05-07 06:09:58 -040073
74 float4 C[2]; // Diffuse and specular color
75
76 UVWQ T[8]; // Texture coordinates
77
78 float f; // Fog
79 float pSize; // Point size
Nicolas Capens0bac2852016-05-07 06:09:58 -040080 };
81
Nicolas Capensec0936c2016-05-18 12:32:02 -040082 float4 v[MAX_VERTEX_OUTPUTS]; // Generic components using semantic declaration
Nicolas Capens0bac2852016-05-07 06:09:58 -040083 };
84
Nicolas Capens2543bd72016-05-17 13:04:01 -040085 // Projected coordinates
86 int X;
87 int Y;
88 float Z;
89 float W;
90
91 int clipFlags;
92 int padding[3];
Nicolas Capens0bac2852016-05-07 06:09:58 -040093 });
94
Nicolas Capensa26bade2016-05-27 13:19:49 -040095 static_assert((sizeof(Vertex) & 0x0000000F) == 0, "Vertex size not a multiple of 16 bytes (alignment requirement)");
Nicolas Capens0bac2852016-05-07 06:09:58 -040096}
97
98#endif // Vertex_hpp