gpu: Refactor command and swap buffers interface for asynch.

This commit is contained in:
bunnei
2019-01-07 23:53:48 -05:00
parent 85b2c3b051
commit 208c599463
7 changed files with 37 additions and 20 deletions

View File

@@ -17,6 +17,13 @@ DmaPusher::~DmaPusher() = default;
MICROPROFILE_DEFINE(DispatchCalls, "GPU", "Execute command buffer", MP_RGB(128, 128, 192));
void DmaPusher::QueuePendingCalls() {
for (auto& entry : dma_writebuffer) {
dma_readbuffer.push(std::move(entry));
}
dma_writebuffer.clear();
}
void DmaPusher::DispatchCalls() {
MICROPROFILE_SCOPE(DispatchCalls);
@@ -89,9 +96,9 @@ bool DmaPusher::Step() {
break;
}
}
} else if (ib_enable && !dma_pushbuffer.empty()) {
} else if (ib_enable && !dma_readbuffer.empty()) {
// Current pushbuffer empty, but we have more IB entries to read
const CommandList& command_list{dma_pushbuffer.front()};
const CommandList& command_list{dma_readbuffer.front()};
const CommandListHeader& command_list_header{command_list[dma_pushbuffer_subindex++]};
dma_get = command_list_header.addr;
dma_put = dma_get + command_list_header.size * sizeof(u32);
@@ -99,7 +106,7 @@ bool DmaPusher::Step() {
if (dma_pushbuffer_subindex >= command_list.size()) {
// We've gone through the current list, remove it from the queue
dma_pushbuffer.pop();
dma_readbuffer.pop();
dma_pushbuffer_subindex = 0;
}
} else {

View File

@@ -61,9 +61,10 @@ public:
~DmaPusher();
void Push(CommandList&& entries) {
dma_pushbuffer.push(std::move(entries));
dma_writebuffer.push_back(std::move(entries));
}
void QueuePendingCalls();
void DispatchCalls();
private:
@@ -75,8 +76,9 @@ private:
GPU& gpu;
std::queue<CommandList> dma_pushbuffer; ///< Queue of command lists to be processed
std::size_t dma_pushbuffer_subindex{}; ///< Index within a command list within the pushbuffer
std::vector<CommandList> dma_writebuffer;
std::queue<CommandList> dma_readbuffer;
std::size_t dma_pushbuffer_subindex{}; ///< Index within a command list within the pushbuffer
struct DmaState {
u32 method; ///< Current method

View File

@@ -61,6 +61,17 @@ const DmaPusher& GPU::DmaPusher() const {
return *dma_pusher;
}
void GPU::PushGPUEntries(Tegra::CommandList&& entries) {
dma_pusher->Push(std::move(entries));
dma_pusher->QueuePendingCalls();
dma_pusher->DispatchCalls();
}
void GPU::SwapBuffers(
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer) {
renderer.SwapBuffers(std::move(framebuffer));
}
u32 RenderTargetBytesPerPixel(RenderTargetFormat format) {
ASSERT(format != RenderTargetFormat::NONE);

View File

@@ -156,6 +156,13 @@ public:
/// Returns a const reference to the GPU DMA pusher.
const Tegra::DmaPusher& DmaPusher() const;
/// Push GPU command entries to be processed
void PushGPUEntries(Tegra::CommandList&& entries);
/// Swap buffers (render frame)
void SwapBuffers(
std::optional<std::reference_wrapper<const Tegra::FramebufferConfig>> framebuffer);
private:
std::unique_ptr<Tegra::DmaPusher> dma_pusher;
std::unique_ptr<Tegra::MemoryManager> memory_manager;