-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
[3.x] Clear glErrors instead of crashing when initializing GLES3 #49791
[3.x] Clear glErrors instead of crashing when initializing GLES3 #49791
Conversation
Ah yes this is something left in from development, good spot. 👍 Note also there is a It didn't occur to me also that something external might set an error condition! 😄 Maybe we can centralize all this in one place, probably in the Rasterizer rather than RasterizerCanvas so it can be accessed from either the canvas or scene rasterizer (I think that's why I put it there originally). Then we can print the error messages clear them out, and not call to crash, that can always be added during debugging. It does seem to make sense to have a convenient central function for doing all this error checking. I think for the initialize function, providing they just print the errors and don't crash, there shouldn't be a problem leaving them in, it might alert us to problems occurring silently and help diagnose issues. The other thing is that some GL implementations are more verbose with their errors than others, and something that passes fine in development might generate an error that is more of a warning in practice, and we don't want it to crash in that circumstance. From memory some things OpenGL doesn't always pick up are parameters, like using an int where there should be a bool or vice versa etc. |
How about a This would replace:
|
Yup that sounds great. 👍 |
9fc726c
to
8788472
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me. I'm not sure the comment about STACK_UNDERFLOW and STACK_OVERFLOW warrants more than a one liner, but this is fine.
It's a one line justification for why I've commented out the subsequent lines. |
Thanks! |
Cherry-picked for 3.3.3. |
In GLES3, sometimes, another application can set a GLError flag. For example, the Android emulator's OpenGL rendering engine with:
glUtilsParamSize: unknow param 0x000082da
. Later, before Godot tries to initialize theRasterizerCanvasGLES3
, it checks whether there is already a GLError:godot/drivers/gles3/rasterizer_canvas_gles3.cpp
Lines 2151 to 2155 in 2966084
and crashes if there is:
godot/drivers/gles3/rasterizer_canvas_gles3.cpp
Lines 68 to 71 in 2966084
This check does not happen in GLES2, so even if there is an existing error, it does not crash:
godot/drivers/gles2/rasterizer_canvas_gles2.cpp
Lines 2322 to 2325 in 2966084
Instead of crashing if there is an existing GLError, this PR clears the GLError before trying to initialize
RasterizerCanvasGLES3
.Note 1: It will still check after initializing for errors and crash if the initializing causes a GLError:
godot/drivers/gles3/rasterizer_canvas_gles3.cpp
Lines 2283 to 2284 in 2966084
Again, this check does not happen on GLES2, so GLES2 won't crash there either. These crashing checks were added as part of #42119. Perhaps they should be removed entirely. cc @lawnjelly
Note 2: This PR is made against 3.x, because there is no GLES3 on master.