Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/blender/blender_python.cpp
| Show All 33 Lines | |||||
| #include <OSL/oslquery.h> | #include <OSL/oslquery.h> | ||||
| #include <OSL/oslconfig.h> | #include <OSL/oslconfig.h> | ||||
| #endif | #endif | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| namespace { | namespace { | ||||
| /* Device list stored static (used by compute_device_list()). */ | |||||
| static ccl::vector<CCLDeviceInfo> device_list; | |||||
| static ccl::DeviceType device_type = DEVICE_NONE; | |||||
| /* Flag describing whether debug flags were synchronized from scene. */ | /* Flag describing whether debug flags were synchronized from scene. */ | ||||
| bool debug_flags_set = false; | bool debug_flags_set = false; | ||||
| void *pylong_as_voidptr_typesafe(PyObject *object) | void *pylong_as_voidptr_typesafe(PyObject *object) | ||||
| { | { | ||||
| if(object == Py_None) | if(object == Py_None) | ||||
| return NULL; | return NULL; | ||||
| return PyLong_AsVoidPtr(object); | return PyLong_AsVoidPtr(object); | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | static PyObject *init_func(PyObject * /*self*/, PyObject *args) | ||||
| BlenderSession::headless = headless; | BlenderSession::headless = headless; | ||||
| VLOG(2) << "Debug flags initialized to:\n" | VLOG(2) << "Debug flags initialized to:\n" | ||||
| << DebugFlags(); | << DebugFlags(); | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| static PyObject *deinit_func(PyObject * /*self*/, PyObject * /*args*/) | |||||
| { | |||||
| ShaderManager::free_memory(); | |||||
| TaskScheduler::free_memory(); | |||||
| Device::free_memory(); | |||||
| device_list.free_memory(); | |||||
| Py_RETURN_NONE; | |||||
| } | |||||
| static PyObject *create_func(PyObject * /*self*/, PyObject *args) | static PyObject *create_func(PyObject * /*self*/, PyObject *args) | ||||
| { | { | ||||
| PyObject *pyengine, *pyuserpref, *pydata, *pyscene, *pyregion, *pyv3d, *pyrv3d; | PyObject *pyengine, *pyuserpref, *pydata, *pyscene, *pyregion, *pyv3d, *pyrv3d; | ||||
| int preview_osl; | int preview_osl; | ||||
| if(!PyArg_ParseTuple(args, "OOOOOOOi", &pyengine, &pyuserpref, &pydata, &pyscene, | if(!PyArg_ParseTuple(args, "OOOOOOOi", &pyengine, &pyuserpref, &pydata, &pyscene, | ||||
| &pyregion, &pyv3d, &pyrv3d, &preview_osl)) | &pyregion, &pyv3d, &pyrv3d, &preview_osl)) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 428 Lines • ▼ Show 20 Lines | VLOG(2) << "Debug flags reset to:\n" | ||||
| << DebugFlags(); | << DebugFlags(); | ||||
| debug_flags_set = false; | debug_flags_set = false; | ||||
| } | } | ||||
| Py_RETURN_NONE; | Py_RETURN_NONE; | ||||
| } | } | ||||
| static PyMethodDef methods[] = { | static PyMethodDef methods[] = { | ||||
| {"init", init_func, METH_VARARGS, ""}, | {"init", init_func, METH_VARARGS, ""}, | ||||
| {"deinit", deinit_func, METH_VARARGS, ""}, | |||||
| {"create", create_func, METH_VARARGS, ""}, | {"create", create_func, METH_VARARGS, ""}, | ||||
| {"free", free_func, METH_O, ""}, | {"free", free_func, METH_O, ""}, | ||||
| {"render", render_func, METH_O, ""}, | {"render", render_func, METH_O, ""}, | ||||
| {"bake", bake_func, METH_VARARGS, ""}, | {"bake", bake_func, METH_VARARGS, ""}, | ||||
| {"draw", draw_func, METH_VARARGS, ""}, | {"draw", draw_func, METH_VARARGS, ""}, | ||||
| {"sync", sync_func, METH_O, ""}, | {"sync", sync_func, METH_O, ""}, | ||||
| {"reset", reset_func, METH_VARARGS, ""}, | {"reset", reset_func, METH_VARARGS, ""}, | ||||
| #ifdef WITH_OSL | #ifdef WITH_OSL | ||||
| Show All 16 Lines | static struct PyModuleDef module = { | ||||
| "Blender cycles render integration", | "Blender cycles render integration", | ||||
| -1, | -1, | ||||
| methods, | methods, | ||||
| NULL, NULL, NULL, NULL | NULL, NULL, NULL, NULL | ||||
| }; | }; | ||||
| static CCLDeviceInfo *compute_device_list(DeviceType type) | static CCLDeviceInfo *compute_device_list(DeviceType type) | ||||
| { | { | ||||
| /* device list stored static */ | |||||
| static ccl::vector<CCLDeviceInfo> device_list; | |||||
| static ccl::DeviceType device_type = DEVICE_NONE; | |||||
| /* create device list if it's not already done */ | /* create device list if it's not already done */ | ||||
| if(type != device_type) { | if(type != device_type) { | ||||
| ccl::vector<DeviceInfo>& devices = ccl::Device::available_devices(); | ccl::vector<DeviceInfo>& devices = ccl::Device::available_devices(); | ||||
| device_type = type; | device_type = type; | ||||
| device_list.clear(); | device_list.clear(); | ||||
| /* add devices */ | /* add devices */ | ||||
| ▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines | |||||