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
path: root/source
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2022-04-11 22:54:05 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2022-04-11 22:59:18 +0300
commit4aa9888854d77ae7377aad1faf98f88fc7363b08 (patch)
tree87a1e31b9983070ebcb9bddd0287687a4c6d5b66 /source
parent07cacb6d148d7124ba9b6865ca25d585e7d3e4fd (diff)
PyGPU: make sure the UniformBuffer is padded to 16 bytes
Alignment with `vec4` is a requirement in C++, so it should be a requirement in Python as well.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/gpu/gpu_py_uniformbuffer.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/python/gpu/gpu_py_uniformbuffer.c b/source/blender/python/gpu/gpu_py_uniformbuffer.c
index f5a0af860b4..be3571d4f7c 100644
--- a/source/blender/python/gpu/gpu_py_uniformbuffer.c
+++ b/source/blender/python/gpu/gpu_py_uniformbuffer.c
@@ -78,12 +78,17 @@ static PyObject *pygpu_uniformbuffer__tp_new(PyTypeObject *UNUSED(self),
return NULL;
}
- if (GPU_context_active_get()) {
- ubo = GPU_uniformbuf_create_ex(
- bpygpu_Buffer_size(pybuffer_obj), pybuffer_obj->buf.as_void, "python_uniformbuffer");
+ if (!GPU_context_active_get()) {
+ STRNCPY(err_out, "No active GPU context found");
}
else {
- STRNCPY(err_out, "No active GPU context found");
+ size_t size = bpygpu_Buffer_size(pybuffer_obj);
+ if ((size % 16) != 0) {
+ STRNCPY(err_out, "UBO is not padded to size of vec4");
+ }
+ else {
+ ubo = GPU_uniformbuf_create_ex(size, pybuffer_obj->buf.as_void, "python_uniformbuffer");
+ }
}
if (ubo == NULL) {