-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
GPU: Functions that may return errors should call SDL_SetError() #10779
Comments
The log calls should generally be switched to SDL_SetError() |
Error setting is reasonable on things like creation functions, where we return NULL if the creation failed, and we should do that. Error setting on hot-path commands will just be futile - those functions shouldn't return anything but void and nobody can check them for errors without turning their client code into an absolute mess. |
We should probably have a similar policy with the SDL render API, and possibly add a debug layer there. @icculus, thoughts? |
I think the render layer is okay as-is: it uses SDL_SetError where reasonable and doesn't need a debug layer because there isn't really much you can do with it that's a surprising silent failure, unlike using OpenGL directly. |
We decided that anything where the underlying APIs return error codes is something we should bubble up into GPU, anything else is probably unrecoverable or we can catch obvious failures with debug mode validations. |
Resolved by 557c6df |
Not yet resolved, see comments. |
Maybe actually resolved by 925e47a ? |
@slouken If it's OK to call both LogError and SetError I'll go ahead and just do that, but isn't it a bit redundant with SDL_LOG_PRIORITY_DEBUG? |
I'm thinking something like this: SDL_SetError(...);
if (debug) {
SDL_LogError(SDL_LOG_CATEGORY_GPU, ...);
} Setting an error doesn't automatically log, and having an error in the GPU log category means that the application can filter it appropriately. As an aside, we should have a hint that forces debug on so users can enable debug validation and error printing from the environment. |
That seems alright to me, but I do worry that not logging errors at all if debug mode is off might cause difficulties for clients if errors come up in deployment. |
That's what the hint is for. "Just set this environment variable (or enable the "Debug GPU option") and send me the debug output" |
Alright, I'm going to revise the functions further tomorrow, we need to restructure some of them to cleanly return errors. |
Currently most (all?) of the error reporting is done through the SDL log, and APIs that may fail (e.g.
SDL_CreateGPUDevice
) do not callSDL_SetError()
. This makes it impossible to, for example, display a message box with the failure reason.The text was updated successfully, but these errors were encountered: