[Bf-blender-cvs] [0f34c24c6f5] pygpu_extensions: Fix errors when binding framebuffer or offscreen (and Cleanup)

Germano Cavalcante noreply at git.blender.org
Fri Feb 12 16:17:22 CET 2021


Commit: 0f34c24c6f5e6c0df9f8a0e1a6220fda5e95c36d
Author: Germano Cavalcante
Date:   Thu Feb 11 21:51:24 2021 -0300
Branches: pygpu_extensions
https://developer.blender.org/rB0f34c24c6f5e6c0df9f8a0e1a6220fda5e95c36d

Fix errors when binding framebuffer or offscreen (and Cleanup)

===================================================================

M	source/blender/python/gpu/gpu_py_framebuffer.c
M	source/blender/python/gpu/gpu_py_offscreen.c

===================================================================

diff --git a/source/blender/python/gpu/gpu_py_framebuffer.c b/source/blender/python/gpu/gpu_py_framebuffer.c
index be01493958b..48b7cf90284 100644
--- a/source/blender/python/gpu/gpu_py_framebuffer.c
+++ b/source/blender/python/gpu/gpu_py_framebuffer.c
@@ -120,15 +120,15 @@ typedef struct {
   PyObject_HEAD /* required python macro */
       BPyGPUFrameBuffer *py_fb;
   int level;
-} BPyGPU_FrameBufferStackContext;
+} PyFrameBufferStackContext;
 
-static void BPyGPUFrameBufferStackContext__tp_dealloc(BPyGPU_FrameBufferStackContext *self)
+static void py_framebuffer_stack_context__tp_dealloc(PyFrameBufferStackContext *self)
 {
   Py_DECREF(self->py_fb);
-  Py_TYPE(self)->tp_free((PyObject *)self);
+  PyObject_DEL(self);
 }
 
-static PyObject *py_framebuffer_stack_context_enter(BPyGPU_FrameBufferStackContext *self)
+static PyObject *py_framebuffer_stack_context_enter(PyFrameBufferStackContext *self)
 {
   PY_FRAMEBUFFER_CHECK_OBJ(self->py_fb);
 
@@ -146,7 +146,7 @@ static PyObject *py_framebuffer_stack_context_enter(BPyGPU_FrameBufferStackConte
   Py_RETURN_NONE;
 }
 
-static PyObject *py_framebuffer_stack_context_exit(BPyGPU_FrameBufferStackContext *self,
+static PyObject *py_framebuffer_stack_context_exit(PyFrameBufferStackContext *self,
                                                    PyObject *UNUSED(args))
 {
   PY_FRAMEBUFFER_CHECK_OBJ(self->py_fb);
@@ -174,10 +174,10 @@ static PyMethodDef py_framebuffer_stack_context_methods[] = {
     {NULL},
 };
 
-static PyTypeObject BPyGPU_framebuffer_stack_context_Type = {
+static PyTypeObject py_framebuffer_stack_context_Type = {
     PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUFrameBufferStackContext",
-    .tp_basicsize = sizeof(BPyGPU_FrameBufferStackContext),
-    .tp_dealloc = (destructor)BPyGPUFrameBufferStackContext__tp_dealloc,
+    .tp_basicsize = sizeof(PyFrameBufferStackContext),
+    .tp_dealloc = (destructor)py_framebuffer_stack_context__tp_dealloc,
     .tp_flags = Py_TPFLAGS_DEFAULT,
     .tp_methods = py_framebuffer_stack_context_methods,
 };
@@ -188,8 +188,8 @@ PyDoc_STRVAR(py_framebuffer_bind_doc,
              "   Context manager to ensure balanced bind calls, even in the case of an error.\n");
 static PyObject *py_framebuffer_bind(BPyGPUFrameBuffer *self)
 {
-  BPyGPU_FrameBufferStackContext *ret = PyObject_New(BPyGPU_FrameBufferStackContext,
-                                                     &BPyGPU_framebuffer_stack_context_Type);
+  PyFrameBufferStackContext *ret = PyObject_New(PyFrameBufferStackContext,
+                                                &py_framebuffer_stack_context_Type);
   ret->py_fb = self;
   ret->level = -1;
   Py_INCREF(self);
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c
index 6dc097d5936..3f59eb23df7 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.c
+++ b/source/blender/python/gpu/gpu_py_offscreen.c
@@ -88,15 +88,15 @@ typedef struct {
   PyObject_HEAD /* required python macro */
       BPyGPUOffScreen *py_offs;
   int level;
-} BPyGPU_OffScreenStackContext;
+} PyOffScreenStackContext;
 
-static void BPyGPUOffScreenStackContext__tp_dealloc(BPyGPU_OffScreenStackContext *self)
+static void py_offscreen_stack_context__tp_dealloc(PyOffScreenStackContext *self)
 {
   Py_DECREF(self->py_offs);
-  Py_TYPE(self)->tp_free((PyObject *)self);
+  PyObject_DEL(self);
 }
 
-static PyObject *py_offscreen_stack_context_enter(BPyGPU_OffScreenStackContext *self)
+static PyObject *py_offscreen_stack_context_enter(PyOffScreenStackContext *self)
 {
   BPY_GPU_OFFSCREEN_CHECK_OBJ(self->py_offs);
 
@@ -112,7 +112,7 @@ static PyObject *py_offscreen_stack_context_enter(BPyGPU_OffScreenStackContext *
   Py_RETURN_NONE;
 }
 
-static PyObject *py_offscreen_stack_context_exit(BPyGPU_OffScreenStackContext *self,
+static PyObject *py_offscreen_stack_context_exit(PyOffScreenStackContext *self,
                                                  PyObject *UNUSED(args))
 {
   BPY_GPU_OFFSCREEN_CHECK_OBJ(self->py_offs);
@@ -138,10 +138,10 @@ static PyMethodDef py_offscreen_stack_context_methods[] = {
     {NULL},
 };
 
-static PyTypeObject BPyGPU_offscreen_stack_context_Type = {
+static PyTypeObject py_offscreen_stack_context_Type = {
     PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUFrameBufferStackContext",
-    .tp_basicsize = sizeof(BPyGPU_OffScreenStackContext),
-    .tp_dealloc = (destructor)BPyGPUOffScreenStackContext__tp_dealloc,
+    .tp_basicsize = sizeof(PyOffScreenStackContext),
+    .tp_dealloc = (destructor)py_offscreen_stack_context__tp_dealloc,
     .tp_flags = Py_TPFLAGS_DEFAULT,
     .tp_methods = py_offscreen_stack_context_methods,
 };
@@ -152,8 +152,8 @@ PyDoc_STRVAR(py_offscreen_bind_doc,
              "   Context manager to ensure balanced bind calls, even in the case of an error.\n");
 static PyObject *py_offscreen_bind(BPyGPUOffScreen *self)
 {
-  BPyGPU_OffScreenStackContext *ret = PyObject_New(BPyGPU_OffScreenStackContext,
-                                                   &BPyGPU_offscreen_stack_context_Type);
+  PyOffScreenStackContext *ret = PyObject_New(PyOffScreenStackContext,
+                                              &py_offscreen_stack_context_Type);
   ret->py_offs = self;
   ret->level = -1;
   Py_INCREF(self);
@@ -175,7 +175,7 @@ static PyObject *py_offscreen_new(PyTypeObject *UNUSED(self), PyObject *args, Py
   char err_out[256];
 
   static const char *_keywords[] = {"width", "height", NULL};
-  static _PyArg_Parser _parser = {"ii|i:GPUOffScreen.__new__", _keywords, 0};
+  static _PyArg_Parser _parser = {"ii:GPUOffScreen.__new__", _keywords, 0};
   if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, &width, &height)) {
     return NULL;
   }



More information about the Bf-blender-cvs mailing list