diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-01-28 10:52:30 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-01-28 10:52:30 -0500 |
| commit | 4c241454f5698de3e6a5be07feb22ce930d63002 (patch) | |
| tree | e13993b18f6f260dbea9c779f77ecd27364b388a /src/entities.cpp | |
| parent | 9702d38dea5e09a2813e54e05f5ebb2c3e746b10 (diff) | |
pke: remove MAX_FRAMES_IN_FLIGHT
Diffstat (limited to 'src/entities.cpp')
| -rw-r--r-- | src/entities.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/entities.cpp b/src/entities.cpp index 123c095..ae9e8b4 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -592,15 +592,15 @@ void EntityType_LoadTexture(EntityType_LoadHelperStruct &helper, const int64_t i VkDescriptorPoolSize descriptorPoolSizes[2]; descriptorPoolSizes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - descriptorPoolSizes[0].descriptorCount = MAX_FRAMES_IN_FLIGHT; + descriptorPoolSizes[0].descriptorCount = swapchainLength; descriptorPoolSizes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - descriptorPoolSizes[1].descriptorCount = MAX_FRAMES_IN_FLIGHT; + descriptorPoolSizes[1].descriptorCount = swapchainLength; VkDescriptorPoolCreateInfo vkDescriptorPoolCreateInfo; vkDescriptorPoolCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; vkDescriptorPoolCreateInfo.pNext = nullptr; vkDescriptorPoolCreateInfo.flags = 0; - vkDescriptorPoolCreateInfo.maxSets = MAX_FRAMES_IN_FLIGHT; + vkDescriptorPoolCreateInfo.maxSets = swapchainLength; vkDescriptorPoolCreateInfo.poolSizeCount = (uint32_t)2; vkDescriptorPoolCreateInfo.pPoolSizes = descriptorPoolSizes; @@ -608,26 +608,28 @@ void EntityType_LoadTexture(EntityType_LoadHelperStruct &helper, const int64_t i auto vkResult = vkCreateDescriptorPool(vkDevice, &vkDescriptorPoolCreateInfo, vkAllocator, &etdHelper.etd->vkDescriptorPool); assert(vkResult == VK_SUCCESS); - VkDescriptorSetLayout descriptorSets[MAX_FRAMES_IN_FLIGHT]; - for (long i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) { + VkDescriptorSetLayout *descriptorSets = pk_new<VkDescriptorSetLayout>(swapchainLength); + for (long i = 0; i < swapchainLength; ++i) { descriptorSets[i] = pkePipelines.descr_layouts.named.texture; } VkDescriptorSetAllocateInfo vkDescriptorSetAllocateInfo; vkDescriptorSetAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; vkDescriptorSetAllocateInfo.pNext = nullptr; vkDescriptorSetAllocateInfo.descriptorPool = etdHelper.etd->vkDescriptorPool; - vkDescriptorSetAllocateInfo.descriptorSetCount = MAX_FRAMES_IN_FLIGHT; + vkDescriptorSetAllocateInfo.descriptorSetCount = swapchainLength; vkDescriptorSetAllocateInfo.pSetLayouts = descriptorSets; - etdHelper.etd->grBinds->vkDescriptorSets = pk_new<VkDescriptorSet>(MAX_FRAMES_IN_FLIGHT); - for (long i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) { + etdHelper.etd->grBinds->vkDescriptorSets = pk_new<VkDescriptorSet>(swapchainLength, MemBkt_Vulkan); + for (long i = 0; i < swapchainLength; ++i) { etdHelper.etd->grBinds->vkDescriptorSets[i] = VkDescriptorSet{}; } vkResult = vkAllocateDescriptorSets(vkDevice, &vkDescriptorSetAllocateInfo, etdHelper.etd->grBinds->vkDescriptorSets); + pk_delete<VkDescriptorSetLayout>(descriptorSets, swapchainLength); + // descriptorSets = CAFE_BABE(VkDescriptorSetLayout); assert(vkResult == VK_SUCCESS); - VkWriteDescriptorSet writeDescriptorSets[2 * MAX_FRAMES_IN_FLIGHT]; - for (long i = 0; i < 2 * MAX_FRAMES_IN_FLIGHT; ++i) { + VkWriteDescriptorSet *writeDescriptorSets = pk_new<VkWriteDescriptorSet>(2 * swapchainLength); + for (long i = 0; i < 2 * swapchainLength; ++i) { writeDescriptorSets[i].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; writeDescriptorSets[i].pNext = nullptr; writeDescriptorSets[i].dstSet = nullptr; @@ -646,9 +648,9 @@ void EntityType_LoadTexture(EntityType_LoadHelperStruct &helper, const int64_t i textureDescriptorInfo.imageView = etdHelper.etd->textureImageView; textureDescriptorInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - VkDescriptorBufferInfo vkDescriptorBufferInfo[MAX_FRAMES_IN_FLIGHT]; + VkDescriptorBufferInfo *vkDescriptorBufferInfo = pk_new<VkDescriptorBufferInfo>(swapchainLength); - for (long i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) { + for (long i = 0; i < swapchainLength; ++i) { vkDescriptorBufferInfo[i].buffer = UniformBuffers[i]; vkDescriptorBufferInfo[i].offset = 0; vkDescriptorBufferInfo[i].range = sizeof(UniformBufferObject); @@ -663,7 +665,9 @@ void EntityType_LoadTexture(EntityType_LoadHelperStruct &helper, const int64_t i writeDescriptorSets[samplerIndex].dstSet = etdHelper.etd->grBinds->vkDescriptorSets[i]; } - vkUpdateDescriptorSets(vkDevice, 2 * MAX_FRAMES_IN_FLIGHT, writeDescriptorSets, 0, nullptr); + vkUpdateDescriptorSets(vkDevice, 2 * swapchainLength, writeDescriptorSets, 0, nullptr); + pk_delete<VkDescriptorBufferInfo>(vkDescriptorBufferInfo, swapchainLength); + pk_delete<VkWriteDescriptorSet>(writeDescriptorSets, 2 * swapchainLength); } void EntityType_LoadMesh(EntityType_LoadHelperStruct &helper, const int64_t meshIndex) { @@ -1346,7 +1350,6 @@ EntityType *EntityType_GetEntityTypes(pk_handle_bucket_index_T bucketIndex, pk_h } void EntityType_Teardown() { - for (pk_handle_bucket_index_T b = 0; b <= EntityType_BC.pkeHandle.bucketIndex; ++b) { auto &bkt = EntityType_BC.buckets[b]; long itemCount = EntityType_BC.pkeHandle.bucketIndex == b ? EntityType_BC.pkeHandle.itemIndex : EntityType_BC.limits.itemIndex; |
