GPU: Deprecate GPU_DATA_UINT_24_8
GPU_DATA_UINT_24_8 isn't used anymore. We cannot phase out the data type as it can still be used by add-ons. This PR will deprecate `GPU_DATA_UINT_24_8`. When used in an add-on a deprecation message will be shown. Pull Request: https://projects.blender.org/blender/blender/pulls/140715
This commit is contained in:
@@ -42,7 +42,7 @@ PyC_StringEnumItems bpygpu_dataformat_items[] = {
|
||||
{GPU_DATA_INT, "INT"},
|
||||
{GPU_DATA_UINT, "UINT"},
|
||||
{GPU_DATA_UBYTE, "UBYTE"},
|
||||
{GPU_DATA_UINT_24_8, "UINT_24_8"},
|
||||
{GPU_DATA_UINT_24_8_DEPRECATED, "UINT_24_8"},
|
||||
{GPU_DATA_10_11_11_REV, "10_11_11_REV"},
|
||||
{0, nullptr},
|
||||
};
|
||||
|
||||
@@ -125,7 +125,7 @@ static const char *pygpu_buffer_formatstr(eGPUDataFormat data_format)
|
||||
return "I";
|
||||
case GPU_DATA_UBYTE:
|
||||
return "B";
|
||||
case GPU_DATA_UINT_24_8:
|
||||
case GPU_DATA_UINT_24_8_DEPRECATED:
|
||||
case GPU_DATA_10_11_11_REV:
|
||||
return "I";
|
||||
default:
|
||||
@@ -182,7 +182,7 @@ static PyObject *pygpu_buffer__sq_item(BPyGPUBuffer *self, Py_ssize_t i)
|
||||
case GPU_DATA_UBYTE:
|
||||
return Py_BuildValue(formatstr, self->buf.as_byte[i]);
|
||||
case GPU_DATA_UINT:
|
||||
case GPU_DATA_UINT_24_8:
|
||||
case GPU_DATA_UINT_24_8_DEPRECATED:
|
||||
case GPU_DATA_10_11_11_REV:
|
||||
return Py_BuildValue(formatstr, self->buf.as_uint[i]);
|
||||
}
|
||||
@@ -386,6 +386,9 @@ static PyObject *pygpu_buffer__tp_new(PyTypeObject * /*type*/, PyObject *args, P
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
if (pygpu_dataformat.value_found == GPU_DATA_UINT_24_8_DEPRECATED) {
|
||||
PyErr_WarnEx(PyExc_DeprecationWarning, "`UINT_24_8` is deprecated, use `FLOAT` instead", 1);
|
||||
}
|
||||
|
||||
if (!pygpu_buffer_pyobj_as_shape(length_ob, shape, &shape_len)) {
|
||||
return nullptr;
|
||||
@@ -480,7 +483,7 @@ static int pygpu_buffer__sq_ass_item(BPyGPUBuffer *self, Py_ssize_t i, PyObject
|
||||
case GPU_DATA_UBYTE:
|
||||
return PyArg_Parse(v, "b:Expected ints", &self->buf.as_byte[i]) ? 0 : -1;
|
||||
case GPU_DATA_UINT:
|
||||
case GPU_DATA_UINT_24_8:
|
||||
case GPU_DATA_UINT_24_8_DEPRECATED:
|
||||
case GPU_DATA_10_11_11_REV:
|
||||
return PyArg_Parse(v, "I:Expected unsigned ints", &self->buf.as_uint[i]) ? 0 : -1;
|
||||
default:
|
||||
@@ -676,6 +679,7 @@ PyDoc_STRVAR(
|
||||
"\n"
|
||||
" :arg format: Format type to interpret the buffer.\n"
|
||||
" Possible values are `FLOAT`, `INT`, `UINT`, `UBYTE`, `UINT_24_8` and `10_11_11_REV`.\n"
|
||||
" `UINT_24_8` is deprecated, use `FLOAT` instead.\n"
|
||||
" :type format: str\n"
|
||||
" :arg dimensions: Array describing the dimensions.\n"
|
||||
" :type dimensions: int\n"
|
||||
|
||||
@@ -550,6 +550,7 @@ PyDoc_STRVAR(
|
||||
" :type slot: int\n"
|
||||
" :arg format: The format that describes the content of a single channel.\n"
|
||||
" Possible values are `FLOAT`, `INT`, `UINT`, `UBYTE`, `UINT_24_8` and `10_11_11_REV`.\n"
|
||||
" `UINT_24_8` is deprecated, use `FLOAT` instead.\n"
|
||||
" :type format: str\n"
|
||||
" :arg data: Optional Buffer object to fill with the pixels values.\n"
|
||||
" :type data: :class:`gpu.types.Buffer`\n"
|
||||
@@ -599,6 +600,10 @@ static PyObject *pygpu_framebuffer_read_color(BPyGPUFrameBuffer *self,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (pygpu_dataformat.value_found == GPU_DATA_UINT_24_8_DEPRECATED) {
|
||||
PyErr_WarnEx(PyExc_DeprecationWarning, "`UINT_24_8` is deprecated, use `FLOAT` instead", 1);
|
||||
}
|
||||
|
||||
if (!IN_RANGE_INCL(channels, 1, 4)) {
|
||||
PyErr_SetString(PyExc_AttributeError, "Color channels must be 1, 2, 3 or 4");
|
||||
return nullptr;
|
||||
|
||||
@@ -349,6 +349,7 @@ PyDoc_STRVAR(
|
||||
"\n"
|
||||
" :arg format: The format that describes the content of a single item.\n"
|
||||
" Possible values are `FLOAT`, `INT`, `UINT`, `UBYTE`, `UINT_24_8` and `10_11_11_REV`.\n"
|
||||
" `UINT_24_8` is deprecated, use `FLOAT` instead.\n"
|
||||
" :type format: str\n"
|
||||
" :arg value: Sequence each representing the value to fill. Sizes 1..4 are supported.\n"
|
||||
" :type value: Sequence[float]\n");
|
||||
@@ -379,6 +380,9 @@ static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObje
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
if (pygpu_dataformat.value_found == GPU_DATA_UINT_24_8_DEPRECATED) {
|
||||
PyErr_WarnEx(PyExc_DeprecationWarning, "`UINT_24_8` is deprecated, use `FLOAT` instead", 1);
|
||||
}
|
||||
|
||||
int shape = PySequence_Size(py_values);
|
||||
if (shape == -1) {
|
||||
@@ -390,7 +394,8 @@ static PyObject *pygpu_texture_clear(BPyGPUTexture *self, PyObject *args, PyObje
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (shape != 1 && ELEM(pygpu_dataformat.value_found, GPU_DATA_UINT_24_8, GPU_DATA_10_11_11_REV))
|
||||
if (shape != 1 &&
|
||||
ELEM(pygpu_dataformat.value_found, GPU_DATA_UINT_24_8_DEPRECATED, GPU_DATA_10_11_11_REV))
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError,
|
||||
"`UINT_24_8` and `10_11_11_REV` only support single values");
|
||||
@@ -439,10 +444,8 @@ static PyObject *pygpu_texture_read(BPyGPUTexture *self)
|
||||
switch (tex_format) {
|
||||
case GPU_DEPTH_COMPONENT16:
|
||||
case GPU_DEPTH_COMPONENT32F:
|
||||
best_data_format = GPU_DATA_FLOAT;
|
||||
break;
|
||||
case GPU_DEPTH32F_STENCIL8:
|
||||
best_data_format = GPU_DATA_UINT_24_8;
|
||||
best_data_format = GPU_DATA_FLOAT;
|
||||
break;
|
||||
case GPU_R8UI:
|
||||
case GPU_R16UI:
|
||||
|
||||
Reference in New Issue
Block a user