mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-29 23:03:18 +00:00
video_core: Added copyGPUCmdBuffers option
This commit is contained in:
parent
3eb47226d9
commit
659e7a4675
4 changed files with 58 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
#include "common/debug.h"
|
||||
#include "common/polyfill_thread.h"
|
||||
#include "common/thread.h"
|
||||
#include "common/config.h"
|
||||
#include "core/libraries/videoout/driver.h"
|
||||
#include "video_core/amdgpu/liverpool.h"
|
||||
#include "video_core/amdgpu/pm4_cmds.h"
|
||||
|
@ -568,9 +569,45 @@ Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, int vqid) {
|
|||
TracyFiberLeave;
|
||||
}
|
||||
|
||||
void Liverpool::CopyCmdBuffers(std::span<const u32>& dcb, std::span<const u32>& ccb) {
|
||||
auto& queue = mapped_queues[GfxQueueId];
|
||||
|
||||
// This is fine because resize doesn't reallocate the buffer on shrink
|
||||
queue.dcb_buffer.resize(queue.dcb_buffer_offset + dcb.size());
|
||||
queue.ccb_buffer.resize(queue.ccb_buffer_offset + dcb.size());
|
||||
|
||||
u32 prev_dcb_buffer_offset = queue.dcb_buffer_offset;
|
||||
u32 prev_ccb_buffer_offset = queue.ccb_buffer_offset;
|
||||
if (!dcb.empty()) {
|
||||
std::memcpy(queue.dcb_buffer.data() + queue.dcb_buffer_offset, dcb.data(),
|
||||
dcb.size_bytes());
|
||||
queue.dcb_buffer_offset += dcb.size();
|
||||
}
|
||||
|
||||
if (!ccb.empty()) {
|
||||
std::memcpy(queue.ccb_buffer.data() + queue.ccb_buffer_offset, ccb.data(),
|
||||
ccb.size_bytes());
|
||||
queue.ccb_buffer_offset += dcb.size();
|
||||
}
|
||||
|
||||
if (!queue.dcb_buffer.empty()) {
|
||||
dcb = std::span<const u32>{queue.dcb_buffer.begin() + prev_dcb_buffer_offset,
|
||||
queue.dcb_buffer.begin() + queue.dcb_buffer_offset};
|
||||
}
|
||||
|
||||
if (!queue.ccb_buffer.empty()) {
|
||||
ccb = std::span<const u32>{queue.ccb_buffer.begin() + prev_ccb_buffer_offset,
|
||||
queue.ccb_buffer.begin() + queue.ccb_buffer_offset};
|
||||
}
|
||||
}
|
||||
|
||||
void Liverpool::SubmitGfx(std::span<const u32> dcb, std::span<const u32> ccb) {
|
||||
auto& queue = mapped_queues[GfxQueueId];
|
||||
|
||||
if (Config::copyGPUCmdBuffers()) {
|
||||
CopyCmdBuffers(dcb, ccb);
|
||||
}
|
||||
|
||||
auto task = ProcessGraphics(dcb, ccb);
|
||||
{
|
||||
std::scoped_lock lock{queue.m_access};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <span>
|
||||
#include <thread>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/bit_field.h"
|
||||
|
@ -1047,6 +1048,8 @@ public:
|
|||
|
||||
void SubmitDone() noexcept {
|
||||
std::scoped_lock lk{submit_mutex};
|
||||
mapped_queues[GfxQueueId].ccb_buffer_offset = 0;
|
||||
mapped_queues[GfxQueueId].dcb_buffer_offset = 0;
|
||||
submit_done = true;
|
||||
submit_cv.notify_one();
|
||||
}
|
||||
|
@ -1108,6 +1111,7 @@ private:
|
|||
Handle handle;
|
||||
};
|
||||
|
||||
void CopyCmdBuffers(std::span<const u32>& dcb, std::span<const u32>& ccb);
|
||||
Task ProcessGraphics(std::span<const u32> dcb, std::span<const u32> ccb);
|
||||
Task ProcessCeUpdate(std::span<const u32> ccb);
|
||||
Task ProcessCompute(std::span<const u32> acb, int vqid);
|
||||
|
@ -1116,6 +1120,10 @@ private:
|
|||
|
||||
struct GpuQueue {
|
||||
std::mutex m_access{};
|
||||
std::atomic_uint32_t dcb_buffer_offset;
|
||||
std::atomic_uint32_t ccb_buffer_offset;
|
||||
std::vector<u32> dcb_buffer;
|
||||
std::vector<u32> ccb_buffer;
|
||||
std::queue<Task::Handle> submits{};
|
||||
ComputeProgram cs_state{};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue