-
-
Notifications
You must be signed in to change notification settings - Fork 3k
fix: query GL_MAX_SAMPLES before setting multisampling hint #8087
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
base: develop
Are you sure you want to change the base?
fix: query GL_MAX_SAMPLES before setting multisampling hint #8087
Conversation
- adds better located exceptions to catch things like "couldn't find matching glx visual" - creates and disposes of temporary gl-enabled window and gl context to grab GL_MAX_SAMPLES from
You should be able to query DesktopGL comes with some limitation compared to WindowsDX in the fact that some graphics capabilities can be queried only after the Game constructor due to how SDL operates things under the hood. I'm a bit on the fence to create a fake window just to query that, I feel like it might introduce more issues in the long run that fixing this use case. |
It also has to create a temporary window no matter what, because GL can't query the API without an active context, and the way MonoGame is consuming SDL and GL it requires creating an SDL window. I think creating the full graphics device chain in managed memory is creating a lot more garbage and introducing more opportunities for bugs instead of just quickly creating and destroying an SDL window in a controlled manner and then creating the real window. This is also, to my understanding, standard practice when using SDL (and GL). I also personally have a concern with the approach of exposing this to the end users and expecting them to deal with it because:
|
After reading the docs on this, I think we can handle this a different way (I could be wrong though). Something like
|
We need to verify that it actually does that. But if it does without error, it seems relevant. |
Unfortunately the GL driver doesn't intelligently do this, and that causes the crash that this PR is meant to prevent.
It may be called a hint, but it's not treated as something optional. The
Note that SDL2 does not expose |
This specifically fixes cases where
MultiSampleCount
is set to something like 16 on a build for Desktop GL and then is run on weaker hardware like a Steam Deck whereGL_MAX_SAMPLES
is 8.Games do not have an API to query for this information to set a valid value for
MultiSampleCount
so the error is effectively unrecoverable and extremely hard to diagnose.The exceptions currently thrown are only symptoms of the issue, they don't expose the actual failure which in this case needed to be queried for via
SDL_GetError()
.