mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-07 06:35:40 +12:00
Add GPU_DEBUG_INFO
CMake-Option
Adds a project-wide setting for allowing renderer code to add additional diagnostic data. Currently used to allow `opengl.hpp` to conditionally implement debug-labeling and scopes.
This commit is contained in:
parent
dbf0597bd8
commit
62fdb29646
2 changed files with 29 additions and 5 deletions
|
@ -13,6 +13,8 @@ endif()
|
|||
project(Alber)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
option(GPU_DEBUG_INFO "Enable additional GPU debugging info" OFF)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include/)
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include/kernel)
|
||||
include_directories (${FMT_INCLUDE_DIR})
|
||||
|
@ -138,4 +140,9 @@ source_group("Source Files\\Third Party" FILES ${THIRD_PARTY_SOURCE_FILES})
|
|||
|
||||
add_executable(Alber ${SOURCE_FILES} ${FS_SOURCE_FILES} ${KERNEL_SOURCE_FILES} ${LOADER_SOURCE_FILES} ${SERVICE_SOURCE_FILES}
|
||||
${PICA_SOURCE_FILES} ${RENDERER_GL_SOURCE_FILES} ${THIRD_PARTY_SOURCE_FILES} ${HEADER_FILES})
|
||||
target_link_libraries(Alber PRIVATE dynarmic SDL2-static glad)
|
||||
target_link_libraries(Alber PRIVATE dynarmic SDL2-static glad)
|
||||
|
||||
|
||||
if(GPU_DEBUG_INFO)
|
||||
target_compile_definitions(Alber PRIVATE GPU_DEBUG_INFO=1)
|
||||
endif()
|
|
@ -44,6 +44,10 @@
|
|||
#include <span>
|
||||
#endif
|
||||
|
||||
#if defined(GPU_DEBUG_INFO)
|
||||
#define OPENGL_DEBUG_INFO
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <sal.h>
|
||||
#define OPENGL_PRINTF_FORMAT _Printf_format_string_
|
||||
|
@ -63,23 +67,29 @@ namespace OpenGL {
|
|||
template <class...>
|
||||
constexpr std::false_type AlwaysFalse{};
|
||||
|
||||
OPENGL_PRINTF_FORMAT_ATTR(3, 4)
|
||||
OPENGL_PRINTF_FORMAT_ATTR(3, 4)
|
||||
static void setObjectLabel(GLenum identifier, GLuint name, OPENGL_PRINTF_FORMAT const char* format, ...) {
|
||||
#if defined(OPENGL_DEBUG_INFO)
|
||||
GLchar label[256] = {};
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
const GLsizei length = vsnprintf(label, std::size(label), format, args);
|
||||
va_end(args);
|
||||
glObjectLabel(identifier, name, length, label);
|
||||
#endif
|
||||
}
|
||||
|
||||
class DebugScope {
|
||||
class DebugScope {
|
||||
#if defined(OPENGL_DEBUG_INFO)
|
||||
inline static GLuint scopeDepth = 0;
|
||||
const GLuint m_scope_depth;
|
||||
#endif
|
||||
|
||||
public:
|
||||
OPENGL_PRINTF_FORMAT_ATTR(2, 3)
|
||||
DebugScope(OPENGL_PRINTF_FORMAT const char* format, ...) : m_scope_depth(scopeDepth++) {
|
||||
DebugScope(OPENGL_PRINTF_FORMAT const char* format, ...)
|
||||
#if defined(OPENGL_DEBUG_INFO)
|
||||
: m_scope_depth(scopeDepth++) {
|
||||
GLchar message[256] = {};
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
@ -87,13 +97,20 @@ namespace OpenGL {
|
|||
va_end(args);
|
||||
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, m_scope_depth, length, message);
|
||||
}
|
||||
#else
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
~DebugScope() {
|
||||
#if defined(OPENGL_DEBUG_INFO)
|
||||
glPopDebugGroup();
|
||||
scopeDepth--;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
struct VertexArray {
|
||||
struct VertexArray {
|
||||
GLuint m_handle = 0;
|
||||
|
||||
void create() {
|
||||
|
|
Loading…
Add table
Reference in a new issue