GPU: Add debug scope capture support for Renderdoc
This adds a new launch argument when building with renderdoc support. It allows to trigger the capture of a specific capture scope. This allows selective capture of some commonly captured parts. Pull Request: https://projects.blender.org/blender/blender/pulls/126791
This commit is contained in:
committed by
Clément Foucault
parent
f7ea83a32d
commit
8ae0264459
@@ -173,6 +173,12 @@ struct Global {
|
||||
bool opengl_deprecation_usage_detected;
|
||||
const char *opengl_deprecation_usage_filename;
|
||||
int opengl_deprecation_usage_lineno;
|
||||
|
||||
/**
|
||||
* Triggers a GPU capture if the name matches a DebugScope.
|
||||
* Set using `--debug-gpu-scope-capture "debug_scope"`.
|
||||
*/
|
||||
char gpu_debug_scope_name[200];
|
||||
};
|
||||
|
||||
/* **************** GLOBAL ********************* */
|
||||
|
||||
@@ -435,17 +435,33 @@ void GLBackend::debug_capture_end()
|
||||
#endif
|
||||
}
|
||||
|
||||
void *GLContext::debug_capture_scope_create(const char * /*name*/)
|
||||
void *GLContext::debug_capture_scope_create(const char *name)
|
||||
{
|
||||
return nullptr;
|
||||
return (void *)name;
|
||||
}
|
||||
|
||||
bool GLContext::debug_capture_scope_begin(void * /*scope*/)
|
||||
bool GLContext::debug_capture_scope_begin(void *scope)
|
||||
{
|
||||
#ifdef WITH_RENDERDOC
|
||||
const char *title = (const char *)scope;
|
||||
if (StringRefNull(title) != StringRefNull(G.gpu_debug_scope_name)) {
|
||||
return false;
|
||||
}
|
||||
GLBackend::get()->debug_capture_begin(title);
|
||||
#endif
|
||||
UNUSED_VARS(scope);
|
||||
return false;
|
||||
}
|
||||
|
||||
void GLContext::debug_capture_scope_end(void * /*scope*/) {}
|
||||
void GLContext::debug_capture_scope_end(void *scope)
|
||||
{
|
||||
#ifdef WITH_RENDERDOC
|
||||
const char *title = (const char *)scope;
|
||||
if (StringRefNull(title) == StringRefNull(G.gpu_debug_scope_name)) {
|
||||
GLBackend::get()->debug_capture_end();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void GLContext::debug_unbind_all_ubo()
|
||||
{
|
||||
|
||||
@@ -62,17 +62,34 @@ void VKBackend::debug_capture_end()
|
||||
#endif
|
||||
}
|
||||
|
||||
void *VKContext::debug_capture_scope_create(const char * /*name*/)
|
||||
void *VKContext::debug_capture_scope_create(const char *name)
|
||||
{
|
||||
return nullptr;
|
||||
return (void *)name;
|
||||
}
|
||||
|
||||
bool VKContext::debug_capture_scope_begin(void * /*scope*/)
|
||||
bool VKContext::debug_capture_scope_begin(void *scope)
|
||||
{
|
||||
#ifdef WITH_RENDERDOC
|
||||
const char *title = (const char *)scope;
|
||||
if (StringRefNull(title) != StringRefNull(G.gpu_debug_scope_name)) {
|
||||
return false;
|
||||
}
|
||||
GLBackend::get()->debug_capture_begin(title);
|
||||
#endif
|
||||
UNUSED_VARS(scope);
|
||||
return false;
|
||||
}
|
||||
|
||||
void VKContext::debug_capture_scope_end(void * /*scope*/) {}
|
||||
void VKContext::debug_capture_scope_end(void *scope)
|
||||
{
|
||||
#ifdef WITH_RENDERDOC
|
||||
const char *title = (const char *)scope;
|
||||
if (StringRefNull(title) == StringRefNull(G.gpu_debug_scope_name)) {
|
||||
GLBackend::get()->debug_capture_end();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace blender::gpu
|
||||
|
||||
namespace blender::gpu::debug {
|
||||
|
||||
@@ -754,6 +754,7 @@ static void print_help(bArgs *ba, bool all)
|
||||
BLI_args_print_arg_doc(ba, "--debug-gpu-force-workarounds");
|
||||
BLI_args_print_arg_doc(ba, "--debug-gpu-compile-shaders");
|
||||
if (defs.with_renderdoc) {
|
||||
BLI_args_print_arg_doc(ba, "--debug-gpu-scope-capture");
|
||||
BLI_args_print_arg_doc(ba, "--debug-gpu-renderdoc");
|
||||
}
|
||||
BLI_args_print_arg_doc(ba, "--debug-wm");
|
||||
@@ -1408,6 +1409,19 @@ static int arg_handle_debug_gpu_compile_shaders_set(int /*argc*/,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char arg_handle_debug_gpu_scope_capture_set_doc[] =
|
||||
"\n"
|
||||
"\tCapture the GPU commands issued inside the give scope name.";
|
||||
static int arg_handle_debug_gpu_scope_capture_set(int argc, const char **argv, void * /*data*/)
|
||||
{
|
||||
if (argc > 1) {
|
||||
STRNCPY(G.gpu_debug_scope_name, argv[1]);
|
||||
return 1;
|
||||
}
|
||||
fprintf(stderr, "\nError: you must specify a scope name to capture.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char arg_handle_debug_gpu_renderdoc_set_doc[] =
|
||||
"\n"
|
||||
"\tEnable Renderdoc integration for GPU frame grabbing and debugging.";
|
||||
@@ -2726,6 +2740,11 @@ void main_args_setup(bContext *C, bArgs *ba, bool all)
|
||||
CB(arg_handle_debug_gpu_compile_shaders_set),
|
||||
nullptr);
|
||||
if (defs.with_renderdoc) {
|
||||
BLI_args_add(ba,
|
||||
nullptr,
|
||||
"--debug-gpu-scope-capture",
|
||||
CB(arg_handle_debug_gpu_scope_capture_set),
|
||||
nullptr);
|
||||
BLI_args_add(
|
||||
ba, nullptr, "--debug-gpu-renderdoc", CB(arg_handle_debug_gpu_renderdoc_set), nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user