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 Vertex_hpp
16#define Vertex_hpp
17
18#include "Color.hpp"
19#include "Common/Types.hpp"
20#include "Main/Config.hpp"
21
22namespace sw
23{
24 enum Out
25 {
26 // Default vertex output semantics
27 Pos = 0,
28 C0 = 1, // Diffuse
29 C1 = 2, // Specular
30 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
40
41 // Variable semantics
42 V0 = 0,
43 Vn_1 = MAX_VERTEX_OUTPUTS - 1,
44
45 Unused,
46 VERTEX_OUTPUT_LAST = Unused,
47 };
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 {
68 // Position
69 float x;
70 float y;
71 float z;
72 float w;
73
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
80 };
81
82 float4 v[MAX_VERTEX_OUTPUTS]; // Generic components using semantic declaration
83 };
84
85 // Projected coordinates
86 int X;
87 int Y;
88 float Z;
89 float W;
90
91 int clipFlags;
92 int padding[3];
93 });
94
95 static_assert((sizeof(Vertex) & 0x0000000F) == 0, "Vertex size not a multiple of 16 bytes (alignment requirement)");
96}
97
98#endif // Vertex_hpp
99