From 8594c7d4b1dee4c8598b151a604bc916c36c36e1 Mon Sep 17 00:00:00 2001 From: kearwood Date: Tue, 30 Aug 2022 00:30:22 -0700 Subject: [PATCH] Implemented KRSampler::destroy --- kraken/KRContext.cpp | 3 +-- kraken/KRSampler.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/kraken/KRContext.cpp b/kraken/KRContext.cpp index 3009bd2..4c6366d 100755 --- a/kraken/KRContext.cpp +++ b/kraken/KRContext.cpp @@ -101,6 +101,7 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo) m_pBundleManager = std::make_unique(*this); m_deviceManager = std::make_unique(*this); + m_deviceManager->initialize(); m_surfaceManager = std::make_unique(*this); m_pPipelineManager = std::make_unique(*this); m_pSamplerManager = std::make_unique(*this); @@ -134,8 +135,6 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo) #error Unsupported #endif - m_deviceManager->initialize(); - m_presentationThread->start(); m_streamerThread->start(); } diff --git a/kraken/KRSampler.cpp b/kraken/KRSampler.cpp index 1031357..de9000f 100644 --- a/kraken/KRSampler.cpp +++ b/kraken/KRSampler.cpp @@ -47,7 +47,7 @@ KRSampler::~KRSampler() bool KRSampler::createSamplers(const SamplerInfo& info) { bool success = true; - m_samplers.clear(); + destroy(); KRDeviceManager* deviceManager = getContext().getDeviceManager(); int iAllocation = 0; @@ -82,5 +82,11 @@ VkSampler KRSampler::getSampler(KrDeviceHandle& handle) void KRSampler::destroy() { - -} \ No newline at end of file + for (std::pair sampler : m_samplers) { + std::unique_ptr &device = getContext().getDeviceManager()->getDevice(sampler.first); + if (device) { + vkDestroySampler(device->m_logicalDevice, sampler.second, nullptr); + } + } + m_samplers.clear(); +}