Changeset View
Changeset View
Standalone View
Standalone View
source/blender/python/gpu/gpu_py_batch.c
| Show First 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | #ifdef USE_GPU_PY_REFERENCES | ||||
| PyList_SET_ITEM(ret->references, 0, (PyObject *)py_vertbuf); | PyList_SET_ITEM(ret->references, 0, (PyObject *)py_vertbuf); | ||||
| Py_INCREF(py_vertbuf); | Py_INCREF(py_vertbuf); | ||||
| if (py_indexbuf != NULL) { | if (py_indexbuf != NULL) { | ||||
| PyList_SET_ITEM(ret->references, 1, (PyObject *)py_indexbuf); | PyList_SET_ITEM(ret->references, 1, (PyObject *)py_indexbuf); | ||||
| Py_INCREF(py_indexbuf); | Py_INCREF(py_indexbuf); | ||||
| } | } | ||||
| BLI_assert(!PyObject_GC_IsTracked((PyObject *)ret)); | |||||
| PyObject_GC_Track(ret); | PyObject_GC_Track(ret); | ||||
| #endif | #endif | ||||
| return (PyObject *)ret; | return (PyObject *)ret; | ||||
| } | } | ||||
| PyDoc_STRVAR(pygpu_batch_vertbuf_add_doc, | PyDoc_STRVAR(pygpu_batch_vertbuf_add_doc, | ||||
| ".. method:: vertbuf_add(buf)\n" | ".. method:: vertbuf_add(buf)\n" | ||||
| ▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static int pygpu_batch__tp_clear(BPyGPUBatch *self) | static int pygpu_batch__tp_clear(BPyGPUBatch *self) | ||||
| { | { | ||||
| Py_CLEAR(self->references); | Py_CLEAR(self->references); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| static int pygpu_batch__tp_is_gc(BPyGPUBatch *self) | |||||
| { | |||||
| return self->references != NULL; | |||||
| } | |||||
| #endif | #endif | ||||
| static void pygpu_batch__tp_dealloc(BPyGPUBatch *self) | static void pygpu_batch__tp_dealloc(BPyGPUBatch *self) | ||||
| { | { | ||||
| GPU_batch_discard(self->batch); | GPU_batch_discard(self->batch); | ||||
| #ifdef USE_GPU_PY_REFERENCES | #ifdef USE_GPU_PY_REFERENCES | ||||
| PyObject_GC_UnTrack(self); | PyObject_GC_UnTrack(self); | ||||
| Show All 24 Lines | PyTypeObject BPyGPUBatch_Type = { | ||||
| PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUBatch", | PyVarObject_HEAD_INIT(NULL, 0).tp_name = "GPUBatch", | ||||
| .tp_basicsize = sizeof(BPyGPUBatch), | .tp_basicsize = sizeof(BPyGPUBatch), | ||||
| .tp_dealloc = (destructor)pygpu_batch__tp_dealloc, | .tp_dealloc = (destructor)pygpu_batch__tp_dealloc, | ||||
| #ifdef USE_GPU_PY_REFERENCES | #ifdef USE_GPU_PY_REFERENCES | ||||
| .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, | .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, | ||||
| .tp_doc = pygpu_batch__tp_doc, | .tp_doc = pygpu_batch__tp_doc, | ||||
| .tp_traverse = (traverseproc)pygpu_batch__tp_traverse, | .tp_traverse = (traverseproc)pygpu_batch__tp_traverse, | ||||
| .tp_clear = (inquiry)pygpu_batch__tp_clear, | .tp_clear = (inquiry)pygpu_batch__tp_clear, | ||||
| .tp_is_gc = (inquiry)pygpu_batch__tp_is_gc, | |||||
| #else | #else | ||||
| .tp_flags = Py_TPFLAGS_DEFAULT, | .tp_flags = Py_TPFLAGS_DEFAULT, | ||||
| #endif | #endif | ||||
| .tp_methods = pygpu_batch__tp_methods, | .tp_methods = pygpu_batch__tp_methods, | ||||
| .tp_new = pygpu_batch__tp_new, | .tp_new = pygpu_batch__tp_new, | ||||
| }; | }; | ||||
| /** \} */ | /** \} */ | ||||
| Show All 24 Lines | |||||