GPU: Renderdoc Frame Capturing #105921
|
@ -26,8 +26,10 @@ class Renderdoc {
|
|||
RENDERDOC_API_1_6_0 *renderdoc_api_ = nullptr;
|
||||
|
||||
public:
|
||||
void start_frame_capture();
|
||||
void end_frame_capture();
|
||||
void start_frame_capture(RENDERDOC_DevicePointer device_handle,
|
||||
RENDERDOC_WindowHandle window_handle);
|
||||
void end_frame_capture(RENDERDOC_DevicePointer device_handle,
|
||||
RENDERDOC_WindowHandle window_handle);
|
||||
|
||||
private:
|
||||
bool check_loaded();
|
||||
|
|
|
@ -8,20 +8,23 @@
|
|||
#include <iostream>
|
||||
|
||||
namespace renderdoc::api {
|
||||
void Renderdoc::start_frame_capture()
|
||||
void Renderdoc::start_frame_capture(RENDERDOC_DevicePointer device_handle,
|
||||
RENDERDOC_WindowHandle window_handle)
|
||||
{
|
||||
if (!check_loaded()) {
|
||||
return;
|
||||
}
|
||||
renderdoc_api_->StartFrameCapture(nullptr, nullptr);
|
||||
renderdoc_api_->StartFrameCapture(device_handle, window_handle);
|
||||
}
|
||||
|
||||
void Renderdoc::end_frame_capture()
|
||||
void Renderdoc::end_frame_capture(RENDERDOC_DevicePointer device_handle,
|
||||
RENDERDOC_WindowHandle window_handle)
|
||||
|
||||
{
|
||||
if (!check_loaded()) {
|
||||
return;
|
||||
}
|
||||
renderdoc_api_->EndFrameCapture(nullptr, nullptr);
|
||||
renderdoc_api_->EndFrameCapture(device_handle, window_handle);
|
||||
}
|
||||
|
||||
bool Renderdoc::check_loaded()
|
||||
|
|
|
@ -197,6 +197,7 @@ set(VULKAN_SRC
|
|||
vulkan/vk_command_buffer.cc
|
||||
vulkan/vk_common.cc
|
||||
vulkan/vk_context.cc
|
||||
vulkan/vk_debug.cc
|
||||
vulkan/vk_descriptor_pools.cc
|
||||
vulkan/vk_descriptor_set.cc
|
||||
vulkan/vk_drawlist.cc
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "renderdoc_api.hh"
|
||||
|
||||
#include "gl_batch.hh"
|
||||
#include "gl_compute.hh"
|
||||
#include "gl_context.hh"
|
||||
|
@ -30,6 +32,7 @@ namespace gpu {
|
|||
class GLBackend : public GPUBackend {
|
||||
private:
|
||||
GLSharedOrphanLists shared_orphan_list_;
|
||||
renderdoc::api::Renderdoc renderdoc_;
|
||||
|
||||
public:
|
||||
GLBackend()
|
||||
|
@ -155,6 +158,9 @@ class GLBackend : public GPUBackend {
|
|||
void render_end(void) override{};
|
||||
void render_step(void) override{};
|
||||
|
||||
void debug_capture_begin();
|
||||
void debug_capture_end();
|
||||
|
||||
private:
|
||||
static void platform_init();
|
||||
static void platform_exit();
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "renderdoc_api.hh"
|
||||
|
||||
#include "gpu_context_private.hh"
|
||||
|
||||
#include "GPU_framebuffer.h"
|
||||
|
@ -97,7 +95,6 @@ class GLContext : public Context {
|
|||
/** #GLBackend owns this data. */
|
||||
GLSharedOrphanLists &shared_orphan_list_;
|
||||
|
||||
renderdoc::api::Renderdoc renderdoc_;
|
||||
|
||||
public:
|
||||
GLContext(void *ghost_window, GLSharedOrphanLists &shared_orphan_list);
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "CLG_log.h"
|
||||
|
||||
#include "gl_backend.hh"
|
||||
#include "gl_context.hh"
|
||||
#include "gl_uniform_buffer.hh"
|
||||
|
||||
|
@ -382,13 +383,23 @@ void GLContext::debug_group_end()
|
|||
|
||||
bool GLContext::debug_capture_begin()
|
||||
{
|
||||
renderdoc_.start_frame_capture();
|
||||
GLBackend::get()->debug_capture_begin();
|
||||
return true;
|
||||
Jeroen-Bakker marked this conversation as resolved
Outdated
|
||||
}
|
||||
|
||||
void GLBackend::debug_capture_begin()
|
||||
{
|
||||
renderdoc_.start_frame_capture(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void GLContext::debug_capture_end()
|
||||
{
|
||||
renderdoc_.end_frame_capture();
|
||||
GLBackend::get()->debug_capture_end();
|
||||
}
|
||||
|
||||
void GLBackend::debug_capture_end()
|
||||
{
|
||||
renderdoc_.end_frame_capture(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void *GLContext::debug_capture_scope_create(const char * /*name*/)
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include "gpu_backend.hh"
|
||||
|
||||
#include "renderdoc_api.hh"
|
||||
|
||||
#include "vk_common.hh"
|
||||
|
||||
#include "shaderc/shaderc.hpp"
|
||||
|
@ -20,6 +22,7 @@ class VKContext;
|
|||
class VKBackend : public GPUBackend {
|
||||
private:
|
||||
shaderc::Compiler shaderc_compiler_;
|
||||
renderdoc::api::Renderdoc renderdoc_api_;
|
||||
|
||||
public:
|
||||
VKBackend()
|
||||
|
@ -59,10 +62,18 @@ class VKBackend : public GPUBackend {
|
|||
void render_end() override;
|
||||
void render_step() override;
|
||||
|
||||
void debug_capture_begin(VkInstance vk_instance);
|
||||
void debug_capture_end(VkInstance vk_instance);
|
||||
|
||||
shaderc::Compiler &get_shaderc_compiler();
|
||||
|
||||
static void capabilities_init(VKContext &context);
|
||||
|
||||
static VKBackend &get()
|
||||
{
|
||||
return *static_cast<VKBackend *>(GPUBackend::get());
|
||||
}
|
||||
|
||||
private:
|
||||
static void init_platform();
|
||||
static void platform_exit();
|
||||
|
|
|
@ -120,35 +120,4 @@ void VKContext::memory_statistics_get(int * /*total_mem*/, int * /*free_mem*/)
|
|||
{
|
||||
}
|
||||
|
||||
void VKContext::debug_group_begin(const char *, int)
|
||||
{
|
||||
}
|
||||
|
||||
void VKContext::debug_group_end()
|
||||
{
|
||||
}
|
||||
|
||||
bool VKContext::debug_capture_begin()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void VKContext::debug_capture_end()
|
||||
{
|
||||
}
|
||||
|
||||
void *VKContext::debug_capture_scope_create(const char * /*name*/)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool VKContext::debug_capture_scope_begin(void * /*scope*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void VKContext::debug_capture_scope_end(void * /*scope*/)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace blender::gpu
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
* Copyright 2022 Blender Foundation. All rights reserved. */
|
||||
|
||||
/** \file
|
||||
* \ingroup gpu
|
||||
*/
|
||||
|
||||
#include "vk_backend.hh"
|
||||
#include "vk_context.hh"
|
||||
|
||||
namespace blender::gpu {
|
||||
void VKContext::debug_group_begin(const char *, int)
|
||||
{
|
||||
}
|
||||
|
||||
void VKContext::debug_group_end()
|
||||
{
|
||||
}
|
||||
|
||||
bool VKContext::debug_capture_begin()
|
||||
{
|
||||
VKBackend::get().debug_capture_begin(vk_instance_);
|
||||
return true;
|
||||
}
|
||||
|
||||
void VKBackend::debug_capture_begin(VkInstance vk_instance)
|
||||
{
|
||||
renderdoc_api_.start_frame_capture(vk_instance, nullptr);
|
||||
}
|
||||
|
||||
void VKContext::debug_capture_end()
|
||||
{
|
||||
VKBackend::get().debug_capture_end(vk_instance_);
|
||||
}
|
||||
|
||||
void VKBackend::debug_capture_end(VkInstance vk_instance)
|
||||
{
|
||||
renderdoc_api_.end_frame_capture(vk_instance, nullptr);
|
||||
}
|
||||
|
||||
void *VKContext::debug_capture_scope_create(const char * /*name*/)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool VKContext::debug_capture_scope_begin(void * /*scope*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void VKContext::debug_capture_scope_end(void * /*scope*/)
|
||||
{
|
||||
}
|
||||
} // namespace blender::gpu
|
|
@ -542,7 +542,7 @@ Vector<uint32_t> VKShader::compile_glsl_to_spirv(Span<const char *> sources,
|
|||
shaderc_shader_kind stage)
|
||||
{
|
||||
std::string combined_sources = combine_sources(sources);
|
||||
VKBackend &backend = static_cast<VKBackend &>(*VKBackend::get());
|
||||
VKBackend &backend = VKBackend::get();
|
||||
shaderc::Compiler &compiler = backend.get_shaderc_compiler();
|
||||
shaderc::CompileOptions options;
|
||||
options.SetOptimizationLevel(shaderc_optimization_level_performance);
|
||||
|
|
Loading…
Reference in New Issue
Why return a bool if it always return true?
Shouldn't this only return true if the function actually succeeded (ie. the RenderDoc API is actually loaded)?