[GPU] Allow dynamic building of GPU packets
This commit is contained in:
parent
14abe1a407
commit
9653c0bafc
|
@ -601,20 +601,18 @@ enum Type3Opcode {
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
template <uint16_t index, uint16_t count, bool one_reg = false>
|
inline uint32_t MakePacketType0(uint16_t index, uint16_t count,
|
||||||
constexpr inline uint32_t MakePacketType0() {
|
bool one_reg = false) {
|
||||||
// ttcccccc cccccccc oiiiiiii iiiiiiii
|
// ttcccccc cccccccc oiiiiiii iiiiiiii
|
||||||
static_assert(index <= 0x7FFF, "index must be <= 0x7FFF");
|
assert(index <= 0x7FFF);
|
||||||
static_assert(count >= 1 && count <= 0x4000,
|
assert(count >= 1 && count <= 0x4000);
|
||||||
"count must be >= 1 and <= 0x4000");
|
|
||||||
return (0u << 30) | (((count - 1) & 0x3FFF) << 16) | (index & 0x7FFF);
|
return (0u << 30) | (((count - 1) & 0x3FFF) << 16) | (index & 0x7FFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <uint16_t index_1, uint16_t index_2>
|
inline uint32_t MakePacketType1(uint16_t index_1, uint16_t index_2) {
|
||||||
constexpr inline uint32_t MakePacketType1() {
|
|
||||||
// tt?????? ??222222 22222111 11111111
|
// tt?????? ??222222 22222111 11111111
|
||||||
static_assert(index_1 <= 0x7FF, "index_1 must be <= 0x7FF");
|
assert(index_1 <= 0x7FF);
|
||||||
static_assert(index_2 <= 0x7FF, "index_2 must be <= 0x7FF");
|
assert(index_2 <= 0x7FF);
|
||||||
return (1u << 30) | ((index_2 & 0x7FF) << 11) | (index_1 & 0x7FF);
|
return (1u << 30) | ((index_2 & 0x7FF) << 11) | (index_1 & 0x7FF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,12 +621,11 @@ constexpr inline uint32_t MakePacketType2() {
|
||||||
return (2u << 30);
|
return (2u << 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <Type3Opcode opcode, uint16_t count, bool predicate = false>
|
inline uint32_t MakePacketType3(Type3Opcode opcode, uint16_t count,
|
||||||
constexpr inline uint32_t MakePacketType3() {
|
bool predicate = false) {
|
||||||
// ttcccccc cccccccc ?ooooooo ???????p
|
// ttcccccc cccccccc ?ooooooo ???????p
|
||||||
static_assert(opcode <= 0x7F, "opcode must be <= 0x7F");
|
assert(opcode <= 0x7F);
|
||||||
static_assert(count >= 1 && count <= 0x4000,
|
assert(count >= 1 && count <= 0x4000);
|
||||||
"count must be >= 1 and <= 0x4000");
|
|
||||||
return (3u << 30) | (((count - 1) & 0x3FFF) << 16) | ((opcode & 0x7F) << 8) |
|
return (3u << 30) | (((count - 1) & 0x3FFF) << 16) | ((opcode & 0x7F) << 8) |
|
||||||
(predicate ? 1 : 0);
|
(predicate ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,7 @@ void VdSwap(lpvoid_t buffer_ptr, // ptr into primary ringbuffer
|
||||||
|
|
||||||
// Write in the texture fetch.
|
// Write in the texture fetch.
|
||||||
dwords[offset++] =
|
dwords[offset++] =
|
||||||
xenos::MakePacketType0<gpu::XE_GPU_REG_SHADER_CONSTANT_FETCH_00_0, 6>();
|
xenos::MakePacketType0(gpu::XE_GPU_REG_SHADER_CONSTANT_FETCH_00_0, 6);
|
||||||
dwords[offset++] = fetch.dword_0;
|
dwords[offset++] = fetch.dword_0;
|
||||||
dwords[offset++] = fetch.dword_1;
|
dwords[offset++] = fetch.dword_1;
|
||||||
dwords[offset++] = fetch.dword_2;
|
dwords[offset++] = fetch.dword_2;
|
||||||
|
@ -382,7 +382,7 @@ void VdSwap(lpvoid_t buffer_ptr, // ptr into primary ringbuffer
|
||||||
dwords[offset++] = fetch.dword_4;
|
dwords[offset++] = fetch.dword_4;
|
||||||
dwords[offset++] = fetch.dword_5;
|
dwords[offset++] = fetch.dword_5;
|
||||||
|
|
||||||
dwords[offset++] = xenos::MakePacketType3<xenos::PM4_XE_SWAP, 4>();
|
dwords[offset++] = xenos::MakePacketType3(xenos::PM4_XE_SWAP, 4);
|
||||||
dwords[offset++] = 'SWAP';
|
dwords[offset++] = 'SWAP';
|
||||||
dwords[offset++] = (*frontbuffer_ptr) & 0x1FFFFFFF;
|
dwords[offset++] = (*frontbuffer_ptr) & 0x1FFFFFFF;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue