From f9f02569d6a0726946ecdfe3c0e109748f23c044 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 15 Apr 2026 13:22:30 -0700 Subject: [PATCH] fix(vulkan): re-allocate megaBoneSet_ after descriptor pool reset and fix PlayerFrame ImGui crash Re-allocate megaBoneSet_[0..1] in M2Renderer::clear() after vkResetDescriptorPool invalidates all sets from boneDescPool_. Stale handles were bound to command buffers during rendering, causing cascading validation errors. Also add ImGui::Dummy() after SetCursorScreenPos in the shaman totem bar to satisfy ImGui's window boundary extension assertion. --- src/rendering/m2_renderer_instance.cpp | 17 +++++++++++++++++ src/ui/game_screen_frames.cpp | 1 + 2 files changed, 18 insertions(+) diff --git a/src/rendering/m2_renderer_instance.cpp b/src/rendering/m2_renderer_instance.cpp index 177afaee..2e2a6c0d 100644 --- a/src/rendering/m2_renderer_instance.cpp +++ b/src/rendering/m2_renderer_instance.cpp @@ -330,6 +330,23 @@ void M2Renderer::clear() { write.pBufferInfo = &bufInfo; vkUpdateDescriptorSets(device, 1, &write, 0, nullptr); } + // Re-allocate mega bone sets (invalidated by pool reset) + for (int i = 0; i < 2; i++) { + megaBoneSet_[i] = allocateBoneSet(); + if (megaBoneSet_[i] && megaBoneBuffer_[i]) { + VkDescriptorBufferInfo mbInfo{}; + mbInfo.buffer = megaBoneBuffer_[i]; + mbInfo.offset = 0; + mbInfo.range = MEGA_BONE_MAX_INSTANCES * MAX_BONES_PER_INSTANCE * sizeof(glm::mat4); + VkWriteDescriptorSet mw{VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET}; + mw.dstSet = megaBoneSet_[i]; + mw.dstBinding = 0; + mw.descriptorCount = 1; + mw.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; + mw.pBufferInfo = &mbInfo; + vkUpdateDescriptorSets(device, 1, &mw, 0, nullptr); + } + } } } models.clear(); diff --git a/src/ui/game_screen_frames.cpp b/src/ui/game_screen_frames.cpp index 867158f3..c8023c9f 100644 --- a/src/ui/game_screen_frames.cpp +++ b/src/ui/game_screen_frames.cpp @@ -464,6 +464,7 @@ void GameScreen::renderPlayerFrame(game::GameHandler& gameHandler) { } } ImGui::SetCursorScreenPos(ImVec2(cursor.x, cursor.y + slotH + 2.0f)); + ImGui::Dummy(ImVec2(totalW, 0.0f)); } }