From 42e8365751641c1577365d5125c9adab3168a558 Mon Sep 17 00:00:00 2001 From: kearwood Date: Thu, 18 Aug 2022 17:57:11 -0700 Subject: [PATCH] Added KRSampler and KRSamplerManager classes. Marked stub functions to be implemented. --- kraken/CMakeLists.txt | 2 ++ kraken/KRContext.cpp | 6 ++++ kraken/KRContext.h | 4 +++ kraken/KRSampler.cpp | 48 +++++++++++++++++++++++++++++ kraken/KRSampler.h | 57 +++++++++++++++++++++++++++++++++++ kraken/KRSamplerManager.cpp | 56 ++++++++++++++++++++++++++++++++++ kraken/KRSamplerManager.h | 60 +++++++++++++++++++++++++++++++++++++ 7 files changed, 233 insertions(+) create mode 100644 kraken/KRSampler.cpp create mode 100644 kraken/KRSampler.h create mode 100644 kraken/KRSamplerManager.cpp create mode 100644 kraken/KRSamplerManager.h diff --git a/kraken/CMakeLists.txt b/kraken/CMakeLists.txt index aaa8081..73ffa12 100644 --- a/kraken/CMakeLists.txt +++ b/kraken/CMakeLists.txt @@ -81,6 +81,8 @@ add_sources(KRSource.cpp) add_sources(KRSourceManager.cpp) add_sources(KRPipeline.cpp) add_sources(KRPipelineManager.cpp) +add_sources(KRSampler.cpp) +add_sources(KRSamplerManager.cpp) add_sources(KRSpotLight.cpp) add_sources(KRSprite.cpp) add_sources(KRTexture.cpp) diff --git a/kraken/KRContext.cpp b/kraken/KRContext.cpp index 6c02ef3..8878944 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_pPipelineManager = std::make_unique(*this); + m_pSamplerManager = std::make_unique(*this); m_pTextureManager = std::make_unique(*this); m_pMaterialManager = std::make_unique(*this, m_pTextureManager.get(), m_pPipelineManager.get()); m_pMeshManager = std::make_unique(*this); @@ -148,6 +149,7 @@ KRContext::~KRContext() m_pTextureManager->destroy(); m_pTextureManager.reset(); m_pPipelineManager.reset(); + m_pSamplerManager.reset(); m_pAnimationManager.reset(); m_pAnimationCurveManager.reset(); m_pSoundManager->destroy(); @@ -214,6 +216,10 @@ KRPipelineManager* KRContext::getPipelineManager() { return m_pPipelineManager.get(); } +KRSamplerManager* KRContext::getSamplerManager() +{ + return m_pSamplerManager.get(); +} KRMeshManager* KRContext::getMeshManager() { return m_pMeshManager.get(); diff --git a/kraken/KRContext.h b/kraken/KRContext.h index 9157fed..5b8e86f 100755 --- a/kraken/KRContext.h +++ b/kraken/KRContext.h @@ -37,6 +37,7 @@ #include "KRTextureManager.h" #include "KRMaterialManager.h" #include "KRPipelineManager.h" +#include "KRSamplerManager.h" #include "KRMeshManager.h" #include "KRAnimationManager.h" #include "KRAnimationCurveManager.h" @@ -53,6 +54,7 @@ class KRPresentationThread; class KRStreamerThread; class KRDeviceManager; class KRSurfaceManager; +class KRSamplerManager; class KRContext { @@ -106,6 +108,7 @@ public: KRTextureManager* getTextureManager(); KRMaterialManager* getMaterialManager(); KRPipelineManager* getPipelineManager(); + KRSamplerManager* getSamplerManager(); KRMeshManager* getMeshManager(); KRAnimationManager* getAnimationManager(); KRAnimationCurveManager* getAnimationCurveManager(); @@ -158,6 +161,7 @@ private: std::unique_ptr m_pTextureManager; std::unique_ptr m_pMaterialManager; std::unique_ptr m_pPipelineManager; + std::unique_ptr m_pSamplerManager; std::unique_ptr m_pMeshManager; std::unique_ptr m_pAnimationManager; std::unique_ptr m_pAnimationCurveManager; diff --git a/kraken/KRSampler.cpp b/kraken/KRSampler.cpp new file mode 100644 index 0000000..703ad3c --- /dev/null +++ b/kraken/KRSampler.cpp @@ -0,0 +1,48 @@ +// +// KRSampler.cpp +// Kraken Engine +// +// Copyright 2022 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + +#include "KRSampler.h" + +KRSampler::KRSampler(KRContext& context, KRSurface& surface, const SamplerInfo& info) + : KRContextObject(context) +{ + // TODO - Implement stub function +} + +KRSampler::~KRSampler() +{ + // TODO - Implement stub function +} + +VkSampler& KRSampler::getSampler() +{ + return m_sampler; +} diff --git a/kraken/KRSampler.h b/kraken/KRSampler.h new file mode 100644 index 0000000..0c2f574 --- /dev/null +++ b/kraken/KRSampler.h @@ -0,0 +1,57 @@ +// +// KRSampler.h +// Kraken Engine +// +// Copyright 2022 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + + +#pragma once + +#include "KREngine-common.h" +#include "KRContextObject.h" +#include "KRSurface.h" + +class SamplerInfo +{ +public: + VkSamplerCreateInfo createInfo; +}; + +class KRSampler : public KRContextObject +{ +public: + + KRSampler(KRContext& context, KRSurface& surface, const SamplerInfo& info); + virtual ~KRSampler(); + + VkSampler& getSampler(); + +private: + + VkSampler m_sampler; +}; diff --git a/kraken/KRSamplerManager.cpp b/kraken/KRSamplerManager.cpp new file mode 100644 index 0000000..3722e12 --- /dev/null +++ b/kraken/KRSamplerManager.cpp @@ -0,0 +1,56 @@ +// +// KRSamplerManager.cpp +// Kraken Engine +// +// Copyright 2022 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + +#include "KREngine-common.h" + +#include "KRSamplerManager.h" + +KRSamplerManager::KRSamplerManager(KRContext& context) + : KRContextObject(context) +{ + // TODO - Implement stub function +} + +KRSamplerManager::~KRSamplerManager() +{ + // TODO - Implement stub function +} + +KRSampler* KRSamplerManager::getSampler(KRSurface& surface, const SamplerInfo& info) +{ + // TODO - Implement stub function + return nullptr; +} + +size_t KRSamplerManager::getSamplerHandlesUsed() +{ + // TODO - Implement stub function +} diff --git a/kraken/KRSamplerManager.h b/kraken/KRSamplerManager.h new file mode 100644 index 0000000..e6aa03e --- /dev/null +++ b/kraken/KRSamplerManager.h @@ -0,0 +1,60 @@ +// +// KRSamplerManager.h +// Kraken Engine +// +// Copyright 2022 Kearwood Gilbert. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other materials +// provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// The views and conclusions contained in the software and documentation are those of the +// authors and should not be interpreted as representing official policies, either expressed +// or implied, of Kearwood Gilbert. +// + +#pragma once + +#include "KREngine-common.h" + +#include "KRDataBlock.h" + +using std::map; +using std::vector; + +#include "KRSampler.h" + +class KRSampler; +class SamplerInfo; + +class KRSamplerManager : public KRContextObject +{ +public: + + KRSamplerManager(KRContext& context); + virtual ~KRSamplerManager(); + + KRSampler* getSampler(KRSurface& surface, const SamplerInfo& info); + + size_t getSamplerHandlesUsed(); + +private: + typedef std::map >, KRSampler*> SamplerMap; + SamplerMap m_samplers; +};