|
Blender V4.3
|
#include <Python.h>#include "GPU_context.hh"#include "GPU_framebuffer.hh"#include "GPU_init_exit.hh"#include "../generic/py_capi_utils.hh"#include "../generic/python_compat.hh"#include "../generic/python_utildefines.hh"#include "../mathutils/mathutils.hh"#include "gpu_py.hh"#include "gpu_py_buffer.hh"#include "gpu_py_framebuffer.hh"#include "gpu_py_texture.hh"Go to the source code of this file.
Classes | |
| struct | PyFrameBufferStackContext |
Macros | |
| #define | BPYGPU_FB_MAX_COLOR_ATTACHMENT 6 |
Functions | |
Public API | |
| PyObject * | BPyGPUFrameBuffer_CreatePyObject (GPUFrameBuffer *fb, bool shared_reference) |
GPUFrameBuffer Common Utilities | |
| #define | PYGPU_FRAMEBUFFER_CHECK_OBJ(bpygpu) |
| #define | GPU_PY_FRAMEBUFFER_STACK_LEN 16 |
| static int | pygpu_framebuffer_valid_check (BPyGPUFrameBuffer *bpygpu_fb) |
| static void | pygpu_framebuffer_free_if_possible (GPUFrameBuffer *fb) |
| static void | pygpu_framebuffer_free_safe (BPyGPUFrameBuffer *self) |
| static bool | pygpu_framebuffer_stack_push_and_bind_or_error (GPUFrameBuffer *fb) |
| static bool | pygpu_framebuffer_stack_pop_and_restore_or_error (GPUFrameBuffer *fb) |
Stack (Context Manager) | |
Safer alternative to ensure balanced push/pop calls. | |
| static PyMethodDef | pygpu_framebuffer_stack_context__tp_methods [] |
| static PyTypeObject | FramebufferStackContext_Type |
| static void | pygpu_framebuffer_stack_context__tp_dealloc (PyFrameBufferStackContext *self) |
| static PyObject * | pygpu_framebuffer_stack_context_enter (PyFrameBufferStackContext *self) |
| static PyObject * | pygpu_framebuffer_stack_context_exit (PyFrameBufferStackContext *self, PyObject *) |
| PyDoc_STRVAR (pygpu_framebuffer_bind_doc, ".. function:: bind()\n" "\n" " Context manager to ensure balanced bind calls, even in the case of an error.\n") | |
| static PyObject * | pygpu_framebuffer_bind (BPyGPUFrameBuffer *self) |
GPUFramebuffer Type | |
| static PyGetSetDef | pygpu_framebuffer__tp_getseters [] |
| static PyMethodDef | pygpu_framebuffer__tp_methods [] |
| PyTypeObject | BPyGPUFrameBuffer_Type |
| static bool | pygpu_framebuffer_new_parse_arg (PyObject *o, GPUAttachment *r_attach) |
| static PyObject * | pygpu_framebuffer__tp_new (PyTypeObject *, PyObject *args, PyObject *kwds) |
| PyDoc_STRVAR (pygpu_framebuffer_is_bound_doc, "Checks if this is the active framebuffer in the context.") | |
| static PyObject * | pygpu_framebuffer_is_bound (BPyGPUFrameBuffer *self, void *) |
| PyDoc_STRVAR (pygpu_framebuffer_clear_doc, ".. method:: clear(color=None, depth=None, stencil=None)\n" "\n" " Fill color, depth and stencil textures with specific value.\n" " Common values: color=(0.0, 0.0, 0.0, 1.0), depth=1.0, stencil=0.\n" "\n" " :arg color: Sequence of 3 or 4 floats representing ``(r, g, b, a)``.\n" " :type color: Sequence[float]\n" " :arg depth: depth value.\n" " :type depth: float\n" " :arg stencil: stencil value.\n" " :type stencil: int\n") | |
| static PyObject * | pygpu_framebuffer_clear (BPyGPUFrameBuffer *self, PyObject *args, PyObject *kwds) |
| PyDoc_STRVAR (pygpu_framebuffer_viewport_set_doc, ".. function:: viewport_set(x, y, xsize, ysize)\n" "\n" " Set the viewport for this framebuffer object.\n" " Note: The viewport state is not saved upon framebuffer rebind.\n" "\n" " :arg x, y: lower left corner of the viewport_set rectangle, in pixels.\n" " :type x, y: int\n" " :arg xsize, ysize: width and height of the viewport_set.\n" " :type xsize, ysize: int\n") | |
| static PyObject * | pygpu_framebuffer_viewport_set (BPyGPUFrameBuffer *self, PyObject *args, void *) |
| PyDoc_STRVAR (pygpu_framebuffer_viewport_get_doc, ".. function:: viewport_get()\n" "\n" " Returns position and dimension to current viewport.\n") | |
| static PyObject * | pygpu_framebuffer_viewport_get (BPyGPUFrameBuffer *self, void *) |
| PyDoc_STRVAR (pygpu_framebuffer_read_color_doc, ".. function:: read_color(x, y, xsize, ysize, channels, slot, format, data=data)\n" "\n" " Read a block of pixels from the frame buffer.\n" "\n" " :arg x, y: Lower left corner of a rectangular block of pixels.\n" " :arg xsize, ysize: Dimensions of the pixel rectangle.\n" " :type x, y, xsize, ysize: int\n" " :arg channels: Number of components to read.\n" " :type channels: int\n" " :arg slot: The framebuffer slot to read data from.\n" " :type slot: int\n" " :arg format: The format that describes the content of a single channel.\n" " Possible values are `FLOAT`, `INT`, `UINT`, `UBYTE`, `UINT_24_8` and `10_11_11_REV`.\n" " :type format: str\n" " :arg data: Optional Buffer object to fill with the pixels values.\n" " :type data: :class:`gpu.types.Buffer`\n" " :return: The Buffer with the read pixels.\n" " :rtype: :class:`gpu.types.Buffer`\n") | |
| static PyObject * | pygpu_framebuffer_read_color (BPyGPUFrameBuffer *self, PyObject *args, PyObject *kwds) |
| PyDoc_STRVAR (pygpu_framebuffer_read_depth_doc, ".. function:: read_depth(x, y, xsize, ysize, data=data)\n" "\n" " Read a pixel depth block from the frame buffer.\n" "\n" " :arg x, y: Lower left corner of a rectangular block of pixels.\n" " :type x, y: int\n" " :arg xsize, ysize: Dimensions of the pixel rectangle.\n" " :type xsize, ysize: int\n" " :arg data: Optional Buffer object to fill with the pixels values.\n" " :type data: :class:`gpu.types.Buffer`\n" " :return: The Buffer with the read pixels.\n" " :rtype: :class:`gpu.types.Buffer`\n") | |
| static PyObject * | pygpu_framebuffer_read_depth (BPyGPUFrameBuffer *self, PyObject *args, PyObject *kwds) |
| static void | BPyGPUFrameBuffer__tp_dealloc (BPyGPUFrameBuffer *self) |
| PyDoc_STRVAR (pygpu_framebuffer__tp_doc, ".. class:: GPUFrameBuffer(depth_slot=None, color_slots=None)\n" "\n" " This object gives access to framebuffer functionalities.\n" " When a 'layer' is specified in a argument, a single layer of a 3D or array " "texture is attached to the frame-buffer.\n" " For cube map textures, layer is translated into a cube map face.\n" "\n" " :arg depth_slot: GPUTexture to attach or a `dict` containing keywords: " "'texture', 'layer' and 'mip'.\n" " :type depth_slot: :class:`gpu.types.GPUTexture` | dict[] | None\n" " :arg color_slots: Tuple where each item can be a GPUTexture or a `dict` " "containing keywords: 'texture', 'layer' and 'mip'.\n" " :type color_slots: :class:`gpu.types.GPUTexture` | " "dict[str, int | :class:`gpu.types.GPUTexture`] | " "Sequence[:class:`gpu.types.GPUTexture` | dict[str, int | :class:`gpu.types.GPUTexture`]] | " "None\n") | |
This file defines the framebuffer functionalities of the 'gpu' module used for off-screen OpenGL rendering.
bpygpu_ for local API.BPyGPU for public API. Definition in file gpu_py_framebuffer.cc.
| #define BPYGPU_FB_MAX_COLOR_ATTACHMENT 6 |
Referenced by pygpu_framebuffer__tp_new(), and pygpu_framebuffer_read_color().
| #define GPU_PY_FRAMEBUFFER_STACK_LEN 16 |
Definition at line 79 of file gpu_py_framebuffer.cc.
Referenced by pygpu_framebuffer_stack_push_and_bind_or_error().
| #define PYGPU_FRAMEBUFFER_CHECK_OBJ | ( | bpygpu | ) |
Definition at line 45 of file gpu_py_framebuffer.cc.
Referenced by pygpu_framebuffer_clear(), pygpu_framebuffer_is_bound(), pygpu_framebuffer_read_color(), pygpu_framebuffer_read_depth(), pygpu_framebuffer_stack_context_enter(), pygpu_framebuffer_stack_context_exit(), and pygpu_framebuffer_viewport_get().
|
static |
Definition at line 725 of file gpu_py_framebuffer.cc.
References pygpu_framebuffer_free_safe(), and self.
| PyObject * BPyGPUFrameBuffer_CreatePyObject | ( | GPUFrameBuffer * | fb, |
| bool | shared_reference ) |
Definition at line 856 of file gpu_py_framebuffer.cc.
References BLI_assert, BPyGPUFrameBuffer_Type, fb(), GPU_framebuffer_py_reference_get(), GPU_framebuffer_py_reference_set(), offsetof, POINTER_OFFSET, self, and UNUSED_VARS.
Referenced by pygpu_framebuffer__tp_new(), and pygpu_state_active_framebuffer_get().
| PyDoc_STRVAR | ( | pygpu_framebuffer__tp_doc | , |
| ".. class:: GPUFrameBuffer(depth_slot=None, color_slots=None)\n" "\n" " This object gives access to framebuffer functionalities.\n" " When a 'layer' is specified in a | argument, | ||
| a single layer of a 3D or array " "texture is attached to the frame-buffer.\n" " For cube map | textures, | ||
| layer is translated into a cube map face.\n" "\n" " :arg depth_slot:GPUTexture to attach or a `dict` containing keywords:" " 'texture' | , | ||
| 'layer' and 'mip'.\n" " :type depth_slot::class:`gpu.types.GPUTexture`|dict|[]None\n" " :arg color_slots:Tuple where each item can be a GPUTexture or a `dict` " "containing keywords:'texture' | , | ||
| 'layer' and 'mip'.\n" " :type color_slots::class:`gpu.types.GPUTexture`|" "dict|" "Sequence]|" "None\n" | [str, int|:class:`gpu.types.GPUTexture`][:class:`gpu.types.GPUTexture`|dict[str, int|:class:`gpu.types.GPUTexture`] ) |
| PyDoc_STRVAR | ( | pygpu_framebuffer_bind_doc | , |
| ".. function:: bind()\n" "\n" " Context manager to ensure balanced bind | calls, | ||
| even in the case of an error.\n" | ) |
| PyDoc_STRVAR | ( | pygpu_framebuffer_clear_doc | , |
| ".. method:: clear(color=None, depth=None, stencil=None)\n" "\n" " Fill | color, | ||
| depth and stencil textures with specific value.\n" " Common values:color | = (0.0, 0.0, 0.0, 1.0), | ||
| depth | = 1.0 ) |
| PyDoc_STRVAR | ( | pygpu_framebuffer_is_bound_doc | , |
| "Checks if this is the active framebuffer in the context." | ) |
| PyDoc_STRVAR | ( | pygpu_framebuffer_read_color_doc | , |
| ".. function:: read_color(x, y, xsize, ysize, channels, slot, format, data=data)\n" "\n" " Read a block of pixels from the frame buffer.\n" "\n" " :arg | x, | ||
| y:Lower left corner of a rectangular block of pixels.\n" " :arg | xsize, | ||
| ysize:Dimensions of the pixel rectangle.\n" " :type | x, | ||
| y | , | ||
| xsize | , | ||
| ysize:int\n" " :arg channels:Number of components to read.\n" " :type channels:int\n" " :arg slot:The framebuffer slot to read data from.\n" " :type slot:int\n" " :arg format:The format that describes the content of a single channel.\n" " Possible values are `FLOAT` | , | ||
| `INT` | , | ||
| `UINT` | , | ||
| `UBYTE` | , | ||
| `UINT_24_8` and `10_11_11_REV`.\n" " :type format:str\n" " :arg data:Optional Buffer object to fill with the pixels values.\n" " :type data::class:`gpu.types.Buffer`\n" " :return:The Buffer with the read pixels.\n" " :rtype::class:`gpu.types.Buffer`\n" | ) |
| PyDoc_STRVAR | ( | pygpu_framebuffer_read_depth_doc | , |
| ".. function:: read_depth(x, y, xsize, ysize, data=data)\n" "\n" " Read a pixel depth block from the frame buffer.\n" "\n" " :arg | x, | ||
| y:Lower left corner of a rectangular block of pixels.\n" " :type | x, | ||
| y:int\n" " :arg | xsize, | ||
| ysize:Dimensions of the pixel rectangle.\n" " :type | xsize, | ||
| ysize:int\n" " :arg data:Optional Buffer object to fill with the pixels values.\n" " :type data::class:`gpu.types.Buffer`\n" " :return:The Buffer with the read pixels.\n" " :rtype::class:`gpu.types.Buffer`\n" | ) |
| PyDoc_STRVAR | ( | pygpu_framebuffer_viewport_get_doc | , |
| ".. function:: viewport_get()\n" "\n" " Returns position and dimension to current viewport.\n" | ) |
| PyDoc_STRVAR | ( | pygpu_framebuffer_viewport_set_doc | , |
| ".. function:: viewport_set(x, y, xsize, ysize)\n" "\n" " Set the viewport for this framebuffer object.\n" " Note: The viewport state is not saved upon framebuffer rebind.\n" "\n" " :arg | x, | ||
| y:lower left corner of the viewport_set | rectangle, | ||
| in pixels.\n" " :type | x, | ||
| y:int\n" " :arg | xsize, | ||
| ysize:width and height of the viewport_set.\n" " :type | xsize, | ||
| ysize:int\n" | ) |
|
static |
Definition at line 324 of file gpu_py_framebuffer.cc.
References BPYGPU_FB_MAX_COLOR_ATTACHMENT, BPYGPU_IS_INIT_OR_ERROR_OBJ, BPyGPUFrameBuffer_CreatePyObject(), GPU_context_active_get(), GPU_framebuffer_config_array(), GPU_framebuffer_create(), GPU_texture_has_depth_format(), PY_ARG_PARSER_HEAD_COMPAT, pygpu_framebuffer_new_parse_arg(), STRINGIFY, and tex.
|
static |
Definition at line 245 of file gpu_py_framebuffer.cc.
References FramebufferStackContext_Type, ret, and self.
|
static |
Definition at line 422 of file gpu_py_framebuffer.cc.
References buffers, col, GPU_COLOR_BIT, GPU_DEPTH_BIT, GPU_framebuffer_bound(), GPU_framebuffer_clear(), GPU_STENCIL_BIT, mathutils_array_parse(), PY_ARG_PARSER_HEAD_COMPAT, PyC_Long_AsU32(), PYGPU_FRAMEBUFFER_CHECK_OBJ, and self.
|
static |
Definition at line 53 of file gpu_py_framebuffer.cc.
References fb(), GPU_framebuffer_free(), GPU_is_init(), and printf.
Referenced by pygpu_framebuffer_free_safe().
|
static |
Definition at line 63 of file gpu_py_framebuffer.cc.
References GPU_framebuffer_py_reference_set(), pygpu_framebuffer_free_if_possible(), and self.
Referenced by BPyGPUFrameBuffer__tp_dealloc().
|
static |
Definition at line 402 of file gpu_py_framebuffer.cc.
References GPU_framebuffer_bound(), PYGPU_FRAMEBUFFER_CHECK_OBJ, and self.
|
static |
Definition at line 265 of file gpu_py_framebuffer.cc.
References bpygpu_ParseTexture(), BPyGPUTexture_Check, GPU_ATTACHMENT_NONE, GPUAttachment::layer, GPUAttachment::mip, pos, and GPUAttachment::tex.
Referenced by pygpu_framebuffer__tp_new().
|
static |
Definition at line 549 of file gpu_py_framebuffer.cc.
References BPyGPUBuffer::as_void, BLI_assert, BPyGPU_Buffer_CreatePyObject(), bpygpu_Buffer_size(), BPyGPU_BufferType, bpygpu_dataformat_items, BPYGPU_FB_MAX_COLOR_ATTACHMENT, BPyGPUBuffer::buf, channels(), BPyGPUBuffer::format, GPU_framebuffer_read_color(), GPU_RGBA8, GPU_texture_dataformat_size(), IN_RANGE_INCL, PY_ARG_PARSER_HEAD_COMPAT, PyC_ParseStringEnum(), PYGPU_FRAMEBUFFER_CHECK_OBJ, self, PyC_StringEnum::value_found, w(), x, and y.
|
static |
Definition at line 656 of file gpu_py_framebuffer.cc.
References BPyGPUBuffer::as_void, BLI_assert, BPyGPU_Buffer_CreatePyObject(), bpygpu_Buffer_size(), BPyGPU_BufferType, BPyGPUBuffer::buf, BPyGPUBuffer::format, GPU_DATA_FLOAT, GPU_framebuffer_read_depth(), GPU_texture_dataformat_size(), PY_ARG_PARSER_HEAD_COMPAT, PYGPU_FRAMEBUFFER_CHECK_OBJ, self, w(), x, and y.
|
static |
Definition at line 126 of file gpu_py_framebuffer.cc.
References self.
|
static |
Definition at line 132 of file gpu_py_framebuffer.cc.
References GPU_framebuffer_stack_level_get(), PYGPU_FRAMEBUFFER_CHECK_OBJ, pygpu_framebuffer_stack_push_and_bind_or_error(), and self.
|
static |
Definition at line 150 of file gpu_py_framebuffer.cc.
References GPU_framebuffer_stack_level_get(), PYGPU_FRAMEBUFFER_CHECK_OBJ, pygpu_framebuffer_stack_pop_and_restore_or_error(), and self.
|
static |
Definition at line 94 of file gpu_py_framebuffer.cc.
References fb(), GPU_framebuffer_bind(), GPU_framebuffer_bound(), GPU_framebuffer_pop(), and GPU_framebuffer_stack_level_get().
Referenced by pygpu_framebuffer_stack_context_exit().
|
static |
Definition at line 81 of file gpu_py_framebuffer.cc.
References fb(), GPU_framebuffer_active_get(), GPU_framebuffer_bind(), GPU_framebuffer_push(), GPU_framebuffer_stack_level_get(), GPU_PY_FRAMEBUFFER_STACK_LEN, and STRINGIFY.
Referenced by pygpu_framebuffer_stack_context_enter().
|
static |
Definition at line 36 of file gpu_py_framebuffer.cc.
References BPyGPUFrameBuffer::fb, and UNLIKELY.
|
static |
Definition at line 513 of file gpu_py_framebuffer.cc.
References GPU_framebuffer_viewport_get(), PYGPU_FRAMEBUFFER_CHECK_OBJ, PyTuple_SET_ITEMS, ret, and self.
|
static |
Definition at line 494 of file gpu_py_framebuffer.cc.
References GPU_framebuffer_viewport_set(), self, x, and y.
| PyTypeObject BPyGPUFrameBuffer_Type |
Definition at line 798 of file gpu_py_framebuffer.cc.
Referenced by bpygpu_types_init(), and BPyGPUFrameBuffer_CreatePyObject().
|
static |
Definition at line 187 of file gpu_py_framebuffer.cc.
Referenced by pygpu_framebuffer_bind().
|
static |
Definition at line 731 of file gpu_py_framebuffer.cc.
|
static |
Definition at line 745 of file gpu_py_framebuffer.cc.
|
static |
Definition at line 177 of file gpu_py_framebuffer.cc.