temporray descriptor pool memory patch

This commit is contained in:
Tyler Murphy 2022-09-29 15:20:36 -04:00
parent 00d822fb3d
commit 6afc638902
2 changed files with 19 additions and 12 deletions

View file

@ -104,7 +104,11 @@ bool DescriptorPool::allocateDescriptor(
allocInfo.pSetLayouts = &descriptorSetLayout; allocInfo.pSetLayouts = &descriptorSetLayout;
allocInfo.descriptorSetCount = 1; 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 false;
} }
return true; return true;
@ -173,15 +177,18 @@ DescriptorWriter &DescriptorWriter::writeImageArray(
auto &bindingDescription = setLayout.bindings[binding]; auto &bindingDescription = setLayout.bindings[binding];
VkWriteDescriptorSet write{}; for(auto &imageInfo : *imageInfos) {
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; VkWriteDescriptorSet write{};
write.descriptorType = bindingDescription.descriptorType; write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
write.dstBinding = binding; write.descriptorType = bindingDescription.descriptorType;
write.dstArrayElement = 0; write.dstBinding = binding;
write.pImageInfo = imageInfos->data(); write.dstArrayElement = 0;
write.descriptorCount = imageInfos->size(); write.pImageInfo = imageInfos->data();
write.descriptorCount = imageInfos->size();
write.pBufferInfo = 0;
writes.push_back(write); writes.push_back(write);
}
return *this; return *this;
} }

View file

@ -28,9 +28,9 @@ Engine::~Engine() {
void Engine::loadDescriptorPool() { void Engine::loadDescriptorPool() {
xeDescriptorPool = DescriptorPool::Builder(xeDevice) xeDescriptorPool = DescriptorPool::Builder(xeDevice)
.setMaxSets(SwapChain::MAX_FRAMES_IN_FLIGHT) .setMaxSets(SwapChain::MAX_FRAMES_IN_FLIGHT)
.addPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 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) .addPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, SwapChain::MAX_FRAMES_IN_FLIGHT * 4)
.addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, SwapChain::MAX_FRAMES_IN_FLIGHT) .addPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, SwapChain::MAX_FRAMES_IN_FLIGHT * 4)
.build(); .build();
} }