34 if (bpygpu_ub->
ubo ==
nullptr) [[unlikely]] {
35 PyErr_SetString(PyExc_ReferenceError,
37 "GPU uniform buffer was freed, no further access is valid");
40 "GPU uniform buffer: internal error");
47#define BPYGPU_UNIFORMBUF_CHECK_OBJ(bpygpu) \
49 if (pygpu_uniformbuffer_valid_check(bpygpu) == -1) [[unlikely]] { \
68 PyObject *pybuffer_obj;
69 char err_out[256] =
"unknown error. See console";
71 static const char *_keywords[] = {
"data",
nullptr};
72 static _PyArg_Parser _parser = {
74 ":GPUUniformBuf.__new__",
78 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, &pybuffer_obj)) {
87 if (PyObject_GetBuffer(pybuffer_obj, &pybuffer, PyBUF_SIMPLE) == -1) {
92 if ((pybuffer.len % 16) != 0) {
93 STRNCPY_UTF8(err_out,
"UBO is not padded to size of vec4");
98 PyBuffer_Release(&pybuffer);
101 if (ubo ==
nullptr) {
102 PyErr_Format(PyExc_RuntimeError,
"GPUUniformBuf.__new__(...) failed with '%s'", err_out);
111 pygpu_uniformbuffer_update_doc,
112 ".. method:: update(data)\n"
114 " Update the data of the uniform buffer object.\n"
116 " :param data: Data to fill the buffer.\n"
117 " :type data: Buffer\n");
123 if (PyObject_GetBuffer(obj, &pybuffer, PyBUF_SIMPLE) == -1) {
129 PyBuffer_Release(&pybuffer);
133#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
136 pygpu_uniformbuffer_free_doc,
137 ".. method:: free()\n"
139 " Free the uniform buffer object.\n"
140 " The uniform buffer object will no longer be accessible.\n");
141static PyObject *pygpu_uniformbuffer_free(BPyGPUUniformBuf *self)
156 Py_TYPE(self)->tp_free(
reinterpret_cast<PyObject *
>(self));
160 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
167 pygpu_uniformbuffer_update_doc},
168#ifdef BPYGPU_USE_GPUOBJ_FREE_METHOD
169 {
"free", (PyCFunction)pygpu_uniformbuffer_free, METH_NOARGS, pygpu_uniformbuffer_free_doc},
171 {
nullptr,
nullptr, 0,
nullptr},
176 pygpu_uniformbuffer__tp_doc,
177 ".. class:: GPUUniformBuf\n"
179 " This object gives access to uniform buffers.\n"
181 " .. method:: __init__(data)\n"
183 " :param data: Data to fill the buffer.\n"
184 " :type data: Buffer\n");
186 PyVarObject_HEAD_INIT(
nullptr, 0)
206 pygpu_uniformbuffer__tp_doc,
250 return reinterpret_cast<PyObject *
>(self);
255#undef BPYGPU_UNIFORMBUF_CHECK_OBJ
#define STRNCPY_UTF8(dst, src)
PyDoc_STRVAR(FalseBP1D___doc__, "Class hierarchy: :class:`freestyle.types.BinaryPredicate1D` > :class:`FalseBP1D`\n" "\n" ".. method:: __call__(inter1, inter2)\n" "\n" " Always returns false.\n" "\n" " :param inter1: The first Interface1D object.\n" " :type inter1: :class:`freestyle.types.Interface1D`\n" " :param inter2: The second Interface1D object.\n" " :type inter2: :class:`freestyle.types.Interface1D`\n" " :return: False.\n" " :rtype: bool\n")
#define BPYGPU_IS_INIT_OR_ERROR_OBJ
#define BPYGPU_USE_GPUOBJ_FREE_METHOD
PyObject * BPyGPUUniformBuf_CreatePyObject(gpu::UniformBuf *ubo)
void GPU_uniformbuf_free(gpu::UniformBuf *ubo)
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 PyMethodDef pygpu_uniformbuffer__tp_methods[]
static int pygpu_uniformbuffer_valid_check(BPyGPUUniformBuf *bpygpu_ub)
static void BPyGPUUniformBuf__tp_dealloc(BPyGPUUniformBuf *self)
gpu::UniformBuf * GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name)
PyTypeObject BPyGPUUniformBuf_Type
void GPU_uniformbuf_update(gpu::UniformBuf *ubo, const void *data)
static PyGetSetDef pygpu_uniformbuffer__tp_getseters[]
static PyObject * pygpu_uniformbuffer_update(BPyGPUUniformBuf *self, PyObject *obj)
static PyObject * pygpu_uniformbuffer__tp_new(PyTypeObject *, PyObject *args, PyObject *kwds)
GPUContext * GPU_context_active_get()
header-only compatibility defines.