mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 19:07:01 +02:00
renderdoc: fix
This commit is contained in:
@@ -25,11 +25,13 @@ namespace Libs::Graphics {
|
||||
enum class RenderDocState : uint32_t {
|
||||
Idle,
|
||||
Requested,
|
||||
Starting,
|
||||
Capturing,
|
||||
};
|
||||
|
||||
static RENDERDOC_API_1_6_0* g_api = nullptr;
|
||||
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;
|
||||
|
||||
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS
|
||||
@@ -140,7 +142,7 @@ bool RenderDocCaptureInProgress() {
|
||||
|
||||
void RenderDocStartCapture() {
|
||||
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)) {
|
||||
return;
|
||||
}
|
||||
@@ -162,6 +164,8 @@ void RenderDocStartCapture() {
|
||||
LOGF("RenderDoc: capture failed to start\n");
|
||||
return;
|
||||
}
|
||||
g_captured_flips.store(0, std::memory_order_release);
|
||||
g_state.store(RenderDocState::Capturing, std::memory_order_release);
|
||||
LOGF("RenderDoc: capture started\n");
|
||||
}
|
||||
|
||||
@@ -175,4 +179,15 @@ void RenderDocEndCapture() {
|
||||
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
|
||||
|
||||
@@ -7,6 +7,7 @@ void RenderDocInit();
|
||||
void RenderDocRequestCapture();
|
||||
void RenderDocStartCapture();
|
||||
void RenderDocEndCapture();
|
||||
void RenderDocOnGuestFlip();
|
||||
|
||||
[[nodiscard]] bool RenderDocCaptureRequested();
|
||||
[[nodiscard]] bool RenderDocCaptureInProgress();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "graphics/host_gpu/renderer/render.h"
|
||||
#include "graphics/host_gpu/renderer/renderContext.h"
|
||||
#include "graphics/presentation/presenter.h"
|
||||
#include "graphics/presentation/renderDoc.h"
|
||||
#include "kernel/pthread.h"
|
||||
#include "libs/errno.h"
|
||||
#include "libs/libs.h"
|
||||
@@ -1127,6 +1128,7 @@ bool FlipQueue::Flip(uint32_t micros) {
|
||||
m_mutex.Unlock();
|
||||
|
||||
m_presenter.Present(*r.frame);
|
||||
Graphics::RenderDocOnGuestFlip();
|
||||
|
||||
m_mutex.Lock();
|
||||
if (m_requests.empty() || m_requests.front().id != r.id ||
|
||||
|
||||
Reference in New Issue
Block a user