Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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" |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 19 | #include "Common/Types.hpp" |
Nicolas Capens | ec0936c | 2016-05-18 12:32:02 -0400 | [diff] [blame] | 20 | #include "Main/Config.hpp" |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 21 | |
| 22 | namespace sw |
| 23 | { |
Nicolas Capens | ec0936c | 2016-05-18 12:32:02 -0400 | [diff] [blame] | 24 | enum Out |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 25 | { |
Nicolas Capens | ec0936c | 2016-05-18 12:32:02 -0400 | [diff] [blame] | 26 | // Default vertex output semantics |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 27 | Pos = 0, |
Nicolas Capens | 995ddea | 2016-05-17 11:48:56 -0400 | [diff] [blame] | 28 | C0 = 1, // Diffuse |
| 29 | C1 = 2, // Specular |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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 |
Nicolas Capens | ec0936c | 2016-05-18 12:32:02 -0400 | [diff] [blame] | 40 | |
| 41 | // Variable semantics |
| 42 | V0 = 0, |
| 43 | Vn_1 = MAX_VERTEX_OUTPUTS - 1, |
| 44 | |
| 45 | Unused, |
| 46 | VERTEX_OUTPUT_LAST = Unused, |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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 | { |
Nicolas Capens | 2543bd7 | 2016-05-17 13:04:01 -0400 | [diff] [blame] | 68 | // Position |
| 69 | float x; |
| 70 | float y; |
| 71 | float z; |
| 72 | float w; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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 |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 80 | }; |
| 81 | |
Nicolas Capens | ec0936c | 2016-05-18 12:32:02 -0400 | [diff] [blame] | 82 | float4 v[MAX_VERTEX_OUTPUTS]; // Generic components using semantic declaration |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 83 | }; |
| 84 | |
Nicolas Capens | 2543bd7 | 2016-05-17 13:04:01 -0400 | [diff] [blame] | 85 | // Projected coordinates |
| 86 | int X; |
| 87 | int Y; |
| 88 | float Z; |
| 89 | float W; |
| 90 | |
| 91 | int clipFlags; |
| 92 | int padding[3]; |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 93 | }); |
| 94 | |
Nicolas Capens | a26bade | 2016-05-27 13:19:49 -0400 | [diff] [blame] | 95 | static_assert((sizeof(Vertex) & 0x0000000F) == 0, "Vertex size not a multiple of 16 bytes (alignment requirement)"); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | #endif // Vertex_hpp |