Implemented KRSampler::createSamplers
This commit is contained in:
@@ -100,6 +100,8 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo)
|
|||||||
m_absolute_time = 0.0f;
|
m_absolute_time = 0.0f;
|
||||||
|
|
||||||
m_pBundleManager = std::make_unique<KRBundleManager>(*this);
|
m_pBundleManager = std::make_unique<KRBundleManager>(*this);
|
||||||
|
m_deviceManager = std::make_unique<KRDeviceManager>(*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);
|
||||||
m_pSamplerManager->init();
|
m_pSamplerManager->init();
|
||||||
@@ -114,8 +116,6 @@ KRContext::KRContext(const KrInitializeInfo* initializeInfo)
|
|||||||
m_pUnknownManager = std::make_unique<KRUnknownManager>(*this);
|
m_pUnknownManager = std::make_unique<KRUnknownManager>(*this);
|
||||||
m_pShaderManager = std::make_unique<KRShaderManager>(*this);
|
m_pShaderManager = std::make_unique<KRShaderManager>(*this);
|
||||||
m_pSourceManager = std::make_unique<KRSourceManager>(*this);
|
m_pSourceManager = std::make_unique<KRSourceManager>(*this);
|
||||||
m_deviceManager = std::make_unique<KRDeviceManager>(*this);
|
|
||||||
m_surfaceManager = std::make_unique<KRSurfaceManager>(*this);
|
|
||||||
m_streamingEnabled = true;
|
m_streamingEnabled = true;
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
|||||||
@@ -31,8 +31,9 @@
|
|||||||
|
|
||||||
#include "KRSampler.h"
|
#include "KRSampler.h"
|
||||||
#include "KRSamplerManager.h"
|
#include "KRSamplerManager.h"
|
||||||
|
#include "KRDeviceManager.h"
|
||||||
|
|
||||||
KRSampler::KRSampler(KRContext& context, const SamplerInfo& info)
|
KRSampler::KRSampler(KRContext& context)
|
||||||
: KRContextObject(context)
|
: KRContextObject(context)
|
||||||
{
|
{
|
||||||
// TODO - Implement stub function
|
// TODO - Implement stub function
|
||||||
@@ -40,7 +41,31 @@ KRSampler::KRSampler(KRContext& context, const SamplerInfo& info)
|
|||||||
|
|
||||||
KRSampler::~KRSampler()
|
KRSampler::~KRSampler()
|
||||||
{
|
{
|
||||||
// TODO - Implement stub function
|
destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KRSampler::createSamplers(const SamplerInfo& info)
|
||||||
|
{
|
||||||
|
bool success = true;
|
||||||
|
m_samplers.clear();
|
||||||
|
KRDeviceManager* deviceManager = getContext().getDeviceManager();
|
||||||
|
int iAllocation = 0;
|
||||||
|
|
||||||
|
for (auto deviceItr = deviceManager->getDevices().begin(); deviceItr != deviceManager->getDevices().end() && iAllocation < KRENGINE_MAX_GPU_COUNT; deviceItr++, iAllocation++) {
|
||||||
|
KRDevice& device = *(*deviceItr).second;
|
||||||
|
VkSampler sampler = VK_NULL_HANDLE;
|
||||||
|
if (vkCreateSampler(device.m_logicalDevice, &info.createInfo, nullptr, &sampler) != VK_SUCCESS) {
|
||||||
|
success = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
m_samplers.push_back(std::make_pair(deviceItr->first, sampler));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkSampler KRSampler::getSampler(KrDeviceHandle& handle)
|
VkSampler KRSampler::getSampler(KrDeviceHandle& handle)
|
||||||
@@ -54,3 +79,8 @@ VkSampler KRSampler::getSampler(KrDeviceHandle& handle)
|
|||||||
assert(false);
|
assert(false);
|
||||||
return VK_NULL_HANDLE;
|
return VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KRSampler::destroy()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -41,11 +41,12 @@ class KRSampler : public KRContextObject
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
KRSampler(KRContext& context, const SamplerInfo& info);
|
KRSampler(KRContext& context);
|
||||||
virtual ~KRSampler();
|
virtual ~KRSampler();
|
||||||
|
|
||||||
VkSampler getSampler(KrDeviceHandle &handle);
|
VkSampler getSampler(KrDeviceHandle &handle);
|
||||||
|
bool createSamplers(const SamplerInfo& info);
|
||||||
|
void destroy();
|
||||||
private:
|
private:
|
||||||
typedef std::vector<std::pair<KrDeviceHandle, VkSampler>> SamplerSet;
|
typedef std::vector<std::pair<KrDeviceHandle, VkSampler>> SamplerSet;
|
||||||
SamplerSet m_samplers;
|
SamplerSet m_samplers;
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ KRSampler* KRSamplerManager::getSampler(const SamplerInfo& info)
|
|||||||
if (itr != m_samplers.end()) {
|
if (itr != m_samplers.end()) {
|
||||||
return itr->second;
|
return itr->second;
|
||||||
}
|
}
|
||||||
KRSampler* sampler = new KRSampler(getContext(), info);
|
KRSampler* sampler = new KRSampler(getContext());
|
||||||
|
sampler->createSamplers(info);
|
||||||
m_samplers[info] = sampler;
|
m_samplers[info] = sampler;
|
||||||
return sampler;
|
return sampler;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user