yuzu-emu
/
yuzu
Archived
1
0
Fork 0

maxwell_3d: Add VertexAttribute struct and cleanup.

This commit is contained in:
bunnei 2018-03-24 16:26:14 -04:00
parent 0ee38e1363
commit 15925b8293
1 changed files with 160 additions and 121 deletions

View File

@ -60,88 +60,169 @@ public:
Fragment = 4, Fragment = 4,
}; };
enum class VertexSize : u32 { struct VertexAttribute {
Size_32_32_32_32 = 0x01, enum class Size : u32 {
Size_32_32_32 = 0x02, Size_32_32_32_32 = 0x01,
Size_16_16_16_16 = 0x03, Size_32_32_32 = 0x02,
Size_32_32 = 0x04, Size_16_16_16_16 = 0x03,
Size_16_16_16 = 0x05, Size_32_32 = 0x04,
Size_8_8_8_8 = 0x0a, Size_16_16_16 = 0x05,
Size_16_16 = 0x0f, Size_8_8_8_8 = 0x0a,
Size_32 = 0x12, Size_16_16 = 0x0f,
Size_8_8_8 = 0x13, Size_32 = 0x12,
Size_8_8 = 0x18, Size_8_8_8 = 0x13,
Size_16 = 0x1b, Size_8_8 = 0x18,
Size_8 = 0x1d, Size_16 = 0x1b,
Size_10_10_10_2 = 0x30, Size_8 = 0x1d,
Size_11_11_10 = 0x31, Size_10_10_10_2 = 0x30,
}; Size_11_11_10 = 0x31,
};
static std::string VertexSizeToString(VertexSize vertex_size) { enum class Type : u32 {
switch (vertex_size) { SignedNorm = 1,
case VertexSize::Size_32_32_32_32: UnsignedNorm = 2,
return "32_32_32_32"; SignedInt = 3,
case VertexSize::Size_32_32_32: UnsignedInt = 4,
return "32_32_32"; UnsignedScaled = 5,
case VertexSize::Size_16_16_16_16: SignedScaled = 6,
return "16_16_16_16"; Float = 7,
case VertexSize::Size_32_32: };
return "32_32";
case VertexSize::Size_16_16_16: union {
return "16_16_16"; BitField<0, 5, u32> buffer;
case VertexSize::Size_8_8_8_8: BitField<6, 1, u32> constant;
return "8_8_8_8"; BitField<7, 14, u32> offset;
case VertexSize::Size_16_16: BitField<21, 6, Size> size;
return "16_16"; BitField<27, 3, Type> type;
case VertexSize::Size_32: BitField<31, 1, u32> bgra;
return "32"; };
case VertexSize::Size_8_8_8:
return "8_8_8"; u32 ComponentCount() const {
case VertexSize::Size_8_8: switch (size) {
return "8_8"; case Size::Size_32_32_32_32:
case VertexSize::Size_16: return 4;
return "16"; case Size::Size_32_32_32:
case VertexSize::Size_8: return 3;
return "8"; case Size::Size_16_16_16_16:
case VertexSize::Size_10_10_10_2: return 4;
return "10_10_10_2"; case Size::Size_32_32:
case VertexSize::Size_11_11_10: return 2;
return "11_11_10"; case Size::Size_16_16_16:
return 3;
case Size::Size_8_8_8_8:
return 4;
case Size::Size_16_16:
return 2;
case Size::Size_32:
return 1;
case Size::Size_8_8_8:
return 3;
case Size::Size_8_8:
return 2;
case Size::Size_16:
return 1;
case Size::Size_8:
return 1;
case Size::Size_10_10_10_2:
return 4;
case Size::Size_11_11_10:
return 3;
default:
UNREACHABLE();
}
} }
UNIMPLEMENTED();
return {};
}
enum class VertexType : u32 { u32 SizeInBytes() const {
SignedNorm = 1, switch (size) {
UnsignedNorm = 2, case Size::Size_32_32_32_32:
SignedInt = 3, return 16;
UnsignedInt = 4, case Size::Size_32_32_32:
UnsignedScaled = 5, return 12;
SignedScaled = 6, case Size::Size_16_16_16_16:
Float = 7, return 8;
}; case Size::Size_32_32:
return 8;
static std::string VertexTypeToString(VertexType vertex_type) { case Size::Size_16_16_16:
switch (vertex_type) { return 6;
case VertexType::SignedNorm: case Size::Size_8_8_8_8:
return "SignedNorm"; return 4;
case VertexType::UnsignedNorm: case Size::Size_16_16:
return "UnsignedNorm"; return 4;
case VertexType::SignedInt: case Size::Size_32:
return "SignedInt"; return 4;
case VertexType::UnsignedInt: case Size::Size_8_8_8:
return "UnsignedInt"; return 3;
case VertexType::UnsignedScaled: case Size::Size_8_8:
return "UnsignedScaled"; return 2;
case VertexType::SignedScaled: case Size::Size_16:
return "SignedScaled"; return 2;
case VertexType::Float: case Size::Size_8:
return "Float"; return 1;
case Size::Size_10_10_10_2:
return 4;
case Size::Size_11_11_10:
return 4;
default:
UNREACHABLE();
}
} }
UNIMPLEMENTED();
return {}; std::string SizeString() const {
} switch (size) {
case Size::Size_32_32_32_32:
return "32_32_32_32";
case Size::Size_32_32_32:
return "32_32_32";
case Size::Size_16_16_16_16:
return "16_16_16_16";
case Size::Size_32_32:
return "32_32";
case Size::Size_16_16_16:
return "16_16_16";
case Size::Size_8_8_8_8:
return "8_8_8_8";
case Size::Size_16_16:
return "16_16";
case Size::Size_32:
return "32";
case Size::Size_8_8_8:
return "8_8_8";
case Size::Size_8_8:
return "8_8";
case Size::Size_16:
return "16";
case Size::Size_8:
return "8";
case Size::Size_10_10_10_2:
return "10_10_10_2";
case Size::Size_11_11_10:
return "11_11_10";
}
UNREACHABLE();
return {};
}
std::string TypeToString() const {
switch (type) {
case Type::SignedNorm:
return "SignedNorm";
case Type::UnsignedNorm:
return "UnsignedNorm";
case Type::SignedInt:
return "SignedInt";
case Type::UnsignedInt:
return "UnsignedInt";
case Type::UnsignedScaled:
return "UnsignedScaled";
case Type::SignedScaled:
return "SignedScaled";
case Type::Float:
return "Float";
}
UNREACHABLE();
return {};
}
};
enum class PrimitiveTopology : u32 { enum class PrimitiveTopology : u32 {
Points = 0x0, Points = 0x0,
@ -222,49 +303,7 @@ public:
INSERT_PADDING_WORDS(0x5B); INSERT_PADDING_WORDS(0x5B);
union { VertexAttribute vertex_attrib_format[NumVertexAttributes];
BitField<0, 5, u32> buffer;
BitField<6, 1, u32> constant;
BitField<7, 14, u32> offset;
BitField<21, 6, VertexSize> size;
BitField<27, 3, VertexType> type;
BitField<31, 1, u32> bgra;
u32 SizeInBytes() const {
switch (size) {
case VertexSize::Size_32_32_32_32:
return 16;
case VertexSize::Size_32_32_32:
return 12;
case VertexSize::Size_16_16_16_16:
return 8;
case VertexSize::Size_32_32:
return 8;
case VertexSize::Size_16_16_16:
return 6;
case VertexSize::Size_8_8_8_8:
return 4;
case VertexSize::Size_16_16:
return 4;
case VertexSize::Size_32:
return 4;
case VertexSize::Size_8_8_8:
return 3;
case VertexSize::Size_8_8:
return 2;
case VertexSize::Size_16:
return 2;
case VertexSize::Size_8:
return 1;
case VertexSize::Size_10_10_10_2:
return 4;
case VertexSize::Size_11_11_10:
return 4;
default:
UNREACHABLE();
}
}
} vertex_attrib_format[NumVertexAttributes];
INSERT_PADDING_WORDS(0xF); INSERT_PADDING_WORDS(0xF);