Flawless Frames feature#9
Conversation
|
@jellysquid3 @Johni0702 please have a look |
I'm guessing your intention with this one was to put a restriction on the consumer, requiring that everything is configured before the frame starts, and allowing the renderer to freely cache that state for one frame as it sees fit. But currently it sounds like the renderer must cache the status at the start of the frame and then must not react to any changes until the next frame.
|
We can relax it. Your interpretation is correct - I assumed no renderer would want to deal with mid-frame changes but there's no need to dissallow it. Do you have a specific use case in mind or is this only for clarification? |
|
Only for clarification. For Sodium and Bobby it'll just be simpler to check once at the place where the fast and the fancy code paths diverge (with both of them there is afaik currently only one such place), rather than having to do it specifically at the start of the frame. |
|
How would I best go about hooking into this with Dynamic FPS (to not reduce FPS while flawless frames are active)? You have a section on "Mods that want to request control of this feature", but I just want to check if it's enabled. |
Interesting question. The current design doesn't anticipate that other mods would want to listen to the activation state, only that the renderer would. But I see how that could be useful. If FREX is present, then it is easy: you can query I suppose we could add another endpoint/interface, or maybe we spilt to this a separate (very tiny) library just so there's no reason not to use it? |
|
Oh, I didn't even notice that the design doesn't intent for other mods to listen to the activation state. In fact, I was going to do just that with Bobby as well. It overall works perfectly well with multiple "renderer" present at the same time if we just drop the section requiring (well, technically it's only a "should" not a "must") that endpoints be only called once:
In fact, I wasn't even fully aware that this restriction existed (I must have read it more like "receives exactly one call per renderer implementation"), so, the endpoint I implemented in the ReplayMod already assumes that it may be called by multiple renderer and will simply call them all when it wants to activate the feature. |
The activation endpoint that's currently exposed is only for changing the status of the feature - turning it on or off. There's nothing for mods to listen to it. The way Fabric Rendering API works, there can only ever be one active renderer and it is responsible for implementing the endpoint so it will naturally have access to the status (or it can use the FREX implementation). That's why this spec didn't include a generic way for other mods to listen to the status. It's a non-issue if a mod depends on FREX but we already said for this feature we wanted to support renderers and mods that can't or don't want to depend on FREX directly. There's an easy fix: just add a separate endpoint for mods to listen to activation status instead of controlling activation status. I'll add that. |
But that will then require a renderer to be present and do the message passing between them when that should not really be required. Neither ReplayMod nor Dynamic FPS need one but they still want to communicate. My point was that the current spec is not only easy to use as a mod wanting to change the status but also as one wanting to let other mods change your status by just acting as a renderer (in the narrow sense of this spec where a renderer is just some thing that influences how stuff gets rendered. not in the Fabric Rendering API sense where there can only be one). |
I see merit in what you are suggesting. To make sure I understand, let me restate it: Any mod can provide this endpoint, and if it does it becomes a listener for all mods that want to control activation of the feature. That part doesn't create any new work for anyone. A mod that wants to control this feature must be prepared to receive multiple consumers and when it wants to activate or deactivate the feature it must call all of them, or else different mods that depend on the feature will be out of sync. This second part is a small but new demand on mods that want to control activation. Even if it is well documented, it's almost inevitable someone will miss it and just stash the first consumer they get and/or assume the API handles aggregation for them. Even so, it will probably be relatively obvious when this happens and it shouldn't be the norm - mods that do this sort of thing are generally already complicated and the authors know to be careful. Is that the idea? |
|
Yup, that's exactly what I was thinking. |
|
Documentation of this feature has been updated to allow for multiple providers and consumers. This change is documentation-only. https://github.com/grondag/frex/blob/1.17/src/main/java/grondag/frex/api/config/FlawlessFrames.java |
Addresses vram-guild/canvas#282
Pasting relevant javadoc here for convenience.