Realtime Compositor: Warn about unsupported setups

This patch warns the user that the compositor setup is not fully
supported when an unsupported node is used. The warning is displayed as
an engine warning overlay and in the node header itself.

See T102353.

Differential Revision: https://developer.blender.org/D16508

Reviewed By: Clement Foucault
This commit is contained in:
Omar Emara 2022-11-23 14:34:31 +02:00
parent 6396d29779
commit 247d75d2b1
25 changed files with 202 additions and 0 deletions

View File

@ -330,6 +330,11 @@ typedef struct bNodeType {
* responsibility of the caller. */
NodeGetCompositorShaderNodeFunction get_compositor_shader_node;
/* A message to display in the node header for unsupported realtime compositor nodes. The message
* is assumed to be static and thus require no memory handling. This field is to be removed when
* all nodes are supported. */
const char *realtime_compositor_unsupported_message;
/* Build a multi-function for this node. */
NodeMultiFunctionBuildFunction build_multi_function;

View File

@ -107,6 +107,10 @@ struct TreeDrawContext {
* currently drawn node tree can be retrieved from the log below.
*/
geo_log::GeoTreeLog *geo_tree_log = nullptr;
/**
* True if there is an active realtime compositor using the node tree, false otherwise.
*/
bool used_by_realtime_compositor = false;
};
float ED_node_grid_size()
@ -1653,12 +1657,45 @@ static char *node_errors_tooltip_fn(bContext * /*C*/, void *argN, const char * /
#define NODE_HEADER_ICON_SIZE (0.8f * U.widget_unit)
static void node_add_unsupported_compositor_operation_error_message_button(
TreeDrawContext &tree_draw_ctx,
bNode &node,
uiBlock &block,
const rctf &rect,
float &icon_offset)
{
icon_offset -= NODE_HEADER_ICON_SIZE;
UI_block_emboss_set(&block, UI_EMBOSS_NONE);
uiDefIconBut(&block,
UI_BTYPE_BUT,
0,
ICON_ERROR,
icon_offset,
rect.ymax - NODE_DY,
NODE_HEADER_ICON_SIZE,
UI_UNIT_Y,
nullptr,
0,
0,
0,
0,
TIP_(node.typeinfo->realtime_compositor_unsupported_message));
UI_block_emboss_set(&block, UI_EMBOSS);
}
static void node_add_error_message_button(TreeDrawContext &tree_draw_ctx,
bNode &node,
uiBlock &block,
const rctf &rect,
float &icon_offset)
{
if (tree_draw_ctx.used_by_realtime_compositor &&
node.typeinfo->realtime_compositor_unsupported_message) {
node_add_unsupported_compositor_operation_error_message_button(
tree_draw_ctx, node, block, rect, icon_offset);
return;
}
Span<geo_log::NodeWarning> warnings;
if (tree_draw_ctx.geo_tree_log) {
geo_log::GeoNodeLog *node_log = tree_draw_ctx.geo_tree_log->nodes.lookup_ptr(node.name);
@ -3059,6 +3096,48 @@ static void snode_setup_v2d(SpaceNode &snode, ARegion &region, const float2 &cen
// XXX snode->curfont = uiSetCurFont_ext(snode->aspect);
}
/* Similar to is_compositor_enabled() in draw_manager.c but checks all 3D views. */
static bool realtime_compositor_is_in_use(const bContext &context)
{
if (!U.experimental.use_realtime_compositor) {
return false;
}
const Scene *scene = CTX_data_scene(&context);
if (!scene->use_nodes) {
return false;
}
if (!scene->nodetree) {
return false;
}
const Main *main = CTX_data_main(&context);
LISTBASE_FOREACH (bScreen *, screen, &main->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
if (space->spacetype != SPACE_VIEW3D) {
continue;
}
const View3D &view_3d = *reinterpret_cast<const View3D *>(space);
if (view_3d.shading.use_compositor == V3D_SHADING_USE_COMPOSITOR_DISABLED) {
continue;
}
if (!(view_3d.shading.type >= OB_MATERIAL)) {
continue;
}
return true;
}
}
}
return false;
}
static void draw_nodetree(const bContext &C,
ARegion &region,
bNodeTree &ntree,
@ -3082,6 +3161,9 @@ static void draw_nodetree(const bContext &C,
tree_draw_ctx.active_geometry_nodes_viewer = viewer_path::find_geometry_nodes_viewer(
workspace->viewer_path, *snode);
}
else if (ntree.type == NTREE_COMPOSIT) {
tree_draw_ctx.used_by_realtime_compositor = realtime_compositor_is_in_use(C);
}
node_update_nodetree(C, tree_draw_ctx, ntree, nodes, blocks);
node_draw_nodetree(C, tree_draw_ctx, region, *snode, ntree, nodes, blocks, parent_key);

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -53,6 +55,7 @@ class AntiAliasingOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -78,6 +81,8 @@ void register_node_type_cmp_antialiasing()
node_type_storage(
&ntype, "NodeAntiAliasingData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -7,6 +7,8 @@
#include "node_composite_util.hh"
#include "BLT_translation.h"
#include "RNA_access.h"
#include "UI_interface.h"
@ -58,6 +60,7 @@ class ConvertColorSpaceOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -82,6 +85,8 @@ void register_node_type_cmp_convert_color_space(void)
node_type_storage(
&ntype, "NodeConvertColorSpace", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "COM_node_operation.hh"
#include "node_composite_util.hh"
@ -44,6 +46,7 @@ class CornerPinOperation : public NodeOperation {
{
get_input("Image").pass_through(get_result("Image"));
get_result("Plane").allocate_invalid();
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -63,6 +66,8 @@ void register_node_type_cmp_cornerpin()
cmp_node_type_base(&ntype, CMP_NODE_CORNERPIN, "Corner Pin", NODE_CLASS_DISTORT);
ntype.declare = file_ns::cmp_node_cornerpin_declare;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -14,6 +14,8 @@
#include "BLI_string_ref.hh"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_cryptomatte.hh"
#include "BKE_global.h"
@ -311,6 +313,7 @@ class CryptoMatteOperation : public NodeOperation {
get_input("Image").pass_through(get_result("Image"));
get_result("Matte").allocate_invalid();
get_result("Pick").allocate_invalid();
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -337,6 +340,8 @@ void register_node_type_cmp_cryptomatte()
node_type_storage(
&ntype, "NodeCryptomatte", file_ns::node_free_cryptomatte, file_ns::node_copy_cryptomatte);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}
@ -398,6 +403,7 @@ class CryptoMatteOperation : public NodeOperation {
get_input("image").pass_through(get_result("Image"));
get_result("Matte").allocate_invalid();
get_result("Pick").allocate_invalid();
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -423,6 +429,8 @@ void register_node_type_cmp_cryptomatte_legacy()
&ntype, "NodeCryptomatte", file_ns::node_free_cryptomatte, file_ns::node_copy_cryptomatte);
ntype.gather_link_search_ops = nullptr;
ntype.get_compositor_operation = legacy_file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -7,6 +7,8 @@
#include <climits>
#include "BLT_translation.h"
#include "RNA_access.h"
#include "UI_interface.h"
@ -92,6 +94,7 @@ class DefocusOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -114,6 +117,8 @@ void register_node_type_cmp_defocus()
ntype.initfunc = file_ns::node_composit_init_defocus;
node_type_storage(&ntype, "NodeDefocus", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -7,6 +7,8 @@
#include "BLI_system.h"
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -63,6 +65,7 @@ class DenoiseOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -85,6 +88,8 @@ void register_node_type_cmp_denoise()
ntype.initfunc = file_ns::node_composit_init_denonise;
node_type_storage(&ntype, "NodeDenoise", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "COM_node_operation.hh"
#include "node_composite_util.hh"
@ -35,6 +37,7 @@ class DisplaceOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -54,6 +57,8 @@ void register_node_type_cmp_displace()
cmp_node_type_base(&ntype, CMP_NODE_DISPLACE, "Displace", NODE_CLASS_DISTORT);
ntype.declare = file_ns::cmp_node_displace_declare;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -8,6 +8,8 @@
#include "UI_interface.h"
#include "UI_resources.h"
#include "BLT_translation.h"
#include "COM_node_operation.hh"
#include "node_composite_util.hh"
@ -46,6 +48,7 @@ class DoubleEdgeMaskOperation : public NodeOperation {
void execute() override
{
get_input("Inner Mask").pass_through(get_result("Mask"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -66,6 +69,8 @@ void register_node_type_cmp_doubleedgemask()
ntype.declare = file_ns::cmp_node_double_edge_mask_declare;
ntype.draw_buttons = file_ns::node_composit_buts_double_edge_mask;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -37,6 +39,7 @@ class IDMaskOperation : public NodeOperation {
void execute() override
{
get_input("ID value").pass_through(get_result("Alpha"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -57,6 +60,8 @@ void register_node_type_cmp_idmask()
ntype.declare = file_ns::cmp_node_idmask_declare;
ntype.draw_buttons = file_ns::node_composit_buts_id_mask;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -11,6 +11,8 @@
#include "BLI_math_vec_types.hh"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_image.h"
@ -876,6 +878,8 @@ void register_node_type_cmp_rlayers()
ntype.initfunc_api = file_ns::node_composit_init_rlayers;
ntype.poll = file_ns::node_composit_poll_rlayers;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Render passes not supported in the Viewport compositor");
ntype.flag |= NODE_PREVIEW;
node_type_storage(
&ntype, nullptr, file_ns::node_composit_free_rlayers, file_ns::node_composit_copy_rlayers);

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -36,6 +38,7 @@ class InpaintOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -56,6 +59,8 @@ void register_node_type_cmp_inpaint()
ntype.declare = file_ns::cmp_node_inpaint_declare;
ntype.draw_buttons = file_ns::node_composit_buts_inpaint;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -76,6 +76,7 @@ class KeyingOperation : public NodeOperation {
get_input("Image").pass_through(get_result("Image"));
get_result("Matte").allocate_invalid();
get_result("Edges").allocate_invalid();
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -99,6 +100,8 @@ void register_node_type_cmp_keying()
node_type_storage(
&ntype, "NodeKeyingData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -11,6 +11,8 @@
#include "BLI_math_base.h"
#include "BLI_math_color.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_lib_id.h"
#include "BKE_tracking.h"
@ -89,6 +91,7 @@ class KeyingScreenOperation : public NodeOperation {
void execute() override
{
get_result("Screen").allocate_invalid();
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -112,6 +115,8 @@ void register_node_type_cmp_keyingscreen()
node_type_storage(
&ntype, "NodeKeyingScreenData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -37,6 +39,7 @@ class MapUVOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -57,6 +60,8 @@ void register_node_type_cmp_mapuv()
ntype.declare = file_ns::cmp_node_map_uv_declare;
ntype.draw_buttons = file_ns::node_composit_buts_map_uv;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "DNA_mask_types.h"
#include "UI_interface.h"
@ -85,6 +87,7 @@ class MaskOperation : public NodeOperation {
void execute() override
{
get_result("Mask").allocate_invalid();
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -107,6 +110,8 @@ void register_node_type_cmp_mask()
ntype.initfunc = file_ns::node_composit_init_mask;
ntype.labelfunc = file_ns::node_mask_label;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
node_type_storage(&ntype, "NodeMask", node_free_standard_storage, node_copy_standard_storage);

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_lib_id.h"
#include "BKE_tracking.h"
@ -92,6 +94,7 @@ class MovieDistortionOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -115,6 +118,8 @@ void register_node_type_cmp_moviedistortion()
ntype.initfunc_api = file_ns::init;
node_type_storage(&ntype, nullptr, file_ns::storage_free, file_ns::storage_copy);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -11,6 +11,8 @@
#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_context.h"
#include "BKE_image_format.h"
@ -447,6 +449,7 @@ class OutputFileOperation : public NodeOperation {
void execute() override
{
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -472,6 +475,8 @@ void register_node_type_cmp_output_file()
&ntype, "NodeImageMultiFile", file_ns::free_output_file, file_ns::copy_output_file);
ntype.updatefunc = file_ns::update_output_file;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "DNA_movieclip_types.h"
#include "DNA_tracking_types.h"
@ -118,6 +120,7 @@ class PlaneTrackDeformOperation : public NodeOperation {
{
get_input("Image").pass_through(get_result("Image"));
get_result("Plane").allocate_invalid();
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -141,6 +144,8 @@ void register_node_type_cmp_planetrackdeform()
node_type_storage(
&ntype, "NodePlaneTrackDeformData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -69,6 +71,7 @@ class Stabilize2DOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -90,6 +93,8 @@ void register_node_type_cmp_stabilize2d()
ntype.draw_buttons = file_ns::node_composit_buts_stabilize2d;
ntype.initfunc_api = file_ns::init;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -49,6 +51,7 @@ class SunBeamsOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -72,6 +75,8 @@ void register_node_type_cmp_sunbeams()
node_type_storage(
&ntype, "NodeSunBeams", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "COM_node_operation.hh"
#include "node_composite_util.hh"
@ -35,6 +37,7 @@ class TextureOperation : public NodeOperation {
{
get_result("Value").allocate_invalid();
get_result("Color").allocate_invalid();
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -55,6 +58,8 @@ void register_node_type_cmp_texture()
ntype.declare = file_ns::cmp_node_texture_declare;
ntype.flag |= NODE_PREVIEW;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -62,6 +64,7 @@ class VectorBlurOperation : public NodeOperation {
void execute() override
{
get_input("Image").pass_through(get_result("Image"));
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -85,6 +88,8 @@ void register_node_type_cmp_vecblur()
node_type_storage(
&ntype, "NodeBlurData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}

View File

@ -5,6 +5,8 @@
* \ingroup cmpnodes
*/
#include "BLT_translation.h"
#include "UI_interface.h"
#include "UI_resources.h"
@ -45,6 +47,7 @@ class ZCombineOperation : public NodeOperation {
{
get_input("Image").pass_through(get_result("Image"));
get_result("Z").allocate_invalid();
context().set_info_message("Viewport compositor setup not fully supported");
}
};
@ -65,6 +68,8 @@ void register_node_type_cmp_zcombine()
ntype.declare = file_ns::cmp_node_zcombine_declare;
ntype.draw_buttons = file_ns::node_composit_buts_zcombine;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.realtime_compositor_unsupported_message = N_(
"Node not supported in the Viewport compositor");
nodeRegisterType(&ntype);
}