Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2022-09-26 09:19:44 +0300
committerJeroen Bakker <jeroen@blender.org>2022-09-26 09:19:44 +0300
commit267aee514adba5b2b871788219535efdddc7f4f3 (patch)
tree424046c2411c22fcfe625f86bdd3cc797037c398 /source/blender/python
parentb4605f61589e67bcdccc599632ae523bafdf65fe (diff)
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()`.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/gpu/gpu_py_capabilities.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/source/blender/python/gpu/gpu_py_capabilities.c b/source/blender/python/gpu/gpu_py_capabilities.c
index b892167cd76..dea057bf8e3 100644
--- a/source/blender/python/gpu/gpu_py_capabilities.c
+++ b/source/blender/python/gpu/gpu_py_capabilities.c
@@ -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},
};