mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 22:06:59 +01:00
renderdoc: fix
This commit is contained in:
@@ -199,17 +199,6 @@ void GuestGpu::Done() {
|
|||||||
if (!IsGpuThread()) {
|
if (!IsGpuThread()) {
|
||||||
WaitForIdle();
|
WaitForIdle();
|
||||||
}
|
}
|
||||||
if (RenderDocCaptureInProgress()) {
|
|
||||||
SendCommandSync([this] {
|
|
||||||
Common::LockGuard render_lock(m_renderer.GetMutex());
|
|
||||||
RenderDocEndCapture();
|
|
||||||
});
|
|
||||||
} else if (RenderDocCaptureRequested()) {
|
|
||||||
SendCommandSync([this] {
|
|
||||||
Common::LockGuard render_lock(m_renderer.GetMutex());
|
|
||||||
RenderDocStartCapture();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
m_graphics_done = true;
|
m_graphics_done = true;
|
||||||
m_done_num++;
|
m_done_num++;
|
||||||
}
|
}
|
||||||
@@ -571,6 +560,10 @@ void GuestGpu::ThreadRun(void* data) {
|
|||||||
|
|
||||||
bool GuestGpu::Process(Submission& submission) {
|
bool GuestGpu::Process(Submission& submission) {
|
||||||
const bool first_slice = !submission.started;
|
const bool first_slice = !submission.started;
|
||||||
|
if (first_slice && RenderDocCaptureRequested()) {
|
||||||
|
Common::LockGuard render_lock(m_renderer.GetMutex());
|
||||||
|
RenderDocStartCapture();
|
||||||
|
}
|
||||||
auto& cp = GetProcessor(submission.queue_id);
|
auto& cp = GetProcessor(submission.queue_id);
|
||||||
|
|
||||||
if (first_slice && submission.reset_processor) {
|
if (first_slice && submission.reset_processor) {
|
||||||
|
|||||||
@@ -25,11 +25,13 @@ namespace Libs::Graphics {
|
|||||||
enum class RenderDocState : uint32_t {
|
enum class RenderDocState : uint32_t {
|
||||||
Idle,
|
Idle,
|
||||||
Requested,
|
Requested,
|
||||||
|
Starting,
|
||||||
Capturing,
|
Capturing,
|
||||||
};
|
};
|
||||||
|
|
||||||
static RENDERDOC_API_1_6_0* g_api = nullptr;
|
static RENDERDOC_API_1_6_0* g_api = nullptr;
|
||||||
static std::atomic<RenderDocState> g_state = RenderDocState::Idle;
|
static std::atomic<RenderDocState> g_state = RenderDocState::Idle;
|
||||||
|
static std::atomic_uint32_t g_captured_flips = 0;
|
||||||
static std::atomic_bool g_unavailable_log = false;
|
static std::atomic_bool g_unavailable_log = false;
|
||||||
|
|
||||||
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS
|
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS
|
||||||
@@ -140,7 +142,7 @@ bool RenderDocCaptureInProgress() {
|
|||||||
|
|
||||||
void RenderDocStartCapture() {
|
void RenderDocStartCapture() {
|
||||||
RenderDocState expected = RenderDocState::Requested;
|
RenderDocState expected = RenderDocState::Requested;
|
||||||
if (g_api == nullptr || !g_state.compare_exchange_strong(expected, RenderDocState::Capturing,
|
if (g_api == nullptr || !g_state.compare_exchange_strong(expected, RenderDocState::Starting,
|
||||||
std::memory_order_acq_rel)) {
|
std::memory_order_acq_rel)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -162,6 +164,8 @@ void RenderDocStartCapture() {
|
|||||||
LOGF("RenderDoc: capture failed to start\n");
|
LOGF("RenderDoc: capture failed to start\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
g_captured_flips.store(0, std::memory_order_release);
|
||||||
|
g_state.store(RenderDocState::Capturing, std::memory_order_release);
|
||||||
LOGF("RenderDoc: capture started\n");
|
LOGF("RenderDoc: capture started\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,4 +179,15 @@ void RenderDocEndCapture() {
|
|||||||
LOGF(ok != 0 ? "RenderDoc: capture finished\n" : "RenderDoc: capture failed\n");
|
LOGF(ok != 0 ? "RenderDoc: capture finished\n" : "RenderDoc: capture failed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderDocOnGuestFlip() {
|
||||||
|
if (!RenderDocCaptureInProgress()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto flip = g_captured_flips.fetch_add(1, std::memory_order_acq_rel) + 1;
|
||||||
|
LOGF("RenderDoc: captured guest flip %u/2\n", flip);
|
||||||
|
if (flip >= 2) {
|
||||||
|
RenderDocEndCapture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Libs::Graphics
|
} // namespace Libs::Graphics
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ void RenderDocInit();
|
|||||||
void RenderDocRequestCapture();
|
void RenderDocRequestCapture();
|
||||||
void RenderDocStartCapture();
|
void RenderDocStartCapture();
|
||||||
void RenderDocEndCapture();
|
void RenderDocEndCapture();
|
||||||
|
void RenderDocOnGuestFlip();
|
||||||
|
|
||||||
[[nodiscard]] bool RenderDocCaptureRequested();
|
[[nodiscard]] bool RenderDocCaptureRequested();
|
||||||
[[nodiscard]] bool RenderDocCaptureInProgress();
|
[[nodiscard]] bool RenderDocCaptureInProgress();
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "graphics/host_gpu/renderer/render.h"
|
#include "graphics/host_gpu/renderer/render.h"
|
||||||
#include "graphics/host_gpu/renderer/renderContext.h"
|
#include "graphics/host_gpu/renderer/renderContext.h"
|
||||||
#include "graphics/presentation/presenter.h"
|
#include "graphics/presentation/presenter.h"
|
||||||
|
#include "graphics/presentation/renderDoc.h"
|
||||||
#include "kernel/pthread.h"
|
#include "kernel/pthread.h"
|
||||||
#include "libs/errno.h"
|
#include "libs/errno.h"
|
||||||
#include "libs/libs.h"
|
#include "libs/libs.h"
|
||||||
@@ -1127,6 +1128,7 @@ bool FlipQueue::Flip(uint32_t micros) {
|
|||||||
m_mutex.Unlock();
|
m_mutex.Unlock();
|
||||||
|
|
||||||
m_presenter.Present(*r.frame);
|
m_presenter.Present(*r.frame);
|
||||||
|
Graphics::RenderDocOnGuestFlip();
|
||||||
|
|
||||||
m_mutex.Lock();
|
m_mutex.Lock();
|
||||||
if (m_requests.empty() || m_requests.front().id != r.id ||
|
if (m_requests.empty() || m_requests.front().id != r.id ||
|
||||||
|
|||||||
Reference in New Issue
Block a user