LG1PclAmbienceStencil: allocate stencils in constructor
This commit is contained in:
@@ -45,6 +45,12 @@ public:
|
||||
Stencil() = default;
|
||||
virtual ~Stencil() = default;
|
||||
|
||||
// Non-copyable, non-movable (stencils are constructed in place)
|
||||
Stencil(const Stencil&) = delete;
|
||||
Stencil& operator=(const Stencil&) = delete;
|
||||
Stencil(Stencil&&) = delete;
|
||||
Stencil& operator=(Stencil&&) = delete;
|
||||
|
||||
/**
|
||||
* Returns true if the Stencil has data, false otherwise.
|
||||
*/
|
||||
|
||||
@@ -32,11 +32,45 @@ public:
|
||||
stencilBuffer(
|
||||
stencilBufferConstraints, // Input constraints
|
||||
stencilBufferConstraints, // Output constraints (same as input)
|
||||
nDgramsPerFrame)
|
||||
nDgramsPerFrame),
|
||||
nRangeDescriptors(0)
|
||||
{}
|
||||
|
||||
~LG1PcloudAmbienceStencil() = default;
|
||||
|
||||
// Implement pure virtual functions from Stencil
|
||||
bool hasData() const override
|
||||
{
|
||||
return nRangeDescriptors > 0;
|
||||
}
|
||||
|
||||
size_t getRelevantCount() const override
|
||||
{
|
||||
// TODO: Implement based on range descriptors
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool isRelevant(size_t offset) const override
|
||||
{
|
||||
// TODO: Implement based on range descriptors
|
||||
(void)offset;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t getNRangeDescriptors() const override
|
||||
{
|
||||
return nRangeDescriptors;
|
||||
}
|
||||
|
||||
bool buildStencilMetadata() override
|
||||
{
|
||||
// TODO: Implement stencil metadata building
|
||||
return true;
|
||||
}
|
||||
|
||||
public:
|
||||
StagingBuffer stencilBuffer;
|
||||
size_t nRangeDescriptors;
|
||||
};
|
||||
|
||||
} // namespace stim_buff
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
#include <list>
|
||||
#include <cstddef>
|
||||
#include <user/stimulusBuffer.h>
|
||||
#include <user/stagingBuffer.h>
|
||||
#include "lg1PcloudAmbienceStencil.h"
|
||||
|
||||
namespace smo {
|
||||
namespace stim_buff {
|
||||
@@ -27,13 +30,20 @@ public:
|
||||
const StagingBuffer::IOEngineConstraints& outputEngineConstraints,
|
||||
const SmoCallbacks& callbacks,
|
||||
cl_mem_flags flags,
|
||||
uint32_t ambienceHighVal_)
|
||||
uint32_t ambienceHighVal_,
|
||||
size_t nStencils_, size_t nDgramsPerFrame_)
|
||||
: StimulusBuffer(
|
||||
parent, deviceAttachmentSpec, histbuffMs,
|
||||
inputEngineConstraints, outputEngineConstraints,
|
||||
callbacks, flags),
|
||||
ambienceHighVal(ambienceHighVal_)
|
||||
{}
|
||||
ambienceHighVal(ambienceHighVal_),
|
||||
nStencils(nStencils_)
|
||||
{
|
||||
// Construct stencils and add to list (FIFO behavior)
|
||||
for (size_t i = 0; i < nStencils; ++i) {
|
||||
stencils.emplace_back(nDgramsPerFrame_);
|
||||
}
|
||||
}
|
||||
|
||||
~PcloudAmbienceStimulusBuffer() = default;
|
||||
|
||||
@@ -45,6 +55,8 @@ public:
|
||||
|
||||
public:
|
||||
uint32_t ambienceHighVal;
|
||||
size_t nStencils;
|
||||
std::list<LG1PcloudAmbienceStencil> stencils;
|
||||
};
|
||||
|
||||
} // namespace stim_buff
|
||||
|
||||
@@ -323,6 +323,16 @@ std::cout << __func__ << ": $$$$$$$ Created PcloudIntensityStimulusBuffer" << st
|
||||
ambienceHighValParamNames, 116);
|
||||
uint32_t ambienceHighVal = static_cast<uint32_t>(ambienceHighValInt);
|
||||
|
||||
// Parse n-stencils from qualeIfaceApiParams
|
||||
const std::vector<std::string> nStencilsParamNames = {
|
||||
"n-stencils"
|
||||
};
|
||||
int nStencilsInt = device::DeviceAttachmentSpec
|
||||
::parseOptionalParamAsIntWithSynonyms(
|
||||
deviceAttachmentSpec->qualeIfaceApiParams,
|
||||
nStencilsParamNames, 1);
|
||||
size_t nStencils = static_cast<size_t>(nStencilsInt);
|
||||
|
||||
/* Calculate slotStrideNBytes:
|
||||
* nDgramsPerStagingBufferFrame * sizeof(uint32_t)
|
||||
*/
|
||||
@@ -334,7 +344,8 @@ std::cout << __func__ << ": $$$$$$$ Created PcloudIntensityStimulusBuffer" << st
|
||||
auto ambienceBuffer = std::make_shared<PcloudAmbienceStimulusBuffer>(
|
||||
*this, deviceAttachmentSpec, histbuffMs,
|
||||
openClAmbienceInputConstraints, openClAmbienceInputConstraints,
|
||||
*smoHooksPtr, CL_MEM_READ_WRITE, ambienceHighVal);
|
||||
*smoHooksPtr, CL_MEM_READ_WRITE, ambienceHighVal,
|
||||
nStencils, this->nDgramsPerStagingBufferFrame);
|
||||
|
||||
std::cout << __func__ << ": $$$$$$$ Created PcloudAmbienceStimulusBuffer" << std::endl;
|
||||
this->stop();
|
||||
|
||||
Reference in New Issue
Block a user