Added baseline functionality including new memory models
This commit is contained in:
parent
9aae5d69db
commit
635fdb02be
22 changed files with 283 additions and 1919 deletions
|
|
@ -26,96 +26,60 @@ Sequence::~Sequence()
|
|||
this->freeMemoryDestroyGPUResources();
|
||||
}
|
||||
|
||||
bool
|
||||
void
|
||||
Sequence::begin()
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute sequence called BEGIN");
|
||||
|
||||
if (this->isRecording()) {
|
||||
KP_LOG_WARN("Kompute Sequence begin called when already recording");
|
||||
return false;
|
||||
KP_LOG_DEBUG("Kompute Sequence begin called when already recording");
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->isRunning()) {
|
||||
KP_LOG_WARN(
|
||||
"Kompute Sequence begin called when sequence still running");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this->mCommandPool) {
|
||||
throw std::runtime_error("Kompute Sequence command pool is null");
|
||||
}
|
||||
|
||||
if (this->mOperations.size()) {
|
||||
KP_LOG_INFO("Kompute Sequence clearing previous operations");
|
||||
this->mOperations.clear();
|
||||
throw std::runtime_error("Kompute Sequence begin called when sequence still running");
|
||||
}
|
||||
|
||||
if (!this->mRecording) {
|
||||
KP_LOG_INFO("Kompute Sequence command recording BEGIN");
|
||||
this->mCommandBuffer->begin(vk::CommandBufferBeginInfo());
|
||||
this->mRecording = true;
|
||||
} else {
|
||||
KP_LOG_WARN("Kompute Sequence attempted to start command recording "
|
||||
"but recording already started");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
void
|
||||
Sequence::end()
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute Sequence calling END");
|
||||
|
||||
if (!this->isRecording()) {
|
||||
KP_LOG_WARN("Kompute Sequence end called when not recording");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this->mCommandPool) {
|
||||
throw std::runtime_error("Kompute Sequence command pool is null");
|
||||
}
|
||||
|
||||
if (this->mRecording) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
KP_LOG_INFO("Kompute Sequence command recording END");
|
||||
this->mCommandBuffer->end();
|
||||
this->mRecording = false;
|
||||
} else {
|
||||
KP_LOG_WARN("Kompute Sequence attempted to end command recording but "
|
||||
"recording not started");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
std::shared_ptr<Sequence>
|
||||
Sequence::eval()
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute sequence EVAL BEGIN");
|
||||
|
||||
bool evalResult = this->evalAsync();
|
||||
if (!evalResult) {
|
||||
KP_LOG_DEBUG("Kompute sequence EVAL FAILURE");
|
||||
return false;
|
||||
}
|
||||
|
||||
evalResult = this->evalAwait();
|
||||
|
||||
KP_LOG_DEBUG("Kompute sequence EVAL SUCCESS");
|
||||
|
||||
return evalResult;
|
||||
return this->evalAsync()->evalAwait();
|
||||
}
|
||||
|
||||
bool
|
||||
std::shared_ptr<Sequence>
|
||||
Sequence::evalAsync()
|
||||
{
|
||||
if (this->isRecording()) {
|
||||
KP_LOG_WARN("Kompute Sequence evalAsync called when still recording");
|
||||
return false;
|
||||
this->end();
|
||||
}
|
||||
if (this->mIsRunning) {
|
||||
KP_LOG_WARN("Kompute Sequence evalAsync called when an eval async was "
|
||||
throw std::runtime_error("Kompute Sequence evalAsync called when an eval async was "
|
||||
"called without successful wait");
|
||||
return false;
|
||||
}
|
||||
|
||||
this->mIsRunning = true;
|
||||
|
|
@ -134,15 +98,15 @@ Sequence::evalAsync()
|
|||
|
||||
this->mComputeQueue->submit(1, &submitInfo, this->mFence);
|
||||
|
||||
return true;
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
bool
|
||||
std::shared_ptr<Sequence>
|
||||
Sequence::evalAwait(uint64_t waitFor)
|
||||
{
|
||||
if (!this->mIsRunning) {
|
||||
KP_LOG_WARN("Kompute Sequence evalAwait called without existing eval");
|
||||
return false;
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
vk::Result result =
|
||||
|
|
@ -153,15 +117,15 @@ Sequence::evalAwait(uint64_t waitFor)
|
|||
this->mIsRunning = false;
|
||||
|
||||
if (result == vk::Result::eTimeout) {
|
||||
KP_LOG_WARN("Kompute Sequence evalAwait timed out");
|
||||
return false;
|
||||
KP_LOG_WARN("Kompute Sequence evalAwait reached timeout of {}", waitFor);
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < this->mOperations.size(); i++) {
|
||||
this->mOperations[i]->postEval();
|
||||
}
|
||||
|
||||
return true;
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -221,6 +185,22 @@ Sequence::freeMemoryDestroyGPUResources()
|
|||
|
||||
}
|
||||
|
||||
std::shared_ptr<Sequence>
|
||||
Sequence::record(std::shared_ptr<OpBase> op)
|
||||
{
|
||||
KP_LOG_DEBUG("Kompute Sequence record function started");
|
||||
|
||||
this->begin();
|
||||
|
||||
KP_LOG_DEBUG(
|
||||
"Kompute Sequence running record on OpBase derived class instance");
|
||||
op->record(this->mCommandBuffer);
|
||||
|
||||
this->mOperations.push_back(op);
|
||||
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
void
|
||||
Sequence::createCommandPool()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue