Page MenuHome

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

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

Diff Detail

rB Blender

Event Timeline

  • Cleanup: limit lines to a maximum of 80 characters.
Brecht Van Lommel (brecht) requested changes to this revision.Dec 31 2018, 1:35 PM
Brecht Van Lommel (brecht) added inline comments.

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

GPU functions for drawing are not available in background mode.

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.Dec 31 2018, 1:35 PM
Germano Cavalcante (mano-wii) marked an inline comment as done.Dec 31 2018, 5:54 PM
Germano Cavalcante (mano-wii) added inline comments.

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.Dec 31 2018, 6:37 PM
This revision is now accepted and ready to land.Jan 2 2019, 12:29 PM
This revision was automatically updated to reflect the committed changes.