Python GPU: Add reference of PyObject GPU object to the GPU object itself

Instead of creating different python wrappers for the same GPU object,
return the same `PyObject` created earlier.

This also allows for more secure access to existing GPU objects.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D11044
This commit is contained in:
Germano Cavalcante
2021-04-29 14:48:59 -03:00
committed by Germano Cavalcante
parent c96506d54a
commit 04b6296e81
12 changed files with 143 additions and 25 deletions

View File

@@ -28,6 +28,11 @@ extern PyTypeObject BPyGPUFrameBuffer_Type;
typedef struct BPyGPUFrameBuffer {
PyObject_HEAD struct GPUFrameBuffer *fb;
#if GPU_USE_PY_REFERENCES
bool shared_reference;
#endif
} BPyGPUFrameBuffer;
PyObject *BPyGPUFrameBuffer_CreatePyObject(struct GPUFrameBuffer *fb) ATTR_NONNULL(1);
PyObject *BPyGPUFrameBuffer_CreatePyObject(struct GPUFrameBuffer *fb, bool shared_reference)
ATTR_NONNULL(1);