cg_api: implement trap_BatchGetUserCmds to fetch an array of command backups in one call#848
cg_api: implement trap_BatchGetUserCmds to fetch an array of command backups in one call#848illwieckz wants to merge 1 commit intofor-0.56.0/syncfrom
trap_BatchGetUserCmds to fetch an array of command backups in one call#848Conversation
getcmds to fetch an array of command backups in one call (the real one)getcmds to fetch an array of command backups in one call
df3a7bf to
412fc9a
Compare
getcmds to fetch an array of command backups in one callimplement trap_GetUserCmdArray to fetch an array of command backups in one call
f925ab4 to
a8abf82
Compare
implement trap_GetUserCmdArray to fetch an array of command backups in one calltrap_GetUserCmdArray to fetch an array of command backups in one call
a8abf82 to
62bbfb1
Compare
trap_GetUserCmdArray to fetch an array of command backups in one calltrap_GetUserCmdArray to fetch an array of command backups in one call
trap_GetUserCmdArray to fetch an array of command backups in one calltrap_GetUserCmdArray to fetch an array of command backups in one call
62bbfb1 to
e2d3010
Compare
|
Check out #854. It should be even faster by requesting only one usercmd_t per frame, and doesn't require ABI changes. |
|
I believe this issue might need an update since mentioned issue was closed? |
|
We may still want to implement this even if we already merged a workaround that fixes the performance problem. What this can bring is to make the code simpler by calling a function once at the beginning of the frame processing, instead of calling a function in various places and in many times. The good thing with the workaround is that it achieves the same performance without breaking engine compatibility, we may still want to refactor and clean-up the code anyway. The priority is just far more lower. |
785c703 to
4b86bb0
Compare
trap_GetUserCmdArray to fetch an array of command backups in one calltrap_BatchGetUserCmds to fetch an array of command backups in one call
|
This one may be less needed since an alternative code already exists and was merged in #854: I like the fact this implementation makes the code less convoluted on game side. This PR makes only sense if For reference: #define CMD_BACKUP 64
#define USERCMD_BUTTONS 16
struct usercmd_t
{
int serverTime;
int angles[ 3 ];
signed char forwardmove, rightmove, upmove;
dtType_t doubleTap;
byte weapon;
byte flags;
byte buttons[ USERCMD_BUTTONS / 8 ];
};
using userCmds_t = std::array<usercmd_t, CMD_BACKUP>; |
|
So, |
|
Actually one advantage of this implementation is that by turning the |
445f3bf to
8b1da58
Compare
|
I noticed this: void CG_DrawActiveFrame( int serverTime, bool demoPlayback )
{
// …
cg.currentCmdNumber = trap_GetCurrentCmdNumber();
// …
cg.currentCmd = trap_BatchGetUserCmds( cg.userCmds );
// …
}I guess that at some point we will be able to merge those two trap calls into a single one. But really, those trap calls now count for less than 1%, that's very good! This Orbit screenshot was taken while running a branch featuring all my currently implement batch trap calls. |
|
In fact This will even divide by two the time spent in trap calls in this function! 😃️ |
…ackups in one call Implement trap_GetUserCmdArray. Also drop now useless trap_GetCurrentCmdNumber and trap_GetUserCmd. Co-authored-by: DolceTriade <vcelestialragev@gmail.com>
8b1da58 to
93bf909
Compare


Engine sidecar of:
trap_BatchGetUserCmdsto fetch an array of command backups in one call Unvanquished/Unvanquished#2660See this thread for details about this:
This branch doesn't build, I don't know how to write the serializer for this.
I believe merging this would break engine compatibility, so we may want to make this branch target a future branch, like
0.55.0/sync.