diff --git a/Src/Client/ServerSession.cpp b/Src/Client/ServerSession.cpp index d0becc9..c948c33 100644 --- a/Src/Client/ServerSession.cpp +++ b/Src/Client/ServerSession.cpp @@ -83,6 +83,7 @@ coro<> ServerSession::asyncDestructor() { using namespace TOS; ServerSession::~ServerSession() { + LOG.info() << "Destroyed"; } coro<> ServerSession::asyncAuthorizeWithServer(tcp::socket &socket, const std::string username, const std::string token, int a_ar_r, std::function onProgress) { diff --git a/Src/Client/Vulkan/AtlasPipeline/SharedStagingBuffer.hpp b/Src/Client/Vulkan/AtlasPipeline/SharedStagingBuffer.hpp index 3952547..fd5eb78 100644 --- a/Src/Client/Vulkan/AtlasPipeline/SharedStagingBuffer.hpp +++ b/Src/Client/Vulkan/AtlasPipeline/SharedStagingBuffer.hpp @@ -16,7 +16,7 @@ class SharedStagingBuffer { public: - static constexpr VkDeviceSize kDefaultSize = 64ull * 1024ull * 1024ull; + static constexpr VkDeviceSize kDefaultSize = 18ull * 1024ull * 1024ull; SharedStagingBuffer(VkDevice device, VkPhysicalDevice physicalDevice, diff --git a/Src/Client/Vulkan/Vulkan.cpp b/Src/Client/Vulkan/Vulkan.cpp index e036594..c8c2744 100644 --- a/Src/Client/Vulkan/Vulkan.cpp +++ b/Src/Client/Vulkan/Vulkan.cpp @@ -29,6 +29,7 @@ #include #include "VulkanRenderSession.hpp" #include +#include extern void LoadSymbolsVulkan(TOS::DynamicLibrary &library); @@ -222,6 +223,8 @@ void Vulkan::run() } catch(const std::exception &exc) { LOG.error() << "Game.Session->shutdown: " << exc.what(); } + + Game.Session = nullptr; } if(!NeedShutdown && glfwWindowShouldClose(Graphics.Window)) { @@ -240,11 +243,12 @@ void Vulkan::run() try { if(Game.Session) Game.Session->shutdown(EnumDisconnect::ByInterface); - Game.Session = nullptr; } catch(const std::exception &exc) { LOG.error() << "Game.Session->shutdown: " << exc.what(); } + Game.Session = nullptr; + try { if(Game.Server) Game.Server->GS.shutdown("Завершение работы из-за остановки клиента"); @@ -2254,6 +2258,10 @@ void Vulkan::gui_MainMenu() { } } + if(ImGui::Button("Memory trim")) { + malloc_trim(0); + } + if(ConnectionProgress.InProgress) { if(ImGui::Button("Отмена")) ConnectionProgress.Cancel = true; @@ -2305,6 +2313,10 @@ void Vulkan::gui_ConnectedToServer() { Game.ImGuiInterfaces.pop_back(); } + if(ImGui::Button("Memory trim")) { + malloc_trim(0); + } + ImGui::End(); if(Game.Выйти) diff --git a/Src/Client/Vulkan/Vulkan.hpp b/Src/Client/Vulkan/Vulkan.hpp index b86e95c..09b8221 100644 --- a/Src/Client/Vulkan/Vulkan.hpp +++ b/Src/Client/Vulkan/Vulkan.hpp @@ -48,7 +48,7 @@ struct DeviceId { struct Settings { DeviceId DeviceMain; uint32_t QueueGraphics = -1, QueueSurface = -1; - bool Debug = true; + bool Debug = false; bool isValid() { diff --git a/Src/Client/Vulkan/VulkanRenderSession.cpp b/Src/Client/Vulkan/VulkanRenderSession.cpp index 4bddccd..e194dbf 100644 --- a/Src/Client/Vulkan/VulkanRenderSession.cpp +++ b/Src/Client/Vulkan/VulkanRenderSession.cpp @@ -317,7 +317,7 @@ void ChunkMeshGenerator::run(uint8_t id) { } else { for(int y = 0; y < 16; y++) for(int x = 0; x < 16; x++) - fullNodes[x+0][y+1][0] = 0; + fullNodes[x+1][y+1][0] = 0; } } else goto end; @@ -875,6 +875,7 @@ void ChunkPreparator::tickSync(const TickSyncData& data) { // Получаем готовые чанки { std::vector chunks = std::move(*CMG.Output.lock()); + uint8_t frameRetirement = (FrameRoulette+FRAME_COUNT_RESOURCE_LATENCY) % FRAME_COUNT_RESOURCE_LATENCY; for(auto& chunk : chunks) { auto iterWorld = Requests.find(chunk.WId); if(iterWorld == Requests.end()) @@ -889,6 +890,14 @@ void ChunkPreparator::tickSync(const TickSyncData& data) { // Чанк ожидаем auto& rChunk = ChunksMesh[chunk.WId][chunk.Pos >> 2][Pos::bvec4u(chunk.Pos & 0x3).pack()]; + if(rChunk.VoxelPointer) + VPV_ToFree[frameRetirement].emplace_back(std::move(rChunk.VoxelPointer)); + if(rChunk.NodePointer) { + VPN_ToFree[frameRetirement].emplace_back(std::move(rChunk.NodePointer), std::move(rChunk.NodeIndexes)); + } + rChunk.VoxelPointer = {}; + rChunk.NodePointer = {}; + rChunk.NodeIndexes = {}; rChunk.Voxels = std::move(chunk.VoxelDefines); if(!chunk.VoxelVertexs.empty()) rChunk.VoxelPointer = VertexPool_Voxels.pushVertexs(std::move(chunk.VoxelVertexs)); diff --git a/Src/Client/Vulkan/VulkanRenderSession.hpp b/Src/Client/Vulkan/VulkanRenderSession.hpp index 713bb82..19b5819 100644 --- a/Src/Client/Vulkan/VulkanRenderSession.hpp +++ b/Src/Client/Vulkan/VulkanRenderSession.hpp @@ -224,7 +224,8 @@ public: } cb.Trs.apply(v); - model.Vertecies[params.Cullface].append_range(v); + const EnumFace cullKey = (params.Cullface == EnumFace::None) ? face : params.Cullface; + model.Vertecies[cullKey].append_range(v); } }