From 9a8fd2f1ddb491892297315a4f76b6ed2b0c1b94 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 May 2023 15:51:54 +1000 Subject: [PATCH] PyAPI: remove deprecated 2D_/3D_ prefix for built-in shader names Names passed to gpu.shader.from_builtin() no longer skip the 2D_/3D_ prefix. --- doc/python_api/examples/gpu.1.py | 2 +- doc/python_api/examples/gpu.3.py | 2 +- doc/python_api/examples/gpu.4.py | 2 +- doc/python_api/examples/gpu.5.py | 2 +- doc/python_api/examples/gpu.6.py | 4 ++-- source/blender/python/gpu/gpu_py_shader.c | 20 +------------------- 6 files changed, 7 insertions(+), 25 deletions(-) diff --git a/doc/python_api/examples/gpu.1.py b/doc/python_api/examples/gpu.1.py index c44e79a77aa..ca810d7f8d1 100644 --- a/doc/python_api/examples/gpu.1.py +++ b/doc/python_api/examples/gpu.1.py @@ -129,7 +129,7 @@ import gpu from gpu_extras.batch import batch_for_shader coords = [(1, 1, 1), (-2, 0, 0), (-2, -1, 3), (0, 1, 1)] -shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') +shader = gpu.shader.from_builtin('UNIFORM_COLOR') batch = batch_for_shader(shader, 'LINES', {"pos": coords}) diff --git a/doc/python_api/examples/gpu.3.py b/doc/python_api/examples/gpu.3.py index 9e8f762d9c9..06efb1f8dbe 100644 --- a/doc/python_api/examples/gpu.3.py +++ b/doc/python_api/examples/gpu.3.py @@ -17,7 +17,7 @@ indices = ( (4, 5), (4, 6), (5, 7), (6, 7), (0, 4), (1, 5), (2, 6), (3, 7)) -shader = gpu.shader.from_builtin('3D_UNIFORM_COLOR') +shader = gpu.shader.from_builtin('UNIFORM_COLOR') batch = batch_for_shader(shader, 'LINES', {"pos": coords}, indices=indices) diff --git a/doc/python_api/examples/gpu.4.py b/doc/python_api/examples/gpu.4.py index b1a1ba827db..7c6b4b94144 100644 --- a/doc/python_api/examples/gpu.4.py +++ b/doc/python_api/examples/gpu.4.py @@ -21,7 +21,7 @@ mesh.loop_triangles.foreach_get( vertex_colors = [(random(), random(), random(), 1) for _ in range(len(mesh.vertices))] -shader = gpu.shader.from_builtin('3D_SMOOTH_COLOR') +shader = gpu.shader.from_builtin('SMOOTH_COLOR') batch = batch_for_shader( shader, 'TRIS', {"pos": vertices, "color": vertex_colors}, diff --git a/doc/python_api/examples/gpu.5.py b/doc/python_api/examples/gpu.5.py index 983372706c1..bc9d09afb92 100644 --- a/doc/python_api/examples/gpu.5.py +++ b/doc/python_api/examples/gpu.5.py @@ -13,7 +13,7 @@ vertices = ( indices = ( (0, 1, 2), (2, 1, 3)) -shader = gpu.shader.from_builtin('2D_UNIFORM_COLOR') +shader = gpu.shader.from_builtin('UNIFORM_COLOR') batch = batch_for_shader(shader, 'TRIS', {"pos": vertices}, indices=indices) diff --git a/doc/python_api/examples/gpu.6.py b/doc/python_api/examples/gpu.6.py index 96decf571ee..a2071d2b2aa 100644 --- a/doc/python_api/examples/gpu.6.py +++ b/doc/python_api/examples/gpu.6.py @@ -12,7 +12,7 @@ IMAGE_NAME = "Untitled" image = bpy.data.images[IMAGE_NAME] texture = gpu.texture.from_image(image) -shader = gpu.shader.from_builtin('2D_IMAGE') +shader = gpu.shader.from_builtin('IMAGE') batch = batch_for_shader( shader, 'TRI_FAN', { @@ -45,7 +45,7 @@ IMAGE_NAME = "Untitled" image = bpy.data.images[IMAGE_NAME] texture = gpu.texture.from_image(image) -shader = gpu.shader.from_builtin('3D_IMAGE') +shader = gpu.shader.from_builtin('IMAGE') batch = batch_for_shader( shader, 'TRIS', { diff --git a/source/blender/python/gpu/gpu_py_shader.c b/source/blender/python/gpu/gpu_py_shader.c index 1b737faaee5..48d40cbf410 100644 --- a/source/blender/python/gpu/gpu_py_shader.c +++ b/source/blender/python/gpu/gpu_py_shader.c @@ -785,24 +785,6 @@ PyTypeObject BPyGPUShader_Type = { /** \name gpu.shader Module API * \{ */ -static int pyc_parse_buitinshader_w_backward_compatibility(PyObject *o, void *p) -{ - struct PyC_StringEnum *e = p; - const char *value = PyUnicode_AsUTF8(o); - if (value && ELEM(value[0], u'2', u'3')) { - /* Deprecated enums that start with "3D_" or "2D_". */ - value += 3; - for (int i = 0; e->items[i].id; i++) { - if (STREQ(e->items[i].id, value)) { - e->value_found = e->items[i].value; - return 1; - } - } - } - - return PyC_ParseStringEnum(o, p); -} - PyDoc_STRVAR(pygpu_shader_unbind_doc, ".. function:: unbind()\n" "\n" @@ -851,7 +833,7 @@ static PyObject *pygpu_shader_from_builtin(PyObject *UNUSED(self), PyObject *arg if (!_PyArg_ParseTupleAndKeywordsFast(args, kwds, &_parser, - pyc_parse_buitinshader_w_backward_compatibility, + PyC_ParseStringEnum, &pygpu_bultinshader, PyC_ParseStringEnum, &pygpu_config))