Code Monkey home page Code Monkey logo

Comments (13)

ikt32 avatar ikt32 commented on July 19, 2024 1

@Guad
Did some measurements:

  • FPS /w no menu onscreen: 82-85FPS
  • FPS /w menu onscreen: 50-55 FPS
  • FPS /w menu onscreen, DisEnableControls commented out: 74-76 FPS
  • FPS /w menu onscreen, input group 2 only: 65-66 FPS

Turns out the foreach (var con in Enum.GetValues(typeof(Control))) in DisEnableControls is responsible for about ~20FPS from the total ~30FPS drop when having the menu open. Not sure how you'd replace this "block everything", but removing the 0 and 1 helps a tiny bit. Only disabling a small set of controls would be even better.

Not sure where the 10 FPS drop comes from exactly, as measuring the impact of the string splittage isn't very conclusive.

Edit -
Replacing that loop with this results in the same behavior, but no FPS drop.

Function.Call(enable ? Hash.ENABLE_ALL_CONTROL_ACTIONS : Hash.DISABLE_ALL_CONTROL_ACTIONS, 2);

Credits to @kagikn for the quick thinking.

from nativeui.

RainerHilmer avatar RainerHilmer commented on July 19, 2024

I think this happens when attaching the tick event to MenuPool.ProcessMenus(). I tried setting the Interval to 100ms and faced the menu flashes all along. Even just calling Yield() after MenuPool.ProcessMenus() causes this. Why does the menu disappear in-between anyway? If that wouldn't be the case we wouldn't have those issue, I'm pretty sure.

from nativeui.

Guad avatar Guad commented on July 19, 2024

That's because with the Draw() method of the menus draws the sprites and text for one frame, so you'd have to call it every frame. If you set the interval too big, it draws it every other frame, which causes the flicker.

from nativeui.

RainerHilmer avatar RainerHilmer commented on July 19, 2024

Got that but isn't there any other way? I mean, the menu functionality of scripthookvdotnet doesn't have this problem. Maybe you can get an idea if you check out the source code of V1.1 and have a look at it. ;-)

from nativeui.

Guad avatar Guad commented on July 19, 2024

This menu uses the same functionality, except that the old scripthookvdotnet menu was much simpler and didn't use any sprites, so it was easy on the performance.

from nativeui.

RainerHilmer avatar RainerHilmer commented on July 19, 2024

How about always pausing the game at menu popup? Do you also need to redraw with each frame then?

from nativeui.

Guad avatar Guad commented on July 19, 2024

Yes, it's how the game implements sprites, there's no way around that.

from nativeui.

aveao avatar aveao commented on July 19, 2024

directx hooking maybe? but that'd take a near complete (if not complete) rewrite

from nativeui.

Guad avatar Guad commented on July 19, 2024

@ardaozkal That'd obscure game items such as the mouse pointer and other stuff.

from nativeui.

ikt32 avatar ikt32 commented on July 19, 2024

ScriptHookV uses it's own drawTexture instead of the DRAW_SPRITE native. Would using that help?

Also, would drawing in a different thread help? Not sure if you can do this with respect to GTAs threads.

nvm this all, doesn't make sense.

from nativeui.

sollaholla avatar sollaholla commented on July 19, 2024

@E66666666 I also noticed shv's drawTexture lags behind a frame. Not sure if it's just me or...

from nativeui.

kagikn avatar kagikn commented on July 19, 2024

Actually, Tanjitsu found Enum.GetValues in DisEnableControls (named as EnableControls in the shvdn3 branch) killed huge FPS before I did.
Didn't noticed that when I made my PR, though.

from nativeui.

Guad avatar Guad commented on July 19, 2024

Well shit, now it looks kinda obvious. Thanks again.

from nativeui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.