Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HACK: rocket: use direct Cvar access for HUD cvars #2984

Closed
wants to merge 1 commit into from

Conversation

illwieckz
Copy link
Member

This is a HACK.

Those cvar checks in the HUD are doing one trap call per frame:

pkg/unvanquished_src.dpkdir/ui/hud_basics.rml
184:		<if cvar="cg_minimapActive" condition="==" value="1">
191:			<if cvar="cg_drawTimer" condition="==" value="1">
194:			<if cvar="cg_drawClock" condition="!=" value="0">
197:			<if cvar="cg_drawFPS" condition="==" value="1">
203:			<if cvar="cg_lagometer" condition="==" value="1">
224:	<if cvar="cg_drawSpeed" condition="!=" value="0">

Those cvars are defined in game client side, so we don't need a trap call at all.

This implementation is an ugly HACK.

What I would like to see instead, is that when a Cvar is defined from the client source code, it is added to a local Cvar Map, either automatically for all of them, either by an explicit call to some function similar to Cvar::Latch, something like:

Cvar::Local(g_drawSpeed);

@illwieckz
Copy link
Member Author

Before:

20240506-095801-000 unvanquished-orbit-hud

After:

20240506-111135-000 unvanquished-orbit-hud

@illwieckz illwieckz changed the title HACK: rocket use direct Cvar access for HUD cvars HACK: rocket: use direct Cvar access for HUD cvars May 6, 2024
@illwieckz illwieckz force-pushed the illwieckz/rocket-cvar-hack branch from 898846b to d1b7cdb Compare May 6, 2024 09:41
@illwieckz
Copy link
Member Author

Wait… the wrong changes were cherry-picked, so weird.

@illwieckz illwieckz force-pushed the illwieckz/rocket-cvar-hack branch from d1b7cdb to 74fa513 Compare May 6, 2024 09:48
@illwieckz
Copy link
Member Author

Wait… the wrong changes were cherry-picked, so weird.

Fixed.

@illwieckz
Copy link
Member Author

illwieckz commented May 6, 2024

When I merge this above all my “batch trap calls” branches, I get no fps difference as spectator with cg_draw2D being enabled or disabled. This not true yet with human and alien hud because of other things that are not investigated yet, but this baseline profits to anyone.

@illwieckz
Copy link
Member Author

We can use the same HACK for RocketCvarInlineElement::OnUpdate.

@VReaperV
Copy link
Contributor

VReaperV commented May 9, 2024

I get no significant difference between /cg_draw2D off and cg_draw2D on on my end with this branch too (it's within 1ms of difference).

@illwieckz illwieckz force-pushed the illwieckz/rocket-cvar-hack branch from 5483d75 to be63875 Compare May 9, 2024 21:43
@illwieckz
Copy link
Member Author

@illwieckz illwieckz closed this May 14, 2024
@illwieckz illwieckz deleted the illwieckz/rocket-cvar-hack branch May 14, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants