LG1PCloudAmbStncl: Use RangeDescriptor obj instead of StagingBuffer
We directly use an instance of RangeDescriptor to avoid incurring the memory cost of using a StagingBuffer here. It's unnecessary since these stencils will always be 32bits large.
This commit is contained in:
@@ -18,16 +18,6 @@ class PcloudAmbienceStencil
|
|||||||
public:
|
public:
|
||||||
typedef uint32_t PcloudAmbienceStimulusValue;
|
typedef uint32_t PcloudAmbienceStimulusValue;
|
||||||
|
|
||||||
/**
|
|
||||||
* RangeDescriptor describes a contiguous range of body spots for
|
|
||||||
* point cloud ambience stencils.
|
|
||||||
*/
|
|
||||||
struct RangeDescriptor : public Stencil::RangeDescriptor
|
|
||||||
{
|
|
||||||
uint32_t bodySpot;
|
|
||||||
size_t nContiguousSpots;
|
|
||||||
};
|
|
||||||
|
|
||||||
PcloudAmbienceStencil() = default;
|
PcloudAmbienceStencil() = default;
|
||||||
virtual ~PcloudAmbienceStencil() = default;
|
virtual ~PcloudAmbienceStencil() = default;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define _STENCIL_H
|
#define _STENCIL_H
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
#include <mentalEntity.h>
|
#include <mentalEntity.h>
|
||||||
|
|
||||||
namespace smo {
|
namespace smo {
|
||||||
@@ -40,6 +41,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
struct RangeDescriptor
|
struct RangeDescriptor
|
||||||
{
|
{
|
||||||
|
uint32_t bodySpot;
|
||||||
|
size_t nContiguousSpots;
|
||||||
};
|
};
|
||||||
|
|
||||||
Stencil() = default;
|
Stencil() = default;
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ if(ENABLE_STIMBUFFAPI_livoxGen1)
|
|||||||
add_library(livoxGen1 SHARED
|
add_library(livoxGen1 SHARED
|
||||||
livoxGen1.cpp
|
livoxGen1.cpp
|
||||||
pcloudStimulusProducer.cpp
|
pcloudStimulusProducer.cpp
|
||||||
lg1PcloudAmbienceStencil.cpp
|
|
||||||
ioUringAssemblyEngine.cpp
|
ioUringAssemblyEngine.cpp
|
||||||
openClCollatingAndMeshingEngine.cpp
|
openClCollatingAndMeshingEngine.cpp
|
||||||
openClKernels.cl.S
|
openClKernels.cl.S
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
#include "lg1PcloudAmbienceStencil.h"
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
namespace smo {
|
|
||||||
namespace stim_buff {
|
|
||||||
|
|
||||||
// Common IOEngineConstraints for LG1 ambience stencil StagingBuffer
|
|
||||||
// (used for both input and output constraints)
|
|
||||||
const StagingBuffer::IOEngineConstraints
|
|
||||||
LG1PcloudAmbienceStencil::stencilBufferConstraints(
|
|
||||||
// slotStartAlignmentByteVal, slotPadToNBytes.
|
|
||||||
sizeof(void*),
|
|
||||||
sizeof(PcloudAmbienceStencil::RangeDescriptor),
|
|
||||||
// frameStartAlignmentByteVal, framePadToNBytes.
|
|
||||||
static_cast<size_t>(sysconf(_SC_PAGE_SIZE)),
|
|
||||||
static_cast<size_t>(sysconf(_SC_PAGE_SIZE)));
|
|
||||||
|
|
||||||
} // namespace stim_buff
|
|
||||||
} // namespace smo
|
|
||||||
@@ -3,37 +3,23 @@
|
|||||||
|
|
||||||
#include "livoxGen1.h"
|
#include "livoxGen1.h"
|
||||||
#include <user/pcloudAmbienceStencil.h>
|
#include <user/pcloudAmbienceStencil.h>
|
||||||
#include <user/stagingBuffer.h>
|
#include <user/stencil.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
namespace smo {
|
namespace smo {
|
||||||
namespace stim_buff {
|
namespace stim_buff {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LG1PcloudAmbienceStencil represents Livox Gen1-specific stencils for
|
* LG1PcloudAmbienceStencil represents Livox Gen1-specific stencils for
|
||||||
* ambience data. The StagingBuffer is sized to handle the worst-case scenario
|
* ambience data. It holds a single RangeDescriptor with bodySpot=0 and
|
||||||
* where every ambience body spot requires its own descriptor
|
* nContiguousSpots=1.
|
||||||
* (nDgramsPerFrame slots).
|
|
||||||
*/
|
*/
|
||||||
class LG1PcloudAmbienceStencil
|
class LG1PcloudAmbienceStencil
|
||||||
: public PcloudAmbienceStencil
|
: public PcloudAmbienceStencil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Common IOEngineConstraints for stencil buffer (used for both input and output)
|
explicit LG1PcloudAmbienceStencil()
|
||||||
static const StagingBuffer::IOEngineConstraints stencilBufferConstraints;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param nDgramsPerFrame Number of datagrams per frame, used to size the
|
|
||||||
* stencil buffer for worst-case scenario (one descriptor per dgram)
|
|
||||||
*/
|
|
||||||
explicit LG1PcloudAmbienceStencil(size_t nDgramsPerFrame)
|
|
||||||
: PcloudAmbienceStencil(),
|
: PcloudAmbienceStencil(),
|
||||||
stencilBuffer(
|
rangeDescriptor{0, 1}
|
||||||
stencilBufferConstraints, // Input constraints
|
|
||||||
stencilBufferConstraints, // Output constraints (same as input)
|
|
||||||
nDgramsPerFrame),
|
|
||||||
nRangeDescriptors(0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~LG1PcloudAmbienceStencil() = default;
|
~LG1PcloudAmbienceStencil() = default;
|
||||||
@@ -41,36 +27,33 @@ public:
|
|||||||
// Implement pure virtual functions from Stencil
|
// Implement pure virtual functions from Stencil
|
||||||
bool hasData() const override
|
bool hasData() const override
|
||||||
{
|
{
|
||||||
return nRangeDescriptors > 0;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getRelevantCount() const override
|
size_t getRelevantCount() const override
|
||||||
{
|
{
|
||||||
// TODO: Implement based on range descriptors
|
return rangeDescriptor.nContiguousSpots;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isRelevant(size_t offset) const override
|
bool isRelevant(size_t offset) const override
|
||||||
{
|
{
|
||||||
// TODO: Implement based on range descriptors
|
return (offset >= rangeDescriptor.bodySpot &&
|
||||||
(void)offset;
|
offset < rangeDescriptor.bodySpot + rangeDescriptor.nContiguousSpots);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getNRangeDescriptors() const override
|
size_t getNRangeDescriptors() const override
|
||||||
{
|
{
|
||||||
return nRangeDescriptors;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool buildStencilMetadata() override
|
bool buildStencilMetadata() override
|
||||||
{
|
{
|
||||||
// TODO: Implement stencil metadata building
|
// Metadata is already built (single fixed descriptor)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StagingBuffer stencilBuffer;
|
smo::cologex::Stencil::RangeDescriptor rangeDescriptor;
|
||||||
size_t nRangeDescriptors;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace stim_buff
|
} // namespace stim_buff
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public:
|
|||||||
|
|
||||||
// Construct stencils and add to list (FIFO behavior)
|
// Construct stencils and add to list (FIFO behavior)
|
||||||
for (size_t i = 0; i < nStencils; ++i) {
|
for (size_t i = 0; i < nStencils; ++i) {
|
||||||
stencils.emplace_back(nDgramsPerFrame_);
|
stencils.emplace_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user