Skip to content

Commit 3d9beaa

Browse files
committed
Add cgame IPC to sync data to Daemon-vulkan
1 parent dc586db commit 3d9beaa

File tree

6 files changed

+105
-0
lines changed

6 files changed

+105
-0
lines changed

src/engine/client/cg_msgdef.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ enum cgameImport_t
136136
CG_REGISTER_BUTTON_COMMANDS,
137137
CG_NOTIFY_TEAMCHANGE,
138138
CG_PREPAREKEYUP,
139+
CG_DISPATCHRAWDATA,
140+
CG_DISPATCHRAWDATASYNC,
139141

140142
// Sound
141143
CG_S_STARTSOUND,
@@ -267,6 +269,11 @@ using NotifyTeamChangeMsg = IPC::SyncMessage<
267269
using PrepareKeyUpMsg = IPC::SyncMessage<
268270
IPC::Message<IPC::Id<VM::QVM, CG_PREPAREKEYUP>>
269271
>;
272+
using DispatchRawDataMsg = IPC::Message<IPC::Id<VM::QVM, CG_DISPATCHRAWDATA>, std::string>;
273+
using DispatchRawDataSyncMsg = IPC::SyncMessage<
274+
IPC::Message<IPC::Id<VM::QVM, CG_DISPATCHRAWDATASYNC>, std::string>,
275+
IPC::Reply<std::string>
276+
>;
270277

271278
// All Sounds
272279

src/engine/client/cl_cgame.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ Maryland 20850 USA.
4646
#include "qcommon/crypto.h"
4747
#include "qcommon/sys.h"
4848

49+
#if USE_VULKAN
50+
#include "../renderer-vulkan/DispatchRawData.h"
51+
#endif
52+
4953
#include "framework/CommonVMServices.h"
5054
#include "framework/CommandSystem.h"
5155
#include "framework/CvarSystem.h"
@@ -938,6 +942,31 @@ void CL_OnTeamChanged( int newTeam )
938942
Cmd::BufferCommandText( "exec -f " TEAMCONFIG_NAME );
939943
}
940944

945+
static void DispatchRawData( const std::string& data ) {
946+
#if USE_VULKAN
947+
DispatchRawData( data.data() );
948+
#else
949+
Q_UNUSED( data );
950+
#endif
951+
}
952+
953+
static std::string DispatchRawDataSync( const std::string& data ) {
954+
#if USE_VULKAN
955+
void* outMem;
956+
int size;
957+
958+
DispatchRawDataSync( data.data(), &outMem, &size );
959+
960+
out.resize( size );
961+
std::string out { ( const char* ) outMem, size };
962+
963+
return out;
964+
#else
965+
Q_UNUSED( data );
966+
return "";
967+
#endif
968+
}
969+
941970
CGameVM::CGameVM(): VM::VMBase("cgame", Cvar::CHEAT), services(nullptr), cmdBuffer("client")
942971
{
943972
}
@@ -1163,6 +1192,18 @@ void CGameVM::QVMSyscall(int syscallNum, Util::Reader& reader, IPC::Channel& cha
11631192
});
11641193
break;
11651194

1195+
case CG_DISPATCHRAWDATA:
1196+
IPC::HandleMsg<DispatchRawDataMsg>( channel, std::move( reader ), [this] ( const std::string& data ) {
1197+
DispatchRawData( data );
1198+
} );
1199+
break;
1200+
1201+
case CG_DISPATCHRAWDATASYNC:
1202+
IPC::HandleMsg<DispatchRawDataSyncMsg>( channel, std::move( reader ), [this]( const std::string& data, std::string& out ) {
1203+
out = DispatchRawDataSync( data );
1204+
} );
1205+
break;
1206+
11661207
// All sounds
11671208

11681209
case CG_S_REGISTERSOUND:
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
===========================================================================
3+
4+
Daemon BSD Source Code
5+
Copyright (c) 2026 Daemon Developers
6+
All rights reserved.
7+
8+
This file is part of the Daemon BSD Source Code (Daemon Source Code).
9+
10+
Redistribution and use in source and binary forms, with or without
11+
modification, are permitted provided that the following conditions are met:
12+
* Redistributions of source code must retain the above copyright
13+
notice, this list of conditions and the following disclaimer.
14+
* Redistributions in binary form must reproduce the above copyright
15+
notice, this list of conditions and the following disclaimer in the
16+
documentation and/or other materials provided with the distribution.
17+
* Neither the name of the Daemon developers nor the
18+
names of its contributors may be used to endorse or promote products
19+
derived from this software without specific prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY
25+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
32+
===========================================================================
33+
*/
34+
// DispatchRawData.h
35+
36+
#ifndef DISPATCH_RAW_DATA_H
37+
#define DISPATCH_RAW_DATA_H
38+
39+
void DispatchRawData( void* memory );
40+
void DispatchRawDataSync( void* memory, void** out, int& outSize );
41+
42+
#endif // DISPATCH_RAW_DATA_H
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
set(RENDERERLIST
2+
DispatchRawData.h
23
)

src/shared/client/cg_api.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ void trap_PrepareKeyUp()
132132
VM::SendMsg<PrepareKeyUpMsg>();
133133
}
134134

135+
void trap_DispatchRawData( const std::string& data ) {
136+
VM::SendMsg<DispatchRawDataMsg>( data );
137+
}
138+
139+
std::string trap_DispatchRawDataSync( const std::string& data ) {
140+
std::string out;
141+
142+
VM::SendMsg<DispatchRawDataSyncMsg>( data, out );
143+
144+
return out;
145+
}
146+
135147
// All Sounds
136148

137149
void trap_S_StartSound( vec3_t origin, int entityNum, soundChannel_t, sfxHandle_t sfx )

src/shared/client/cg_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ int trap_LAN_ServerStatus( const char *serverAddress, char *serverSt
133133
void trap_LAN_ResetServerStatus();
134134
void trap_R_GetShaderNameFromHandle( const qhandle_t shader, char *out, int len );
135135
void trap_PrepareKeyUp();
136+
void trap_DispatchRawData( const std::string& data );
137+
std::string trap_DispatchRawDataSync( const std::string& data );
136138
void trap_R_SetAltShaderTokens( const char * );
137139
void trap_S_UpdateEntityVelocity( int entityNum, const vec3_t velocity );
138140
void trap_S_UpdateEntityPositionVelocity( int entityNum, const vec3_t position, const vec3_t velocity );

0 commit comments

Comments
 (0)