Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-09-06 17:40:07 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-06 23:13:06 +0300
commit7ffff04e4900ca284519900d12bd1490e218c4f4 (patch)
treed148ee3c5c286a45bc33f521c2c606e47dd43968 /source/blender/python/gpu
parent98fc3f263cf18a1222d7ffe7dc0e1c0a1fa47ecd (diff)
GPUVertBuf: Make GPUVertBuf private to the GPU module
This is just a cleanup to isolate the internals of the vertbuf. This adds some getters to avoid refactor of existing code.
Diffstat (limited to 'source/blender/python/gpu')
-rw-r--r--source/blender/python/gpu/gpu_py_batch.c7
-rw-r--r--source/blender/python/gpu/gpu_py_vertex_buffer.c18
2 files changed, 14 insertions, 11 deletions
diff --git a/source/blender/python/gpu/gpu_py_batch.c b/source/blender/python/gpu/gpu_py_batch.c
index bb7028c11ab..60b78b51890 100644
--- a/source/blender/python/gpu/gpu_py_batch.c
+++ b/source/blender/python/gpu/gpu_py_batch.c
@@ -141,11 +141,12 @@ static PyObject *bpygpu_Batch_vertbuf_add(BPyGPUBatch *self, BPyGPUVertBuf *py_b
return NULL;
}
- if (self->batch->verts[0]->vertex_len != py_buf->buf->vertex_len) {
+ if (GPU_vertbuf_get_vertex_len(self->batch->verts[0]) !=
+ GPU_vertbuf_get_vertex_len(py_buf->buf)) {
PyErr_Format(PyExc_TypeError,
"Expected %d length, got %d",
- self->batch->verts[0]->vertex_len,
- py_buf->buf->vertex_len);
+ GPU_vertbuf_get_vertex_len(self->batch->verts[0]),
+ GPU_vertbuf_get_vertex_len(py_buf->buf));
return NULL;
}
diff --git a/source/blender/python/gpu/gpu_py_vertex_buffer.c b/source/blender/python/gpu/gpu_py_vertex_buffer.c
index 9372770e45e..d8c6e67816a 100644
--- a/source/blender/python/gpu/gpu_py_vertex_buffer.c
+++ b/source/blender/python/gpu/gpu_py_vertex_buffer.c
@@ -124,7 +124,8 @@ static bool bpygpu_vertbuf_fill_impl(GPUVertBuf *vbo,
const char *exc_str_size_mismatch = "Expected a %s of size %d, got %u";
bool ok = true;
- const GPUVertAttr *attr = &vbo->format.attrs[data_id];
+ const GPUVertAttr *attr = &GPU_vertbuf_get_format(vbo)->attrs[data_id];
+ uint vert_len = GPU_vertbuf_get_vertex_len(vbo);
if (PyObject_CheckBuffer(seq)) {
Py_buffer pybuffer;
@@ -136,9 +137,9 @@ static bool bpygpu_vertbuf_fill_impl(GPUVertBuf *vbo,
const uint comp_len = pybuffer.ndim == 1 ? 1 : (uint)pybuffer.shape[1];
- if (pybuffer.shape[0] != vbo->vertex_len) {
+ if (pybuffer.shape[0] != vert_len) {
PyErr_Format(
- PyExc_ValueError, exc_str_size_mismatch, "sequence", vbo->vertex_len, pybuffer.shape[0]);
+ PyExc_ValueError, exc_str_size_mismatch, "sequence", vert_len, pybuffer.shape[0]);
ok = false;
}
else if (comp_len != attr->comp_len) {
@@ -162,8 +163,8 @@ static bool bpygpu_vertbuf_fill_impl(GPUVertBuf *vbo,
const uint seq_len = PySequence_Fast_GET_SIZE(seq_fast);
- if (seq_len != vbo->vertex_len) {
- PyErr_Format(PyExc_ValueError, exc_str_size_mismatch, "sequence", vbo->vertex_len, seq_len);
+ if (seq_len != vert_len) {
+ PyErr_Format(PyExc_ValueError, exc_str_size_mismatch, "sequence", vert_len, seq_len);
}
PyObject **seq_items = PySequence_Fast_ITEMS(seq_fast);
@@ -217,12 +218,12 @@ static int bpygpu_attr_fill(GPUVertBuf *buf,
PyObject *py_seq_data,
const char *error_prefix)
{
- if (id < 0 || id >= buf->format.attr_len) {
+ if (id < 0 || id >= GPU_vertbuf_get_format(buf)->attr_len) {
PyErr_Format(PyExc_ValueError, "Format id %d out of range", id);
return 0;
}
- if (buf->data == NULL) {
+ if (GPU_vertbuf_get_data(buf) == NULL) {
PyErr_SetString(PyExc_ValueError, "Can't fill, static buffer already in use");
return 0;
}
@@ -288,8 +289,9 @@ static PyObject *bpygpu_VertBuf_attr_fill(BPyGPUVertBuf *self, PyObject *args, P
id = PyLong_AsLong(identifier);
}
else if (PyUnicode_Check(identifier)) {
+ const GPUVertFormat *format = GPU_vertbuf_get_format(self->buf);
const char *name = PyUnicode_AsUTF8(identifier);
- id = GPU_vertformat_attr_id_get(&self->buf->format, name);
+ id = GPU_vertformat_attr_id_get(format, name);
if (id == -1) {
PyErr_SetString(PyExc_ValueError, "Unknown attribute name");
return NULL;