mirror of
https://github.com/Takiiiiiiii/strato.git
synced 2025-07-17 08:46:39 +00:00
Support using in-app renderdoc API to capture individual executions
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
#include <common/settings.h>
|
||||
#include <loader/loader.h>
|
||||
#include <gpu.h>
|
||||
#include <dlfcn.h>
|
||||
#include "command_executor.h"
|
||||
|
||||
namespace skyline::gpu::interconnect {
|
||||
@ -92,6 +93,13 @@ namespace skyline::gpu::interconnect {
|
||||
void CommandRecordThread::Run() {
|
||||
auto &gpu{*state.gpu};
|
||||
|
||||
RENDERDOC_API_1_4_2 *renderDocApi{};
|
||||
if (void *mod{dlopen("libVkLayer_GLES_RenderDoc.so", RTLD_NOW | RTLD_NOLOAD)}) {
|
||||
auto *pfnGetApi{reinterpret_cast<pRENDERDOC_GetAPI>(dlsym(mod, "RENDERDOC_GetAPI"))};
|
||||
if (int ret{pfnGetApi(eRENDERDOC_API_Version_1_4_2, (void **)&renderDocApi)}; ret != 1)
|
||||
Logger::Warn("Failed to intialise RenderDoc API: {}", ret);
|
||||
}
|
||||
|
||||
std::vector<Slot> slots{};
|
||||
std::generate_n(std::back_inserter(slots), *state.settings->executorSlotCount, [&] () -> Slot { return gpu; });
|
||||
|
||||
@ -103,8 +111,17 @@ namespace skyline::gpu::interconnect {
|
||||
try {
|
||||
signal::SetSignalHandler({SIGINT, SIGILL, SIGTRAP, SIGBUS, SIGFPE, SIGSEGV}, signal::ExceptionalSignalHandler);
|
||||
|
||||
incoming.Process([this](Slot *slot) {
|
||||
incoming.Process([this, renderDocApi, &gpu](Slot *slot) {
|
||||
VkInstance instance{*gpu.vkInstance};
|
||||
if (renderDocApi && slot->capture)
|
||||
renderDocApi->StartFrameCapture(RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(instance), nullptr);
|
||||
|
||||
ProcessSlot(slot);
|
||||
|
||||
if (renderDocApi && slot->capture)
|
||||
renderDocApi->EndFrameCapture(RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(instance), nullptr);
|
||||
slot->capture = false;
|
||||
|
||||
outgoing.Push(slot);
|
||||
}, [] {});
|
||||
} catch (const signal::SignalException &e) {
|
||||
@ -144,11 +161,11 @@ namespace skyline::gpu::interconnect {
|
||||
|
||||
void CommandExecutor::RotateRecordSlot() {
|
||||
if (slot) {
|
||||
slot->capt = capt;
|
||||
slot->capture = captureNextExecution;
|
||||
recordThread.ReleaseSlot(slot);
|
||||
}
|
||||
|
||||
capt = false;
|
||||
captureNextExecution = false;
|
||||
slot = recordThread.AcquireSlot();
|
||||
cycle = slot->Reset(gpu);
|
||||
slot->executionNumber = executionNumber;
|
||||
|
@ -4,7 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/container/stable_vector.hpp>
|
||||
#include <unordered_set>
|
||||
#include <renderdoc_app.h>
|
||||
#include <common/linear_allocator.h>
|
||||
#include <gpu/megabuffer.h>
|
||||
#include "command_nodes.h"
|
||||
@ -15,7 +15,6 @@ namespace skyline::gpu::interconnect {
|
||||
*/
|
||||
class CommandRecordThread {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Single execution slot, buffered back and forth between the GPFIFO thread and the record thread
|
||||
*/
|
||||
@ -28,6 +27,7 @@ namespace skyline::gpu::interconnect {
|
||||
boost::container::stable_vector<node::NodeVariant> nodes;
|
||||
LinearAllocatorState<> allocator;
|
||||
u32 executionNumber;
|
||||
bool capture{}; //!< If this slot's Vulkan commands should be captured using the renderdoc API
|
||||
|
||||
Slot(GPU &gpu);
|
||||
|
||||
@ -160,7 +160,7 @@ namespace skyline::gpu::interconnect {
|
||||
ContextTag tag; //!< The tag associated with this command executor, any tagged resource locking must utilize this tag
|
||||
size_t submissionNumber{};
|
||||
u32 executionNumber{};
|
||||
bool capt{};
|
||||
bool captureNextExecution{};
|
||||
|
||||
CommandExecutor(const DeviceState &state);
|
||||
|
||||
|
Reference in New Issue
Block a user