-
Notifications
You must be signed in to change notification settings - Fork 36
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
Deferred Lua Execution #1180
Open
geringsj
wants to merge
10
commits into
master
Choose a base branch
from
lua_deferred
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Deferred Lua Execution #1180
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This comment was marked as outdated.
This comment was marked as outdated.
… execution this preserves order of CLI commands for lua execution. regrettably this also touches all parsing of CLI inputs, but should keep the logic sound.
This comment was marked as outdated.
This comment was marked as outdated.
1 similar comment
This comment was marked as outdated.
This comment was marked as outdated.
how much stuff has to actually run before services? could we get rid of the first execute_deferred_lua(); ? this feels a bit off tbh. |
When a .lua file wants to take control over the render loop it would be nice to execute that lua code before entering RenderNextFrame(). Or we find a way to abort a started frame and ensure nothing breaks (e.g. profiling) when executing mmRenderNextFrame() from within RenderNextFrame(). Until now this is handled in main() by executing project files before entering the main loop.
Am 27. April 2023 13:34:58 MESZ schrieb Guido Reina ***@***.***>:
…how much stuff has to actually run before services? could we get rid of the first execute_deferred_lua(); ? this feels a bit off tbh.
--
Reply to this email directly or view it on GitHub:
#1180 (comment)
You are receiving this because you authored the thread.
Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR restructures the Lua resources to provide a deferred lua execution method, such that services and the CLI can queue lua commands which get executed at one single, foreseeable point in the main loop.
Summary of Changes
main()
, twice a frame the lua queue gets processed: beforeRenderNextFrame()
, and insideRenderNextFrame()
before rendering of entry points (after services possibly issued lua commands)main()
moved to use deferred luaReferences and Context
This refactoring streamlines the Lua execution logic in the program, getting rid of project file and CLI Lua inputs confusion. This allows, for example, to load a project file and directly alter parameters of instantiated modules via CLI. At the same time, when taking control over the main loop via a lua project file, we remain outside of
RenderNextFrame()
. For the GUI, this allows for a strictly data-driven GUI re-design, decoupling of GUI event handling (before rendering of the frame) from rendering of the GUI draw list.Challenges
To keep the Lua execution outside of a frame, we need to flush the Lua queue before
RenderNextFrame()
. However, because services can issue Lua commands too (incoming network messages, keyboard/mouse + GUI inputs, resulting graph changes), Lua also needs to be flushed after service resource updates/digestion and before rendering of the graph. Having two Lua flushes leads to problems, e.g. Lua scripts coming from network get executed inside a frame, which is problematic when they containmmRenderNextFrame()
. However, not executing Lua after service updates ignores latest rendering state inputs for one frame, which seems even worse.Test Instructions
CLI project files, param changes, lua execution, order of lua commands is respected:
./megamol.exe -p ../examples/testspheres.lua --param ::data::numSpheres=100 --param ::view::anim::play=true -e "print(\"\n\nHello MegaMol\n\n.\"); print(mmHelp())"
Load other project file after 500 frames:
./megamol.exe -p ../examples/testspheres.lua --param ::data::numSpheres=100 --param ::view::anim::play=true -e "for i = 1,500,1; do mmRenderNextFrame(); end; mmClearGraph()" -p ../examples/infovis-spheres.lua
2023-04-17-18-33-06_Trim.mp4