Skip to content

Commit 209a6ed

Browse files
committed
Add sgame IPC to sync data to Daemon-vulkan
1 parent 3d9beaa commit 209a6ed

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

src/engine/server/sg_msgdef.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ enum gameImport_t
5050
BOT_FREE_CLIENT,
5151
BOT_GET_CONSOLE_MESSAGE,
5252
BOT_DEBUG_DRAW,
53+
54+
DISPATCH_RAWDATA,
55+
DISPATCH_RAWDATASYNC
5356
};
5457

5558
using LocateGameDataMsg1 = IPC::Message<IPC::Id<VM::QVM, G_LOCATE_GAME_DATA1>, IPC::SharedMemory, int, int, int>;
@@ -114,6 +117,11 @@ using BotGetConsoleMessageMsg = IPC::SyncMessage<
114117
>;
115118
// HACK: sgame message that only works when running in a client
116119
using BotDebugDrawMsg = IPC::Message<IPC::Id<VM::QVM, BOT_DEBUG_DRAW>, std::vector<char>>;
120+
using DispatchRawDataMsg = IPC::Message<IPC::Id<VM::QVM, DISPATCH_RAWDATA>, std::string>;
121+
using DispatchRawDataSyncMsg = IPC::SyncMessage<
122+
IPC::Message<IPC::Id<VM::QVM, DISPATCH_RAWDATASYNC>, std::string>,
123+
IPC::Reply<std::string>
124+
>;
117125

118126

119127

src/engine/server/sv_sgame.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ Maryland 20850 USA.
4545
#include "client/client.h" // For bot debug draw
4646
#endif
4747

48+
#if USE_VULKAN
49+
#include "../renderer-vulkan/DispatchRawData.h"
50+
#endif
51+
4852
// Suppress warnings for unused [this] lambda captures.
4953
#ifdef __clang__
5054
#pragma clang diagnostic ignored "-Wunused-lambda-capture"
@@ -323,6 +327,31 @@ void SV_InitGameProgs()
323327
SV_InitGameVM();
324328
}
325329

330+
static void DispatchRawData( const std::string& data ) {
331+
#if USE_VULKAN
332+
DispatchRawData( data.data() );
333+
#else
334+
Q_UNUSED( data );
335+
#endif
336+
}
337+
338+
static std::string DispatchRawDataSync( const std::string& data ) {
339+
#if USE_VULKAN
340+
void* outMem;
341+
int size;
342+
343+
DispatchRawDataSync( data.data(), &outMem, &size );
344+
345+
out.resize( size );
346+
std::string out { ( const char* ) outMem, size };
347+
348+
return out;
349+
#else
350+
Q_UNUSED( data );
351+
return "";
352+
#endif
353+
}
354+
326355
GameVM::GameVM(): VM::VMBase("sgame", Cvar::NONE), services(nullptr) {
327356
}
328357

@@ -594,6 +623,18 @@ void GameVM::QVMSyscall(int syscallNum, Util::Reader& reader, IPC::Channel& chan
594623
});
595624
break;
596625

626+
case DISPATCH_RAWDATA:
627+
IPC::HandleMsg<DispatchRawDataMsg>( channel, std::move( reader ), [this] ( const std::string& data ) {
628+
DispatchRawData( data );
629+
} );
630+
break;
631+
632+
case DISPATCH_RAWDATASYNC:
633+
IPC::HandleMsg<DispatchRawDataSyncMsg>( channel, std::move( reader ), [this]( const std::string& data, std::string& out ) {
634+
out = DispatchRawDataSync( data );
635+
} );
636+
break;
637+
597638
default:
598639
Sys::Drop("Bad game system trap: %d", syscallNum);
599640
}

src/shared/server/sg_api.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,15 @@ int trap_BotGetServerCommand(int clientNum, char *message, int size)
164164
Q_strncpyz(message, message2.c_str(), size);
165165
return res;
166166
}
167+
168+
void trap_DispatchRawData( const std::string& data ) {
169+
VM::SendMsg<DispatchRawDataMsg>( data );
170+
}
171+
172+
std::string trap_DispatchRawDataSync( const std::string& data ) {
173+
std::string out;
174+
175+
VM::SendMsg<DispatchRawDataSyncMsg>( data, out );
176+
177+
return out;
178+
}

src/shared/server/sg_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ int trap_BotAllocateClient();
4848
void trap_BotFreeClient( int clientNum );
4949
void trap_GetUsercmd( int clientNum, usercmd_t *cmd );
5050
int trap_BotGetServerCommand( int clientNum, char *message, int size );
51+
void trap_DispatchRawData( const std::string& data );
52+
std::string trap_DispatchRawDataSync( const std::string& data );
5153
int trap_RSA_GenerateMessage( const char *public_key, char *cleartext, char *encrypted );
5254
void trap_GenFingerprint( const char *pubkey, int size, char *buffer, int bufsize );
5355
void trap_GetPlayerPubkey( int clientNum, char *pubkey, int size );

0 commit comments

Comments
 (0)