Skip to content

Commit 5c68cbd

Browse files
corporatesharkmeta-codesync[bot]
authored andcommitted
igl | opengl | Add Tracy profiler markers to Context (glx)
Reviewed By: rudybear Differential Revision: D114575219 fbshipit-source-id: 6a5fb267253f23697e663c60e3ac8f963bc5d024
1 parent d4e479e commit 5c68cbd

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/igl/opengl/glx/Context.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <dlfcn.h>
1414
#include <string>
1515
#include <vector>
16+
#include <igl/Macros.h>
1617
#include <igl/Texture.h>
1718

1819
namespace {
@@ -56,6 +57,7 @@ using PFNGLXGETCURRENTCONTEXTPROC = GLXContext (*)();
5657

5758
struct GLXSharedModule {
5859
GLXSharedModule() {
60+
IGL_PROFILER_FUNCTION_COLOR(IGL_PROFILER_COLOR_CREATE);
5961
std::vector<std::string> libs = {
6062
"libGLX.so.0",
6163
"libGL.so.1",
@@ -92,6 +94,7 @@ struct GLXSharedModule {
9294
}
9395

9496
~GLXSharedModule() {
97+
IGL_PROFILER_FUNCTION_COLOR(IGL_PROFILER_COLOR_DESTROY);
9598
if (module_) {
9699
dlclose(module_);
97100
}
@@ -144,6 +147,7 @@ Context::Context(std::shared_ptr<GLXSharedModule> module,
144147
uint32_t width /* = 0 */,
145148
uint32_t height /* = 0 */) :
146149
contextOwned_(true), offscreen_(offscreen), module_(std::move(module)) {
150+
IGL_PROFILER_FUNCTION_COLOR(IGL_PROFILER_COLOR_CREATE);
147151
if (!module_) {
148152
module_ = std::make_shared<GLXSharedModule>();
149153
}
@@ -200,6 +204,7 @@ Context::Context(std::shared_ptr<GLXSharedModule> module,
200204
display_(display),
201205
windowHandle_(windowHandle),
202206
contextHandle_(contextHandle) {
207+
IGL_PROFILER_FUNCTION_COLOR(IGL_PROFILER_COLOR_CREATE);
203208
if (!module_) {
204209
module_ = std::make_shared<GLXSharedModule>();
205210
}
@@ -216,6 +221,7 @@ Context::Context(std::shared_ptr<GLXSharedModule> module,
216221
}
217222

218223
Context::~Context() {
224+
IGL_PROFILER_FUNCTION_COLOR(IGL_PROFILER_COLOR_DESTROY);
219225
// Clear pool explicitly, since it might have reference back to IContext.
220226
getAdapterPool().clear();
221227

@@ -240,6 +246,7 @@ Context::~Context() {
240246
}
241247

242248
void Context::setCurrent() {
249+
IGL_PROFILER_FUNCTION();
243250
if (!module_->glXMakeCurrent(display_, windowHandle_, contextHandle_)) {
244251
IGL_DEBUG_ABORT("[IGL] Failed to activate OpenGL render context. GLX error 0x%08X:\n",
245252
GetLastError());
@@ -248,6 +255,7 @@ void Context::setCurrent() {
248255
}
249256

250257
void Context::clearCurrentContext() const {
258+
IGL_PROFILER_FUNCTION();
251259
if (!module_->glXMakeCurrent(display_, None, nullptr)) {
252260
IGL_DEBUG_ASSERT(
253261
false, "[IGL] Failed to clear OpenGL render context. GLX error 0x%08X:\n", GetLastError());
@@ -263,6 +271,7 @@ bool Context::isCurrentSharegroup() const {
263271
}
264272

265273
void Context::present(std::shared_ptr<ITexture> surface) const {
274+
IGL_PROFILER_FUNCTION_COLOR(IGL_PROFILER_COLOR_PRESENT);
266275
module_->glXSwapBuffers(display_, windowHandle_);
267276
module_->glXMakeCurrent(display_, windowHandle_, contextHandle_);
268277
}

0 commit comments

Comments
 (0)