-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can we make glGetError processing available for every function automatically or with a switch? #44
Comments
I think XS helper function and compile switch (so no runtime overhead when the "autodie" isn't enabled) would be the best way to go. If someone wants to "autodie" at runtime, could an OpenGL::Modern::Strict module do that using AUTOLOAD and injecting the check? |
My understanding of OpenGL debugging is that it is something that you use to develop your code and not something to be in the non-Debug version due to the extreme performance consequences. At the moment, your perl implementation seems reasonable as glGetError() is one of the "good" routines with no pointer args or return values and so is correctly implemented. If we want a better performing debug capability, I think it would need to hook in at the C layer. |
@devel-chm Also my perl implementation would work, but also be horrible shit performance-wise to the point of making proper debugging nearly impossible. So yeah, some kind of C implementation is necessary. However so far you haven't actually opined yet on which of the options i floated are viable or if you see other options. Are you going to make a more detailed post later? @CandyAngel |
This option is perfectly doable performance-wise:
We already have this code: https://github.com/devel-chm/OpenGL-Modern/blob/master/utils/generate-XS.pl#L307-L312 I profiled OpenGL::Modern with and without that code, and that check seems to be nearly free, in terms of CPU time, or at the very least so small that it completely disappears into the noise. In Microidium:
As such, we can implement:
|
Thanks for the timings. I think the general option should be the runtime enable/disable which would give convenience at the cost of performance. You could have a use switch to choose a non-debug version for more performance. XS acceleration of glGetError can be done as well---even for the case of non-debug XS for OpenGL. |
Again i am confused. Why are you talking about XS acceleration? Why are you talking about performance cost? I described above that i profiled the XS code we already have that does something like that and found zero measurable performance impact. The proposal is not to do any perl code at all, but go to XS immediately, and this is so simple i can probably do it myself. if ( glGetErrorAfterGLCalls ) {
GLenum err;
while ((err = glGetError()) != GL_NO_ERROR) {
warn( "OpenGL error: " '%s'", err);
}
croak( "OpenGL error encountered.");
} Due to being in XS the performance impact of this is below the noise level if glGetErrorAfterGLCalls is 0. At the same time glGetErrorAfterGLCalls can be activated or disabled any time with a dead simple XS function that sets/unsets it. |
I'm confused about why you are confused. The original question had 4 options, I just replied based on your timings that option 4 would be a good default, option 3 could be used for extra performance by cutting out unneeded overhead---even if small, option 2 is not good (build time selection is only good for perl gurus and not general perl OpenGL developers), and that option 1 could be done at any case. |
Because the conclusion of my timings post was "we can do option 4 just fine in all XS with no measurable performance impact", which means no further discussion of Perl code, performance, or even the other options was needed, as far as i can tell. |
That was not the case but, as I started with, option 4 is good. |
Alright, i get it, you were agreeing with that last proposal, just in such a way that i failed to read it correctly. |
Official spec: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetError.xhtml
Examples: https://blog.nobel-joergensen.com/2013/01/29/debugging-opengl-using-glgeterror/
Short version, every GL function has the potential to push an error state onto the gl error stack. Right now in Perl in order to interrogate this, one has to do roughly the following for every single call (optimally) or group of calls.
As you can see the performance implications of this are immense. Better solutions i can think of:
use OpenGL::Modern -debug;
OpenGL::Modern::glpSetDebug( 0 || 1 )
Do you think any of that would be acceptable?
The text was updated successfully, but these errors were encountered: