From 5acce60d376292bc228211075c9fe05b41c84ccd Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 24 Jul 2015 23:05:11 +0200 Subject: Compositor: Fixes for the debug pass This commit fixes issues with wrong socket type being added to the Cycles debug pass compositor operation, which lead to crashes with non-value pass types. This commit also reverts socket renaming thing because while it's was behaving ok on runtime file reload might have loose the links which is annoying. --- .../compositor/nodes/COM_RenderLayersNode.cpp | 11 ++++++++- .../compositor/operations/COM_RenderLayersProg.cpp | 26 ++++++++++++++-------- .../compositor/operations/COM_RenderLayersProg.h | 4 ++-- .../nodes/composite/nodes/node_composite_image.c | 6 +---- source/blender/render/extern/include/RE_pipeline.h | 1 + .../blender/render/intern/source/render_result.c | 5 +++++ 6 files changed, 36 insertions(+), 17 deletions(-) diff --git a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp index 69d2bf86531..842edcf35c9 100644 --- a/source/blender/compositor/nodes/COM_RenderLayersNode.cpp +++ b/source/blender/compositor/nodes/COM_RenderLayersNode.cpp @@ -27,6 +27,10 @@ #include "COM_ScaleOperation.h" #include "COM_SetValueOperation.h" +#ifdef WITH_CYCLES_DEBUG +# include "RE_pipeline.h" +#endif + RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode) { /* pass */ @@ -88,6 +92,11 @@ void RenderLayersNode::convertToOperations(NodeConverter &converter, const Compo testSocketLink(converter, context, 30, new RenderLayersCyclesOperation(SCE_PASS_SUBSURFACE_COLOR)); #ifdef WITH_CYCLES_DEBUG - testSocketLink(converter, context, 31, new RenderLayersCyclesDebugOperation(SCE_PASS_DEBUG)); + { + Scene *scene = (Scene *)this->getbNode()->id; + Render *re = RE_GetRender(scene->id.name); + int debug_pass_type = ((re != NULL) ? RE_debug_pass_type_get(re) : scene->r.debug_pass_type); + testSocketLink(converter, context, 31, new RenderLayersCyclesDebugOperation(SCE_PASS_DEBUG, debug_pass_type)); + } #endif } diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.cpp b/source/blender/compositor/operations/COM_RenderLayersProg.cpp index d93d327d07d..999565dc40f 100644 --- a/source/blender/compositor/operations/COM_RenderLayersProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersProg.cpp @@ -393,16 +393,24 @@ RenderLayersUVOperation::RenderLayersUVOperation() : RenderLayersBaseProg(SCE_PA #ifdef WITH_CYCLES_DEBUG -RenderLayersCyclesDebugOperation::RenderLayersCyclesDebugOperation(int pass) - : RenderLayersBaseProg(pass, 1) +RenderLayersCyclesDebugOperation::RenderLayersCyclesDebugOperation( + int pass, + int debug_pass_type) + : RenderLayersBaseProg(pass, RE_debug_pass_num_channels_get(debug_pass_type)) { - this->addOutputSocket(COM_DT_VALUE); -} - -void RenderLayersCyclesDebugOperation::setScene(Scene *scene) -{ - RenderLayersBaseProg::setScene(scene); - this->m_elementsize = RE_debug_pass_num_channels_get(m_scene->r.debug_pass_type); + switch(m_elementsize) { + case 1: + this->addOutputSocket(COM_DT_VALUE); + break; + case 3: + this->addOutputSocket(COM_DT_VECTOR); + break; + case 4: + this->addOutputSocket(COM_DT_COLOR); + break; + default: + BLI_assert(!"Unkown debug pass type element size."); + } } #endif diff --git a/source/blender/compositor/operations/COM_RenderLayersProg.h b/source/blender/compositor/operations/COM_RenderLayersProg.h index edefd9aeb18..89eb2a6954d 100644 --- a/source/blender/compositor/operations/COM_RenderLayersProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersProg.h @@ -215,8 +215,8 @@ public: #ifdef WITH_CYCLES_DEBUG class RenderLayersCyclesDebugOperation : public RenderLayersBaseProg { public: - RenderLayersCyclesDebugOperation(int pass); - void setScene(Scene *scene); + RenderLayersCyclesDebugOperation(int pass, + int debug_pass_type); }; #endif diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 21142900e20..4f02c106569 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -457,11 +457,7 @@ void node_cmp_rlayers_force_hidden_passes(bNode *node) set_output_visible(node, passflag, RRES_OUT_SUBSURFACE_COLOR, SCE_PASS_SUBSURFACE_COLOR); #ifdef WITH_CYCLES_DEBUG - { - bNodeSocket *sock = BLI_findlink(&node->outputs, RRES_OUT_DEBUG); - set_output_visible(node, passflag, RRES_OUT_DEBUG, SCE_PASS_DEBUG); - strcpy(sock->name, RE_debug_pass_name_get(scene->r.debug_pass_type)); - } + set_output_visible(node, passflag, RRES_OUT_DEBUG, SCE_PASS_DEBUG); #endif } diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 7951248b38e..2a679f0f0d0 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -366,6 +366,7 @@ struct RenderView *RE_RenderViewGetByName(struct RenderResult *res, const char * #ifdef WITH_CYCLES_DEBUG int RE_debug_pass_num_channels_get(int pass_type); const char *RE_debug_pass_name_get(int pass_type); +int RE_debug_pass_type_get(struct Render *re); #endif #endif /* __RE_PIPELINE_H__ */ diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 8d63c84b438..639ce204808 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -563,6 +563,11 @@ static RenderPass *render_layer_add_debug_pass(RenderResult *rr, BLI_strncpy(rpass->internal_name, rpass->name, sizeof(rpass->internal_name)); return rpass; } + +int RE_debug_pass_type_get(Render *re) +{ + return re->r.debug_pass_type; +} #endif /* called by main render as well for parts */ -- cgit v1.2.3