Fix #103978 Add deprecation warnings to GPUBatch program usage. #105295

Closed
Prakhar-Singh-Chouhan wants to merge 1 commits from (deleted):#103978 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 14 additions and 1 deletions

View File

@ -174,6 +174,12 @@ PyDoc_STRVAR(
" :type program: :class:`gpu.types.GPUShader`\n");
static PyObject *pygpu_batch_program_set(BPyGPUBatch *self, BPyGPUShader *py_shader)
{
PyErr_WarnEx(PyExc_DeprecationWarning,
"calls to 'gpu.types.GPUBatch.program_set' is deprecated'",
1);
if (!BPyGPUShader_Check(py_shader)) {
PyErr_Format(PyExc_TypeError, "Expected a GPUShader, got %s", Py_TYPE(py_shader)->tp_name);
return NULL;
@ -227,6 +233,13 @@ static PyObject *pygpu_batch_draw(BPyGPUBatch *self, PyObject *args)
GPU_batch_set_shader(self->batch, py_program->shader);
}
if(args<2 || self<2)
Review

Seems like an incorrect check. It could be added in the if(py_program == NULL) check.

Seems like an incorrect check. It could be added in the `if(py_program == NULL)` check.
{
PyErr_WarnEx(PyExc_DeprecationWarning,
"'GPU BATCH' program is deprecated. Please add a valid program parameter ",
Review

Description of the message is confusing.
We also want to limit this message to be shown once as typically this function will be used many times per second and can overflood the console.

Description of the message is confusing. We also want to limit this message to be shown once as typically this function will be used many times per second and can overflood the console.
1);
}
GPU_batch_draw(self->batch);
Py_RETURN_NONE;
}
@ -334,7 +347,7 @@ PyTypeObject BPyGPUBatch_Type = {
PyObject *BPyGPUBatch_CreatePyObject(GPUBatch *batch)
{
BPyGPUBatch *self;
#ifdef USE_GPU_PY_REFERENCES
self = (BPyGPUBatch *)_PyObject_GC_New(&BPyGPUBatch_Type);
self->references = NULL;