DAP: Add intrin DAPSpecs

We now specify intrins as separate DAPS lines. This syntax is much
nicer and well-grouped than the previous negtrin-*/postrin-* param
names.

Alas, we're about to replace it in the next few commits already though.
This commit is contained in:
2026-04-12 04:06:47 -04:00
parent c696316a1e
commit fc1fcae0b0
14 changed files with 595 additions and 284 deletions
@@ -4,6 +4,7 @@
#include <unistd.h>
#include <iomanip>
#include <cstddef>
#include <string>
#include <user/spMcRingBuffer.h>
#include <componentThread.h>
#include <spinscale/asynchronousLoop.h>
@@ -13,6 +14,24 @@
#include "livoxGen1.h"
#include "pcloudStimulusProducer.h"
namespace {
void requirePcloudAmbienceFromStimbuff(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
{
const std::string fromName =
smo::stim_buff::parseRequiredFromStimbuffQualeIfaceName(
spec->qualeIfaceApiParams);
if (fromName != "pcloudAmbience")
{
throw std::runtime_error(
"LivoxGen1 PcloudAmbience intrinsic pipelines require "
"from-stimbuff=pcloudAmbience (got '" + fromName + "').");
}
}
} // namespace
namespace smo {
namespace stim_buff {
@@ -132,7 +151,8 @@ bool PcloudStimulusProducer::supportsQualeIfaceApi(
const std::string& qualeIfaceApi)
{
return qualeIfaceApi == "mesh" || qualeIfaceApi == "pcloudIntensity" ||
qualeIfaceApi == "pcloudAmbience";
qualeIfaceApi == "pcloudAmbience" || qualeIfaceApi == "negtrin" ||
qualeIfaceApi == "postrin";
}
bool PcloudStimulusProducer::exportsQualeIfaceApi(
@@ -228,6 +248,11 @@ PcloudStimulusProducer::getAttachedStimulusBuffer(
if (std::dynamic_pointer_cast<PcloudAmbienceStimulusBuffer>(buffer))
{ return buffer; }
}
else if (qualeIfaceApi == "negtrin" || qualeIfaceApi == "postrin")
{
if (std::dynamic_pointer_cast<PcloudAmbienceIntrinStimulusBuffer>(buffer))
{ return buffer; }
}
// Type mismatch - return nullptr
return nullptr;
@@ -259,6 +284,22 @@ void PcloudStimulusProducer::destroyAttachedStimulusBuffer(
ambienceBuff.reset();
ambienceStimulusBuffer.store(nullptr, std::memory_order_release);
}
auto negIntrinBuff = negtrinAmbienceIntrinStimulusBuffer.load(
std::memory_order_acquire);
if (negIntrinBuff == buffer)
{
negIntrinBuff.reset();
negtrinAmbienceIntrinStimulusBuffer.store(
nullptr, std::memory_order_release);
}
auto posIntrinBuff = postrinAmbienceIntrinStimulusBuffer.load(
std::memory_order_acquire);
if (posIntrinBuff == buffer)
{
posIntrinBuff.reset();
postrinAmbienceIntrinStimulusBuffer.store(
nullptr, std::memory_order_release);
}
// Call base class implementation to remove from attachedStimulusBuffers
StimulusProducer::destroyAttachedStimulusBuffer(buffer);
@@ -343,12 +384,38 @@ PcloudStimulusProducer::getOrCreateAttachedStimulusBuffer(
this->start();
return ambienceStimBuff;
}
else if (qualeIfaceApi == "negtrin" || qualeIfaceApi == "postrin")
{
requirePcloudAmbienceFromStimbuff(deviceAttachmentSpec);
auto intrinBuff = std::make_shared<PcloudAmbienceIntrinStimulusBuffer>(
*this, deviceAttachmentSpec, histbuffMs,
openClAmbienceInputConstraints, openClAmbienceInputConstraints,
*smoHooksPtr, CL_MEM_READ_WRITE,
this->nDgramsPerStagingBufferFrame);
this->stop();
addAttachedStimulusBufferIfNotExists(intrinBuff);
if (qualeIfaceApi == "negtrin")
{
negtrinAmbienceIntrinStimulusBuffer.store(
intrinBuff, std::memory_order_release);
}
else
{
postrinAmbienceIntrinStimulusBuffer.store(
intrinBuff, std::memory_order_release);
}
this->start();
return intrinBuff;
}
else
{
throw std::runtime_error(
"Unsupported qualeIfaceApi: '" + qualeIfaceApi + "' for "
"PcloudStimulusProducer. "
"Supported values: mesh, pcloudIntensity, pcloudAmbience");
"Supported values: mesh, pcloudIntensity, pcloudAmbience, "
"negtrin, postrin");
}
}