Skip to content

Move most skeleton stuff to engine#1489

Merged
illwieckz merged 4 commits intofor-0.56.0/syncfrom
reaper/engine-skeleton/sync
Mar 22, 2026
Merged

Move most skeleton stuff to engine#1489
illwieckz merged 4 commits intofor-0.56.0/syncfrom
reaper/engine-skeleton/sync

Conversation

@VReaperV
Copy link
Contributor

@VReaperV VReaperV commented Jan 5, 2025

Cgame-side pr: Unvanquished/Unvanquished#3276.

A proper solution to the issue of highly inefficient IPC with skeletal models. Skeleton will now be built and blended in the engine instead of cgame, and it will no longer be transferred through IPC at all, +this will avoid a bunch of extraneous copies. An additional benefit is that this will skip doing anything with skeletons for entities that get culled away. Cgame will now only send the relevant frame numbers/lerp/etc through IPC as part refEntity_t.

The layout I'm using for testing is this: https://users.unvanquished.net/~reaper/maps/layouts/plat23/test.dat.

@VReaperV VReaperV added T-Improvement Improvement for an existing feature A-Renderer T-Cleanup T-Performance labels Jan 5, 2025
@VReaperV VReaperV changed the base branch from master to for-0.56.0/sync January 5, 2025 23:30
@illwieckz
Copy link
Member

illwieckz commented Jan 6, 2025

Probably related to that problem reported by CodeQL:

Thread 1 "daemon" received signal SIGSEGV, Segmentation fault.
Util::SerializeTraits<refEntity_t, void>::Read (stream=...) at src/engine/client/cg_msgdef.h:127
127				ent.boneMods = stream.Read<std::vector<BoneMod>&>();

@VReaperV
Copy link
Contributor Author

VReaperV commented Jan 7, 2025

Oh yeah, that was an unfinished change.

@VReaperV VReaperV force-pushed the reaper/engine-skeleton/sync branch from 5ae3f4d to dc1a501 Compare January 7, 2025 09:44
@illwieckz
Copy link
Member

illwieckz commented Jan 7, 2025

So, this fixe dll. I now can get it run as exe too, but with nexe (PNaCl) I get:

Warn: IPC: Unexpected end of message

@VReaperV VReaperV force-pushed the reaper/engine-skeleton/sync branch from de64f25 to 926b067 Compare January 7, 2025 18:04
@VReaperV
Copy link
Contributor Author

VReaperV commented Jan 7, 2025

So, this fixe dll. I now can get it run as exe too, but with nexe (PNaCl) I get:

Warn: IPC: Unexpected end of message

I've added a few more fixes, can you check if you still get this error? Do note that I have pushed fixes both on this branch and on the Unvanquished one.

@illwieckz
Copy link
Member

I get the same.

Anyway, can you rebase on latest for-0.56.0/sync so I can also test with Saigo? 🙂️

@VReaperV VReaperV force-pushed the reaper/engine-skeleton/sync branch from 926b067 to 99c6824 Compare January 7, 2025 18:19
@VReaperV
Copy link
Contributor Author

VReaperV commented Jan 7, 2025

I get the same.

Hmm, that's weird. I'd need to look at it later, there are stil la few bugs that need to be fixed.

@VReaperV
Copy link
Contributor Author

VReaperV commented Jan 7, 2025

Anyway, can you rebase on latest for-0.56.0/sync so I can also test with Saigo? 🙂️

Done, although I haven't tested it yet after rebase.

@illwieckz
Copy link
Member

Thanks, the rebase was successful (I can build the game with Saigo).

I get the same error with a nexe built with Saigo.

@VReaperV
Copy link
Contributor Author

VReaperV commented Jan 7, 2025

Maybe there's padding being inserted into BoneMod in either daemon or saigo/nacl game, but not the other... At least that's the only potential explanation I have right now.

@VReaperV
Copy link
Contributor Author

VReaperV commented Jan 7, 2025

This is mostly done now, I believe the only remaining issues are because trap_R_LerpTag() needs to be modified to just work from the engine instead, +fixing the legs skeletons. Well, and whatever the above error is.

@VReaperV
Copy link
Contributor Author

VReaperV commented Jan 8, 2025

So I've unfortunately run into another issue: CG_SetAttachmentTag() (which is used for particle systems and such) requires some of the skeletons to already be built.

There are 3 options I can see right now: add more IPC calls to get skeletons just for those entities (which is really ugly), go back to the implementation that simply batches skeletons, or move particle systems to engine. The latter might also solve some performance issues with particle systems that we have right now.

@VReaperV
Copy link
Contributor Author

VReaperV commented Jan 8, 2025

This version is, however, faster than #1386.

@VReaperV VReaperV force-pushed the reaper/engine-skeleton/sync branch from cf47328 to 06b3c18 Compare January 8, 2025 10:04
@VReaperV
Copy link
Contributor Author

VReaperV commented Jan 8, 2025

This fixes a few things. The problems still remaining are legs skeletons not being set to torso skeletons, some animations missing/incorrect, and the above problem about particle systems/trail systems attachments.

@VReaperV
Copy link
Contributor Author

VReaperV commented Jan 9, 2025

So I've unfortunately run into another issue: CG_SetAttachmentTag() (which is used for particle systems and such) requires some of the skeletons to already be built.

There are 3 options I can see right now: add more IPC calls to get skeletons just for those entities (which is really ugly), go back to the implementation that simply batches skeletons, or move particle systems to engine. The latter might also solve some performance issues with particle systems that we have right now.

I figured out another solution for this:

  1. Add all non-particle and non-trail entities.
  2. Update their positions/skeletons etc. with an IPC call, but don't render them yet.
  3. Write the positions of bones (for tag attachments) that we're interested in with the command buffer.
  4. Read it on cgame side, and use those positions to spawn particles/trails.
  5. Add the particle and trail entities and render everything as normal.

@VReaperV VReaperV force-pushed the reaper/engine-skeleton/sync branch 2 times, most recently from 1640110 to 88c50b0 Compare December 29, 2025 00:04
@VReaperV VReaperV changed the title WIP: Move most skeleton stuff to engine Move most skeleton stuff to engine Dec 29, 2025
@VReaperV VReaperV marked this pull request as ready for review December 29, 2025 00:09
@VReaperV
Copy link
Contributor Author

I've fixed all the issues I could find, just need to clean-up the code now.

@VReaperV VReaperV force-pushed the reaper/engine-skeleton/sync branch 4 times, most recently from a70fcfd to e058114 Compare December 29, 2025 19:48
@illwieckz
Copy link
Member

I would like to get this merged for 0.56.0 RC2, so basically within the week.

@slipher
Copy link
Member

slipher commented Feb 23, 2026

I would like to get this merged for 0.56.0 RC2, so basically within the week.

Note that I have found a bug, reported on the engine-side PR.

@illwieckz
Copy link
Member

illwieckz commented Feb 23, 2026

I would like to get this merged for 0.56.0 RC2, so basically within the week.

Note that I have found a bug, reported on the engine-side PR.

Yes, I have mentioned it on the enginegame-side PR.

If not possible to fix and merge this before RC2, I do remind that the release is expected for being released in one month. It would be good to still have an RC with this before releasing, so this gives about 3 weeks to give enough time between the last RC and the release.

@VReaperV VReaperV force-pushed the reaper/engine-skeleton/sync branch 3 times, most recently from e863ba9 to f4a57b0 Compare March 19, 2026 07:05
@VReaperV VReaperV force-pushed the reaper/engine-skeleton/sync branch 3 times, most recently from 8e02b16 to 1890d0a Compare March 19, 2026 09:01
@illwieckz
Copy link
Member

Finally, we're doing it! 🎉️

illwieckz
illwieckz previously approved these changes Mar 19, 2026
Copy link
Member

@illwieckz illwieckz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@illwieckz illwieckz dismissed their stale review March 20, 2026 00:15

Remaining bugs spotted.

}

#define RF_SWAPCULL 0x000040 // swap CT_FRONT_SIDED and CT_BACK_SIDED
inline RenderFx operator|=( const RenderFx& lhs, const RenderFx& rhs ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff gives me compiler warnings:

/unv/Unvanquished/src/cgame/cg_weapons.cpp: In function ‘void CG_AddViewWeapon(playerState_t*)’:
/unv/Unvanquished/src/cgame/cg_weapons.cpp:1773:34: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
 1773 |                 hand.renderfx |= RF_SWAPCULL;
      |                                  ^~~~~~~~~~~
In file included from /unv/Unvanquished/src/cgame/cg_local.h:36,
                 from /unv/Unvanquished/src/cgame/cg_weapons.cpp:31:
/unv/Unvanquished/daemon/src/engine/renderer/tr_types.h:72:17: note: candidate 1: ‘RenderFx operator|=(const RenderFx&, const RenderFx&)’
   72 | inline RenderFx operator|=( const RenderFx& lhs, const RenderFx& rhs ) {
      |                 ^~~~~~~~
/unv/Unvanquished/src/cgame/cg_weapons.cpp:1773:34: note: candidate 2: ‘operator|=(RenderFx&, int)’ (built-in)
 1773 |                 hand.renderfx |= RF_SWAPCULL;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should work now I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now get errors instead of warnings:

src/cgame/cg_players.cpp: In function ‘void CG_PlayerFloatSprite(centity_t*, qhandle_t, std::vector<refEntity_t>&)’:
src/cgame/cg_players.cpp:2534:24: error: invalid conversion from ‘int’ to ‘RenderFx’ [-fpermissive]
 2534 |         ent.renderfx = rf;
      |                        ^~
      |                        |
      |                        int
src/cgame/cg_players.cpp: In function ‘void CG_PlayerSkeletal(centity_t*, int, vec_t*, int)’:
src/cgame/cg_players.cpp:2750:25: error: invalid conversion from ‘int’ to ‘RenderFx’ [-fpermissive]
 2750 |         legs.renderfx = renderfx;
      |                         ^~~~~~~~
      |                         |
      |                         int
src/cgame/cg_players.cpp: In function ‘void CG_Player(centity_t*)’:
src/cgame/cg_players.cpp:2988:33: error: invalid conversion from ‘int’ to ‘RenderFx’ [-fpermissive]
 2988 |                 legs.renderfx = renderfx;
      |                                 ^~~~~~~~
      |                                 |
      |                                 int
src/cgame/cg_players.cpp:3058:42: error: invalid conversion from ‘int’ to ‘RenderFx’ [-fpermissive]
 3058 |                         torso.renderfx = renderfx;
      |                                          ^~~~~~~~
      |                                          |
      |                                          int
src/cgame/cg_players.cpp:3074:41: error: invalid conversion from ‘int’ to ‘RenderFx’ [-fpermissive]
 3074 |                         head.renderfx = renderfx;
      |                                         ^~~~~~~~
      |                                         |
      |                                         int
src/cgame/cg_ents.cpp: In function ‘void CG_General(centity_t*)’:
src/cgame/cg_ents.cpp:313:33: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
  313 |                 ent.renderfx |= RF_THIRD_PERSON; // only draw from mirrors
      |                                 ^~~~~~~~~~~~~~~
In file included from src/cgame/cg_local.h:36,
                 from src/cgame/cg_ents.cpp:30:
daemon/src/engine/renderer/tr_types.h:72:17: note: candidate 1: ‘RenderFx operator|=(const RenderFx&, const RenderFx&)’
   72 | inline RenderFx operator|=( const RenderFx& lhs, const RenderFx& rhs ) {
      |                 ^~~~~~~~
src/cgame/cg_ents.cpp:313:33: note: candidate 2: ‘operator|=(RenderFx&, int)’ (built-in)
  313 |                 ent.renderfx |= RF_THIRD_PERSON; // only draw from mirrors
      |                                 ^~~~~~~~~~~~~~~
src/cgame/cg_ents.cpp: In function ‘void CG_Missile(centity_t*)’:
src/cgame/cg_ents.cpp:403:45: error: invalid conversion from ‘int’ to ‘RenderFx’ [-fpermissive]
  403 |                 ent.renderfx = ma->renderfx | RF_NOSHADOW;
      |                                ~~~~~~~~~~~~~^~~~~~~~~~~~~
      |                                             |
      |                                             int
src/cgame/cg_ents.cpp: In function ‘void CG_LightFlare(centity_t*)’:
src/cgame/cg_ents.cpp:661:27: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
  661 |         flare.renderfx |= RF_DEPTHHACK;
      |                           ^~~~~~~~~~~~
daemon/src/engine/renderer/tr_types.h:72:17: note: candidate 1: ‘RenderFx operator|=(const RenderFx&, const RenderFx&)’
   72 | inline RenderFx operator|=( const RenderFx& lhs, const RenderFx& rhs ) {
      |                 ^~~~~~~~
src/cgame/cg_ents.cpp:661:27: note: candidate 2: ‘operator|=(RenderFx&, int)’ (built-in)
  661 |         flare.renderfx |= RF_DEPTHHACK;
      |                           ^~~~~~~~~~~~

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I forgot to push the commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it works! Thanks a lot!

Copy link
Member

@illwieckz illwieckz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, for real.

@VReaperV VReaperV force-pushed the reaper/engine-skeleton/sync branch 2 times, most recently from 3f602f4 to 72b2d17 Compare March 22, 2026 07:38
@illwieckz illwieckz force-pushed the reaper/engine-skeleton/sync branch from 72b2d17 to a700306 Compare March 22, 2026 22:35
@illwieckz illwieckz merged commit a700306 into for-0.56.0/sync Mar 22, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants