diff options
author | Siddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in> | 2021-12-17 16:01:32 +0300 |
---|---|---|
committer | Siddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in> | 2021-12-17 16:01:32 +0300 |
commit | dbc41b30f88b96f7d8c6e995b17f5930eb55cc77 (patch) | |
tree | c6c495328443ea3621e5df2ef483b0e0dd504496 /source/blender/python/gpu/gpu_py_offscreen.c | |
parent | 99a2af76d10e05a18987be5d554ada197b1ca086 (diff) | |
parent | 7c9e4099854a4fc8eab4db97173c1aacd25f9e08 (diff) |
Merge branch 'master' into soc-2021-uv-edge-select-supportsoc-2021-uv-edge-select-support
Diffstat (limited to 'source/blender/python/gpu/gpu_py_offscreen.c')
-rw-r--r-- | source/blender/python/gpu/gpu_py_offscreen.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c index 6f23c2213e2..48fbe09f0ce 100644 --- a/source/blender/python/gpu/gpu_py_offscreen.c +++ b/source/blender/python/gpu/gpu_py_offscreen.c @@ -44,6 +44,7 @@ #include "GPU_context.h" #include "GPU_framebuffer.h" #include "GPU_texture.h" +#include "GPU_viewport.h" #include "ED_view3d.h" #include "ED_view3d_offscreen.h" @@ -355,6 +356,15 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar GPU_offscreen_bind(self->ofs, true); + /* Cache the #GPUViewport so the frame-buffers and associated textures are + * not reallocated each time, see: T89204 */ + if (!self->viewport) { + self->viewport = GPU_viewport_create(); + } + else { + GPU_viewport_tag_update(self->viewport); + } + ED_view3d_draw_offscreen(depsgraph, scene, v3d->shading.type, @@ -370,7 +380,7 @@ static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *ar do_color_management, true, self->ofs, - NULL); + self->viewport); GPU_offscreen_unbind(self->ofs, true); @@ -391,6 +401,11 @@ static PyObject *pygpu_offscreen_free(BPyGPUOffScreen *self) { BPY_GPU_OFFSCREEN_CHECK_OBJ(self); + if (self->viewport) { + GPU_viewport_free(self->viewport); + self->viewport = NULL; + } + GPU_offscreen_free(self->ofs); self->ofs = NULL; Py_RETURN_NONE; @@ -399,6 +414,9 @@ static PyObject *pygpu_offscreen_free(BPyGPUOffScreen *self) static void BPyGPUOffScreen__tp_dealloc(BPyGPUOffScreen *self) { + if (self->viewport) { + GPU_viewport_free(self->viewport); + } if (self->ofs) { GPU_offscreen_free(self->ofs); } @@ -469,6 +487,7 @@ PyObject *BPyGPUOffScreen_CreatePyObject(GPUOffScreen *ofs) self = PyObject_New(BPyGPUOffScreen, &BPyGPUOffScreen_Type); self->ofs = ofs; + self->viewport = NULL; return (PyObject *)self; } |