diff options
Diffstat (limited to 'intern/cycles/blender/blender_python.cpp')
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index bf7605ed5b1..513941b1fcc 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -40,6 +40,10 @@ #include <OSL/oslconfig.h> #endif +#ifdef WITH_OPENCL +#include "device/device_intern.h" +#endif + CCL_NAMESPACE_BEGIN namespace { @@ -624,6 +628,31 @@ static PyObject *opencl_disable_func(PyObject * /*self*/, PyObject * /*value*/) DebugFlags().opencl.device_type = DebugFlags::OpenCL::DEVICE_NONE; Py_RETURN_NONE; } + +static PyObject *opencl_compile_func(PyObject * /*self*/, PyObject *args) +{ + PyObject *sequence = PySequence_Fast(args, "Arguments must be a sequence"); + if(sequence == NULL) { + Py_RETURN_FALSE; + } + + vector<string> parameters; + for(Py_ssize_t i = 0; i < PySequence_Fast_GET_SIZE(sequence); i++) { + PyObject *item = PySequence_Fast_GET_ITEM(sequence, i); + PyObject *item_as_string = PyObject_Str(item); + const char *parameter_string = PyUnicode_AsUTF8(item_as_string); + parameters.push_back(parameter_string); + Py_DECREF(item_as_string); + } + Py_DECREF(sequence); + + if (device_opencl_compile_kernel(parameters)) { + Py_RETURN_TRUE; + } + else { + Py_RETURN_FALSE; + } +} #endif static bool denoise_parse_filepaths(PyObject *pyfilepaths, vector<string>& filepaths) @@ -899,6 +928,7 @@ static PyMethodDef methods[] = { {"system_info", system_info_func, METH_NOARGS, ""}, #ifdef WITH_OPENCL {"opencl_disable", opencl_disable_func, METH_NOARGS, ""}, + {"opencl_compile", opencl_compile_func, METH_VARARGS, ""}, #endif /* Standalone denoising */ |