Skip to content

Conversation

@frank-weindel
Copy link
Contributor

@frank-weindel frank-weindel commented Sep 20, 2023

The u_dimensions uniform 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 $dimensions it 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

The `u_dimensions` uniform used by both RoundedRectangleShader and DynamicShader
are automatically filled in per quad that is rendered. The was 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 `$dimensions` it 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.
@frank-weindel frank-weindel mentioned this pull request Sep 20, 2023
4 tasks
@frank-weindel frank-weindel merged commit f8f0029 into main Sep 26, 2023
frank-weindel added a commit that referenced this pull request Oct 4, 2023
I've added alpha to the shader props which can be used for automatic
shader props similar to [$dimensions](#1).
This is a prop we need for some of the DynamicShader effects.

This pull request is also related to #15
@wouterlucas wouterlucas deleted the shader-automatic-prop-refactor branch October 6, 2023 12:02
chiefcll pushed a commit that referenced this pull request Oct 20, 2023
github-merge-queue bot pushed a commit that referenced this pull request Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants