Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 30 additions & 18 deletions Plugins/nosUtilities/Source/Ring.h
Original file line number Diff line number Diff line change
Expand Up @@ -794,47 +794,59 @@ struct RingNodeBase : NodeContext
resource = std::make_unique<GPUTextureResource>();
else
resource = std::make_unique<CPUTrivialResource>();
if (auto inputVal = GetWatchedPinValue(NSN_Input))
resource->CheckNewResource(NSN_Input, *inputVal, std::nullopt);
if (auto alignmentVal = GetWatchedPinValue(NSN_Alignment))
resource->CheckNewResource(NSN_Alignment, *alignmentVal, std::nullopt);
uint32_t size = 1;
if (auto sizeVal = GetWatchedPinValue(NSN_Size))
size = *InterpretPinValue<uint32_t>(*sizeVal);
Ring = std::make_unique<TRing>(size, std::move(resource));

Ring = std::make_unique<TRing>(1, std::move(resource));

Ring->Stop();
}

RingNodeBase(nosFbNodePtr node, OnRestartType onRestart) : NodeContext(node), OnRestart(onRestart), TypeInfo(NSN_Generic)
{
nos::Name typeName = NSN_Generic;
if(auto* pins = node->pins())
for (auto* pin : *pins)
if (pin->name()->c_str() == NSN_Output)
IsOutLive = pin->live();
for (auto& pin : Pins | std::views::values)
if (pin.TypeName != NSN_Generic && (pin.Name == NSN_Output || pin.Name == NSN_Input))
typeName = pin.TypeName;

AddPinValueWatcher(NSN_Size, [this](nos::Buffer const& newSize, std::optional<nos::Buffer> oldVal) {
if (!Ring)
return;
uint32_t size = *newSize.As<uint32_t>();
if (oldVal && oldVal == newSize)
return;
RequestRingResize(size);
});
AddPinValueWatcher(NSN_Input, [this](nos::Buffer const& newBuf, std::optional<nos::Buffer> oldVal) {
if (Ring->ResInterface->CheckNewResource(NSN_Input, newBuf, oldVal))
if (Ring && Ring->ResInterface->CheckNewResource(NSN_Input, newBuf, oldVal))
{
SendPathRestart();
Ring->Stop();
NeedsRecreation = true;
}
});
AddPinValueWatcher(NSN_Alignment, [this](nos::Buffer const& newAlignment, std::optional<nos::Buffer> oldVal) {
if (Ring->ResInterface->CheckNewResource(NSN_Alignment, newAlignment, oldVal))
if (Ring && Ring->ResInterface->CheckNewResource(NSN_Alignment, newAlignment, oldVal))
{
SendPathRestart();
Ring->Stop();
NeedsRecreation = true;
}
});
AddPinValueWatcher(NOS_NAME_STATIC("RepeatWhenFilling"), [this](nos::Buffer const& newVal, std::optional<nos::Buffer> oldVal) {
RepeatWhenFilling = *newVal.As<bool>();
});
}

RingNodeBase(nosFbNodePtr node, OnRestartType onRestart) : NodeContext(node), OnRestart(onRestart), TypeInfo(NSN_Generic)
{
nos::Name typeName = NSN_Generic;
if(auto* pins = node->pins())
for (auto* pin : *pins)
if (pin->name()->c_str() == NSN_Output)
IsOutLive = pin->live();
for (auto& pin : Pins | std::views::values)
if (pin.TypeName != NSN_Generic && (pin.Name == NSN_Output || pin.Name == NSN_Input))
typeName = pin.TypeName;
AddPinValueWatcher(NOS_NAME_STATIC("RepeatWhenFilling"),
[this](nos::Buffer const& newVal, std::optional<nos::Buffer> oldVal) {
RepeatWhenFilling = *newVal.As<bool>();
nosEngine.SendPathRestart(NodeId);
});
if (typeName != NSN_Generic) {
TypeInfo = nos::TypeInfo(typeName);
Init();
Expand Down