Refactored to use shared pointers
This commit is contained in:
parent
81d592e6e0
commit
e8b0cac2c7
4 changed files with 21 additions and 22 deletions
|
|
@ -119,8 +119,8 @@ void Manager::createInstance() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this->mInstance = new vk::Instance();
|
this->mInstance = std::make_shared<vk::Instance>();
|
||||||
vk::createInstance(&computeInstanceCreateInfo, nullptr, this->mInstance);
|
vk::createInstance(&computeInstanceCreateInfo, nullptr, this->mInstance.get());
|
||||||
SPDLOG_DEBUG("Kompute Manager Instance Created");
|
SPDLOG_DEBUG("Kompute Manager Instance Created");
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
@ -199,12 +199,12 @@ void Manager::createDevice() {
|
||||||
1, // Number of deviceQueueCreateInfo
|
1, // Number of deviceQueueCreateInfo
|
||||||
&deviceQueueCreateInfo);
|
&deviceQueueCreateInfo);
|
||||||
|
|
||||||
this->mDevice = new vk::Device();
|
this->mDevice = std::make_shared<vk::Device>();
|
||||||
physicalDevice.createDevice(&deviceCreateInfo, nullptr, this->mDevice);
|
physicalDevice.createDevice(&deviceCreateInfo, nullptr, this->mDevice.get());
|
||||||
SPDLOG_DEBUG("Kompute Manager device created");
|
SPDLOG_DEBUG("Kompute Manager device created");
|
||||||
|
|
||||||
this->mComputeQueue = new vk::Queue();
|
this->mComputeQueue = std::make_shared<vk::Queue>();
|
||||||
this->mDevice->getQueue(this->mComputeQueueFamilyIndex, 0, this->mComputeQueue);
|
this->mDevice->getQueue(this->mComputeQueueFamilyIndex, 0, this->mComputeQueue.get());
|
||||||
SPDLOG_DEBUG("Kompute Manager compute queue obtained");
|
SPDLOG_DEBUG("Kompute Manager compute queue obtained");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,13 @@ public:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vk::Instance* mInstance = nullptr;
|
std::shared_ptr<vk::Instance> mInstance = nullptr;
|
||||||
bool mFreeInstance = false;
|
bool mFreeInstance = false;
|
||||||
uint32_t mPhysicalDeviceIndex = -1;
|
uint32_t mPhysicalDeviceIndex = -1;
|
||||||
vk::Device* mDevice = nullptr;
|
std::shared_ptr<vk::Device> mDevice = nullptr;
|
||||||
bool mFreeDevice = false;
|
bool mFreeDevice = false;
|
||||||
uint32_t mComputeQueueFamilyIndex = -1;
|
uint32_t mComputeQueueFamilyIndex = -1;
|
||||||
vk::Queue* mComputeQueue = nullptr;
|
std::shared_ptr<vk::Queue> mComputeQueue = nullptr;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
vk::DebugReportCallbackEXT mDebugReportCallback;
|
vk::DebugReportCallbackEXT mDebugReportCallback;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ Sequence::Sequence()
|
||||||
SPDLOG_DEBUG("Kompute Sequence base constructor");
|
SPDLOG_DEBUG("Kompute Sequence base constructor");
|
||||||
}
|
}
|
||||||
|
|
||||||
Sequence::Sequence(vk::Device* device, vk::Queue* computeQueue, uint32_t queueIndex)
|
Sequence::Sequence(std::shared_ptr<vk::Device> device, std::shared_ptr<vk::Queue> computeQueue, uint32_t queueIndex)
|
||||||
{
|
{
|
||||||
SPDLOG_DEBUG("Kompute Sequence Constructor with existing device & queue");
|
SPDLOG_DEBUG("Kompute Sequence Constructor with existing device & queue");
|
||||||
|
|
||||||
|
|
@ -114,12 +114,10 @@ void Sequence::createCommandPool() {
|
||||||
|
|
||||||
this->mFreeCommandPool = true;
|
this->mFreeCommandPool = true;
|
||||||
|
|
||||||
spdlog::info("cmdpoolinfo");
|
|
||||||
vk::CommandPoolCreateInfo commandPoolInfo(vk::CommandPoolCreateFlags(), this->mQueueIndex);
|
vk::CommandPoolCreateInfo commandPoolInfo(vk::CommandPoolCreateFlags(), this->mQueueIndex);
|
||||||
spdlog::info("about to create");
|
this->mCommandPool = std::make_shared<vk::CommandPool>();
|
||||||
this->mCommandPool = new vk::CommandPool();
|
this->mDevice->createCommandPool(&commandPoolInfo, nullptr, this->mCommandPool.get());
|
||||||
this->mDevice->createCommandPool(&commandPoolInfo, nullptr, this->mCommandPool);
|
SPDLOG_DEBUG("Kompute Manager Command Pool Created");
|
||||||
spdlog::info("created");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sequence::createCommandBuffer() {
|
void Sequence::createCommandBuffer() {
|
||||||
|
|
@ -135,8 +133,9 @@ void Sequence::createCommandBuffer() {
|
||||||
|
|
||||||
vk::CommandBufferAllocateInfo commandBufferAllocateInfo(*this->mCommandPool, vk::CommandBufferLevel::ePrimary, 1);
|
vk::CommandBufferAllocateInfo commandBufferAllocateInfo(*this->mCommandPool, vk::CommandBufferLevel::ePrimary, 1);
|
||||||
|
|
||||||
this->mCommandBuffer = new vk::CommandBuffer();
|
this->mCommandBuffer = std::make_shared<vk::CommandBuffer>();
|
||||||
this->mDevice->allocateCommandBuffers(&commandBufferAllocateInfo, this->mCommandBuffer);
|
this->mDevice->allocateCommandBuffers(&commandBufferAllocateInfo, this->mCommandBuffer.get());
|
||||||
|
SPDLOG_DEBUG("Kompute Manager Command Buffer Created");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Sequence();
|
Sequence();
|
||||||
Sequence(vk::Device* device, vk::Queue* computeQueue, uint32_t queueIndex);
|
Sequence(std::shared_ptr<vk::Device> device, std::shared_ptr<vk::Queue> computeQueue, uint32_t queueIndex);
|
||||||
~Sequence();
|
~Sequence();
|
||||||
|
|
||||||
// Record command functions
|
// Record command functions
|
||||||
|
|
@ -36,12 +36,12 @@ public:
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vk::Device* mDevice = nullptr;
|
std::shared_ptr<vk::Device> mDevice = nullptr;
|
||||||
vk::Queue* mComputeQueue = nullptr;
|
std::shared_ptr<vk::Queue> mComputeQueue = nullptr;
|
||||||
uint32_t mQueueIndex = -1;
|
uint32_t mQueueIndex = -1;
|
||||||
vk::CommandPool* mCommandPool = nullptr;
|
std::shared_ptr<vk::CommandPool> mCommandPool = nullptr;
|
||||||
bool mFreeCommandPool = false;
|
bool mFreeCommandPool = false;
|
||||||
vk::CommandBuffer* mCommandBuffer = nullptr;
|
std::shared_ptr<vk::CommandBuffer> mCommandBuffer = nullptr;
|
||||||
bool mFreeCommandBuffer = false;
|
bool mFreeCommandBuffer = false;
|
||||||
|
|
||||||
// Record state
|
// Record state
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue