From a27f055af867ed6d68271d0e80239d72762cc37e Mon Sep 17 00:00:00 2001 From: DrSocalkwe3n Date: Mon, 10 Feb 2025 18:46:03 +0600 Subject: [PATCH] ParsedPacket --- Src/Client/Abstract.hpp | 2 ++ Src/Client/ServerSession.cpp | 27 +++++++++++++++++++++++++++ Src/Client/ServerSession.hpp | 18 +++++++++++++++++- Src/Client/Vulkan/Vulkan.cpp | 19 ------------------- 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/Src/Client/Abstract.hpp b/Src/Client/Abstract.hpp index 644e71c..b0e522b 100644 --- a/Src/Client/Abstract.hpp +++ b/Src/Client/Abstract.hpp @@ -128,6 +128,8 @@ public: } Registry; virtual ~IServerSession(); + + virtual void atFreeDrawTime() = 0; }; diff --git a/Src/Client/ServerSession.cpp b/Src/Client/ServerSession.cpp index 8e98ea9..041aba0 100644 --- a/Src/Client/ServerSession.cpp +++ b/Src/Client/ServerSession.cpp @@ -1,5 +1,6 @@ #include "ServerSession.hpp" #include "Client/Abstract.hpp" +#include "Common/Abstract.hpp" #include "Common/Net.hpp" #include #include @@ -13,6 +14,18 @@ namespace LV::Client { +ParsedPacket::~ParsedPacket() = default; + +struct PP_Content_ChunkVoxels : public ParsedPacket { + WorldId_c Id; + Pos::GlobalChunk Pos; + std::vector Cubes; + + PP_Content_ChunkVoxels(ToClient::L1 l1, uint8_t l2, WorldId_c id, Pos::GlobalChunk pos, std::vector &&cubes) + : ParsedPacket(l1, l2), Id(id), Pos(pos), Cubes(std::move(cubes)) + {} +}; + using namespace TOS; ServerSession::~ServerSession() { @@ -174,6 +187,10 @@ void ServerSession::onJoystick() { } +void ServerSession::atFreeDrawTime() { + +} + coro<> ServerSession::run() { auto useLock = UseLock.lock(); @@ -363,6 +380,16 @@ coro<> ServerSession::rP_Content(Net::AsyncSocket &sock) { cube.Right.Z = co_await sock.read(); } + auto packet = std::make_unique( + ToClient::L1::Content, + (uint8_t) ToClient::L2Content::ChunkVoxels, + wcId, + pos, + std::move(cubes) + ); + + while(!NetInputPackets.push(std::move(packet))); + LOG.info() << "Приняты воксели чанка " << int(wcId) << " / " << pos.X << ":" << pos.Y << ":" << pos.Z << " Вокселей " << cubes.size(); co_return; diff --git a/Src/Client/ServerSession.hpp b/Src/Client/ServerSession.hpp index d2ff2cd..c15cd4b 100644 --- a/Src/Client/ServerSession.hpp +++ b/Src/Client/ServerSession.hpp @@ -7,10 +7,22 @@ #include "Common/Packets.hpp" #include #include +#include +#include namespace LV::Client { +struct ParsedPacket { + ToClient::L1 Level1; + uint8_t Level2; + + ParsedPacket(ToClient::L1 l1, uint8_t l2) + : Level1(l1), Level2(l2) + {} + virtual ~ParsedPacket(); +}; + class ServerSession : public AsyncObject, public IServerSession, public ISurfaceEventListener { std::unique_ptr Socket; IRenderSession *RS = nullptr; @@ -23,10 +35,12 @@ class ServerSession : public AsyncObject, public IServerSession, public ISurface glm::quat Quat; } Camera; + boost::lockfree::spsc_queue> NetInputPackets; + public: // Нужен сокет, на котором только что был согласован игровой протокол (asyncInitGameProtocol) ServerSession(asio::io_context &ioc, std::unique_ptr &&socket, IRenderSession *rs = nullptr) - : AsyncObject(ioc), Socket(std::move(socket)), RS(rs) + : AsyncObject(ioc), Socket(std::move(socket)), RS(rs), NetInputPackets(1024) { assert(Socket.get()); co_spawn(run()); @@ -63,6 +77,8 @@ public: virtual void onKeyboardBtn(int btn, int state) override; virtual void onJoystick() override; + virtual void atFreeDrawTime() override; + private: coro<> run(); void protocolError(); diff --git a/Src/Client/Vulkan/Vulkan.cpp b/Src/Client/Vulkan/Vulkan.cpp index fb915cf..c6af639 100644 --- a/Src/Client/Vulkan/Vulkan.cpp +++ b/Src/Client/Vulkan/Vulkan.cpp @@ -1163,14 +1163,6 @@ void Vulkan::checkLibrary() bool canContinue = true; // Необходимый функционал - if(!device.DeviceFeatures.depthBounds) - { - report << "\t*depthBounds: " - << device.DeviceFeatures.depthBounds - << '\n'; - canContinue = false; - } - if(!device.DeviceFeatures.geometryShader) { report << "\t*geometryShader: " @@ -1179,14 +1171,6 @@ void Vulkan::checkLibrary() canContinue = false; } - if(!device.DeviceFeatures.dualSrcBlend) - { - report << "\t*geometryShader: " - << device.DeviceFeatures.imageCubeArray - << '\n'; - canContinue = false; - } - // Проверка наличия необходимых расширений for(auto ext : NeedExtensions) if(std::find_if(device.Extensions.begin(), device.Extensions.end(), [&](const vkDeviceExtension &obj) { return obj.ExtensionName == ext; }) == device.Extensions.end()) @@ -1428,10 +1412,7 @@ void Vulkan::initNextSettings() .features = {0} }; - features.features.depthBounds = true; features.features.geometryShader = true; - features.features.dualSrcBlend = true; - features.features.shaderInt16 = true; feat11.uniformAndStorageBuffer16BitAccess = true; feat11.storageBuffer16BitAccess = true;