ParsedPacket

This commit is contained in:
2025-02-10 18:46:03 +06:00
parent cea3a0ca28
commit a27f055af8
4 changed files with 46 additions and 20 deletions

View File

@@ -128,6 +128,8 @@ public:
} Registry; } Registry;
virtual ~IServerSession(); virtual ~IServerSession();
virtual void atFreeDrawTime() = 0;
}; };

View File

@@ -1,5 +1,6 @@
#include "ServerSession.hpp" #include "ServerSession.hpp"
#include "Client/Abstract.hpp" #include "Client/Abstract.hpp"
#include "Common/Abstract.hpp"
#include "Common/Net.hpp" #include "Common/Net.hpp"
#include <boost/asio/deadline_timer.hpp> #include <boost/asio/deadline_timer.hpp>
#include <boost/asio/this_coro.hpp> #include <boost/asio/this_coro.hpp>
@@ -13,6 +14,18 @@
namespace LV::Client { namespace LV::Client {
ParsedPacket::~ParsedPacket() = default;
struct PP_Content_ChunkVoxels : public ParsedPacket {
WorldId_c Id;
Pos::GlobalChunk Pos;
std::vector<VoxelCube> Cubes;
PP_Content_ChunkVoxels(ToClient::L1 l1, uint8_t l2, WorldId_c id, Pos::GlobalChunk pos, std::vector<VoxelCube> &&cubes)
: ParsedPacket(l1, l2), Id(id), Pos(pos), Cubes(std::move(cubes))
{}
};
using namespace TOS; using namespace TOS;
ServerSession::~ServerSession() { ServerSession::~ServerSession() {
@@ -174,6 +187,10 @@ void ServerSession::onJoystick() {
} }
void ServerSession::atFreeDrawTime() {
}
coro<> ServerSession::run() { coro<> ServerSession::run() {
auto useLock = UseLock.lock(); auto useLock = UseLock.lock();
@@ -363,6 +380,16 @@ coro<> ServerSession::rP_Content(Net::AsyncSocket &sock) {
cube.Right.Z = co_await sock.read<uint8_t>(); cube.Right.Z = co_await sock.read<uint8_t>();
} }
auto packet = std::make_unique<PP_Content_ChunkVoxels>(
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(); LOG.info() << "Приняты воксели чанка " << int(wcId) << " / " << pos.X << ":" << pos.Y << ":" << pos.Z << " Вокселей " << cubes.size();
co_return; co_return;

View File

@@ -7,10 +7,22 @@
#include "Common/Packets.hpp" #include "Common/Packets.hpp"
#include <TOSLib.hpp> #include <TOSLib.hpp>
#include <boost/asio/io_context.hpp> #include <boost/asio/io_context.hpp>
#include <memory>
#include <boost/lockfree/spsc_queue.hpp>
namespace LV::Client { 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 { class ServerSession : public AsyncObject, public IServerSession, public ISurfaceEventListener {
std::unique_ptr<Net::AsyncSocket> Socket; std::unique_ptr<Net::AsyncSocket> Socket;
IRenderSession *RS = nullptr; IRenderSession *RS = nullptr;
@@ -23,10 +35,12 @@ class ServerSession : public AsyncObject, public IServerSession, public ISurface
glm::quat Quat; glm::quat Quat;
} Camera; } Camera;
boost::lockfree::spsc_queue<std::unique_ptr<ParsedPacket>> NetInputPackets;
public: public:
// Нужен сокет, на котором только что был согласован игровой протокол (asyncInitGameProtocol) // Нужен сокет, на котором только что был согласован игровой протокол (asyncInitGameProtocol)
ServerSession(asio::io_context &ioc, std::unique_ptr<Net::AsyncSocket> &&socket, IRenderSession *rs = nullptr) ServerSession(asio::io_context &ioc, std::unique_ptr<Net::AsyncSocket> &&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()); assert(Socket.get());
co_spawn(run()); co_spawn(run());
@@ -63,6 +77,8 @@ public:
virtual void onKeyboardBtn(int btn, int state) override; virtual void onKeyboardBtn(int btn, int state) override;
virtual void onJoystick() override; virtual void onJoystick() override;
virtual void atFreeDrawTime() override;
private: private:
coro<> run(); coro<> run();
void protocolError(); void protocolError();

View File

@@ -1163,14 +1163,6 @@ void Vulkan::checkLibrary()
bool canContinue = true; bool canContinue = true;
// Необходимый функционал // Необходимый функционал
if(!device.DeviceFeatures.depthBounds)
{
report << "\t*depthBounds: "
<< device.DeviceFeatures.depthBounds
<< '\n';
canContinue = false;
}
if(!device.DeviceFeatures.geometryShader) if(!device.DeviceFeatures.geometryShader)
{ {
report << "\t*geometryShader: " report << "\t*geometryShader: "
@@ -1179,14 +1171,6 @@ void Vulkan::checkLibrary()
canContinue = false; canContinue = false;
} }
if(!device.DeviceFeatures.dualSrcBlend)
{
report << "\t*geometryShader: "
<< device.DeviceFeatures.imageCubeArray
<< '\n';
canContinue = false;
}
// Проверка наличия необходимых расширений // Проверка наличия необходимых расширений
for(auto ext : NeedExtensions) for(auto ext : NeedExtensions)
if(std::find_if(device.Extensions.begin(), device.Extensions.end(), [&](const vkDeviceExtension &obj) { return obj.ExtensionName == ext; }) == device.Extensions.end()) 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 = {0}
}; };
features.features.depthBounds = true;
features.features.geometryShader = true; features.features.geometryShader = true;
features.features.dualSrcBlend = true;
features.features.shaderInt16 = true;
feat11.uniformAndStorageBuffer16BitAccess = true; feat11.uniformAndStorageBuffer16BitAccess = true;
feat11.storageBuffer16BitAccess = true; feat11.storageBuffer16BitAccess = true;