Blender V5.3
gpu_py_offscreen.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2015 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
14
15#include <Python.h>
16
17#include "BLI_string_utf8.hh"
18
19#include "BKE_global.hh"
20#include "BKE_lib_id.hh" /* For #BKE_id_is_in_global_main. */
21#include "BKE_scene.hh"
22
23#include "DNA_view3d_types.h"
24
25#include "GPU_context.hh"
26#include "GPU_framebuffer.hh"
27#include "GPU_state.hh"
28#include "GPU_texture.hh"
29#include "GPU_viewport.hh"
30
32
34
36#include "../generic/python_compat.hh" /* IWYU pragma: keep. */
37
38#include "gpu_py.hh"
39#include "gpu_py_texture.hh"
40
41#include "gpu_py_offscreen.hh" /* own include */
42
43namespace blender {
44
45/* Define the free method to avoid breakage. */
46#define BPYGPU_USE_GPUOBJ_FREE_METHOD
47
48/* -------------------------------------------------------------------- */
51
53 {int(gpu::TextureFormat::UNORM_8_8_8_8), "RGBA8"},
54 {int(gpu::TextureFormat::UNORM_16_16_16_16), "RGBA16"},
55 {int(gpu::TextureFormat::SFLOAT_16_16_16_16), "RGBA16F"},
56 {int(gpu::TextureFormat::SFLOAT_32_32_32_32), "RGBA32F"},
57 {0, nullptr},
58};
59
61{
62 if (py_ofs->ofs == nullptr) [[unlikely]] {
63 PyErr_SetString(PyExc_ReferenceError,
65 "GPU offscreen was freed, no further access is valid"
66#else
67 "GPU offscreen: internal error"
68#endif
69 );
70 return -1;
71 }
72 return 0;
73}
74
75#define BPY_GPU_OFFSCREEN_CHECK_OBJ(bpygpu) \
76 { \
77 if (pygpu_offscreen_valid_check(bpygpu) == -1) [[unlikely]] { \
78 return nullptr; \
79 } \
80 } \
81 ((void)0)
82
84
85/* -------------------------------------------------------------------- */
91
93 PyObject_HEAD /* Required Python macro. */
95 int level;
96 bool is_explicitly_bound; /* Bound by "bind" method. */
97};
98
100{
101 Py_DECREF(self->py_offscreen);
102 PyObject_DEL(self);
103}
104
106{
108
110
111 if (!self->is_explicitly_bound) {
112 if (self->level != -1) {
113 PyErr_SetString(PyExc_RuntimeError, "Already in use");
114 return nullptr;
115 }
116
117 GPU_offscreen_bind(self->py_offscreen->ofs, true);
119 }
120
121 Py_RETURN_NONE;
122}
123
125 PyObject * /*args*/)
126{
128
130
131 if (self->level == -1) {
132 PyErr_SetString(PyExc_RuntimeError, "Not yet in use\n");
133 return nullptr;
134 }
135
136 const int level = GPU_framebuffer_stack_level_get();
137 if (level != self->level) {
138 PyErr_Format(
139 PyExc_RuntimeError, "Level of bind mismatch, expected %d, got %d\n", self->level, level);
140 }
141
143 Py_RETURN_NONE;
144}
145
146#ifdef __GNUC__
147# ifdef __clang__
148# pragma clang diagnostic push
149# pragma clang diagnostic ignored "-Wcast-function-type"
150# else
151# pragma GCC diagnostic push
152# pragma GCC diagnostic ignored "-Wcast-function-type"
153# endif
154#endif
155
157 {"__enter__", reinterpret_cast<PyCFunction>(pygpu_offscreen_stack_context_enter), METH_NOARGS},
158 {"__exit__", reinterpret_cast<PyCFunction>(pygpu_offscreen_stack_context_exit), METH_VARARGS},
159 {nullptr},
160};
161
162#ifdef __GNUC__
163# ifdef __clang__
164# pragma clang diagnostic pop
165# else
166# pragma GCC diagnostic pop
167# endif
168#endif
169
171 /* Wrap. */
172 pygpu_offscreen_stack_context__tp_doc,
173 "Context manager for off-screen framebuffer binding.");
175 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
176 /*tp_name*/ "OffScreenStackContext",
177 /*tp_basicsize*/ sizeof(OffScreenStackContext),
178 /*tp_itemsize*/ 0,
179 /*tp_dealloc*/ reinterpret_cast<destructor>(pygpu_offscreen_stack_context__tp_dealloc),
180 /*tp_vectorcall_offset*/ 0,
181 /*tp_getattr*/ nullptr,
182 /*tp_setattr*/ nullptr,
183 /*tp_as_async*/ nullptr,
184 /*tp_repr*/ nullptr,
185 /*tp_as_number*/ nullptr,
186 /*tp_as_sequence*/ nullptr,
187 /*tp_as_mapping*/ nullptr,
188 /*tp_hash*/ nullptr,
189 /*tp_call*/ nullptr,
190 /*tp_str*/ nullptr,
191 /*tp_getattro*/ nullptr,
192 /*tp_setattro*/ nullptr,
193 /*tp_as_buffer*/ nullptr,
194 /*tp_flags*/ Py_TPFLAGS_DEFAULT,
195 /*tp_doc*/ pygpu_offscreen_stack_context__tp_doc,
196 /*tp_traverse*/ nullptr,
197 /*tp_clear*/ nullptr,
198 /*tp_richcompare*/ nullptr,
199 /*tp_weaklistoffset*/ 0,
200 /*tp_iter*/ nullptr,
201 /*tp_iternext*/ nullptr,
203 /*tp_members*/ nullptr,
204 /*tp_getset*/ nullptr,
205 /*tp_base*/ nullptr,
206 /*tp_dict*/ nullptr,
207 /*tp_descr_get*/ nullptr,
208 /*tp_descr_set*/ nullptr,
209 /*tp_dictoffset*/ 0,
210 /*tp_init*/ nullptr,
211 /*tp_alloc*/ nullptr,
212 /*tp_new*/ nullptr,
213 /*tp_free*/ nullptr,
214 /*tp_is_gc*/ nullptr,
215 /*tp_bases*/ nullptr,
216 /*tp_mro*/ nullptr,
217 /*tp_cache*/ nullptr,
218 /*tp_subclasses*/ nullptr,
219 /*tp_weaklist*/ nullptr,
220 /*tp_del*/ nullptr,
221 /*tp_version_tag*/ 0,
222 /*tp_finalize*/ nullptr,
223 /*tp_vectorcall*/ nullptr,
224};
225
227 /* Wrap. */
228 pygpu_offscreen_bind_doc,
229 ".. method:: bind()\n"
230 "\n"
231 " Context manager to ensure balanced bind calls, even in the case of an error.\n"
232 "\n"
233 " :return: A context manager for the off-screen binding.\n"
234 " :rtype: :class:`gpu.types.OffScreenStackContext`\n");
236{
239 ret->py_offscreen = self;
240 ret->level = -1;
241 ret->is_explicitly_bound = false;
242 Py_INCREF(self);
243
244 PyObject *enter_ret = pygpu_offscreen_stack_context_enter(ret);
245 if (enter_ret == nullptr) [[unlikely]] {
246 Py_DECREF(ret);
247 return nullptr;
248 }
249 Py_DECREF(enter_ret);
250 ret->is_explicitly_bound = true;
251
252 return reinterpret_cast<PyObject *>(ret);
253}
254
256 /* Wrap. */
257 pygpu_offscreen_unbind_doc,
258 ".. method:: unbind(*, restore=True)\n"
259 "\n"
260 " Unbind the offscreen object.\n"
261 "\n"
262 " :param restore: Restore the OpenGL state, can only be used when the state has been "
263 "saved before.\n"
264 " :type restore: bool\n");
265static PyObject *pygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
266{
267 bool restore = true;
268
270
271 static const char *_keywords[] = {"restore", nullptr};
272 static _PyArg_Parser _parser = {
273 "|$" /* Optional, keyword only arguments. */
274 "O&" /* `restore` */
275 ":unbind",
276 _keywords,
277 nullptr,
278 };
279 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, PyC_ParseBool, &restore)) {
280 return nullptr;
281 }
282
283 GPU_offscreen_unbind(self->ofs, restore);
285 Py_RETURN_NONE;
286}
287
289
290/* -------------------------------------------------------------------- */
293
294static PyObject *pygpu_offscreen__tp_new(PyTypeObject * /*self*/, PyObject *args, PyObject *kwds)
295{
297
298 GPUOffScreen *ofs = nullptr;
299 int width, height;
301 int(gpu::TextureFormat::UNORM_8_8_8_8)};
302 char err_out[256];
303
304 static const char *_keywords[] = {"width", "height", "format", nullptr};
305 static _PyArg_Parser _parser = {
306 "i" /* `width` */
307 "i" /* `height` */
308 "|$" /* Optional, keyword only arguments. */
309 "O&" /* `format` */
310 ":GPUOffScreen.__new__",
311 _keywords,
312 nullptr,
313 };
314 if (!_PyArg_ParseTupleAndKeywordsFast(
315 args, kwds, &_parser, &width, &height, PyC_ParseStringEnum, &pygpu_textureformat))
316 {
317 return nullptr;
318 }
319
321 ofs = GPU_offscreen_create(width,
322 height,
323 true,
324 gpu::TextureFormat(pygpu_textureformat.value_found),
326 false,
327 err_out);
328 }
329 else {
330 STRNCPY_UTF8(err_out, "No active GPU context found");
331 }
332
333 if (ofs == nullptr) {
334 PyErr_Format(PyExc_RuntimeError,
335 "gpu.offscreen.new(...) failed with '%s'",
336 err_out[0] ? err_out : "unknown error");
337 return nullptr;
338 }
339
341}
342
344 /* Wrap. */
345 pygpu_offscreen_width_doc,
346 "Width of the texture.\n"
347 "\n"
348 ":type: int\n");
349static PyObject *pygpu_offscreen_width_get(BPyGPUOffScreen *self, void * /*type*/)
350{
352 return PyLong_FromLong(GPU_offscreen_width(self->ofs));
353}
354
356 /* Wrap. */
357 pygpu_offscreen_height_doc,
358 "Height of the texture.\n"
359 "\n"
360 ":type: int\n");
361static PyObject *pygpu_offscreen_height_get(BPyGPUOffScreen *self, void * /*type*/)
362{
364 return PyLong_FromLong(GPU_offscreen_height(self->ofs));
365}
366
368 /* Wrap. */
369 pygpu_offscreen_texture_color_doc,
370 "The color texture attached.\n"
371 "\n"
372 ":type: :class:`gpu.types.GPUTexture`\n");
379
381 /* Wrap. */
382 pygpu_offscreen_draw_view3d_doc,
383 ".. method:: draw_view3d(scene, view_layer, view3d, region, view_matrix, projection_matrix, "
384 "*, do_color_management=False, draw_background=True)\n"
385 "\n"
386 " Draw the 3d viewport in the offscreen object.\n"
387 "\n"
388 " :param scene: Scene to draw.\n"
389 " :type scene: :class:`bpy.types.Scene`\n"
390 " :param view_layer: View layer to draw.\n"
391 " :type view_layer: :class:`bpy.types.ViewLayer`\n"
392 " :param view3d: 3D View to get the drawing settings from.\n"
393 " :type view3d: :class:`bpy.types.SpaceView3D`\n"
394 " :param region: Region of the 3D View (required as temporary draw target).\n"
395 " :type region: :class:`bpy.types.Region`\n"
396 " :param view_matrix: View Matrix (e.g. ``camera.matrix_world.inverted()``).\n"
397 " :type view_matrix: :class:`mathutils.Matrix`\n"
398 " :param projection_matrix: Projection Matrix (e.g. ``camera.calc_matrix_camera(...)``).\n"
399 " :type projection_matrix: :class:`mathutils.Matrix`\n"
400 " :param do_color_management: Color manage the output.\n"
401 " :type do_color_management: bool\n"
402 " :param draw_background: Draw background.\n"
403 " :type draw_background: bool\n");
404static PyObject *pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
405{
406 MatrixObject *py_mat_view, *py_mat_projection;
407 PyObject *py_scene, *py_view_layer, *py_region, *py_view3d;
408
409 Depsgraph *depsgraph;
410 Scene *scene;
411 ViewLayer *view_layer;
412 View3D *v3d;
413 ARegion *region;
414
415 bool do_color_management = false;
416 bool draw_background = true;
417
419
420 static const char *_keywords[] = {
421 "scene",
422 "view_layer",
423 "view3d",
424 "region",
425 "view_matrix",
426 "projection_matrix",
427 "do_color_management",
428 "draw_background",
429 nullptr,
430 };
431 static _PyArg_Parser _parser = {
432 "O" /* `scene` */
433 "O" /* `view_layer` */
434 "O" /* `view3d` */
435 "O" /* `region` */
436 "O&" /* `view_matrix` */
437 "O&" /* `projection_matrix` */
438 "|$" /* Optional, keyword only arguments. */
439 "O&" /* `do_color_management` */
440 "O&" /* `draw_background` */
441 ":draw_view3d",
442 _keywords,
443 nullptr,
444 };
445 if (!_PyArg_ParseTupleAndKeywordsFast(args,
446 kwds,
447 &_parser,
448 &py_scene,
449 &py_view_layer,
450 &py_view3d,
451 &py_region,
453 &py_mat_view,
455 &py_mat_projection,
457 &do_color_management,
459 &draw_background) ||
460 (!(scene = static_cast<Scene *>(PyC_RNA_AsPointer(py_scene, "Scene"))) ||
461 !(view_layer = static_cast<ViewLayer *>(PyC_RNA_AsPointer(py_view_layer, "ViewLayer"))) ||
462 !(v3d = static_cast<View3D *>(PyC_RNA_AsPointer(py_view3d, "SpaceView3D"))) ||
463 !(region = static_cast<ARegion *>(PyC_RNA_AsPointer(py_region, "Region")))))
464 {
465 return nullptr;
466 }
467
469 /* NOTE(@ideasman42): Nested draw calls could be supported.
470 * Adding support for this looks to be possible but non-trivial. */
471 PyErr_SetString(PyExc_RuntimeError, "Nested off-screen drawing not supported");
472 return nullptr;
473 }
474
476
477 depsgraph = BKE_scene_ensure_depsgraph(G_MAIN, scene, view_layer);
478
479 GPU_offscreen_bind(self->ofs, true);
480
481 /* Cache the #GPUViewport so the frame-buffers and associated textures are
482 * not reallocated each time, see: #89204 */
483 if (!self->viewport) {
485 }
486 else {
488 }
489
490 ED_view3d_draw_offscreen(depsgraph,
491 scene,
492 eDrawType(v3d->shading.type),
493 v3d,
494 region,
495 nullptr,
498 reinterpret_cast<const float (*)[4]>(py_mat_view->matrix),
499 reinterpret_cast<const float (*)[4]>(py_mat_projection->matrix),
500 true,
501 draw_background,
502 "",
503 do_color_management,
504 true,
505 self->ofs,
506 self->viewport);
507
508 GPU_offscreen_unbind(self->ofs, true);
509
510 Py_RETURN_NONE;
511}
512
513#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
515 /* Wrap. */
516 pygpu_offscreen_free_doc,
517 ".. method:: free()\n"
518 "\n"
519 " Free the offscreen object.\n"
520 " The framebuffer, texture and render objects will no longer be accessible.\n");
522{
524
525 if (self->viewport) {
527 self->viewport = nullptr;
528 }
529
530 GPU_offscreen_free(self->ofs);
531 self->ofs = nullptr;
532 Py_RETURN_NONE;
533}
534#endif
535
537{
538 if (self->viewport) {
540 }
541 if (self->ofs) {
542 GPU_offscreen_free(self->ofs);
543 }
544 Py_TYPE(self)->tp_free(reinterpret_cast<PyObject *>(self));
545}
546
547static PyGetSetDef pygpu_offscreen__tp_getseters[] = {
548 {"texture_color",
549 reinterpret_cast<getter>(pygpu_offscreen_texture_color_get),
550 static_cast<setter>(nullptr),
551 pygpu_offscreen_texture_color_doc,
552 nullptr},
553 {"width",
554 reinterpret_cast<getter>(pygpu_offscreen_width_get),
555 static_cast<setter>(nullptr),
556 pygpu_offscreen_width_doc,
557 nullptr},
558 {"height",
559 reinterpret_cast<getter>(pygpu_offscreen_height_get),
560 static_cast<setter>(nullptr),
561 pygpu_offscreen_height_doc,
562 nullptr},
563 {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */
564};
565
566#ifdef __GNUC__
567# ifdef __clang__
568# pragma clang diagnostic push
569# pragma clang diagnostic ignored "-Wcast-function-type"
570# else
571# pragma GCC diagnostic push
572# pragma GCC diagnostic ignored "-Wcast-function-type"
573# endif
574#endif
575
576static PyMethodDef pygpu_offscreen__tp_methods[] = {
577 {"bind",
578 reinterpret_cast<PyCFunction>(pygpu_offscreen_bind),
579 METH_NOARGS,
580 pygpu_offscreen_bind_doc},
581 {"unbind",
582 reinterpret_cast<PyCFunction>(pygpu_offscreen_unbind),
583 METH_VARARGS | METH_KEYWORDS,
584 pygpu_offscreen_unbind_doc},
585 {"draw_view3d",
586 reinterpret_cast<PyCFunction>(pygpu_offscreen_draw_view3d),
587 METH_VARARGS | METH_KEYWORDS,
588 pygpu_offscreen_draw_view3d_doc},
589#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
590 {"free",
591 reinterpret_cast<PyCFunction>(pygpu_offscreen_free),
592 METH_NOARGS,
593 pygpu_offscreen_free_doc},
594#endif
595 {nullptr, nullptr, 0, nullptr},
596};
597
598#ifdef __GNUC__
599# ifdef __clang__
600# pragma clang diagnostic pop
601# else
602# pragma GCC diagnostic pop
603# endif
604#endif
605
607 /* Wrap. */
608 pygpu_offscreen__tp_doc,
609 ".. class:: GPUOffScreen\n"
610 "\n"
611 " This object gives access to off screen buffers.\n"
612 "\n"
613 " .. method:: __init__(width, height, *, format='RGBA8')\n"
614 "\n"
615 " :param width: Horizontal dimension of the buffer.\n"
616 " :type width: int\n"
617 " :param height: Vertical dimension of the buffer.\n"
618 " :type height: int\n"
619 " :param format: Internal data format inside GPU memory for color attachment texture.\n"
620 " :type format: Literal['RGBA8', 'RGBA16', 'RGBA16F', 'RGBA32F']\n");
621PyTypeObject BPyGPUOffScreen_Type = {
622 /*ob_base*/ PyVarObject_HEAD_INIT(nullptr, 0)
623 /*tp_name*/ "GPUOffScreen",
624 /*tp_basicsize*/ sizeof(BPyGPUOffScreen),
625 /*tp_itemsize*/ 0,
626 /*tp_dealloc*/ reinterpret_cast<destructor>(BPyGPUOffScreen__tp_dealloc),
627 /*tp_vectorcall_offset*/ 0,
628 /*tp_getattr*/ nullptr,
629 /*tp_setattr*/ nullptr,
630 /*tp_compare*/ nullptr,
631 /*tp_repr*/ nullptr,
632 /*tp_as_number*/ nullptr,
633 /*tp_as_sequence*/ nullptr,
634 /*tp_as_mapping*/ nullptr,
635 /*tp_hash*/ nullptr,
636 /*tp_call*/ nullptr,
637 /*tp_str*/ nullptr,
638 /*tp_getattro*/ nullptr,
639 /*tp_setattro*/ nullptr,
640 /*tp_as_buffer*/ nullptr,
641 /*tp_flags*/ Py_TPFLAGS_DEFAULT,
642 /*tp_doc*/ pygpu_offscreen__tp_doc,
643 /*tp_traverse*/ nullptr,
644 /*tp_clear*/ nullptr,
645 /*tp_richcompare*/ nullptr,
646 /*tp_weaklistoffset*/ 0,
647 /*tp_iter*/ nullptr,
648 /*tp_iternext*/ nullptr,
649 /*tp_methods*/ pygpu_offscreen__tp_methods,
650 /*tp_members*/ nullptr,
651 /*tp_getset*/ pygpu_offscreen__tp_getseters,
652 /*tp_base*/ nullptr,
653 /*tp_dict*/ nullptr,
654 /*tp_descr_get*/ nullptr,
655 /*tp_descr_set*/ nullptr,
656 /*tp_dictoffset*/ 0,
657 /*tp_init*/ nullptr,
658 /*tp_alloc*/ nullptr,
659 /*tp_new*/ pygpu_offscreen__tp_new,
660 /*tp_free*/ nullptr,
661 /*tp_is_gc*/ nullptr,
662 /*tp_bases*/ nullptr,
663 /*tp_mro*/ nullptr,
664 /*tp_cache*/ nullptr,
665 /*tp_subclasses*/ nullptr,
666 /*tp_weaklist*/ nullptr,
667 /*tp_del*/ nullptr,
668 /*tp_version_tag*/ 0,
669 /*tp_finalize*/ nullptr,
670 /*tp_vectorcall*/ nullptr,
671};
672
674
675/* -------------------------------------------------------------------- */
678
680{
681 BPyGPUOffScreen *self;
682
683 self = PyObject_New(BPyGPUOffScreen, &BPyGPUOffScreen_Type);
684 self->ofs = ofs;
685 self->viewport = nullptr;
686
687 return reinterpret_cast<PyObject *>(self);
688}
689
691
692#undef BPY_GPU_OFFSCREEN_CHECK_OBJ
693
694} // namespace blender
#define G_MAIN
#define STRNCPY_UTF8(dst, src)
#define BPYGPU_IS_INIT_OR_ERROR_OBJ
Definition gpu_py.hh:45
#define BPY_GPU_OFFSCREEN_CHECK_OBJ(bpygpu)
#define BPYGPU_USE_GPUOBJ_FREE_METHOD
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bool ED_view3d_draw_offscreen_check_nested()
void GPU_offscreen_free(GPUOffScreen *offscreen)
static PyGetSetDef pygpu_offscreen__tp_getseters[]
int PyC_ParseBool(PyObject *o, void *p)
void GPU_viewport_tag_update(GPUViewport *viewport)
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
static PyObject * pygpu_offscreen_width_get(BPyGPUOffScreen *self, void *)
PyTypeObject PyGPUOffscreenStackContext_Type
int GPU_offscreen_width(const GPUOffScreen *offscreen)
static void BPyGPUOffScreen__tp_dealloc(BPyGPUOffScreen *self)
static PyObject * pygpu_offscreen__tp_new(PyTypeObject *, PyObject *args, PyObject *kwds)
void GPU_apply_state()
Definition gpu_state.cc:294
static PyMethodDef pygpu_offscreen__tp_methods[]
static PyObject * pygpu_offscreen_bind(BPyGPUOffScreen *self)
static PyObject * pygpu_offscreen_free(BPyGPUOffScreen *self)
int GPU_offscreen_height(const GPUOffScreen *offscreen)
void GPU_offscreen_unbind(GPUOffScreen *offscreen, bool restore)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_HOST_READ
static PyObject * pygpu_offscreen_unbind(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
PyObject * BPyGPUOffScreen_CreatePyObject(GPUOffScreen *ofs)
void GPU_offscreen_bind(GPUOffScreen *offscreen, bool save)
static PyObject * pygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, PyObject *args, PyObject *kwds)
uint GPU_framebuffer_stack_level_get()
void * PyC_RNA_AsPointer(PyObject *value, const char *type_name)
void GPU_viewport_free(GPUViewport *viewport)
static int pygpu_offscreen_valid_check(BPyGPUOffScreen *py_ofs)
gpu::Texture * GPU_offscreen_color_texture(const GPUOffScreen *offscreen)
static PyObject * pygpu_offscreen_height_get(BPyGPUOffScreen *self, void *)
int Matrix_Parse4x4(PyObject *o, void *p)
static PyObject * pygpu_offscreen_texture_color_get(BPyGPUOffScreen *self, void *)
static PyObject * pygpu_offscreen_stack_context_enter(OffScreenStackContext *self)
Depsgraph * BKE_scene_ensure_depsgraph(Main *bmain, Scene *scene, ViewLayer *view_layer)
Definition scene.cc:3644
GPUOffScreen * GPU_offscreen_create(int width, int height, bool with_depth_buffer, gpu::TextureFormat format, eGPUTextureUsage usage, bool clear, char err_out[256])
int PyC_ParseStringEnum(PyObject *o, void *p)
static void pygpu_offscreen_stack_context__tp_dealloc(OffScreenStackContext *self)
static PyObject * pygpu_offscreen_stack_context_exit(OffScreenStackContext *self, PyObject *)
bool BKE_id_is_in_global_main(ID *id)
Definition lib_id.cc:2759
void ED_view3d_draw_offscreen(Depsgraph *depsgraph, const Scene *scene, eDrawType drawtype, View3D *v3d, ARegion *region, bContext *context, int winx, int winy, const float viewmat[4][4], const float winmat[4][4], bool is_image_render, bool draw_background, const char *viewname, bool do_color_management, bool restore_rv3d_mats, GPUOffScreen *ofs, GPUViewport *viewport)
GPUContext * GPU_context_active_get()
PyObject * BPyGPUTexture_CreatePyObject(gpu::Texture *tex, bool shared_reference)
GPUViewport * GPU_viewport_create()
static PyMethodDef pygpu_offscreen_stack_context__tp_methods[]
static const PyC_StringEnumItems pygpu_framebuffer_color_texture_formats[]
PyTypeObject BPyGPUOffScreen_Type
header-only compatibility defines.
PyObject_HEAD GPUOffScreen * ofs
PyObject_HEAD BPyGPUOffScreen * py_offscreen
View3DShading shading