comparison Framework/OpenGL/OpenGLIncludes.h @ 961:92e32e263ae9 toa2019082601

Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 26 Aug 2019 11:01:53 +0200
parents 1091b2adeb5a
children 3ea70a62ca00
comparison
equal deleted inserted replaced
960:733be18fe140 961:92e32e263ae9
39 # include <GL/gl.h> 39 # include <GL/gl.h>
40 # include <GL/glext.h> 40 # include <GL/glext.h>
41 #endif 41 #endif
42 42
43 #if ORTHANC_ENABLE_SDL == 1 43 #if ORTHANC_ENABLE_SDL == 1
44 #include <SDL_video.h> 44 # include <SDL_video.h>
45 45
46 #define ORTHANC_OPENGL_CHECK(name) \ 46 # ifdef NDEBUG
47
48 // glGetError is very expensive!
49
50 # define ORTHANC_OPENGL_CHECK(name)
51 # define ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT(msg)
52 # define ORTHANC_CHECK_CURRENT_CONTEXT(context)
53
54 # else
55
56 # define ORTHANC_OPENGL_CHECK(name) \
47 if(true) \ 57 if(true) \
48 { \ 58 { \
49 GLenum error = glGetError(); \ 59 GLenum error = glGetError(); \
50 if (error != GL_NO_ERROR) { \ 60 if (error != GL_NO_ERROR) { \
51 SDL_GLContext ctx = SDL_GL_GetCurrentContext(); \ 61 SDL_GLContext ctx = SDL_GL_GetCurrentContext(); \
52 LOG(ERROR) << "Error when calling " << name << " | current context is: 0x" << std::hex << ctx << " | error code is " << error; \ 62 LOG(ERROR) << "Error when calling " << name << " | current context is: 0x" << std::hex << ctx << " | error code is " << error; \
53 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,"OpenGL error in " name " | See log."); \ 63 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,"OpenGL error in " name " | See log."); \
54 } \ 64 } \
55 } else (void)0 65 } else (void)0
56 66
57 #define ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT(msg) \ 67 # define ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT(msg) \
58 if(true) \ 68 if(true) \
59 { \ 69 { \
60 SDL_GLContext ctx = SDL_GL_GetCurrentContext(); \ 70 SDL_GLContext ctx = SDL_GL_GetCurrentContext(); \
61 LOG(TRACE) << msg << " | Current OpenGL context is " << std::hex << ctx; \ 71 LOG(TRACE) << msg << " | Current OpenGL context is " << std::hex << ctx; \
62 } else (void)0 72 } else (void)0
63 73
64 #define ORTHANC_CHECK_CURRENT_CONTEXT(context) \ 74 # define ORTHANC_CHECK_CURRENT_CONTEXT(context) \
65 if(true) \ 75 if(true) \
66 { \ 76 { \
67 SDL_GLContext actualCtx = SDL_GL_GetCurrentContext(); \ 77 SDL_GLContext actualCtx = SDL_GL_GetCurrentContext(); \
68 void* expectedCtx = context.DebugGetInternalContext(); \ 78 void* expectedCtx = context.DebugGetInternalContext(); \
69 if(expectedCtx != actualCtx) \ 79 if(expectedCtx != actualCtx) \
70 { \ 80 { \
71 LOG(ERROR) << "Expected context was " << std::hex << expectedCtx << " while actual context is " << std::hex << actualCtx; \ 81 LOG(ERROR) << "Expected context was " << std::hex << expectedCtx << " while actual context is " << std::hex << actualCtx; \
72 } \ 82 } \
73 } else (void)0 83 } else (void)0
84
85 # endif
74 86
75 #endif 87 #endif
76 88
77 #if ORTHANC_ENABLE_WASM == 1 89 #if ORTHANC_ENABLE_WASM == 1
78 #include <emscripten/html5.h> 90 #include <emscripten/html5.h>