Implement automatic $ prefixed shader props
#1
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.
The
u_dimensionsuniform used by both RoundedRectangleShader and DynamicShader are automatically filled in per quad that is rendered. The way it was done originally makes it difficult for the renderer to tell generally if two consecutive quads that use the same shaders can be batched into the same render operation.With
$prefixed automatic shader props, Shaders opt-into using them and simply set their defaults to a compatible type (for$dimensionsit is simply a Rect). The renderer, during addQuad() will fill our the correct values for automatic shader props prior to rendering.Shaders now can implement a
canBatchShaderProps()method to compare two sets of shader props to see if it can be batched into the same render opertion. The default behavior is to return false. Some Shaders like the DynamicShader may opt not to implement this at all if the overhead of comparing the two sets of shader props is too high.This is a pre-requisite for Clipping in order to smooth out the logic needed to decide when to spawn a new render op