Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/python.cpp
| Show First 20 Lines • Show All 900 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| BlenderSession::print_render_stats = true; | BlenderSession::print_render_stats = true; | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| static PyObject *get_device_types_func(PyObject * /*self*/, PyObject * /*args*/) | static PyObject *get_device_types_func(PyObject * /*self*/, PyObject * /*args*/) | ||||
| { | { | ||||
| vector<DeviceType> device_types = Device::available_types(); | vector<DeviceType> device_types = Device::available_types(); | ||||
| bool has_cuda = false, has_optix = false, has_hip = false; | bool has_cuda = false, has_optix = false, has_hip = false, has_metal = false; | ||||
| foreach (DeviceType device_type, device_types) { | foreach (DeviceType device_type, device_types) { | ||||
| has_cuda |= (device_type == DEVICE_CUDA); | has_cuda |= (device_type == DEVICE_CUDA); | ||||
| has_optix |= (device_type == DEVICE_OPTIX); | has_optix |= (device_type == DEVICE_OPTIX); | ||||
| has_hip |= (device_type == DEVICE_HIP); | has_hip |= (device_type == DEVICE_HIP); | ||||
| has_metal |= (device_type == DEVICE_METAL); | |||||
| } | } | ||||
| PyObject *list = PyTuple_New(3); | PyObject *list = PyTuple_New(4); | ||||
| PyTuple_SET_ITEM(list, 0, PyBool_FromLong(has_cuda)); | PyTuple_SET_ITEM(list, 0, PyBool_FromLong(has_cuda)); | ||||
| PyTuple_SET_ITEM(list, 1, PyBool_FromLong(has_optix)); | PyTuple_SET_ITEM(list, 1, PyBool_FromLong(has_optix)); | ||||
| PyTuple_SET_ITEM(list, 2, PyBool_FromLong(has_hip)); | PyTuple_SET_ITEM(list, 2, PyBool_FromLong(has_hip)); | ||||
| PyTuple_SET_ITEM(list, 3, PyBool_FromLong(has_metal)); | |||||
| return list; | return list; | ||||
| } | } | ||||
| static PyObject *set_device_override_func(PyObject * /*self*/, PyObject *arg) | static PyObject *set_device_override_func(PyObject * /*self*/, PyObject *arg) | ||||
| { | { | ||||
| PyObject *override_string = PyObject_Str(arg); | PyObject *override_string = PyObject_Str(arg); | ||||
| string override = PyUnicode_AsUTF8(override_string); | string override = PyUnicode_AsUTF8(override_string); | ||||
| Py_DECREF(override_string); | Py_DECREF(override_string); | ||||
| Show All 12 Lines | else if (override == "CUDA") { | ||||
| BlenderSession::device_override = DEVICE_MASK_CUDA; | BlenderSession::device_override = DEVICE_MASK_CUDA; | ||||
| } | } | ||||
| else if (override == "OPTIX") { | else if (override == "OPTIX") { | ||||
| BlenderSession::device_override = DEVICE_MASK_OPTIX; | BlenderSession::device_override = DEVICE_MASK_OPTIX; | ||||
| } | } | ||||
| else if (override == "HIP") { | else if (override == "HIP") { | ||||
| BlenderSession::device_override = DEVICE_MASK_HIP; | BlenderSession::device_override = DEVICE_MASK_HIP; | ||||
| } | } | ||||
| else if (override == "METAL") { | |||||
| BlenderSession::device_override = DEVICE_MASK_METAL; | |||||
| } | |||||
| else { | else { | ||||
| printf("\nError: %s is not a valid Cycles device.\n", override.c_str()); | printf("\nError: %s is not a valid Cycles device.\n", override.c_str()); | ||||
| Py_RETURN_FALSE; | Py_RETURN_FALSE; | ||||
| } | } | ||||
| if (include_cpu) { | if (include_cpu) { | ||||
| BlenderSession::device_override = (DeviceTypeMask)(BlenderSession::device_override | | BlenderSession::device_override = (DeviceTypeMask)(BlenderSession::device_override | | ||||
| DEVICE_MASK_CPU); | DEVICE_MASK_CPU); | ||||
| ▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines | |||||