descriptor pool final fix

This commit is contained in:
tylermurphy534 2022-09-29 18:11:53 -04:00
parent 6afc638902
commit 915469e0f3
4 changed files with 16 additions and 17 deletions

View file

@ -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();

View file

@ -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;

View file

@ -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};

View file

@ -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;
};