Implemented KRSampler::destroy

This commit is contained in:
2022-08-30 00:30:22 -07:00
parent 6682cbdedd
commit 8594c7d4b1
2 changed files with 10 additions and 5 deletions

View File

@@ -101,6 +101,7 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo)
m_pBundleManager = std::make_unique<KRBundleManager>(*this); m_pBundleManager = std::make_unique<KRBundleManager>(*this);
m_deviceManager = std::make_unique<KRDeviceManager>(*this); m_deviceManager = std::make_unique<KRDeviceManager>(*this);
m_deviceManager->initialize();
m_surfaceManager = std::make_unique<KRSurfaceManager>(*this); m_surfaceManager = std::make_unique<KRSurfaceManager>(*this);
m_pPipelineManager = std::make_unique<KRPipelineManager>(*this); m_pPipelineManager = std::make_unique<KRPipelineManager>(*this);
m_pSamplerManager = std::make_unique<KRSamplerManager>(*this); m_pSamplerManager = std::make_unique<KRSamplerManager>(*this);
@@ -134,8 +135,6 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo)
#error Unsupported #error Unsupported
#endif #endif
m_deviceManager->initialize();
m_presentationThread->start(); m_presentationThread->start();
m_streamerThread->start(); m_streamerThread->start();
} }

View File

@@ -47,7 +47,7 @@ KRSampler::~KRSampler()
bool KRSampler::createSamplers(const SamplerInfo& info) bool KRSampler::createSamplers(const SamplerInfo& info)
{ {
bool success = true; bool success = true;
m_samplers.clear(); destroy();
KRDeviceManager* deviceManager = getContext().getDeviceManager(); KRDeviceManager* deviceManager = getContext().getDeviceManager();
int iAllocation = 0; int iAllocation = 0;
@@ -82,5 +82,11 @@ VkSampler KRSampler::getSampler(KrDeviceHandle& handle)
void KRSampler::destroy() void KRSampler::destroy()
{ {
for (std::pair<KrDeviceHandle, VkSampler> sampler : m_samplers) {
} std::unique_ptr<KRDevice> &device = getContext().getDeviceManager()->getDevice(sampler.first);
if (device) {
vkDestroySampler(device->m_logicalDevice, sampler.second, nullptr);
}
}
m_samplers.clear();
}