Add renderdoc support in stream scene
This commit is contained in:
@@ -48,6 +48,11 @@
|
||||
#include <thread>
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
|
||||
#include "wivrn_config.h"
|
||||
#if WIVRN_FEATURE_RENDERDOC
|
||||
#include "vk/renderdoc.h"
|
||||
#endif
|
||||
|
||||
using namespace wivrn;
|
||||
|
||||
// clang-format off
|
||||
@@ -905,11 +910,13 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
|
||||
std::array<int, view_count> image_indices;
|
||||
|
||||
#if WIVRN_FEATURE_RENDERDOC
|
||||
renderdoc_begin(*vk_instance);
|
||||
#endif
|
||||
command_buffer.reset();
|
||||
|
||||
vk::CommandBufferBeginInfo begin_info;
|
||||
begin_info.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
|
||||
command_buffer.begin(begin_info);
|
||||
command_buffer.begin(vk::CommandBufferBeginInfo{
|
||||
.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit,
|
||||
});
|
||||
|
||||
// Keep a reference to the resources needed to blit the images until vkWaitForFences
|
||||
|
||||
@@ -1090,6 +1097,9 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
vk::SubmitInfo submit_info;
|
||||
submit_info.setCommandBuffers(*command_buffer);
|
||||
queue.lock()->submit(submit_info, *fence);
|
||||
#if WIVRN_FEATURE_RENDERDOC
|
||||
renderdoc_end(*vk_instance);
|
||||
#endif
|
||||
swapchain.release();
|
||||
|
||||
std::vector<XrCompositionLayerProjectionView> layer_view(view_count);
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "renderdoc.h"
|
||||
#include "renderdoc_app.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <iostream>
|
||||
|
||||
static RENDERDOC_API_1_0_0 * renderdoc_init()
|
||||
{
|
||||
RENDERDOC_API_1_0_0 * renderdoc_api = nullptr;
|
||||
auto renderdoc_module = dlopen("librenderdoc.so", RTLD_NOW | RTLD_NOLOAD);
|
||||
if (not renderdoc_module)
|
||||
return nullptr;
|
||||
auto * func = reinterpret_cast<pRENDERDOC_GetAPI>(dlsym(renderdoc_module, "RENDERDOC_GetAPI"));
|
||||
if (!func)
|
||||
{
|
||||
std::cerr << "Failed to load RENDERDOC_GetAPI function." << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
if (!func(eRENDERDOC_API_Version_1_0_0, reinterpret_cast<void **>(&renderdoc_api)))
|
||||
{
|
||||
std::cerr << "Failed to obtain RenderDoc 1.0.0 API." << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int major, minor, patch;
|
||||
renderdoc_api->GetAPIVersion(&major, &minor, &patch);
|
||||
return renderdoc_api;
|
||||
}
|
||||
|
||||
static RENDERDOC_API_1_0_0 * get_renderdoc()
|
||||
{
|
||||
static RENDERDOC_API_1_0_0 * renderdoc_api = renderdoc_init();
|
||||
return renderdoc_api;
|
||||
}
|
||||
|
||||
void wivrn::renderdoc_begin(VkInstance inst)
|
||||
{
|
||||
if (auto renderdoc_api = get_renderdoc())
|
||||
renderdoc_api->StartFrameCapture(RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(inst), nullptr);
|
||||
}
|
||||
void wivrn::renderdoc_end(VkInstance inst)
|
||||
{
|
||||
if (auto renderdoc_api = get_renderdoc())
|
||||
renderdoc_api->EndFrameCapture(RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(inst), nullptr);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <vulkan/vulkan.h>
|
||||
namespace wivrn
|
||||
{
|
||||
void renderdoc_begin(VkInstance);
|
||||
void renderdoc_end(VkInstance);
|
||||
} // namespace wivrn
|
||||
Reference in New Issue
Block a user