Changeset View
Standalone View
source/lib/ogl.h
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | |||||
//----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
// implementation limits / feature detect | // implementation limits / feature detect | ||||
extern GLint ogl_max_tex_size; /// [pixels] | extern GLint ogl_max_tex_size; /// [pixels] | ||||
extern GLint ogl_max_tex_units; /// limit on GL_TEXTUREn | extern GLint ogl_max_tex_units; /// limit on GL_TEXTUREn | ||||
#define OGL_SCOPED_DEBUG_GROUP(groupName) ogl_DebugScopedGroup glDebugScopedGroup(groupName) | |||||
#ifndef NDEBUG | |||||
/** | |||||
vladislavbelov: It should be `0` I suppose. | |||||
* RAII for glPushDebugGroupKHR() and pglPopDebugGroupKHR(). | |||||
Not Done Inline ActionsMaybe ogl_DebugScopedGroup? vladislavbelov: Maybe `ogl_DebugScopedGroup`? | |||||
*/ | |||||
struct ogl_DebugScopedGroup | |||||
{ | |||||
ogl_DebugScopedGroup(const char* message) | |||||
{ | |||||
pglPushDebugGroupKHR(GL_DEBUG_SOURCE_APPLICATION, 0x0ad, -1, message); | |||||
} | |||||
~ogl_DebugScopedGroup() | |||||
{ | |||||
pglPopDebugGroupKHR(); | |||||
} | |||||
Not Done Inline ActionsMaybe we need to check for the extension. vladislavbelov: Maybe we need to check for the extension. | |||||
}; | |||||
#else | |||||
Not Done Inline ActionsIt doesn't make sense to generate even an empty struct. I suggest to replace ogl_DebugGroup group("Draw GUI element"); by one macro like OGL_DEBUG_GROUP("Draw GUI element");, like it's done for profiler. BTW can't we just add groups in PROFILER2? Because we already have GL queries there and it seems reasonable to have them together. vladislavbelov: It doesn't make sense to generate even an empty `struct`. I suggest to replace `ogl_DebugGroup… | |||||
Not Done Inline ActionsNote that your PROFILE2() macro does exactly the same thing, by creating a CProfile2Region object named profile2__ (see source/ps/Profiler2.h:536), except this object contains a m_Name pointer so it can’t be eluded by the compiler. It shouldn’t contain it though, you don’t reuse it at all after the constructor is done, that sounds like an easy optimisation. Adding groups the same way would be ok, but I’m not sure why go through the indirection of your profiler when you just want to have raii for OpenGL calls. linkmauve: Note that your `PROFILE2()` macro does exactly the same thing, by creating a `CProfile2Region`… | |||||
// Fallback when we’re not debugging. | |||||
struct ogl_DebugScopedGroup | |||||
{ | |||||
ogl_DebugScopedGroup(const char* UNUSED(message)) {} | |||||
~ogl_DebugScopedGroup() {} | |||||
}; | |||||
#endif | |||||
#endif // #ifndef INCLUDED_OGL | #endif // #ifndef INCLUDED_OGL |
It should be 0 I suppose.