diff --git a/engine/xe_descriptors.cpp b/engine/xe_descriptors.cpp index 00e627a..2625222 100644 --- a/engine/xe_descriptors.cpp +++ b/engine/xe_descriptors.cpp @@ -104,7 +104,11 @@ bool DescriptorPool::allocateDescriptor( allocInfo.pSetLayouts = &descriptorSetLayout; allocInfo.descriptorSetCount = 1; - if (vkAllocateDescriptorSets(xeDevice.device(), &allocInfo, &descriptor) != VK_SUCCESS) { + VkResult result = vkAllocateDescriptorSets(xeDevice.device(), &allocInfo, &descriptor); + if (result != VK_SUCCESS) { + if(result == VK_ERROR_OUT_OF_POOL_MEMORY) { + std::cout << "[ERROR] failed to allocate descriptor set, descriptor pool out of memory" << "\n"; + } return false; } return true; @@ -173,15 +177,18 @@ DescriptorWriter &DescriptorWriter::writeImageArray( auto &bindingDescription = setLayout.bindings[binding]; - VkWriteDescriptorSet write{}; - write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; - write.descriptorType = bindingDescription.descriptorType; - write.dstBinding = binding; - write.dstArrayElement = 0; - write.pImageInfo = imageInfos->data(); - write.descriptorCount = imageInfos->size(); + for(auto &imageInfo : *imageInfos) { + VkWriteDescriptorSet write{}; + write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; + write.descriptorType = bindingDescription.descriptorType; + write.dstBinding = binding; + write.dstArrayElement = 0; + write.pImageInfo = imageInfos->data(); + write.descriptorCount = imageInfos->size(); + write.pBufferInfo = 0; - writes.push_back(write); + writes.push_back(write); + } return *this; } diff --git a/engine/xe_engine.cpp b/engine/xe_engine.cpp index 70dda64..5af5ef8 100644 --- a/engine/xe_engine.cpp +++ b/engine/xe_engine.cpp @@ -28,9 +28,9 @@ Engine::~Engine() { void Engine::loadDescriptorPool() { xeDescriptorPool = DescriptorPool::Builder(xeDevice) .setMaxSets(SwapChain::MAX_FRAMES_IN_FLIGHT) - .addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, SwapChain::MAX_FRAMES_IN_FLIGHT) - .addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, SwapChain::MAX_FRAMES_IN_FLIGHT) - .addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 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(); }