GPU: Use --debug-gpu-renderdoc For Renderdoc Integration. #106541

Merged
Jeroen Bakker merged 2 commits from Jeroen-Bakker/blender:gpu-renderdoc-startup-option into main 2023-04-04 12:46:59 +02:00
6 changed files with 36 additions and 20 deletions

View File

@ -61,17 +61,6 @@ void Renderdoc::load()
RENDERDOC_GetAPI(eRENDERDOC_API_Version_1_1_2, (void **)&renderdoc_api_);
}
#endif
if (renderdoc_api_ != nullptr) {
int major;
int minor;
int patch;
renderdoc_api_->GetAPIVersion(&major, &minor, &patch);
std::cout << "Found renderdoc API [" << major << "." << minor << "." << patch << "]";
}
else {
std::cerr << "Unable to load renderdoc API.\n";
}
}
} // namespace renderdoc::api

View File

@ -201,11 +201,12 @@ enum {
G_DEBUG_IO = (1 << 17), /* IO Debugging (for Collada, ...). */
G_DEBUG_GPU_FORCE_WORKAROUNDS = (1 << 18), /* force gpu workarounds bypassing detections. */
G_DEBUG_GPU_FORCE_DISABLE_SSBO = (1 << 19), /* force disabling usage of SSBO's */
G_DEBUG_XR = (1 << 20), /* XR/OpenXR messages */
G_DEBUG_XR_TIME = (1 << 21), /* XR/OpenXR timing messages */
G_DEBUG_GPU_RENDERDOC = (1 << 20), /* Enable Renderdoc integration. */
G_DEBUG_XR = (1 << 21), /* XR/OpenXR messages */
G_DEBUG_XR_TIME = (1 << 22), /* XR/OpenXR timing messages */
G_DEBUG_GHOST = (1 << 22), /* Debug GHOST module. */
G_DEBUG_WINTAB = (1 << 23), /* Debug Wintab. */
G_DEBUG_GHOST = (1 << 23), /* Debug GHOST module. */
G_DEBUG_WINTAB = (1 << 24), /* Debug Wintab. */
};
#define G_DEBUG_ALL \

View File

@ -389,10 +389,11 @@ bool GLContext::debug_capture_begin()
bool GLBackend::debug_capture_begin()
{
#ifdef WITH_RENDERDOC
return renderdoc_.start_frame_capture(nullptr, nullptr);
#else
return false;
if (G.debug & G_DEBUG_GPU_RENDERDOC) {
return renderdoc_.start_frame_capture(nullptr, nullptr);
}
#endif
return false;
}
void GLContext::debug_capture_end()
@ -403,7 +404,9 @@ void GLContext::debug_capture_end()
void GLBackend::debug_capture_end()
{
#ifdef WITH_RENDERDOC
renderdoc_.end_frame_capture(nullptr, nullptr);
if (G.debug & G_DEBUG_GPU_RENDERDOC) {
renderdoc_.end_frame_capture(nullptr, nullptr);
}
#endif
}

View File

@ -18,7 +18,7 @@ namespace blender::gpu {
void GPUTest::SetUp()
{
prev_g_debug_ = G.debug;
G.debug |= G_DEBUG_GPU;
G.debug |= G_DEBUG_GPU | G_DEBUG_GPU_RENDERDOC;
CLG_init();
GPU_backend_type_selection_set(gpu_backend_type);

View File

@ -54,6 +54,10 @@ if(WITH_VULKAN_BACKEND)
add_definitions(-DWITH_VULKAN_BACKEND)
endif()
if(WITH_RENDERDOC)
add_definitions(-DWITH_RENDERDOC)
endif()
if(WITH_CODEC_FFMPEG)
add_definitions(-DWITH_FFMPEG)
endif()

View File

@ -582,6 +582,9 @@ static int arg_handle_print_help(int UNUSED(argc), const char **UNUSED(argv), vo
BLI_args_print_arg_doc(ba, "--debug-gpu");
BLI_args_print_arg_doc(ba, "--debug-gpu-force-workarounds");
BLI_args_print_arg_doc(ba, "--debug-gpu-disable-ssbo");
# ifdef WITH_RENDERDOC
BLI_args_print_arg_doc(ba, "--debug-gpu-renderdoc");
# endif
BLI_args_print_arg_doc(ba, "--debug-wm");
# ifdef WITH_XR_OPENXR
BLI_args_print_arg_doc(ba, "--debug-xr");
@ -1118,6 +1121,19 @@ static int arg_handle_debug_gpu_set(int UNUSED(argc),
return 0;
}
# ifdef WITH_RENDERDOC
static const char arg_handle_debug_gpu_renderdoc_set_doc[] =
"\n"
"\tEnable Renderdoc integration for GPU frame grabbing and debugging.";
static int arg_handle_debug_gpu_renderdoc_set(int UNUSED(argc),
const char **UNUSED(argv),
void *UNUSED(data))
{
G.debug |= G_DEBUG_GPU_RENDERDOC | G_DEBUG_GPU;
return 0;
}
# endif
static const char arg_handle_gpu_backend_set_doc[] =
"\n"
"\tForce to use a specific GPU backend. Valid options: "
@ -2245,6 +2261,9 @@ void main_args_setup(bContext *C, bArgs *ba)
CB_EX(arg_handle_debug_mode_generic_set, jobs),
(void *)G_DEBUG_JOBS);
BLI_args_add(ba, NULL, "--debug-gpu", CB(arg_handle_debug_gpu_set), NULL);
# ifdef WITH_RENDERDOC
BLI_args_add(ba, NULL, "--debug-gpu-renderdoc", CB(arg_handle_debug_gpu_renderdoc_set), NULL);
# endif
BLI_args_add(ba,
NULL,