summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortylermurphy534 <tylermurphy534@gmail.com>2022-09-29 18:11:53 -0400
committertylermurphy534 <tylermurphy534@gmail.com>2022-09-29 18:11:53 -0400
commit915469e0f3467022f7fd3541350b04b8668d20f7 (patch)
tree19faf29890e88b8f7b21b401d8e1c5ddad9b0259
parenttemporray descriptor pool memory patch (diff)
downloadminecraftvulkan-915469e0f3467022f7fd3541350b04b8668d20f7.tar.gz
minecraftvulkan-915469e0f3467022f7fd3541350b04b8668d20f7.tar.bz2
minecraftvulkan-915469e0f3467022f7fd3541350b04b8668d20f7.zip
descriptor pool final fix
Diffstat (limited to '')
-rw-r--r--engine/xe_engine.cpp10
-rw-r--r--engine/xe_engine.hpp6
-rw-r--r--engine/xe_render_system.cpp14
-rw-r--r--engine/xe_render_system.hpp3
4 files changed, 16 insertions, 17 deletions
diff --git a/engine/xe_engine.cpp b/engine/xe_engine.cpp
index 5af5ef8..4f64bbf 100644
--- a/engine/xe_engine.cpp
+++ b/engine/xe_engine.cpp
@@ -13,7 +13,6 @@ Engine::Engine(int width, int height, std::string name, const char *icon) : xeWi
xeRenderer{xeWindow, xeDevice},
xeCamera{},
xeInput{xeWindow} {
- loadDescriptorPool();
alutInit(0, NULL);
std::cout << "Audio device: " << alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER) << "\n";
_instance = this;
@@ -25,15 +24,6 @@ Engine::~Engine() {
alutExit();
};
-void Engine::loadDescriptorPool() {
- xeDescriptorPool = DescriptorPool::Builder(xeDevice)
- .setMaxSets(SwapChain::MAX_FRAMES_IN_FLIGHT)
- .addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, SwapChain::MAX_FRAMES_IN_FLIGHT * 4)
- .addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, SwapChain::MAX_FRAMES_IN_FLIGHT * 4)
- .addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, SwapChain::MAX_FRAMES_IN_FLIGHT * 4)
- .build();
-}
-
bool Engine::poll() {
glfwPollEvents();
auto newTime = std::chrono::high_resolution_clock::now();
diff --git a/engine/xe_engine.hpp b/engine/xe_engine.hpp
index ae75afa..b181688 100644
--- a/engine/xe_engine.hpp
+++ b/engine/xe_engine.hpp
@@ -40,9 +40,7 @@ class Engine {
static Engine* getInstance();
private:
-
- void loadDescriptorPool();
-
+
Window xeWindow;
Device xeDevice;
Renderer xeRenderer;
@@ -54,8 +52,6 @@ class Engine {
float FOV = 50.f;
- std::unique_ptr<DescriptorPool> xeDescriptorPool;
-
friend class RenderSystem;
friend class Image;
friend class Model;
diff --git a/engine/xe_render_system.cpp b/engine/xe_render_system.cpp
index 1ceff78..770bfd5 100644
--- a/engine/xe_render_system.cpp
+++ b/engine/xe_render_system.cpp
@@ -15,11 +15,11 @@ RenderSystem::RenderSystem(
uint32_t vertexSize
) : xeDevice{xeEngine.xeDevice},
xeRenderer{xeEngine.xeRenderer},
- xeDescriptorPool{xeEngine.xeDescriptorPool},
pushCunstantDataSize{pushCunstantDataSize},
uniformBindings{uniformBindings},
imageBindings{imageBindings},
imageArrayBindings{imageArrayBindings} {
+ createDescriptorPool();
createDescriptorSetLayout();
createUniformBuffers();
createDescriptorSets();
@@ -31,6 +31,18 @@ RenderSystem::~RenderSystem() {
vkDestroyPipelineLayout(xeDevice.device(), pipelineLayout, nullptr);
};
+void RenderSystem::createDescriptorPool() {
+ DescriptorPool::Builder builder{xeDevice};
+ builder.setMaxSets(SwapChain::MAX_FRAMES_IN_FLIGHT);
+ builder.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, uniformBindings.size() * SwapChain::MAX_FRAMES_IN_FLIGHT);
+ uint32_t images = imageBindings.size();
+ for ( const auto &[binding, size]: imageArrayBindings) {
+ images += size.size();
+ }
+ builder.addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, images * SwapChain::MAX_FRAMES_IN_FLIGHT);
+ xeDescriptorPool = builder.build();
+}
+
void RenderSystem::createDescriptorSetLayout() {
DescriptorSetLayout::Builder builder{xeDevice};
diff --git a/engine/xe_render_system.hpp b/engine/xe_render_system.hpp
index e0915dd..bbf96f8 100644
--- a/engine/xe_render_system.hpp
+++ b/engine/xe_render_system.hpp
@@ -124,6 +124,7 @@ class RenderSystem {
private:
+ void createDescriptorPool();
void createDescriptorSetLayout();
void createUniformBuffers();
void createDescriptorSets();
@@ -148,7 +149,7 @@ class RenderSystem {
VkPipelineLayout pipelineLayout;
std::unique_ptr<Pipeline> xePipeline;
- std::unique_ptr<DescriptorPool> &xeDescriptorPool;
+ std::unique_ptr<DescriptorPool> xeDescriptorPool;
std::unique_ptr<DescriptorSetLayout> xeDescriptorSetLayout;
};