Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/python/gpu')
-rw-r--r--source/blender/python/gpu/gpu_py.c1
-rw-r--r--source/blender/python/gpu/gpu_py_buffer.c7
-rw-r--r--source/blender/python/gpu/gpu_py_buffer.h7
-rw-r--r--source/blender/python/gpu/gpu_py_offscreen.c21
-rw-r--r--source/blender/python/gpu/gpu_py_offscreen.h4
-rw-r--r--source/blender/python/gpu/gpu_py_select.c1
-rw-r--r--source/blender/python/gpu/gpu_py_texture.c1
7 files changed, 34 insertions, 8 deletions
diff --git a/source/blender/python/gpu/gpu_py.c b/source/blender/python/gpu/gpu_py.c
index e6ba46b2b05..a2d4b0e1031 100644
--- a/source/blender/python/gpu/gpu_py.c
+++ b/source/blender/python/gpu/gpu_py.c
@@ -58,6 +58,7 @@ struct PyC_StringEnumItems bpygpu_dataformat_items[] = {
{GPU_DATA_10_11_11_REV, "10_11_11_REV"},
{0, NULL},
};
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/python/gpu/gpu_py_buffer.c b/source/blender/python/gpu/gpu_py_buffer.c
index abfde7b48c8..f074b51af32 100644
--- a/source/blender/python/gpu/gpu_py_buffer.c
+++ b/source/blender/python/gpu/gpu_py_buffer.c
@@ -687,13 +687,6 @@ size_t bpygpu_Buffer_size(BPyGPUBuffer *buffer)
return pygpu_buffer_calc_size(buffer->format, buffer->shape_len, buffer->shape);
}
-/**
- * Create a buffer object
- *
- * \param shape: An array of `shape_len` integers representing the size of each dimension.
- * \param buffer: When not NULL holds a contiguous buffer
- * with the correct format from which the buffer will be initialized
- */
BPyGPUBuffer *BPyGPU_Buffer_CreatePyObject(const int format,
const Py_ssize_t *shape,
const int shape_len,
diff --git a/source/blender/python/gpu/gpu_py_buffer.h b/source/blender/python/gpu/gpu_py_buffer.h
index 9df22e9b780..cbc46339628 100644
--- a/source/blender/python/gpu/gpu_py_buffer.h
+++ b/source/blender/python/gpu/gpu_py_buffer.h
@@ -48,6 +48,13 @@ typedef struct BPyGPUBuffer {
} BPyGPUBuffer;
size_t bpygpu_Buffer_size(BPyGPUBuffer *buffer);
+/**
+ * Create a buffer object
+ *
+ * \param shape: An array of `shape_len` integers representing the size of each dimension.
+ * \param buffer: When not NULL holds a contiguous buffer
+ * with the correct format from which the buffer will be initialized
+ */
BPyGPUBuffer *BPyGPU_Buffer_CreatePyObject(const int format,
const Py_ssize_t *shape,
const int shape_len,
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;
}
diff --git a/source/blender/python/gpu/gpu_py_offscreen.h b/source/blender/python/gpu/gpu_py_offscreen.h
index 309735a6202..78bad595a3d 100644
--- a/source/blender/python/gpu/gpu_py_offscreen.h
+++ b/source/blender/python/gpu/gpu_py_offscreen.h
@@ -26,9 +26,13 @@ extern PyTypeObject BPyGPUOffScreen_Type;
#define BPyGPUOffScreen_Check(v) (Py_TYPE(v) == &BPyGPUOffScreen_Type)
+struct GPUOffscreen;
+struct GPUViewport;
+
typedef struct BPyGPUOffScreen {
PyObject_HEAD
struct GPUOffScreen *ofs;
+ struct GPUViewport *viewport;
} BPyGPUOffScreen;
PyObject *BPyGPUOffScreen_CreatePyObject(struct GPUOffScreen *ofs) ATTR_NONNULL(1);
diff --git a/source/blender/python/gpu/gpu_py_select.c b/source/blender/python/gpu/gpu_py_select.c
index 4db102118f1..43980530f38 100644
--- a/source/blender/python/gpu/gpu_py_select.c
+++ b/source/blender/python/gpu/gpu_py_select.c
@@ -56,6 +56,7 @@ static PyObject *pygpu_select_load_id(PyObject *UNUSED(self), PyObject *value)
GPU_select_load_id(id);
Py_RETURN_NONE;
}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/python/gpu/gpu_py_texture.c b/source/blender/python/gpu/gpu_py_texture.c
index c034c31d828..66b9cf5e86e 100644
--- a/source/blender/python/gpu/gpu_py_texture.c
+++ b/source/blender/python/gpu/gpu_py_texture.c
@@ -527,6 +527,7 @@ PyTypeObject BPyGPUTexture_Type = {
/* -------------------------------------------------------------------- */
/** \name GPU Texture module
* \{ */
+
PyDoc_STRVAR(pygpu_texture_from_image_doc,
".. function:: from_image(image)\n"
"\n"