57 if (PyTuple_GET_SIZE(args) || (kwds && PyDict_Size(kwds))) {
58 PyErr_SetString(PyExc_ValueError,
"This function takes no arguments");
70 const uint sizes[] = {1, 1, 2, 2, 4, 4, 4};
71 return len * sizes[type];
76 pygpu_vertformat_attr_add_doc,
77 ".. method:: attr_add(id, comp_type, len, fetch_mode)\n"
79 " Add a new attribute to the format.\n"
81 " :param id: Name of the attribute. Often ``position``, ``normal``, ...\n"
83 " :param comp_type: The data type that will be used to store the value in memory.\n"
84 " :type comp_type: Literal['I8', 'U8', 'I16', 'U16', 'I32', 'U32', 'F32', 'I10']\n"
85 " :param len: How many individual values the attribute consists of\n"
86 " (e.g. 2 for uv coordinates).\n"
88 " :param fetch_mode: How values from memory will be converted when used in the shader.\n"
89 " This is mainly useful for memory optimizations when you want to store values with\n"
90 " reduced precision. E.g. you can store a float in only 1 byte but it will be\n"
91 " converted to a normal 4 byte float when used.\n"
92 " :type fetch_mode: Literal['FLOAT', 'INT', 'INT_TO_FLOAT_UNIT']\n");
105 static const char *_keywords[] = {
"id",
"comp_type",
"len",
"fetch_mode",
nullptr};
106 static _PyArg_Parser _parser = {
116 if (!_PyArg_ParseTupleAndKeywordsFast(args,
134 PyExc_DeprecationWarning,
135 "Using GPUVertFormat.attr_add(...) with component count greater than 4 is deprecated. "
136 "Use several attributes for each matrix columns instead.",
141 PyErr_WarnEx(PyExc_DeprecationWarning,
142 "Using GPUVertFormat.attr_add(...) with a format that is not 4 bytes aligned is "
143 "deprecated. Add padding components and/or higher precision integers.",
148 &self->
fmt,
id, comp_type_enum,
len, fetch_mode_enum);
150 return PyLong_FromLong(attr_id);
155# pragma clang diagnostic push
156# pragma clang diagnostic ignored "-Wcast-function-type"
158# pragma GCC diagnostic push
159# pragma GCC diagnostic ignored "-Wcast-function-type"
166 METH_VARARGS | METH_KEYWORDS,
167 pygpu_vertformat_attr_add_doc},
168 {
nullptr,
nullptr, 0,
nullptr},
173# pragma clang diagnostic pop
175# pragma GCC diagnostic pop
181 Py_TYPE(self)->tp_free(self);
186 pygpu_vertformat__tp_doc,
187 ".. class:: GPUVertFormat()\n"
189 " This object contains information about the structure of a vertex buffer.\n");
191 PyVarObject_HEAD_INIT(
nullptr, 0)
211 pygpu_vertformat__tp_doc,
257 memset(&self->
fmt, 0,
sizeof(self->
fmt));
260 return reinterpret_cast<PyObject *
>(self);
#define BPYGPU_IS_INIT_OR_ERROR_OBJ
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
PyTypeObject BPyGPUVertFormat_Type
static PyC_StringEnumItems pygpu_vertcomptype_items[]
static uint attr_size(GPUVertCompType type, int len)
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")
@ GPU_FETCH_INT_TO_FLOAT_UNIT
PyObject * BPyGPUVertFormat_CreatePyObject(GPUVertFormat *fmt)
static PyC_StringEnumItems pygpu_vertfetchmode_items[]
uint GPU_vertformat_attr_add_legacy(GPUVertFormat *, StringRef name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
static PyObject * pygpu_vertformat__tp_new(PyTypeObject *, PyObject *args, PyObject *kwds)
int PyC_ParseStringEnum(PyObject *o, void *p)
static constexpr int GPU_VERT_ATTR_MAX_LEN
static PyMethodDef pygpu_vertformat__tp_methods[]
static PyObject * pygpu_vertformat_attr_add(BPyGPUVertFormat *self, PyObject *args, PyObject *kwds)
static void pygpu_vertformat__tp_dealloc(BPyGPUVertFormat *self)
header-only compatibility defines.