GPU: Add GPU frame capture support. #105717

Merged
Jeroen Bakker merged 4 commits from Jason-Fielder/blender:GPU_frame_capture_support_2 into main 2023-03-16 08:54:18 +01:00
2 changed files with 56 additions and 42 deletions
Showing only changes of commit c7db9faf9b - Show all commits

View File

@ -5,6 +5,40 @@
* \ingroup gpu
*
* Helpers for GPU / drawing debugging.
*
*
** GPU debug capture usage example:
*
** Instant frame capture. **
*
* \code
* #include "GPU_debug.h"
* static void do_render_engine(Render *re)
* {
* GPU_debug_capture_begin();
* RE_engine_render(re, false);
* GPU_debug_capture_end();
* }
* \endcode
*
** Capture scopes. **
*
* \code
* #include "GPU_debug.h"
* void *capture_scope = nullptr;
* static void do_render_engine(Render *re)
* {
* if (!capture_scope) {
* // Create capture scope which will display in external tool.

API docs although not really specified in https://wiki.blender.org/wiki/Style_Guide/C_Cpp we normally
open and close the comment on its own line eg:

/**
 * GPU Frame capture support.
 *
 * Allows instantaneous Frame capture of GPU calls between begin/end.
 */

In this case, we should use Comment sections and add API docs per function.

API docs although not really specified in https://wiki.blender.org/wiki/Style_Guide/C_Cpp we normally open and close the comment on its own line eg: ``` /** * GPU Frame capture support. * * Allows instantaneous Frame capture of GPU calls between begin/end. */ ``` In this case, we should use Comment sections and add API docs per function.
* capture_scope = GPU_debug_capture_scope_create("Render Frame");
* }
*
* // Commands within scope boundary captured when requested in tool.
* GPU_debug_capture_scope_begin(capture_scope);

Spelling: frame

Spelling: frame
* RE_engine_render(re, false);
* GPU_debug_capture_scope_end(capture_scope);
* }
* \endcode
*/
#pragma once
@ -29,56 +63,37 @@ void GPU_debug_get_groups_names(int name_buf_len, char *r_name_buf);
*/
bool GPU_debug_group_match(const char *ref);
/** GPU Frame capture support.
* Allows instananeous Frame capture of GPU calls between begin/end. */
/**
* GPU Frame capture support.
*
* Allows instananeous frame capture of GPU calls between begin/end.
Review

instantaneous

instan**t**aneous
*/
void GPU_debug_capture_begin(void);
void GPU_debug_capture_end(void);
/** GPU debug frae capture scopes.
* Allows creation of a GPU Frame Capture scope that define a region within which an external GPU
/**
* GPU debug frame capture scopes.
*
* Allows creation of a GPU frame capture scope that define a region within which an external GPU
* Frame capture tool can perform a deferred capture of GPU API calls within the boundary upon user
* request. */
/* Returns a pointer wrapping a n API-specific capture scope.
* A capture scope should be created a single time and only used within one begin/end pair.*/
* request.
*
* \param name Unique name of capture scope displayed within capture tool.
* \return pointer wrapping an API-specific capture scope object.
* \note a capture scope should be created a single time and only used within one begin/end pair.
*/
void *GPU_debug_capture_scope_create(const char *name);
/* Used to declare the region within which GPU calls are captured when the scope is triggered.
* These functions will return true if the desired tool is actively capturing this scope when
* executed. Otherwise, false.*/
/**
* Used to declare the region within which GPU calls are captured when the scope is triggered.
*
* \param scope Pointer to capture scope object created with GPU_debug_capture_scope_create.
* \return True if the capture tool is actively capturing this scope when function is executed.
* Otherwise, False.
*/
bool GPU_debug_capture_scope_begin(void *scope);
void GPU_debug_capture_scope_end(void *scope);
/** GPU Debug Capture Usage Example
*
** Instant frame capture. **
*
* #include "GPU_debug.h"
* static void do_render_engine(Render *re)
* {
* GPU_debug_capture_begin();
* RE_engine_render(re, false);
* GPU_debug_capture_end();
* }
*
*
** Capture Scopes. **
*
* void *capture_scope = nullptr;
* static void do_render_engine(Render *re)
* {
* if (!capture_scope) {
* // Create capture scope which will display in external tool.
* capture_scope = GPU_debug_capture_scope_create("Render Frame");
* }
*
* // Commands within scope boundary captured when requested in tool.
* GPU_debug_capture_scope_begin(capture_scope);
* RE_engine_render(re, false);
* GPU_debug_capture_scope_end(capture_scope);
* }
*/
#ifdef __cplusplus
}
#endif

View File

@ -112,7 +112,6 @@ bool MTLContext::debug_capture_scope_begin(void *scope)
void MTLContext::debug_capture_scope_end(void *scope)
{
[(id<MTLCaptureScope>)scope endScope];
MTLCaptureManager *capture_manager = [MTLCaptureManager sharedCaptureManager];
}
/** \} */