Compositor: Move Execution Mode and Precision from bNodeTree to Scene
This allows to expose these settings in the Performance panel in the render buttons. Also moves compositor-specific options away from the generic node tree structure. For the backwards-compatibility the options are still present in the DNA for the bNodeTree. This is to minimize the impact on the Studio which has used the GPU compositor for a while now. They can be removed in a future release. There is no functional changes expected. Pull Request: https://projects.blender.org/blender/blender/pulls/121583
This commit is contained in:
committed by
Sergey Sharybin
parent
52de90d06b
commit
7b4232e8aa
@@ -823,19 +823,19 @@ class NODE_PT_quality(bpy.types.Panel):
|
||||
layout.use_property_split = True
|
||||
layout.use_property_decorate = False
|
||||
|
||||
scene = context.scene
|
||||
rd = scene.render
|
||||
|
||||
snode = context.space_data
|
||||
tree = snode.node_tree
|
||||
prefs = bpy.context.preferences
|
||||
|
||||
use_realtime = False
|
||||
col = layout.column()
|
||||
if prefs.experimental.use_experimental_compositors:
|
||||
col.prop(tree, "execution_mode")
|
||||
use_realtime = tree.execution_mode == 'REALTIME'
|
||||
col.prop(tree, "precision")
|
||||
col.prop(rd, "compositor_device", text="Device")
|
||||
col.prop(rd, "compositor_precision", text="Precision")
|
||||
|
||||
col = layout.column()
|
||||
col.active = not use_realtime
|
||||
col.prop(tree, "use_viewer_border")
|
||||
|
||||
col = layout.column()
|
||||
|
||||
@@ -29,7 +29,7 @@ extern "C" {
|
||||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 32
|
||||
#define BLENDER_FILE_SUBVERSION 33
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
|
||||
|
||||
@@ -3132,6 +3132,7 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 3)) {
|
||||
constexpr int NTREE_EXECUTION_MODE_CPU = 0;
|
||||
constexpr int NTREE_EXECUTION_MODE_FULL_FRAME = 1;
|
||||
|
||||
constexpr int NTREE_COM_GROUPNODE_BUFFER = 1 << 3;
|
||||
@@ -3465,6 +3466,19 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 33)) {
|
||||
constexpr int NTREE_EXECUTION_MODE_GPU = 2;
|
||||
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
if (scene->nodetree) {
|
||||
if (scene->nodetree->execution_mode == NTREE_EXECUTION_MODE_GPU) {
|
||||
scene->r.compositor_device = SCE_COMPOSITOR_DEVICE_GPU;
|
||||
}
|
||||
scene->r.compositor_precision = scene->nodetree->precision;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Always bump subversion in BKE_blender_version.h when adding versioning
|
||||
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.
|
||||
|
||||
@@ -78,7 +78,7 @@ void COM_execute(Render *render,
|
||||
compositor_reset_node_tree_status(node_tree);
|
||||
|
||||
if (U.experimental.use_full_frame_compositor &&
|
||||
node_tree->execution_mode == NTREE_EXECUTION_MODE_GPU)
|
||||
scene->r.compositor_device == SCE_COMPOSITOR_DEVICE_GPU)
|
||||
{
|
||||
/* GPU compositor. */
|
||||
RE_compositor_execute(*render, *scene, *render_data, *node_tree, view_name, render_context);
|
||||
|
||||
@@ -162,10 +162,10 @@ class Context : public realtime_compositor::Context {
|
||||
|
||||
realtime_compositor::ResultPrecision get_precision() const override
|
||||
{
|
||||
switch (get_node_tree().precision) {
|
||||
case NODE_TREE_COMPOSITOR_PRECISION_AUTO:
|
||||
switch (get_scene().r.compositor_precision) {
|
||||
case SCE_COMPOSITOR_PRECISION_AUTO:
|
||||
return realtime_compositor::ResultPrecision::Half;
|
||||
case NODE_TREE_COMPOSITOR_PRECISION_FULL:
|
||||
case SCE_COMPOSITOR_PRECISION_FULL:
|
||||
return realtime_compositor::ResultPrecision::Full;
|
||||
}
|
||||
|
||||
|
||||
@@ -4457,7 +4457,7 @@ static bool realtime_compositor_is_in_use(const bContext &context)
|
||||
}
|
||||
|
||||
if (U.experimental.use_full_frame_compositor &&
|
||||
scene->nodetree->execution_mode == NTREE_EXECUTION_MODE_GPU)
|
||||
scene->r.compositor_device == SCE_COMPOSITOR_DEVICE_GPU)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ static bool is_compositing_possible(const bContext *C)
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
/* CPU compositor can always run. */
|
||||
if (!U.experimental.use_full_frame_compositor ||
|
||||
scene->nodetree->execution_mode != NTREE_EXECUTION_MODE_GPU)
|
||||
scene->r.compositor_device != SCE_COMPOSITOR_DEVICE_GPU)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -678,9 +678,9 @@ typedef struct bNodeTree {
|
||||
/** Tile size for compositor engine. */
|
||||
int chunksize DNA_DEPRECATED;
|
||||
/** Execution mode to use for compositor engine. */
|
||||
int execution_mode;
|
||||
/** Execution mode to use for compositor engine. */
|
||||
int precision;
|
||||
int execution_mode DNA_DEPRECATED;
|
||||
/** Precision used by the GPU execution of the compositor tree. */
|
||||
int precision DNA_DEPRECATED;
|
||||
|
||||
/** #NodeGroupColorTag. */
|
||||
int color_tag;
|
||||
@@ -842,18 +842,6 @@ enum {
|
||||
// NTREE_IS_LOCALIZED = 1 << 5,
|
||||
};
|
||||
|
||||
/* tree->execution_mode */
|
||||
typedef enum eNodeTreeExecutionMode {
|
||||
NTREE_EXECUTION_MODE_CPU = 0,
|
||||
NTREE_EXECUTION_MODE_GPU = 2,
|
||||
} eNodeTreeExecutionMode;
|
||||
|
||||
/* tree->precision */
|
||||
typedef enum eNodeTreePrecision {
|
||||
NODE_TREE_COMPOSITOR_PRECISION_AUTO = 0,
|
||||
NODE_TREE_COMPOSITOR_PRECISION_FULL = 1,
|
||||
} eNodeTreePrecision;
|
||||
|
||||
typedef enum eNodeTreeRuntimeFlag {
|
||||
/** There is a node that references an image with animation. */
|
||||
NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION = 1 << 0,
|
||||
|
||||
@@ -825,6 +825,12 @@ typedef struct RenderData {
|
||||
float motion_blur_shutter;
|
||||
int motion_blur_position;
|
||||
struct CurveMapping mblur_shutter_curve;
|
||||
|
||||
/** Device to use for compositor engine. */
|
||||
int compositor_device; /* eCompositorDevice */
|
||||
|
||||
/** Precision used by the GPU execution of the compositor tree. */
|
||||
int compositor_precision; /* eCompositorPrecision */
|
||||
} RenderData;
|
||||
|
||||
/** #RenderData::quality_flag */
|
||||
@@ -845,6 +851,18 @@ enum {
|
||||
SCE_MB_END = 2,
|
||||
};
|
||||
|
||||
/** #RenderData::compositor_device */
|
||||
typedef enum eCompositorDevice {
|
||||
SCE_COMPOSITOR_DEVICE_CPU = 0,
|
||||
SCE_COMPOSITOR_DEVICE_GPU = 1,
|
||||
} eCompositorDevice;
|
||||
|
||||
/** #RenderData::compositor_precision */
|
||||
typedef enum eCompositorPrecision {
|
||||
SCE_COMPOSITOR_PRECISION_AUTO = 0,
|
||||
SCE_COMPOSITOR_PRECISION_FULL = 1,
|
||||
} eCompositorPrecision;
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -110,22 +110,6 @@ const EnumPropertyItem rna_enum_node_group_color_tag_items[] = {
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem rna_enum_execution_mode_items[] = {
|
||||
{NTREE_EXECUTION_MODE_CPU, "CPU", 0, "CPU", ""},
|
||||
{NTREE_EXECUTION_MODE_GPU, "GPU", 0, "GPU", ""},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem rna_enum_precision_items[] = {
|
||||
{NODE_TREE_COMPOSITOR_PRECISION_AUTO,
|
||||
"AUTO",
|
||||
0,
|
||||
"Auto",
|
||||
"Full precision for final renders, half precision otherwise"},
|
||||
{NODE_TREE_COMPOSITOR_PRECISION_FULL, "FULL", 0, "Full", "Full precision"},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
const EnumPropertyItem rna_enum_mapping_type_items[] = {
|
||||
{NODE_MAPPING_TYPE_POINT, "POINT", 0, "Point", "Transform a point"},
|
||||
{NODE_MAPPING_TYPE_TEXTURE,
|
||||
@@ -10570,18 +10554,6 @@ static void rna_def_composite_nodetree(BlenderRNA *brna)
|
||||
RNA_def_struct_sdna(srna, "bNodeTree");
|
||||
RNA_def_struct_ui_icon(srna, ICON_RENDERLAYERS);
|
||||
|
||||
prop = RNA_def_property(srna, "precision", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, nullptr, "precision");
|
||||
RNA_def_property_enum_items(prop, rna_enum_precision_items);
|
||||
RNA_def_property_ui_text(prop, "Precision", "The precision of compositor intermediate result");
|
||||
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, "rna_NodeTree_update");
|
||||
|
||||
prop = RNA_def_property(srna, "execution_mode", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, nullptr, "execution_mode");
|
||||
RNA_def_property_enum_items(prop, rna_enum_execution_mode_items);
|
||||
RNA_def_property_ui_text(prop, "Execution Mode", "Set how compositing is executed");
|
||||
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, "rna_NodeTree_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_viewer_border", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", NTREE_VIEWER_BORDER);
|
||||
RNA_def_property_ui_text(
|
||||
|
||||
@@ -1831,6 +1831,18 @@ void rna_Scene_use_freestyle_update(Main * /*bmain*/, Scene * /*scene*/, Pointer
|
||||
}
|
||||
}
|
||||
|
||||
void rna_Scene_compositor_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
|
||||
{
|
||||
Scene *scene = (Scene *)ptr->owner_id;
|
||||
|
||||
if (scene->nodetree) {
|
||||
bNodeTree *ntree = reinterpret_cast<bNodeTree *>(scene->nodetree);
|
||||
WM_main_add_notifier(NC_NODE | NA_EDITED, &ntree->id);
|
||||
WM_main_add_notifier(NC_SCENE | ND_NODES, &ntree->id);
|
||||
ED_node_tree_propagate_change(nullptr, bmain, ntree);
|
||||
}
|
||||
}
|
||||
|
||||
void rna_Scene_use_view_map_cache_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA * /*ptr*/)
|
||||
{
|
||||
# ifdef WITH_FREESTYLE
|
||||
@@ -6696,6 +6708,22 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem compositor_device_items[] = {
|
||||
{SCE_COMPOSITOR_DEVICE_CPU, "CPU", 0, "CPU", ""},
|
||||
{SCE_COMPOSITOR_DEVICE_GPU, "GPU", 0, "GPU", ""},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem compositor_precision_items[] = {
|
||||
{SCE_COMPOSITOR_PRECISION_AUTO,
|
||||
"AUTO",
|
||||
0,
|
||||
"Auto",
|
||||
"Full precision for final renders, half precision otherwise"},
|
||||
{SCE_COMPOSITOR_PRECISION_FULL, "FULL", 0, "Full", "Full precision"},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
rna_def_scene_ffmpeg_settings(brna);
|
||||
|
||||
srna = RNA_def_struct(brna, "RenderSettings", nullptr);
|
||||
@@ -7423,6 +7451,20 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
|
||||
RNA_def_property_struct_type(prop, "BakeSettings");
|
||||
RNA_def_property_ui_text(prop, "Bake Data", "");
|
||||
|
||||
/* Compositor. */
|
||||
|
||||
prop = RNA_def_property(srna, "compositor_device", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_items(prop, compositor_device_items);
|
||||
RNA_def_property_ui_text(prop, "Compositor Device", "Set how compositing is executed");
|
||||
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, "rna_Scene_compositor_update");
|
||||
|
||||
prop = RNA_def_property(srna, "compositor_precision", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, nullptr, "compositor_precision");
|
||||
RNA_def_property_enum_items(prop, compositor_precision_items);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Compositor Precision", "The precision of compositor intermediate result");
|
||||
RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, "rna_Scene_compositor_update");
|
||||
|
||||
/* Nestled Data. */
|
||||
/* *** Non-Animated *** */
|
||||
RNA_define_animate_sdna(false);
|
||||
|
||||
@@ -322,8 +322,8 @@ class Context : public realtime_compositor::Context {
|
||||
|
||||
realtime_compositor::ResultPrecision get_precision() const override
|
||||
{
|
||||
switch (input_data_.node_tree->precision) {
|
||||
case NODE_TREE_COMPOSITOR_PRECISION_AUTO:
|
||||
switch (input_data_.scene->r.compositor_precision) {
|
||||
case SCE_COMPOSITOR_PRECISION_AUTO:
|
||||
/* Auto uses full precision for final renders and half procession otherwise. */
|
||||
if (this->render_context()) {
|
||||
return realtime_compositor::ResultPrecision::Full;
|
||||
@@ -331,7 +331,7 @@ class Context : public realtime_compositor::Context {
|
||||
else {
|
||||
return realtime_compositor::ResultPrecision::Half;
|
||||
}
|
||||
case NODE_TREE_COMPOSITOR_PRECISION_FULL:
|
||||
case SCE_COMPOSITOR_PRECISION_FULL:
|
||||
return realtime_compositor::ResultPrecision::Full;
|
||||
}
|
||||
|
||||
|
||||
@@ -667,7 +667,7 @@ void RE_FreeUnusedGPUResources()
|
||||
/* Detect if scene is using GPU compositing, and if either a node editor is
|
||||
* showing the nodes, or an image editor is showing the render result or viewer. */
|
||||
if (!(scene->use_nodes && scene->nodetree &&
|
||||
scene->nodetree->execution_mode == NTREE_EXECUTION_MODE_GPU))
|
||||
scene->r.compositor_device == SCE_COMPOSITOR_DEVICE_GPU))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1693,7 +1693,7 @@ static bool is_compositing_possible_on_gpu(Scene *scene, ReportList *reports)
|
||||
{
|
||||
/* CPU compositor can always run. */
|
||||
if (!U.experimental.use_full_frame_compositor ||
|
||||
scene->nodetree->execution_mode != NTREE_EXECUTION_MODE_GPU)
|
||||
scene->r.compositor_device != SCE_COMPOSITOR_DEVICE_GPU)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ except ImportError:
|
||||
|
||||
ENABLE_REALTIME_COMPOSITOR_SCRIPT = "import bpy; " \
|
||||
"bpy.context.preferences.experimental.use_experimental_compositors = True; " \
|
||||
"bpy.data.scenes[0].node_tree.execution_mode = 'GPU'"
|
||||
"bpy.data.scenes[0].render.compositor_device = 'GPU'"
|
||||
|
||||
|
||||
def get_arguments(filepath, output_filepath):
|
||||
|
||||
Reference in New Issue
Block a user