mirror of
https://github.com/ZDoom/ZDRay.git
synced 2024-11-22 03:51:26 +00:00
Merge pull request #49 from MrRaveYard/pr_renderdoc
Add RenderDoc support
This commit is contained in:
commit
1427ca5f35
2 changed files with 49 additions and 0 deletions
|
@ -195,6 +195,7 @@ set( SOURCES
|
|||
src/lightmap/glsl_frag.h
|
||||
src/lightmap/glsl_vert.h
|
||||
src/lightmap/glsl_frag_resolve.h
|
||||
src/lightmap/renderdoc_app.h
|
||||
src/math/mat.cpp
|
||||
src/math/plane.cpp
|
||||
src/math/angle.cpp
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "framework/halffloat.h"
|
||||
#include "vulkanbuilders.h"
|
||||
#include "vulkancompatibledevice.h"
|
||||
#include "renderdoc_app.h"
|
||||
#include "stacktrace.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
@ -23,6 +24,46 @@
|
|||
extern bool VKDebug;
|
||||
extern bool NoRtx;
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
RENDERDOC_API_1_4_2* rdoc_api;
|
||||
|
||||
void LoadRenderDoc()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (auto mod = GetModuleHandle("renderdoc.dll"))
|
||||
{
|
||||
pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)GetProcAddress(mod, "RENDERDOC_GetAPI");
|
||||
int ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_4_2, (void**)&rdoc_api);
|
||||
assert(ret == 1);
|
||||
|
||||
if (ret != 1)
|
||||
{
|
||||
printf("RENDERDOC_GetAPI returned %d\n", ret);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (void* mod = dlopen("librenderdoc.so", RTLD_NOW | RTLD_NOLOAD))
|
||||
{
|
||||
pRENDERDOC_GetAPI RENDERDOC_GetAPI = (pRENDERDOC_GetAPI)dlsym(mod, "RENDERDOC_GetAPI");
|
||||
int ret = RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_4_2, (void**)&rdoc_api);
|
||||
assert(ret == 1);
|
||||
|
||||
if (ret != 1)
|
||||
{
|
||||
printf("RENDERDOC_GetAPI returned %d\n", ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rdoc_api)
|
||||
{
|
||||
printf("RenderDoc enabled\n");
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanPrintLog(const char* typestr, const std::string& msg)
|
||||
{
|
||||
printf("[%s] %s\n", typestr, msg.c_str());
|
||||
|
@ -36,6 +77,9 @@ void VulkanError(const char* text)
|
|||
|
||||
GPURaytracer::GPURaytracer()
|
||||
{
|
||||
if(!rdoc_api)
|
||||
LoadRenderDoc();
|
||||
|
||||
auto instance = std::make_shared<VulkanInstance>(VKDebug);
|
||||
device = std::make_unique<VulkanDevice>(instance, nullptr, VulkanCompatibleDevice::SelectDevice(instance, nullptr, 0));
|
||||
useRayQuery = !NoRtx && device->PhysicalDevice.Features.RayQuery.rayQuery;
|
||||
|
@ -48,6 +92,8 @@ GPURaytracer::~GPURaytracer()
|
|||
|
||||
void GPURaytracer::Raytrace(LevelMesh* level)
|
||||
{
|
||||
if (rdoc_api) rdoc_api->StartFrameCapture(nullptr, nullptr);
|
||||
|
||||
mesh = level;
|
||||
|
||||
printf("Building Vulkan acceleration structures\n");
|
||||
|
@ -91,6 +137,8 @@ void GPURaytracer::Raytrace(LevelMesh* level)
|
|||
}
|
||||
|
||||
printf("Ray trace complete\n");
|
||||
|
||||
if (rdoc_api) rdoc_api->EndFrameCapture(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void GPURaytracer::RenderAtlasImage(size_t pageIndex)
|
||||
|
|
Loading…
Reference in a new issue