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.
This commit is contained in:
@@ -78,12 +78,17 @@ static PyObject *pygpu_uniformbuffer__tp_new(PyTypeObject *UNUSED(self),
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GPU_context_active_get()) {
|
if (!GPU_context_active_get()) {
|
||||||
ubo = GPU_uniformbuf_create_ex(
|
STRNCPY(err_out, "No active GPU context found");
|
||||||
bpygpu_Buffer_size(pybuffer_obj), pybuffer_obj->buf.as_void, "python_uniformbuffer");
|
|
||||||
}
|
}
|
||||||
else {
|
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) {
|
if (ubo == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user