2023-06-14 16:52:36 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
#include <Python.h>
|
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "blender/CCL_api.h"
|
2012-01-09 16:58:01 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "blender/device.h"
|
|
|
|
|
#include "blender/session.h"
|
|
|
|
|
#include "blender/sync.h"
|
|
|
|
|
#include "blender/util.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "session/denoising.h"
|
|
|
|
|
#include "session/merge.h"
|
2019-02-06 12:57:10 +01:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/debug.h"
|
2024-12-26 19:41:25 +01:00
|
|
|
|
2022-09-21 17:58:34 +02:00
|
|
|
#include "util/guiding.h"
|
2025-06-22 22:23:52 +02:00
|
|
|
#include "util/log.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/openimagedenoise.h"
|
|
|
|
|
#include "util/path.h"
|
|
|
|
|
#include "util/string.h"
|
|
|
|
|
#include "util/task.h"
|
|
|
|
|
#include "util/types.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2024-03-23 01:24:18 +01:00
|
|
|
#include "GPU_state.hh"
|
2022-12-02 15:56:12 +01:00
|
|
|
|
2025-03-04 17:27:10 +01:00
|
|
|
#include "scene/osl.h"
|
2012-11-03 14:32:35 +00:00
|
|
|
|
2024-09-27 14:39:49 +02:00
|
|
|
#ifdef WITH_METAL
|
|
|
|
|
# include "device/metal/device.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
2016-01-12 16:00:48 +05:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
/* Flag describing whether debug flags were synchronized from scene. */
|
|
|
|
|
bool debug_flags_set = false;
|
|
|
|
|
|
|
|
|
|
void *pylong_as_voidptr_typesafe(PyObject *object)
|
2014-07-01 15:43:37 +06:00
|
|
|
{
|
2023-09-17 09:01:48 +10:00
|
|
|
if (object == Py_None) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2014-07-01 15:43:37 +06:00
|
|
|
return PyLong_AsVoidPtr(object);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-04 20:02:08 +02:00
|
|
|
PyObject *pyunicode_from_string(const char *str)
|
|
|
|
|
{
|
2025-05-17 09:18:03 +10:00
|
|
|
/* Ignore errors if device API returns invalid UTF8 strings. */
|
2020-05-04 20:02:08 +02:00
|
|
|
return PyUnicode_DecodeUTF8(str, strlen(str), "ignore");
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-12 16:00:48 +05:00
|
|
|
/* Synchronize debug flags from a given Blender scene.
|
|
|
|
|
* Return truth when device list needs invalidation.
|
|
|
|
|
*/
|
2024-12-26 17:53:59 +01:00
|
|
|
void debug_flags_sync_from_scene(BL::Scene b_scene)
|
2016-01-12 16:00:48 +05:00
|
|
|
{
|
|
|
|
|
DebugFlagsRef flags = DebugFlags();
|
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
|
/* Synchronize CPU flags. */
|
|
|
|
|
flags.cpu.avx2 = get_boolean(cscene, "debug_use_cpu_avx2");
|
2024-02-09 17:25:58 +01:00
|
|
|
flags.cpu.sse42 = get_boolean(cscene, "debug_use_cpu_sse42");
|
2018-01-19 10:59:58 +01:00
|
|
|
flags.cpu.bvh_layout = (BVHLayout)get_enum(cscene, "debug_bvh_layout");
|
2016-05-06 22:34:15 +02:00
|
|
|
/* Synchronize CUDA flags. */
|
|
|
|
|
flags.cuda.adaptive_compile = get_boolean(cscene, "debug_use_cuda_adaptive_compile");
|
2024-12-30 16:45:02 +01:00
|
|
|
flags.hip.adaptive_compile = get_boolean(cscene, "debug_use_hip_adaptive_compile");
|
|
|
|
|
flags.metal.adaptive_compile = get_boolean(cscene, "debug_use_metal_adaptive_compile");
|
2019-09-12 14:50:06 +02:00
|
|
|
/* Synchronize OptiX flags. */
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
flags.optix.use_debug = get_boolean(cscene, "debug_use_optix_debug");
|
2016-01-12 16:00:48 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Reset debug flags to default values.
|
|
|
|
|
* Return truth when device list needs invalidation.
|
|
|
|
|
*/
|
2024-12-26 17:53:59 +01:00
|
|
|
void debug_flags_reset()
|
2016-01-12 16:00:48 +05:00
|
|
|
{
|
|
|
|
|
DebugFlagsRef flags = DebugFlags();
|
|
|
|
|
flags.reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} /* namespace */
|
|
|
|
|
|
2014-02-12 23:13:45 +01:00
|
|
|
void python_thread_state_save(void **python_thread_state)
|
2014-02-12 21:49:34 +01:00
|
|
|
{
|
2014-02-12 23:13:45 +01:00
|
|
|
*python_thread_state = (void *)PyEval_SaveThread();
|
2014-02-12 21:49:34 +01:00
|
|
|
}
|
|
|
|
|
|
2014-02-12 23:13:45 +01:00
|
|
|
void python_thread_state_restore(void **python_thread_state)
|
2014-02-12 21:49:34 +01:00
|
|
|
{
|
2014-02-12 23:13:45 +01:00
|
|
|
PyEval_RestoreThread((PyThreadState *)*python_thread_state);
|
2024-12-26 17:53:55 +01:00
|
|
|
*python_thread_state = nullptr;
|
2014-02-12 21:49:34 +01:00
|
|
|
}
|
|
|
|
|
|
2023-02-15 16:15:59 +11:00
|
|
|
static const char *PyC_UnicodeAsBytes(PyObject *py_str, PyObject **coerce)
|
2014-10-14 14:53:49 +02:00
|
|
|
{
|
2021-02-13 22:57:01 +11:00
|
|
|
const char *result = PyUnicode_AsUTF8(py_str);
|
2016-03-23 13:58:31 +01:00
|
|
|
if (result) {
|
|
|
|
|
/* 99% of the time this is enough but we better support non unicode
|
2019-06-12 09:04:10 +10:00
|
|
|
* chars since blender doesn't limit this.
|
2016-03-23 13:58:31 +01:00
|
|
|
*/
|
|
|
|
|
return result;
|
2014-10-14 14:53:49 +02:00
|
|
|
}
|
2024-12-26 17:53:59 +01:00
|
|
|
PyErr_Clear();
|
|
|
|
|
if (PyBytes_Check(py_str)) {
|
|
|
|
|
return PyBytes_AS_STRING(py_str);
|
2014-10-14 14:53:49 +02:00
|
|
|
}
|
2024-12-26 17:53:59 +01:00
|
|
|
|
|
|
|
|
*coerce = PyUnicode_EncodeFSDefault(py_str);
|
|
|
|
|
if (*coerce) {
|
|
|
|
|
return PyBytes_AS_STRING(*coerce);
|
|
|
|
|
}
|
|
|
|
|
/* Clear the error, so Cycles can be at least used without
|
|
|
|
|
* GPU and OSL support,
|
|
|
|
|
*/
|
|
|
|
|
PyErr_Clear();
|
|
|
|
|
return "";
|
2014-10-14 14:53:49 +02:00
|
|
|
}
|
|
|
|
|
|
2015-03-27 15:47:55 +05:00
|
|
|
static PyObject *init_func(PyObject * /*self*/, PyObject *args)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *path;
|
|
|
|
|
PyObject *user_path;
|
2015-02-18 21:16:52 +05:00
|
|
|
int headless;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2022-01-10 16:05:17 +01:00
|
|
|
if (!PyArg_ParseTuple(args, "OOi", &path, &user_path, &headless)) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return nullptr;
|
2014-10-14 14:53:49 +02:00
|
|
|
}
|
|
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *path_coerce = nullptr;
|
|
|
|
|
PyObject *user_path_coerce = nullptr;
|
2023-02-15 16:15:59 +11:00
|
|
|
path_init(PyC_UnicodeAsBytes(path, &path_coerce),
|
|
|
|
|
PyC_UnicodeAsBytes(user_path, &user_path_coerce));
|
2014-10-14 14:53:49 +02:00
|
|
|
Py_XDECREF(path_coerce);
|
|
|
|
|
Py_XDECREF(user_path_coerce);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2015-02-18 21:16:52 +05:00
|
|
|
BlenderSession::headless = headless;
|
|
|
|
|
|
2011-12-24 02:47:13 +00:00
|
|
|
Py_RETURN_NONE;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-02-07 03:40:41 +05:00
|
|
|
static PyObject *exit_func(PyObject * /*self*/, PyObject * /*args*/)
|
|
|
|
|
{
|
2024-09-27 14:39:49 +02:00
|
|
|
#ifdef WITH_METAL
|
|
|
|
|
device_metal_exit();
|
|
|
|
|
#endif
|
|
|
|
|
|
2025-03-04 17:27:10 +01:00
|
|
|
ColorSpaceManager::free_memory();
|
|
|
|
|
OSLManager::free_memory();
|
2016-02-07 03:40:41 +05:00
|
|
|
TaskScheduler::free_memory();
|
|
|
|
|
Device::free_memory();
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-27 15:47:55 +05:00
|
|
|
static PyObject *create_func(PyObject * /*self*/, PyObject *args)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *pyengine;
|
|
|
|
|
PyObject *pypreferences;
|
|
|
|
|
PyObject *pydata;
|
|
|
|
|
PyObject *pyscreen;
|
|
|
|
|
PyObject *pyregion;
|
|
|
|
|
PyObject *pyv3d;
|
|
|
|
|
PyObject *pyrv3d;
|
2015-02-18 21:16:52 +05:00
|
|
|
int preview_osl;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-11 13:37:45 +01:00
|
|
|
if (!PyArg_ParseTuple(args,
|
2019-09-11 08:22:53 +02:00
|
|
|
"OOOOOOOi",
|
2019-02-11 13:37:45 +01:00
|
|
|
&pyengine,
|
|
|
|
|
&pypreferences,
|
|
|
|
|
&pydata,
|
2019-09-11 08:22:53 +02:00
|
|
|
&pyscreen,
|
2015-02-18 21:16:52 +05:00
|
|
|
&pyregion,
|
|
|
|
|
&pyv3d,
|
|
|
|
|
&pyrv3d,
|
|
|
|
|
&preview_osl))
|
|
|
|
|
{
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2015-02-11 01:02:36 +05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* RNA */
|
2019-09-11 08:22:53 +02:00
|
|
|
ID *bScreen = (ID *)PyLong_AsVoidPtr(pyscreen);
|
|
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA engineptr = RNA_pointer_create_discrete(
|
2024-12-26 17:53:59 +01:00
|
|
|
nullptr, &RNA_RenderEngine, PyLong_AsVoidPtr(pyengine));
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::RenderEngine engine(engineptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA preferencesptr = RNA_pointer_create_discrete(
|
2024-12-26 17:53:59 +01:00
|
|
|
nullptr, &RNA_Preferences, PyLong_AsVoidPtr(pypreferences));
|
2019-02-11 13:37:45 +01:00
|
|
|
BL::Preferences preferences(preferencesptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const PointerRNA dataptr = RNA_main_pointer_create((Main *)PyLong_AsVoidPtr(pydata));
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::BlendData data(dataptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA regionptr = RNA_pointer_create_discrete(
|
2023-09-06 00:48:50 +02:00
|
|
|
bScreen, &RNA_Region, pylong_as_voidptr_typesafe(pyregion));
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::Region region(regionptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA v3dptr = RNA_pointer_create_discrete(
|
2023-09-06 00:48:50 +02:00
|
|
|
bScreen, &RNA_SpaceView3D, pylong_as_voidptr_typesafe(pyv3d));
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::SpaceView3D v3d(v3dptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA rv3dptr = RNA_pointer_create_discrete(
|
2023-09-06 00:48:50 +02:00
|
|
|
bScreen, &RNA_RegionView3D, pylong_as_voidptr_typesafe(pyrv3d));
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::RegionView3D rv3d(rv3dptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* create session */
|
|
|
|
|
BlenderSession *session;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
if (rv3d) {
|
2013-01-28 17:37:51 +00:00
|
|
|
/* interactive viewport session */
|
2024-12-29 17:32:00 +01:00
|
|
|
const int width = region.width();
|
|
|
|
|
const int height = region.height();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-11 13:37:45 +01:00
|
|
|
session = new BlenderSession(engine, preferences, data, v3d, rv3d, width, height);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-01-28 17:37:51 +00:00
|
|
|
/* offline session or preview render */
|
2019-02-11 13:37:45 +01:00
|
|
|
session = new BlenderSession(engine, preferences, data, preview_osl);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
return PyLong_FromVoidPtr(session);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-27 15:47:55 +05:00
|
|
|
static PyObject *free_func(PyObject * /*self*/, PyObject *value)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2011-12-24 02:47:13 +00:00
|
|
|
delete (BlenderSession *)PyLong_AsVoidPtr(value);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-12-24 02:47:13 +00:00
|
|
|
Py_RETURN_NONE;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
static PyObject *render_func(PyObject * /*self*/, PyObject *args)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *pysession;
|
|
|
|
|
PyObject *pydepsgraph;
|
2018-02-26 16:46:48 +01:00
|
|
|
|
2023-09-17 09:01:48 +10:00
|
|
|
if (!PyArg_ParseTuple(args, "OO", &pysession, &pydepsgraph)) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2018-02-26 16:46:48 +01:00
|
|
|
|
|
|
|
|
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
|
|
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA depsgraphptr = RNA_pointer_create_discrete(
|
2024-12-26 17:53:55 +01:00
|
|
|
nullptr, &RNA_Depsgraph, (ID *)PyLong_AsVoidPtr(pydepsgraph));
|
2018-02-26 16:46:48 +01:00
|
|
|
BL::Depsgraph b_depsgraph(depsgraphptr);
|
2014-02-12 23:13:45 +01:00
|
|
|
|
2021-06-14 23:50:24 +10:00
|
|
|
/* Allow Blender to execute other Python scripts. */
|
2014-02-12 23:13:45 +01:00
|
|
|
python_thread_state_save(&session->python_thread_state);
|
|
|
|
|
|
2021-06-14 23:50:24 +10:00
|
|
|
session->render(b_depsgraph);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-02-12 23:13:45 +01:00
|
|
|
python_thread_state_restore(&session->python_thread_state);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-12-24 02:47:13 +00:00
|
|
|
Py_RETURN_NONE;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
static PyObject *render_frame_finish_func(PyObject * /*self*/, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
PyObject *pysession;
|
|
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O", &pysession)) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
|
|
|
|
|
|
|
|
|
|
/* Allow Blender to execute other Python scripts. */
|
|
|
|
|
python_thread_state_save(&session->python_thread_state);
|
|
|
|
|
|
|
|
|
|
session->render_frame_finish();
|
|
|
|
|
|
|
|
|
|
python_thread_state_restore(&session->python_thread_state);
|
|
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *draw_func(PyObject * /*self*/, PyObject *args)
|
|
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *py_session;
|
|
|
|
|
PyObject *py_graph;
|
|
|
|
|
PyObject *py_screen;
|
|
|
|
|
PyObject *py_space_image;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(args, "OOOO", &py_session, &py_graph, &py_screen, &py_space_image)) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(py_session);
|
|
|
|
|
|
|
|
|
|
ID *b_screen = (ID *)PyLong_AsVoidPtr(py_screen);
|
|
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA b_space_image_ptr = RNA_pointer_create_discrete(
|
2023-09-06 00:48:50 +02:00
|
|
|
b_screen, &RNA_SpaceImageEditor, pylong_as_voidptr_typesafe(py_space_image));
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
BL::SpaceImageEditor b_space_image(b_space_image_ptr);
|
|
|
|
|
|
|
|
|
|
session->draw(b_space_image);
|
|
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-02 19:05:07 -02:00
|
|
|
/* pixel_array and result passed as pointers */
|
2015-03-27 15:47:55 +05:00
|
|
|
static PyObject *bake_func(PyObject * /*self*/, PyObject *args)
|
2014-01-02 19:05:07 -02:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *pysession;
|
|
|
|
|
PyObject *pydepsgraph;
|
|
|
|
|
PyObject *pyobject;
|
2014-01-02 19:05:07 -02:00
|
|
|
const char *pass_type;
|
2024-12-29 17:32:00 +01:00
|
|
|
int pass_filter;
|
|
|
|
|
int width;
|
|
|
|
|
int height;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
if (!PyArg_ParseTuple(args,
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
"OOOsiii",
|
2018-02-26 16:46:48 +01:00
|
|
|
&pysession,
|
|
|
|
|
&pydepsgraph,
|
|
|
|
|
&pyobject,
|
|
|
|
|
&pass_type,
|
|
|
|
|
&pass_filter,
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
&width,
|
|
|
|
|
&height))
|
2023-09-17 09:01:48 +10:00
|
|
|
{
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-02 19:05:07 -02:00
|
|
|
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA depsgraphptr = RNA_pointer_create_discrete(
|
2024-12-26 17:53:55 +01:00
|
|
|
nullptr, &RNA_Depsgraph, PyLong_AsVoidPtr(pydepsgraph));
|
2018-02-26 16:46:48 +01:00
|
|
|
BL::Depsgraph b_depsgraph(depsgraphptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const PointerRNA objectptr = RNA_id_pointer_create((ID *)PyLong_AsVoidPtr(pyobject));
|
2014-01-02 19:05:07 -02:00
|
|
|
BL::Object b_object(objectptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-05-22 20:18:45 -03:00
|
|
|
python_thread_state_save(&session->python_thread_state);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-14 23:50:24 +10:00
|
|
|
session->bake(b_depsgraph, b_object, pass_type, pass_filter, width, height);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-05-22 20:18:45 -03:00
|
|
|
python_thread_state_restore(&session->python_thread_state);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-02 19:05:07 -02:00
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
static PyObject *view_draw_func(PyObject * /*self*/, PyObject *args)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *pysession;
|
|
|
|
|
PyObject *pygraph;
|
|
|
|
|
PyObject *pyv3d;
|
|
|
|
|
PyObject *pyrv3d;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2023-09-17 09:01:48 +10:00
|
|
|
if (!PyArg_ParseTuple(args, "OOOO", &pysession, &pygraph, &pyv3d, &pyrv3d)) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2018-07-06 10:17:58 +02:00
|
|
|
|
2011-05-05 13:51:33 +00:00
|
|
|
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-05-05 13:51:33 +00:00
|
|
|
if (PyLong_AsVoidPtr(pyrv3d)) {
|
2011-04-27 11:58:34 +00:00
|
|
|
/* 3d view drawing */
|
|
|
|
|
int viewport[4];
|
2022-12-02 15:56:12 +01:00
|
|
|
GPU_viewport_size_get_i(viewport);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
session->view_draw(viewport[2], viewport[3]);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2011-12-24 02:47:13 +00:00
|
|
|
Py_RETURN_NONE;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2015-03-27 15:47:55 +05:00
|
|
|
static PyObject *reset_func(PyObject * /*self*/, PyObject *args)
|
2012-11-09 08:46:53 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *pysession;
|
|
|
|
|
PyObject *pydata;
|
|
|
|
|
PyObject *pydepsgraph;
|
2012-11-09 08:46:53 +00:00
|
|
|
|
2023-09-17 09:01:48 +10:00
|
|
|
if (!PyArg_ParseTuple(args, "OOO", &pysession, &pydata, &pydepsgraph)) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2012-11-09 08:46:53 +00:00
|
|
|
|
|
|
|
|
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
|
|
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const PointerRNA dataptr = RNA_main_pointer_create((Main *)PyLong_AsVoidPtr(pydata));
|
2012-11-09 08:46:53 +00:00
|
|
|
BL::BlendData b_data(dataptr);
|
|
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA depsgraphptr = RNA_pointer_create_discrete(
|
2024-12-26 17:53:55 +01:00
|
|
|
nullptr, &RNA_Depsgraph, PyLong_AsVoidPtr(pydepsgraph));
|
2018-05-23 12:13:21 +02:00
|
|
|
BL::Depsgraph b_depsgraph(depsgraphptr);
|
2012-11-09 08:46:53 +00:00
|
|
|
|
2014-02-12 23:13:45 +01:00
|
|
|
python_thread_state_save(&session->python_thread_state);
|
2012-11-09 08:46:53 +00:00
|
|
|
|
2021-06-14 23:50:24 +10:00
|
|
|
session->reset_session(b_data, b_depsgraph);
|
2012-11-09 08:46:53 +00:00
|
|
|
|
2014-02-12 23:13:45 +01:00
|
|
|
python_thread_state_restore(&session->python_thread_state);
|
2012-11-09 08:46:53 +00:00
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
static PyObject *sync_func(PyObject * /*self*/, PyObject *args)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *pysession;
|
|
|
|
|
PyObject *pydepsgraph;
|
2018-02-26 16:46:48 +01:00
|
|
|
|
2023-09-17 09:01:48 +10:00
|
|
|
if (!PyArg_ParseTuple(args, "OO", &pysession, &pydepsgraph)) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2018-02-26 16:46:48 +01:00
|
|
|
|
|
|
|
|
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
|
|
|
|
|
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA depsgraphptr = RNA_pointer_create_discrete(
|
2024-12-26 17:53:55 +01:00
|
|
|
nullptr, &RNA_Depsgraph, PyLong_AsVoidPtr(pydepsgraph));
|
2018-02-26 16:46:48 +01:00
|
|
|
BL::Depsgraph b_depsgraph(depsgraphptr);
|
2014-02-12 23:13:45 +01:00
|
|
|
|
|
|
|
|
python_thread_state_save(&session->python_thread_state);
|
|
|
|
|
|
2021-06-14 23:50:24 +10:00
|
|
|
session->synchronize(b_depsgraph);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-02-12 23:13:45 +01:00
|
|
|
python_thread_state_restore(&session->python_thread_state);
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2011-12-24 02:47:13 +00:00
|
|
|
Py_RETURN_NONE;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2019-01-29 16:39:30 +01:00
|
|
|
static PyObject *available_devices_func(PyObject * /*self*/, PyObject *args)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2019-01-29 16:39:30 +01:00
|
|
|
const char *type_name;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "s", &type_name)) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-01-29 16:39:30 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const DeviceType type = Device::type_from_string(type_name);
|
2020-10-19 23:58:28 +11:00
|
|
|
/* "NONE" is defined by the add-on, see: `CyclesPreferences.get_device_types`. */
|
|
|
|
|
if ((type == DEVICE_NONE) && (strcmp(type_name, "NONE") != 0)) {
|
2020-10-15 16:35:41 +11:00
|
|
|
PyErr_Format(PyExc_ValueError, "Device \"%s\" not known.", type_name);
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2020-10-15 16:35:41 +11:00
|
|
|
}
|
|
|
|
|
|
2019-01-29 16:39:30 +01:00
|
|
|
uint mask = (type == DEVICE_NONE) ? DEVICE_MASK_ALL : DEVICE_MASK(type);
|
|
|
|
|
mask |= DEVICE_MASK_CPU;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-29 16:39:30 +01:00
|
|
|
vector<DeviceInfo> devices = Device::available_devices(mask);
|
2012-01-09 16:58:01 +00:00
|
|
|
PyObject *ret = PyTuple_New(devices.size());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-09 16:58:01 +00:00
|
|
|
for (size_t i = 0; i < devices.size(); i++) {
|
2024-12-29 17:32:00 +01:00
|
|
|
const DeviceInfo &device = devices[i];
|
|
|
|
|
const string type_name = Device::string_from_type(device.type);
|
2025-06-03 20:07:52 +02:00
|
|
|
PyObject *device_tuple = PyTuple_New(8);
|
2020-05-04 20:02:08 +02:00
|
|
|
PyTuple_SET_ITEM(device_tuple, 0, pyunicode_from_string(device.description.c_str()));
|
|
|
|
|
PyTuple_SET_ITEM(device_tuple, 1, pyunicode_from_string(type_name.c_str()));
|
|
|
|
|
PyTuple_SET_ITEM(device_tuple, 2, pyunicode_from_string(device.id.c_str()));
|
2020-06-08 17:16:10 +02:00
|
|
|
PyTuple_SET_ITEM(device_tuple, 3, PyBool_FromLong(device.has_peer_memory));
|
2023-09-13 16:02:49 +02:00
|
|
|
PyTuple_SET_ITEM(device_tuple, 4, PyBool_FromLong(device.use_hardware_raytracing));
|
2024-02-06 17:46:21 +01:00
|
|
|
PyTuple_SET_ITEM(
|
|
|
|
|
device_tuple, 5, PyBool_FromLong(device.denoisers & DENOISER_OPENIMAGEDENOISE));
|
2024-06-03 22:41:25 +02:00
|
|
|
PyTuple_SET_ITEM(device_tuple, 6, PyBool_FromLong(device.denoisers & DENOISER_OPTIX));
|
2025-06-03 20:07:52 +02:00
|
|
|
PyTuple_SET_ITEM(device_tuple, 7, PyBool_FromLong(device.has_execution_optimization));
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
PyTuple_SET_ITEM(ret, i, device_tuple);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-03 14:32:35 +00:00
|
|
|
#ifdef WITH_OSL
|
2013-03-18 16:34:57 +00:00
|
|
|
|
2015-03-27 15:47:55 +05:00
|
|
|
static PyObject *osl_compile_func(PyObject * /*self*/, PyObject *args)
|
2012-11-03 14:32:35 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const char *inputfile = nullptr;
|
|
|
|
|
const char *outputfile = nullptr;
|
2012-11-03 14:32:35 +00:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
if (!PyArg_ParseTuple(args, "ss", &inputfile, &outputfile)) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2024-12-26 17:53:59 +01:00
|
|
|
}
|
2018-07-06 10:17:58 +02:00
|
|
|
|
2012-11-03 14:32:35 +00:00
|
|
|
/* return */
|
2025-03-04 17:27:10 +01:00
|
|
|
if (!OSLManager::osl_compile(inputfile, outputfile)) {
|
2012-11-03 14:32:35 +00:00
|
|
|
Py_RETURN_FALSE;
|
2024-12-26 17:53:59 +01:00
|
|
|
}
|
2012-11-03 14:32:35 +00:00
|
|
|
|
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-03-27 15:47:55 +05:00
|
|
|
static PyObject *system_info_func(PyObject * /*self*/, PyObject * /*value*/)
|
2015-01-06 14:13:21 +05:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const string system_info = Device::device_capabilities();
|
2020-05-04 20:02:08 +02:00
|
|
|
return pyunicode_from_string(system_info.c_str());
|
2015-01-06 14:13:21 +05:00
|
|
|
}
|
|
|
|
|
|
2019-03-19 14:38:57 +01:00
|
|
|
static bool image_parse_filepaths(PyObject *pyfilepaths, vector<string> &filepaths)
|
2019-02-06 12:57:10 +01:00
|
|
|
{
|
|
|
|
|
if (PyUnicode_Check(pyfilepaths)) {
|
|
|
|
|
const char *filepath = PyUnicode_AsUTF8(pyfilepaths);
|
|
|
|
|
filepaths.push_back(filepath);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
PyObject *sequence = PySequence_Fast(pyfilepaths,
|
|
|
|
|
"File paths must be a string or sequence of strings");
|
2024-12-26 17:53:55 +01:00
|
|
|
if (sequence == nullptr) {
|
2019-02-06 12:57:10 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
for (Py_ssize_t i = 0; i < PySequence_Fast_GET_SIZE(sequence); i++) {
|
|
|
|
|
PyObject *item = PySequence_Fast_GET_ITEM(sequence, i);
|
|
|
|
|
const char *filepath = PyUnicode_AsUTF8(item);
|
2024-12-26 17:53:55 +01:00
|
|
|
if (filepath == nullptr) {
|
2019-02-06 12:57:10 +01:00
|
|
|
PyErr_SetString(PyExc_ValueError, "File paths must be a string or sequence of strings.");
|
|
|
|
|
Py_DECREF(sequence);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
filepaths.push_back(filepath);
|
|
|
|
|
}
|
|
|
|
|
Py_DECREF(sequence);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *denoise_func(PyObject * /*self*/, PyObject *args, PyObject *keywords)
|
|
|
|
|
{
|
|
|
|
|
static const char *keyword_list[] = {
|
2024-12-26 17:53:55 +01:00
|
|
|
"preferences", "scene", "view_layer", "input", "output", nullptr};
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *pypreferences;
|
|
|
|
|
PyObject *pyscene;
|
|
|
|
|
PyObject *pyviewlayer;
|
|
|
|
|
PyObject *pyinput;
|
|
|
|
|
PyObject *pyoutput = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(args,
|
|
|
|
|
keywords,
|
2022-01-04 21:39:54 +01:00
|
|
|
"OOOO|O",
|
2019-02-06 12:57:10 +01:00
|
|
|
(char **)keyword_list,
|
2019-02-11 13:37:45 +01:00
|
|
|
&pypreferences,
|
|
|
|
|
&pyscene,
|
|
|
|
|
&pyviewlayer,
|
2019-02-06 12:57:10 +01:00
|
|
|
&pyinput,
|
2022-01-04 21:39:54 +01:00
|
|
|
&pyoutput))
|
|
|
|
|
{
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-02-06 12:57:10 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
/* Get device specification from preferences and scene. */
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA preferencesptr = RNA_pointer_create_discrete(
|
2024-12-26 17:53:59 +01:00
|
|
|
nullptr, &RNA_Preferences, PyLong_AsVoidPtr(pypreferences));
|
2019-02-11 13:37:45 +01:00
|
|
|
BL::Preferences b_preferences(preferencesptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const PointerRNA sceneptr = RNA_id_pointer_create((ID *)PyLong_AsVoidPtr(pyscene));
|
2019-02-06 12:57:10 +01:00
|
|
|
BL::Scene b_scene(sceneptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-06-03 22:41:25 +02:00
|
|
|
DeviceInfo preferences_device;
|
2024-12-29 17:32:00 +01:00
|
|
|
const DeviceInfo pathtrace_device = blender_device_info(
|
2024-06-03 22:41:25 +02:00
|
|
|
b_preferences, b_scene, true, true, preferences_device);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
/* Get denoising parameters from view layer. */
|
2025-01-24 16:45:32 +01:00
|
|
|
const PointerRNA viewlayerptr = RNA_pointer_create_discrete(
|
2023-09-06 00:48:50 +02:00
|
|
|
(ID *)PyLong_AsVoidPtr(pyscene), &RNA_ViewLayer, PyLong_AsVoidPtr(pyviewlayer));
|
2022-01-04 21:39:54 +01:00
|
|
|
BL::ViewLayer b_view_layer(viewlayerptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-06-03 22:41:25 +02:00
|
|
|
DenoiseParams params = BlenderSync::get_denoise_params(
|
|
|
|
|
b_scene, b_view_layer, true, preferences_device);
|
2022-01-04 21:39:54 +01:00
|
|
|
params.use = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
/* Parse file paths list. */
|
2024-12-29 17:32:00 +01:00
|
|
|
vector<string> input;
|
|
|
|
|
vector<string> output;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-19 14:38:57 +01:00
|
|
|
if (!image_parse_filepaths(pyinput, input)) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-02-06 12:57:10 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
if (pyoutput) {
|
2019-03-19 14:38:57 +01:00
|
|
|
if (!image_parse_filepaths(pyoutput, output)) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-02-06 12:57:10 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-02-06 12:57:10 +01:00
|
|
|
else {
|
|
|
|
|
output = input;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
if (input.empty()) {
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, "No input file paths specified.");
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-02-06 12:57:10 +01:00
|
|
|
}
|
|
|
|
|
if (input.size() != output.size()) {
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, "Number of input and output file paths does not match.");
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-02-06 12:57:10 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
/* Create denoiser. */
|
2024-06-03 22:41:25 +02:00
|
|
|
/* We are using preference device here, because path trace device will be identical to it unless
|
|
|
|
|
* scene is setting CPU render or command line override render device. But both of this options
|
|
|
|
|
* are for render, not for denoising. */
|
|
|
|
|
DenoiserPipeline denoiser(preferences_device, params);
|
2019-02-06 12:57:10 +01:00
|
|
|
denoiser.input = input;
|
|
|
|
|
denoiser.output = output;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
/* Run denoiser. */
|
|
|
|
|
if (!denoiser.run()) {
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, denoiser.error.c_str());
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-02-06 12:57:10 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-19 14:38:57 +01:00
|
|
|
static PyObject *merge_func(PyObject * /*self*/, PyObject *args, PyObject *keywords)
|
|
|
|
|
{
|
2024-12-26 17:53:55 +01:00
|
|
|
static const char *keyword_list[] = {"input", "output", nullptr};
|
2024-12-29 17:32:00 +01:00
|
|
|
PyObject *pyinput;
|
|
|
|
|
PyObject *pyoutput = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-19 14:38:57 +01:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(
|
2024-01-02 18:12:54 +01:00
|
|
|
args, keywords, "OO", (char **)keyword_list, &pyinput, &pyoutput))
|
|
|
|
|
{
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-03-19 14:38:57 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-19 14:38:57 +01:00
|
|
|
/* Parse input list. */
|
|
|
|
|
vector<string> input;
|
|
|
|
|
if (!image_parse_filepaths(pyinput, input)) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-03-19 14:38:57 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-19 14:38:57 +01:00
|
|
|
/* Parse output string. */
|
|
|
|
|
if (!PyUnicode_Check(pyoutput)) {
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, "Output must be a string.");
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-03-19 14:38:57 +01:00
|
|
|
}
|
2024-12-29 17:32:00 +01:00
|
|
|
const string output = PyUnicode_AsUTF8(pyoutput);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-19 14:38:57 +01:00
|
|
|
/* Merge. */
|
|
|
|
|
ImageMerger merger;
|
|
|
|
|
merger.input = input;
|
|
|
|
|
merger.output = output;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-19 14:38:57 +01:00
|
|
|
if (!merger.run()) {
|
|
|
|
|
PyErr_SetString(PyExc_ValueError, merger.error.c_str());
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2019-03-19 14:38:57 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-19 14:38:57 +01:00
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-12 16:00:48 +05:00
|
|
|
static PyObject *debug_flags_update_func(PyObject * /*self*/, PyObject *args)
|
|
|
|
|
{
|
|
|
|
|
PyObject *pyscene;
|
|
|
|
|
if (!PyArg_ParseTuple(args, "O", &pyscene)) {
|
2024-12-26 17:53:55 +01:00
|
|
|
return nullptr;
|
2016-01-12 16:00:48 +05:00
|
|
|
}
|
|
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const PointerRNA sceneptr = RNA_id_pointer_create((ID *)PyLong_AsVoidPtr(pyscene));
|
|
|
|
|
const BL::Scene b_scene(sceneptr);
|
2016-01-12 16:00:48 +05:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
debug_flags_sync_from_scene(b_scene);
|
2016-01-12 16:00:48 +05:00
|
|
|
|
|
|
|
|
debug_flags_set = true;
|
|
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static PyObject *debug_flags_reset_func(PyObject * /*self*/, PyObject * /*args*/)
|
|
|
|
|
{
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
debug_flags_reset();
|
2016-01-12 16:00:48 +05:00
|
|
|
if (debug_flags_set) {
|
|
|
|
|
debug_flags_set = false;
|
|
|
|
|
}
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-27 15:46:13 +02:00
|
|
|
static PyObject *enable_print_stats_func(PyObject * /*self*/, PyObject * /*args*/)
|
|
|
|
|
{
|
|
|
|
|
BlenderSession::print_render_stats = true;
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
static PyObject *get_device_types_func(PyObject * /*self*/, PyObject * /*args*/)
|
|
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const vector<DeviceType> device_types = Device::available_types();
|
|
|
|
|
bool has_cuda = false;
|
|
|
|
|
bool has_optix = false;
|
|
|
|
|
bool has_hip = false;
|
|
|
|
|
bool has_metal = false;
|
|
|
|
|
bool has_oneapi = false;
|
|
|
|
|
bool has_hiprt = false;
|
|
|
|
|
for (const DeviceType device_type : device_types) {
|
2019-01-29 16:39:30 +01:00
|
|
|
has_cuda |= (device_type == DEVICE_CUDA);
|
2019-09-12 14:50:06 +02:00
|
|
|
has_optix |= (device_type == DEVICE_OPTIX);
|
2021-09-28 16:51:14 +02:00
|
|
|
has_hip |= (device_type == DEVICE_HIP);
|
2021-12-07 15:11:35 +00:00
|
|
|
has_metal |= (device_type == DEVICE_METAL);
|
2022-06-29 12:58:04 +02:00
|
|
|
has_oneapi |= (device_type == DEVICE_ONEAPI);
|
2023-04-24 19:05:30 +02:00
|
|
|
has_hiprt |= (device_type == DEVICE_HIPRT);
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
}
|
2023-04-24 19:05:30 +02:00
|
|
|
PyObject *list = PyTuple_New(6);
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
PyTuple_SET_ITEM(list, 0, PyBool_FromLong(has_cuda));
|
2019-09-12 14:50:06 +02:00
|
|
|
PyTuple_SET_ITEM(list, 1, PyBool_FromLong(has_optix));
|
2021-09-28 16:51:14 +02:00
|
|
|
PyTuple_SET_ITEM(list, 2, PyBool_FromLong(has_hip));
|
2021-12-07 15:11:35 +00:00
|
|
|
PyTuple_SET_ITEM(list, 3, PyBool_FromLong(has_metal));
|
2022-06-29 12:58:04 +02:00
|
|
|
PyTuple_SET_ITEM(list, 4, PyBool_FromLong(has_oneapi));
|
2023-04-24 19:05:30 +02:00
|
|
|
PyTuple_SET_ITEM(list, 5, PyBool_FromLong(has_hiprt));
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-02 00:48:01 +02:00
|
|
|
static PyObject *set_device_override_func(PyObject * /*self*/, PyObject *arg)
|
|
|
|
|
{
|
|
|
|
|
PyObject *override_string = PyObject_Str(arg);
|
|
|
|
|
string override = PyUnicode_AsUTF8(override_string);
|
|
|
|
|
Py_DECREF(override_string);
|
|
|
|
|
|
|
|
|
|
bool include_cpu = false;
|
|
|
|
|
const string cpu_suffix = "+CPU";
|
|
|
|
|
if (string_endswith(override, cpu_suffix)) {
|
|
|
|
|
include_cpu = true;
|
|
|
|
|
override = override.substr(0, override.length() - cpu_suffix.length());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (override == "CPU") {
|
|
|
|
|
BlenderSession::device_override = DEVICE_MASK_CPU;
|
|
|
|
|
}
|
|
|
|
|
else if (override == "CUDA") {
|
|
|
|
|
BlenderSession::device_override = DEVICE_MASK_CUDA;
|
|
|
|
|
}
|
|
|
|
|
else if (override == "OPTIX") {
|
|
|
|
|
BlenderSession::device_override = DEVICE_MASK_OPTIX;
|
|
|
|
|
}
|
2021-09-28 16:51:14 +02:00
|
|
|
else if (override == "HIP") {
|
|
|
|
|
BlenderSession::device_override = DEVICE_MASK_HIP;
|
|
|
|
|
}
|
2021-12-07 15:11:35 +00:00
|
|
|
else if (override == "METAL") {
|
|
|
|
|
BlenderSession::device_override = DEVICE_MASK_METAL;
|
|
|
|
|
}
|
2022-06-29 12:58:04 +02:00
|
|
|
else if (override == "ONEAPI") {
|
|
|
|
|
BlenderSession::device_override = DEVICE_MASK_ONEAPI;
|
|
|
|
|
}
|
2020-10-02 00:48:01 +02:00
|
|
|
else {
|
2025-07-10 19:44:14 +02:00
|
|
|
LOG_ERROR << override << " is not a valid Cycles device.";
|
2020-10-02 00:48:01 +02:00
|
|
|
Py_RETURN_FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (include_cpu) {
|
|
|
|
|
BlenderSession::device_override = (DeviceTypeMask)(BlenderSession::device_override |
|
|
|
|
|
DEVICE_MASK_CPU);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-01 12:06:03 +11:00
|
|
|
#ifdef __GNUC__
|
|
|
|
|
# ifdef __clang__
|
|
|
|
|
# pragma clang diagnostic push
|
|
|
|
|
# pragma clang diagnostic ignored "-Wcast-function-type"
|
|
|
|
|
# else
|
|
|
|
|
# pragma GCC diagnostic push
|
|
|
|
|
# pragma GCC diagnostic ignored "-Wcast-function-type"
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
static PyMethodDef methods[] = {
|
|
|
|
|
{"init", init_func, METH_VARARGS, ""},
|
2016-02-07 03:40:41 +05:00
|
|
|
{"exit", exit_func, METH_VARARGS, ""},
|
2011-04-27 11:58:34 +00:00
|
|
|
{"create", create_func, METH_VARARGS, ""},
|
2011-12-24 02:47:13 +00:00
|
|
|
{"free", free_func, METH_O, ""},
|
2018-02-26 16:46:48 +01:00
|
|
|
{"render", render_func, METH_VARARGS, ""},
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{"render_frame_finish", render_frame_finish_func, METH_VARARGS, ""},
|
2011-04-27 11:58:34 +00:00
|
|
|
{"draw", draw_func, METH_VARARGS, ""},
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
{"bake", bake_func, METH_VARARGS, ""},
|
|
|
|
|
{"view_draw", view_draw_func, METH_VARARGS, ""},
|
2018-02-26 16:46:48 +01:00
|
|
|
{"sync", sync_func, METH_VARARGS, ""},
|
2012-11-09 08:46:53 +00:00
|
|
|
{"reset", reset_func, METH_VARARGS, ""},
|
2012-11-03 14:32:35 +00:00
|
|
|
#ifdef WITH_OSL
|
|
|
|
|
{"osl_compile", osl_compile_func, METH_VARARGS, ""},
|
|
|
|
|
#endif
|
2019-01-29 16:39:30 +01:00
|
|
|
{"available_devices", available_devices_func, METH_VARARGS, ""},
|
2015-01-06 14:13:21 +05:00
|
|
|
{"system_info", system_info_func, METH_NOARGS, ""},
|
2016-03-30 15:55:12 +02:00
|
|
|
|
2019-02-06 12:57:10 +01:00
|
|
|
/* Standalone denoising */
|
|
|
|
|
{"denoise", (PyCFunction)denoise_func, METH_VARARGS | METH_KEYWORDS, ""},
|
2019-03-19 14:38:57 +01:00
|
|
|
{"merge", (PyCFunction)merge_func, METH_VARARGS | METH_KEYWORDS, ""},
|
2019-02-06 12:57:10 +01:00
|
|
|
|
2016-03-30 15:55:12 +02:00
|
|
|
/* Debugging routines */
|
2016-01-12 16:00:48 +05:00
|
|
|
{"debug_flags_update", debug_flags_update_func, METH_VARARGS, ""},
|
|
|
|
|
{"debug_flags_reset", debug_flags_reset_func, METH_NOARGS, ""},
|
2016-03-30 15:55:12 +02:00
|
|
|
|
2018-07-27 15:46:13 +02:00
|
|
|
/* Statistics. */
|
|
|
|
|
{"enable_print_stats", enable_print_stats_func, METH_NOARGS, ""},
|
|
|
|
|
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
/* Compute Device selection */
|
|
|
|
|
{"get_device_types", get_device_types_func, METH_VARARGS, ""},
|
2020-10-02 00:48:01 +02:00
|
|
|
{"set_device_override", set_device_override_func, METH_O, ""},
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
|
2024-12-26 17:53:55 +01:00
|
|
|
{nullptr, nullptr, 0, nullptr},
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
2025-04-01 12:06:03 +11:00
|
|
|
#ifdef __GNUC__
|
|
|
|
|
# ifdef __clang__
|
|
|
|
|
# pragma clang diagnostic pop
|
|
|
|
|
# else
|
|
|
|
|
# pragma GCC diagnostic pop
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
static struct PyModuleDef module = {
|
2023-07-16 17:43:31 +10:00
|
|
|
/*m_base*/ PyModuleDef_HEAD_INIT,
|
|
|
|
|
/*m_name*/ "_cycles",
|
|
|
|
|
/*m_doc*/ "Blender cycles render integration",
|
|
|
|
|
/*m_size*/ -1,
|
|
|
|
|
/*m_methods*/ methods,
|
|
|
|
|
/*m_slots*/ nullptr,
|
|
|
|
|
/*m_traverse*/ nullptr,
|
|
|
|
|
/*m_clear*/ nullptr,
|
|
|
|
|
/*m_free*/ nullptr,
|
2011-04-27 11:58:34 +00:00
|
|
|
};
|
|
|
|
|
|
2012-01-09 16:58:01 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
|
|
void *CCL_python_module_init()
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-06-09 18:56:12 +00:00
|
|
|
PyObject *mod = PyModule_Create(&ccl::module);
|
2011-12-24 02:47:13 +00:00
|
|
|
|
|
|
|
|
#ifdef WITH_OSL
|
2013-12-08 15:03:17 +06:00
|
|
|
/* TODO(sergey): This gives us library we've been linking against.
|
|
|
|
|
* In theory with dynamic OSL library it might not be
|
|
|
|
|
* accurate, but there's nothing in OSL API which we
|
2014-03-01 01:21:25 +01:00
|
|
|
* might use to get version in runtime.
|
2013-12-08 15:03:17 +06:00
|
|
|
*/
|
2024-12-29 17:32:00 +01:00
|
|
|
const int curversion = OSL_LIBRARY_VERSION_CODE;
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_osl", Py_True);
|
2013-12-08 15:03:17 +06:00
|
|
|
PyModule_AddObject(
|
|
|
|
|
mod,
|
|
|
|
|
"osl_version",
|
|
|
|
|
Py_BuildValue("(iii)", curversion / 10000, (curversion / 100) % 100, curversion % 100));
|
|
|
|
|
PyModule_AddObject(
|
|
|
|
|
mod,
|
|
|
|
|
"osl_version_string",
|
|
|
|
|
PyUnicode_FromFormat(
|
|
|
|
|
"%2d, %2d, %2d", curversion / 10000, (curversion / 100) % 100, curversion % 100));
|
2011-12-24 02:47:13 +00:00
|
|
|
#else
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_osl", Py_False);
|
2013-12-08 15:19:21 +06:00
|
|
|
PyModule_AddStringConstant(mod, "osl_version", "unknown");
|
|
|
|
|
PyModule_AddStringConstant(mod, "osl_version_string", "unknown");
|
2011-12-24 02:47:13 +00:00
|
|
|
#endif
|
|
|
|
|
|
2022-09-21 17:58:34 +02:00
|
|
|
if (ccl::guiding_supported()) {
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_path_guiding", Py_True);
|
2022-09-21 17:58:34 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_path_guiding", Py_False);
|
2022-09-21 17:58:34 +02:00
|
|
|
}
|
|
|
|
|
|
2018-11-07 12:58:12 +01:00
|
|
|
#ifdef WITH_EMBREE
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_embree", Py_True);
|
2018-11-07 12:58:12 +01:00
|
|
|
#else /* WITH_EMBREE */
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_embree", Py_False);
|
2018-11-07 12:58:12 +01:00
|
|
|
#endif /* WITH_EMBREE */
|
|
|
|
|
|
2023-03-16 11:56:55 +01:00
|
|
|
#ifdef WITH_EMBREE_GPU
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_embree_gpu", Py_True);
|
2023-03-16 11:56:55 +01:00
|
|
|
#else /* WITH_EMBREE_GPU */
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_embree_gpu", Py_False);
|
2023-03-16 11:56:55 +01:00
|
|
|
#endif /* WITH_EMBREE_GPU */
|
|
|
|
|
|
2020-06-01 00:11:17 +02:00
|
|
|
if (ccl::openimagedenoise_supported()) {
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_openimagedenoise", Py_True);
|
2020-06-01 00:11:17 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_openimagedenoise", Py_False);
|
2020-06-01 00:11:17 +02:00
|
|
|
}
|
|
|
|
|
|
2021-11-25 14:32:53 +01:00
|
|
|
#ifdef WITH_CYCLES_DEBUG
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_debug", Py_True);
|
2021-11-25 14:32:53 +01:00
|
|
|
#else /* WITH_CYCLES_DEBUG */
|
2024-09-26 17:07:06 +10:00
|
|
|
PyModule_AddObjectRef(mod, "with_debug", Py_False);
|
2021-11-25 14:32:53 +01:00
|
|
|
#endif /* WITH_CYCLES_DEBUG */
|
|
|
|
|
|
2012-01-09 16:58:01 +00:00
|
|
|
return (void *)mod;
|
|
|
|
|
}
|