diff --git a/Plugins/nosCompositing/Nodes/LayoutQuadCanvas.nosnode b/Plugins/nosCompositing/Nodes/LayoutQuadCanvas.nosnode index bc1859ec..02756fc9 100644 --- a/Plugins/nosCompositing/Nodes/LayoutQuadCanvas.nosnode +++ b/Plugins/nosCompositing/Nodes/LayoutQuadCanvas.nosnode @@ -4,12 +4,13 @@ "class_name": "LayoutQuadCanvas", "menu_info": { "category": "Compositing|Layout", - "display_name": "Layout Quad Canvas" + "display_name": "Layout Quad Canvas (Deprecated)" }, "node": { "id": "9ad95de1-d52a-409a-809d-da7d98b13f30", "name": "LayoutQuadCanvas", "class_name": "LayoutQuadCanvas", + "description": "Deprecated: use Quad Merge instead, which does the same 2x2 composition as a single node with a Resolution pin.\nThis node is kept so existing graphs keep working.", "pins": [ { "id": "acdf750c-9637-4807-9d29-578f11bcc010", @@ -1628,7 +1629,7 @@ }, { "id": "c886b125-d628-4ade-91eb-390ffff53476", - "name": "Array (1)", + "name": "OutputInfos", "class_name": "nos.reflect.Array", "pins": [ { @@ -2053,7 +2054,7 @@ "value": "/LayoutDrawer" } ], - "display_name": "Layout Quad Canvas", + "display_name": "Layout Quad Canvas (Deprecated)", "plugin_version": { "major": 3, "minor": 10, diff --git a/Plugins/nosCompositing/Nodes/QuadMerge.nosnode b/Plugins/nosCompositing/Nodes/QuadMerge.nosnode index 64b90a8a..0d50f9f9 100644 --- a/Plugins/nosCompositing/Nodes/QuadMerge.nosnode +++ b/Plugins/nosCompositing/Nodes/QuadMerge.nosnode @@ -10,7 +10,10 @@ "concatenate", "add", "quarter", - "texture" + "texture", + "quad", + "canvas", + "layout" ] }, "node": { @@ -52,11 +55,37 @@ "can_show_as": "INPUT_PIN_OR_PROPERTY", "description": "Quadrant 3: bottom/right" }, + { + "name": "Resolution", + "type_name": "nos.fb.vec2u", + "show_as": "PROPERTY", + "can_show_as": "INPUT_PIN_OR_PROPERTY", + "data": { + "x": 1920, + "y": 1080 + }, + "description": "Resolution of the merged output texture", + "visualizers": [ + { + "type": "NAMED_VALUE", + "name": "nos.mediaio.ResolutionVisualizer" + } + ] + }, { "name": "Output", "type_name": "nos.sys.vulkan.Texture", "show_as": "OUTPUT_PIN", - "can_show_as": "OUTPUT_PIN_OR_PROPERTY" + "can_show_as": "OUTPUT_PIN_OR_PROPERTY", + "extensions": [ + { + "name": "texture_options", + "type_name": "nos.sys.vulkan.TexturePinOptions", + "data": { + "unscaled": true + } + } + ] } ] } diff --git a/Plugins/nosCompositing/Source/CompositingMain.cpp b/Plugins/nosCompositing/Source/CompositingMain.cpp index a9cbb7dd..caf36d88 100644 --- a/Plugins/nosCompositing/Source/CompositingMain.cpp +++ b/Plugins/nosCompositing/Source/CompositingMain.cpp @@ -15,6 +15,7 @@ namespace nos::compositing void RegisterBoxFit(nosNodeFunctions*); nosResult RegisterChannelViewer(nosNodeFunctions*); nosResult RegisterMerge(nosNodeFunctions*); +void RegisterQuadMerge(nosNodeFunctions*); nosResult RegisterLayoutDrawer(nosNodeFunctions*); void RegisterFreeLayout(nosNodeFunctions*); void RegisterGridLayout(nosNodeFunctions*); @@ -31,6 +32,7 @@ enum class Nodes : size_t BoxFit, ChannelViewer, Merge, + QuadMerge, LayoutDrawer, FreeLayout, GridLayout, @@ -75,6 +77,7 @@ nosResult NOSAPI_CALL ExportNodeFunctions(size_t* outCount, nosNodeFunctions** o GEN_CASE_NODE(BoxFit) GEN_CASE_NODE_RESULT(ChannelViewer) GEN_CASE_NODE_RESULT(Merge) + GEN_CASE_NODE(QuadMerge) GEN_CASE_NODE_RESULT(LayoutDrawer) GEN_CASE_NODE(FreeLayout) GEN_CASE_NODE(GridLayout) diff --git a/Plugins/nosCompositing/Source/QuadMerge.cpp b/Plugins/nosCompositing/Source/QuadMerge.cpp new file mode 100644 index 00000000..c7136618 --- /dev/null +++ b/Plugins/nosCompositing/Source/QuadMerge.cpp @@ -0,0 +1,40 @@ +// Copyright MediaZ Teknoloji A.S. All Rights Reserved. + +#include + +#include + +namespace nos::compositing +{ +// The quadrant compositing itself is done declaratively by Shaders/QuadMerge.frag. This node exists only to size the +// output texture from the Resolution pin, since the output is marked unscaled. +struct QuadMergeNode : NodeContext +{ + nosResult ExecuteNode(NodeExecuteParams const& params) override + { + auto outputTex = params.GetPinObject(NOS_NAME("Output")); + auto outputTexInfo = sys::vulkan::GetResourceInfo(outputTex); + const nos::fb::vec2u& resolution = *params.GetPinValue(NOS_NAME("Resolution")); + + if (!outputTexInfo || resolution.x() != outputTexInfo->Width || resolution.y() != outputTexInfo->Height) + { + SetPinObject(NOS_NAME("Output"), + sys::vulkan::CreateTexture( + { + .Width = resolution.x(), + .Height = resolution.y(), + .Usage = nosImageUsage(NOS_IMAGE_USAGE_TRANSFER_DST | NOS_IMAGE_USAGE_TRANSFER_SRC | + NOS_IMAGE_USAGE_SAMPLED), + }, + "QuadMergeResult")); + } + + return nosVulkan->ExecuteGPUNode(this, params.RawParams); + } +}; + +void RegisterQuadMerge(nosNodeFunctions* funcs) +{ + NOS_BIND_NODE_CLASS(NOS_NAME("QuadMerge"), QuadMergeNode, funcs); +} +} // namespace nos::compositing