Page MenuHome

Fix T59773: Throw an error message if the gpu module is used in backgound mode.
ClosedPublic

Authored by Germano Cavalcante (mano-wii) on Sun, Dec 30, 12:21 AM.

Diff Detail

Repository
rB Blender

Event Timeline

  • Cleanup: limit lines to a maximum of 80 characters.
Brecht Van Lommel (brecht) requested changes to this revision.Mon, Dec 31, 1:35 PM
Brecht Van Lommel (brecht) added inline comments.
source/blender/python/gpu/gpu_py.c
56

This is too vague. Could be something more specific like:

GPU functions for drawing are not available in background mode.
63

This seems to permanently disable the GPU module when Python tries to import it. But it can be initialized later on still, so this seems wrong.

Maybe it is better to disallow important the module at the top level. @Bastien Montagne (mont29) say in the task it wasn't necessary, but to me that seems like the cleaner solution?

This revision now requires changes to proceed.Mon, Dec 31, 1:35 PM
Germano Cavalcante (mano-wii) marked an inline comment as done.Mon, Dec 31, 5:54 PM
Germano Cavalcante (mano-wii) added inline comments.
source/blender/python/gpu/gpu_py.c
63

I agree, I didn't think of this. With a small change in the C code the python files can be initialized before the GPU.
Another solution would be to check if the GPU is initialized before calling each function. I tried to avoid this because some drawing functions can be called too often and it would be good to avoid overhead.
But the overhead is small. editing...

  • Check if gpu is initialized before calls instead of when initializing module.

    I have added check only on functions that initialize types and on the one that gets builtin shaders. Since these should always be called first and that the code in python should be stopped after an error.
Germano Cavalcante (mano-wii) marked an inline comment as done.Mon, Dec 31, 6:37 PM
This revision is now accepted and ready to land.Wed, Jan 2, 12:29 PM
This revision was automatically updated to reflect the committed changes.