Blender
V3.3
|
#include <Python.h>
#include "GPU_context.h"
#include "GPU_framebuffer.h"
#include "GPU_init_exit.h"
#include "../generic/py_capi_utils.h"
#include "../generic/python_utildefines.h"
#include "../mathutils/mathutils.h"
#include "gpu_py.h"
#include "gpu_py_buffer.h"
#include "gpu_py_framebuffer.h"
#include "gpu_py_texture.h"
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) | |
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 *UNUSED(args)) |
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 struct 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 *UNUSED(self), 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 *UNUSED(type)) |
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: float sequence each representing ``(r, g, b, a)``.\n" " :type color: sequence of 3 or 4 floats\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" " :param x, y: lower left corner of the viewport_set rectangle, in pixels.\n" " :param xsize, ysize: width and height of the viewport_set.\n" " :type x, y, xsize, ysize: int\n") | |
static PyObject * | pygpu_framebuffer_viewport_set (BPyGPUFrameBuffer *self, PyObject *args, void *UNUSED(type)) |
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 *UNUSED(type)) |
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" " :param x, y: Lower left corner of a rectangular block of pixels.\n" " :param xsize, ysize: Dimensions of the pixel rectangle.\n" " :type x, y, xsize, ysize: int\n" " :param channels: Number of components to read.\n" " :type channels: int\n" " :param slot: The framebuffer slot to read data from.\n" " :type slot: int\n" " :param 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 type: 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" " :param x, y: Lower left corner of a rectangular block of pixels.\n" " :param xsize, ysize: Dimensions of the pixel rectangle.\n" " :type x, y, 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 functionallities.\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 or Nonetype\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: tuple or Nonetype\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.c.
#define BPYGPU_FB_MAX_COLOR_ATTACHMENT 6 |
#define GPU_PY_FRAMEBUFFER_STACK_LEN 16 |
Definition at line 75 of file gpu_py_framebuffer.c.
#define PYGPU_FRAMEBUFFER_CHECK_OBJ | ( | bpygpu | ) |
Definition at line 41 of file gpu_py_framebuffer.c.
|
static |
Definition at line 643 of file gpu_py_framebuffer.c.
References pygpu_framebuffer_free_safe().
PyObject* BPyGPUFrameBuffer_CreatePyObject | ( | GPUFrameBuffer * | fb, |
bool | shared_reference | ||
) |
Definition at line 717 of file gpu_py_framebuffer.c.
References BLI_assert, BPyGPUFrameBuffer_Type, fb(), GPU_framebuffer_py_reference_get(), GPU_framebuffer_py_reference_set(), NULL, POINTER_OFFSET, self, and UNUSED_VARS.
Referenced by pygpu_framebuffer__tp_new().
PyDoc_STRVAR | ( | pygpu_framebuffer__tp_doc | , |
".. class:: GPUFrameBuffer(depth_slot=None, color_slots=None)\n" "\n" " This object gives access to framebuffer functionallities.\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 or Nonetype\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:tuple or Nonetype\n" | |||
) |
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" " :param | x, | ||
y:Lower left corner of a rectangular block of pixels.\n" " :param | xsize, | ||
ysize:Dimensions of the pixel rectangle.\n" " :type | x, | ||
y | , | ||
xsize | , | ||
ysize:int\n" " :param channels:Number of components to read.\n" " :type channels:int\n" " :param slot:The framebuffer slot to read data from.\n" " :type slot:int\n" " :param 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 type: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" " :param | x, | ||
y:Lower left corner of a rectangular block of pixels.\n" " :param | xsize, | ||
ysize:Dimensions of the pixel rectangle.\n" " :type | x, | ||
y | , | ||
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" " :param | x, | ||
y:lower left corner of the viewport_set | rectangle, | ||
in pixels.\n" " :param | xsize, | ||
ysize:width and height of the viewport_set.\n" " :type | x, | ||
y | , | ||
xsize | , | ||
ysize:int\n" | |||
) |
|
static |
Definition at line 266 of file gpu_py_framebuffer.c.
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_depth(), NULL, pygpu_framebuffer_new_parse_arg(), STRINGIFY, and tex.
|
static |
Definition at line 186 of file gpu_py_framebuffer.c.
References FramebufferStackContext_Type, and ret.
|
static |
Definition at line 360 of file gpu_py_framebuffer.c.
References col, GPU_COLOR_BIT, GPU_DEPTH_BIT, GPU_framebuffer_bound(), GPU_framebuffer_clear(), GPU_STENCIL_BIT, mathutils_array_parse(), NULL, PyC_Long_AsU32(), PYGPU_FRAMEBUFFER_CHECK_OBJ, and self.
|
static |
Definition at line 49 of file gpu_py_framebuffer.c.
References fb(), GPU_framebuffer_free(), and GPU_is_init().
Referenced by pygpu_framebuffer_free_safe().
|
static |
Definition at line 59 of file gpu_py_framebuffer.c.
References GPU_framebuffer_py_reference_set(), NULL, pygpu_framebuffer_free_if_possible(), and self.
Referenced by BPyGPUFrameBuffer__tp_dealloc().
|
static |
Definition at line 342 of file gpu_py_framebuffer.c.
References GPU_framebuffer_bound(), PYGPU_FRAMEBUFFER_CHECK_OBJ, and self.
|
static |
Definition at line 207 of file gpu_py_framebuffer.c.
References bpygpu_ParseTexture(), BPyGPUTexture_Check, GPUAttachment::layer, GPUAttachment::mip, NULL, pos, and GPUAttachment::tex.
Referenced by pygpu_framebuffer__tp_new().
|
static |
Definition at line 479 of file gpu_py_framebuffer.c.
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, NULL, PyC_ParseStringEnum(), PYGPU_FRAMEBUFFER_CHECK_OBJ, self, PyC_StringEnum::value_found, w(), x, and y.
|
static |
Definition at line 579 of file gpu_py_framebuffer.c.
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(), NULL, PYGPU_FRAMEBUFFER_CHECK_OBJ, self, w(), x, and y.
|
static |
Definition at line 122 of file gpu_py_framebuffer.c.
References self.
|
static |
Definition at line 128 of file gpu_py_framebuffer.c.
References GPU_framebuffer_stack_level_get(), NULL, PYGPU_FRAMEBUFFER_CHECK_OBJ, pygpu_framebuffer_stack_push_and_bind_or_error(), and self.
|
static |
Definition at line 146 of file gpu_py_framebuffer.c.
References GPU_framebuffer_stack_level_get(), NULL, PYGPU_FRAMEBUFFER_CHECK_OBJ, pygpu_framebuffer_stack_pop_and_restore_or_error(), and self.
|
static |
Definition at line 90 of file gpu_py_framebuffer.c.
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 77 of file gpu_py_framebuffer.c.
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 32 of file gpu_py_framebuffer.c.
References BPyGPUFrameBuffer::fb, NULL, and UNLIKELY.
|
static |
Definition at line 444 of file gpu_py_framebuffer.c.
References GPU_framebuffer_viewport_get(), PYGPU_FRAMEBUFFER_CHECK_OBJ, PyTuple_SET_ITEMS, ret, and self.
|
static |
Definition at line 427 of file gpu_py_framebuffer.c.
References GPU_framebuffer_viewport_set(), NULL, self, x, and y.
PyTypeObject BPyGPUFrameBuffer_Type |
Definition at line 700 of file gpu_py_framebuffer.c.
Referenced by bpygpu_types_init(), and BPyGPUFrameBuffer_CreatePyObject().
|
static |
Definition at line 174 of file gpu_py_framebuffer.c.
Referenced by pygpu_framebuffer_bind().
|
static |
Definition at line 649 of file gpu_py_framebuffer.c.
|
static |
Definition at line 649 of file gpu_py_framebuffer.c.
|
static |
Definition at line 168 of file gpu_py_framebuffer.c.