Python: Add platform feature support methods to `gpu.capabilities` module.

Depending on the actual platform, Blender will disable features that are
known to have a faulty implementation. Add-on developers or users don't
have the ability to check what is actually enabled.

This patch will add the ability to check for

* Compute shader support `gpu.capabilities.compute_shader_support_get()`.
* SSBO support `gpu.capabilities.shader_storage_buffer_objects_support_get()`.
* Image load/store `gpu.capabilities.shader_image_load_store_support_get()`.
This commit is contained in:
Jeroen Bakker 2022-09-26 08:19:44 +02:00
parent b4605f6158
commit 267aee514a
1 changed files with 48 additions and 0 deletions

View File

@ -191,6 +191,40 @@ static PyObject *pygpu_extensions_get(PyObject *UNUSED(self))
return ret;
}
PyDoc_STRVAR(pygpu_compute_shader_support_get_doc,
".. function:: compute_shader_support_get()\n"
"\n"
" Are compute shaders supported.\n"
"\n"
" :return: True when supported, False when not supported.\n"
" :rtype: bool\n");
static PyObject *pygpu_compute_shader_support_get(PyObject *UNUSED(self))
{
return PyBool_FromLong(GPU_compute_shader_support());
}
PyDoc_STRVAR(pygpu_shader_storage_buffer_objects_support_get_doc,
".. function:: shader_storage_buffer_objects_support_get()\n"
"\n"
" Are SSBO's supported.\n"
"\n"
" :return: True when supported, False when not supported.\n"
" :rtype: bool\n");
static PyObject *pygpu_shader_storage_buffer_objects_support_get(PyObject *UNUSED(self))
{
return PyBool_FromLong(GPU_shader_storage_buffer_objects_support());
}
PyDoc_STRVAR(pygpu_shader_image_load_store_support_get_doc,
".. function:: shader_image_load_store_support_get()\n"
"\n"
" Is image load/store supported.\n"
"\n"
" :return: True when supported, False when not supported.\n"
" :rtype: bool\n");
static PyObject *pygpu_shader_image_load_store_support_get(PyObject *UNUSED(self))
{
return PyBool_FromLong(GPU_shader_image_load_store_support());
}
/** \} */
/* -------------------------------------------------------------------- */
@ -247,6 +281,20 @@ static struct PyMethodDef pygpu_capabilities__tp_methods[] = {
METH_NOARGS,
pygpu_max_varying_floats_get_doc},
{"extensions_get", (PyCFunction)pygpu_extensions_get, METH_NOARGS, pygpu_extensions_get_doc},
{"compute_shader_support_get",
(PyCFunction)pygpu_compute_shader_support_get,
METH_NOARGS,
pygpu_compute_shader_support_get_doc},
{"shader_storage_buffer_objects_support_get",
(PyCFunction)pygpu_shader_storage_buffer_objects_support_get,
METH_NOARGS,
pygpu_shader_storage_buffer_objects_support_get_doc},
{"shader_image_load_store_support_get",
(PyCFunction)pygpu_shader_image_load_store_support_get,
METH_NOARGS,
pygpu_shader_image_load_store_support_get_doc},
{NULL, NULL, 0, NULL},
};