diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-07-27 15:26:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-07-27 15:36:01 +0300 |
commit | 58eacb8e7c7ae95bf34896d9cdd868e7a11e044e (patch) | |
tree | 7e62d569d7196bbfc20be0b4a5cb3e822eaa8bc4 /source/blender/python/gpu | |
parent | b1a2abd6b2ba92c0b9134ae72b502a375556a417 (diff) |
Cleanup: pass sizeof array element to PyC_AsArray
Replace the is_double argument which was only used for single/double
precision floats.
This allows supporting different sized int types more easily.
Diffstat (limited to 'source/blender/python/gpu')
-rw-r--r-- | source/blender/python/gpu/gpu_py_element.c | 8 | ||||
-rw-r--r-- | source/blender/python/gpu/gpu_py_shader.c | 6 | ||||
-rw-r--r-- | source/blender/python/gpu/gpu_py_texture.c | 7 |
3 files changed, 14 insertions, 7 deletions
diff --git a/source/blender/python/gpu/gpu_py_element.c b/source/blender/python/gpu/gpu_py_element.c index 2dd8d1c379e..2fb722f74db 100644 --- a/source/blender/python/gpu/gpu_py_element.c +++ b/source/blender/python/gpu/gpu_py_element.c @@ -144,8 +144,12 @@ static PyObject *pygpu_IndexBuf__tp_new(PyTypeObject *UNUSED(type), PyObject *ar goto finally; } - ok = PyC_AsArray_FAST( - values, seq_fast_item, verts_per_prim, &PyLong_Type, false, error_prefix) == 0; + ok = PyC_AsArray_FAST(values, + sizeof(*values), + seq_fast_item, + verts_per_prim, + &PyLong_Type, + error_prefix) == 0; if (ok) { for (uint j = 0; j < verts_per_prim; j++) { diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c index 00e876aee7d..b3f1c186716 100644 --- a/source/blender/python/gpu/gpu_py_shader.c +++ b/source/blender/python/gpu/gpu_py_shader.c @@ -309,7 +309,8 @@ static PyObject *pygpu_shader_uniform_bool(BPyGPUShader *self, PyObject *args) ret = -1; } else { - ret = PyC_AsArray_FAST(values, seq_fast, length, &PyLong_Type, false, error_prefix); + ret = PyC_AsArray_FAST( + values, sizeof(*values), seq_fast, length, &PyLong_Type, error_prefix); } Py_DECREF(seq_fast); } @@ -448,7 +449,8 @@ static PyObject *pygpu_shader_uniform_int(BPyGPUShader *self, PyObject *args) ret = -1; } else { - ret = PyC_AsArray_FAST(values, seq_fast, length, &PyLong_Type, false, error_prefix); + ret = PyC_AsArray_FAST( + values, sizeof(*values), seq_fast, length, &PyLong_Type, error_prefix); } Py_DECREF(seq_fast); } diff --git a/source/blender/python/gpu/gpu_py_texture.c b/source/blender/python/gpu/gpu_py_texture.c index ca41662db9d..4cbbd77438c 100644 --- a/source/blender/python/gpu/gpu_py_texture.c +++ b/source/blender/python/gpu/gpu_py_texture.c @@ -153,7 +153,7 @@ static PyObject *pygpu_texture__tp_new(PyTypeObject *UNUSED(self), PyObject *arg int len = 1; if (PySequence_Check(py_size)) { len = PySequence_Size(py_size); - if (PyC_AsArray(size, py_size, len, &PyLong_Type, false, "GPUTexture.__new__") == -1) { + if (PyC_AsArray(size, sizeof(*size), py_size, len, &PyLong_Type, "GPUTexture.__new__") == -1) { return NULL; } } @@ -321,10 +321,11 @@ static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObje memset(&values, 0, sizeof(values)); if (PyC_AsArray(&values, + (pygpu_dataformat.value_found == GPU_DATA_FLOAT) ? sizeof(*values.f) : + sizeof(*values.i), py_values, shape, - pygpu_dataformat.value_found == GPU_DATA_FLOAT ? &PyFloat_Type : &PyLong_Type, - false, + (pygpu_dataformat.value_found == GPU_DATA_FLOAT) ? &PyFloat_Type : &PyLong_Type, "clear") == -1) { return NULL; } |