hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en/latest/
MIT License
12.94k stars 676 forks source link

Partial rerendering #2383

Open szokejokepu opened 3 weeks ago

szokejokepu commented 3 weeks ago

Is your feature request related to a problem? Please describe. I want to build an interface where I have potentially a long render loop for an raw texture image, but most of the rest of the interface is static: buttons, tabs, etc. which never change.

Describe the solution you'd like I would like to only partially rerender the GUI, only in places where it matters, and not rerender the whole complex static interface at every render loop. Seems to me like a waste of resources.

Describe alternatives you've considered I guess what I'm describing is similar to a sort of reactive programming, which is used a lot in web html programming like VueJS, ReactJS etc. but I couldn't find a similar pattern in DPG.

Additional context Here's a program I'm working on for which I'm trying to speed up the processing. DPG_example

v-ein commented 3 weeks ago

but I couldn't find a similar pattern in DPG

Probably because it doesn't work well with the immediate-mode GUI paradigm.

While re-rendering all those buttons is truly a waste of resources, it's often considered an acceptable tradeoff, talking from the ease of development point of view. Also, on modern hardware it's not much resources anyway - at least for your example (I know, it's a poor argument, especially for battery-powered devices; it's a compromise anyway).

In more complex GUIs containing thousands of elements, partial rendering would of course have a more visible effect.

Also, if you're seeking to reduce the CPU load for your app, try adding this on your app init:

dpg.configure_app(wait_for_input=True) 
szokejokepu commented 2 weeks ago

Thanks for the tip with the wait_for_input. I'll give it a try, although since I have a manual rendering loop, not the automatic one, I don't think it makes a lot of difference.

To the original problem, thanks for your response. I didn't realize that this is a "feature not a bug" sort of deal, so it will probably not be implemented on principle basis. Fine by me. Feel free to close the feature request if this is the case.

v-ein commented 2 weeks ago

Well, actually, something like partial rendering might eventually get added to Dear ImGui and then probably to DPG as well. Take a look at this post, section 6.10, where Omar is talking about per-window refresh rate options:

https://github.com/ocornut/imgui/issues/7892

I'd say it's unlikely to happen soon anyway.