[GPU] Allow dynamic building of GPU packets

This commit is contained in:
DrChat
2018-04-03 19:08:30 -05:00
parent 14abe1a407
commit 9653c0bafc
2 changed files with 13 additions and 16 deletions

View File

@@ -601,20 +601,18 @@ enum Type3Opcode {
};
// clang-format on
template <uint16_t index, uint16_t count, bool one_reg = false>
constexpr inline uint32_t MakePacketType0() {
inline uint32_t MakePacketType0(uint16_t index, uint16_t count,
bool one_reg = false) {
// ttcccccc cccccccc oiiiiiii iiiiiiii
static_assert(index <= 0x7FFF, "index must be <= 0x7FFF");
static_assert(count >= 1 && count <= 0x4000,
"count must be >= 1 and <= 0x4000");
assert(index <= 0x7FFF);
assert(count >= 1 && count <= 0x4000);
return (0u << 30) | (((count - 1) & 0x3FFF) << 16) | (index & 0x7FFF);
}
template <uint16_t index_1, uint16_t index_2>
constexpr inline uint32_t MakePacketType1() {
inline uint32_t MakePacketType1(uint16_t index_1, uint16_t index_2) {
// tt?????? ??222222 22222111 11111111
static_assert(index_1 <= 0x7FF, "index_1 must be <= 0x7FF");
static_assert(index_2 <= 0x7FF, "index_2 must be <= 0x7FF");
assert(index_1 <= 0x7FF);
assert(index_2 <= 0x7FF);
return (1u << 30) | ((index_2 & 0x7FF) << 11) | (index_1 & 0x7FF);
}
@@ -623,12 +621,11 @@ constexpr inline uint32_t MakePacketType2() {
return (2u << 30);
}
template <Type3Opcode opcode, uint16_t count, bool predicate = false>
constexpr inline uint32_t MakePacketType3() {
inline uint32_t MakePacketType3(Type3Opcode opcode, uint16_t count,
bool predicate = false) {
// ttcccccc cccccccc ?ooooooo ???????p
static_assert(opcode <= 0x7F, "opcode must be <= 0x7F");
static_assert(count >= 1 && count <= 0x4000,
"count must be >= 1 and <= 0x4000");
assert(opcode <= 0x7F);
assert(count >= 1 && count <= 0x4000);
return (3u << 30) | (((count - 1) & 0x3FFF) << 16) | ((opcode & 0x7F) << 8) |
(predicate ? 1 : 0);
}