-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Optimization for distorted rects + "similar" objects #549
Open
ggcrunchy
wants to merge
25
commits into
coronalabs:master
Choose a base branch
from
ggcrunchy:DeformedRectOptimization
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.
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
…nd buffer and assignment logic Next up, prepare details from graphics.defineEffect()
…from Program Slight redesign of TimeTransform with caching (to synchronize multiple invocations with a frame) and slightly less heavyweight call site
Err, was calling Modulo for sine method, heh That said, time transform seems to work in basic test
Fixed error detection for positive number time transform inputs Relaxed amplitude positivity requirement
Maintenance Revert Test
My mistake adding back changes made
This reverts commit 0b5e1e9.
…s done on primitive type change
Shchvova
approved these changes
Dec 14, 2023
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.
Distorted rects use a slight modification of the fragment shell to do their work. Unfortunately, this means that they count as having a different program than other objects, even if everything else is the same (from the renderer's point of view), so for instance this sequence will break batching at each step:
distorted rect, normal rect, distorted rect, normal rect
Those might all have the same image or use a common sheet, in which case our intuition would be that this all should batch.
The shell's distortion mod is actually a superset of the normal behavior, so after the initial switch, we can in fact just leave it in place so long as the only change in render state would be a "downgrade" of the current program.
For most path-based display objects,
q
(v_TexCoordZ
, in the shell) is set to 1, the exception being distorted rects, of course, which add some fractional delta.Box2D debugging, emitters, and particle systems each zero out their vertices and so will have
q
of 0, as far as I can tell.Dividing by zero is not usually good, so we probably don't want to let these make it to the distortion mod.
As it happens, rects use the triangle strip primitive type, whereas Box2D uses line loops and the others are triangle fans, and the renderer must break a batch to switch types. So we can piggyback on this break that has to happen anyway and demote the distortion mod to avoid issues with zeroes.
With a long enough chain of "normal rect"s, the cost of extra shader instructions will overtake what you would have incurred by switching the program. (Quite a long chain, probably.) I have some comments about a possible solution.
A lower-tech way would be to demote—as with primitive types—whenever we break a batch due to
!enoughSpace
.