diff options
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/gpu/gpu_py_platform.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/python/gpu/gpu_py_platform.c b/source/blender/python/gpu/gpu_py_platform.c index 656024ae22c..b877e3ceb98 100644 --- a/source/blender/python/gpu/gpu_py_platform.c +++ b/source/blender/python/gpu/gpu_py_platform.c @@ -55,6 +55,34 @@ static PyObject *pygpu_platform_version_get(PyObject *UNUSED(self)) return PyUnicode_FromString(GPU_platform_version()); } +PyDoc_STRVAR( + pygpu_platform_device_type_get_doc, + ".. function:: device_type_get()\n" + "\n" + " Get GPU device type.\n" + "\n" + " :return: Device type ('APPLE', 'NVIDIA', 'AMD', 'INTEL', 'SOFTWARE', 'UNKNOWN').\n" + " :rtype: str\n"); +static PyObject *pygpu_platform_device_type_get(PyObject *UNUSED(self)) +{ + if (GPU_type_matches(GPU_DEVICE_APPLE, GPU_OS_ANY, GPU_DRIVER_ANY)) { + return PyUnicode_FromString("APPLE"); + } + if (GPU_type_matches(GPU_DEVICE_NVIDIA, GPU_OS_ANY, GPU_DRIVER_ANY)) { + return PyUnicode_FromString("NVIDIA"); + } + if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY)) { + return PyUnicode_FromString("AMD"); + } + if (GPU_type_matches(GPU_DEVICE_INTEL | GPU_DEVICE_INTEL_UHD, GPU_OS_ANY, GPU_DRIVER_ANY)) { + return PyUnicode_FromString("INTEL"); + } + if (GPU_type_matches(GPU_DEVICE_SOFTWARE, GPU_OS_ANY, GPU_DRIVER_ANY)) { + return PyUnicode_FromString("SOFTWARE"); + } + return PyUnicode_FromString("UNKNOWN"); +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -74,6 +102,10 @@ static struct PyMethodDef pygpu_platform__tp_methods[] = { (PyCFunction)pygpu_platform_version_get, METH_NOARGS, pygpu_platform_version_get_doc}, + {"device_type_get", + (PyCFunction)pygpu_platform_device_type_get, + METH_NOARGS, + pygpu_platform_device_type_get_doc}, {NULL, NULL, 0, NULL}, }; |