Skip to content

added timing functionality to shaders #573

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

jfboeve
Copy link
Collaborator

@jfboeve jfboeve commented May 14, 2025

Added time functionality to shaders, these work separate from the props (so props don't have to be recalculated) which should result in better performance overal.

@jfboeve jfboeve marked this pull request as draft May 14, 2025 09:27
@jfboeve jfboeve requested a review from wouterlucas August 15, 2025 08:17
@jfboeve jfboeve marked this pull request as ready for review August 15, 2025 08:18
@@ -504,6 +510,11 @@ export class Stage {
if (renderRequested === true) {
this.renderRequested = false;
}

if (this.timedNodes > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we requesting a new render on timedNodes? would this mean we'd never reach idle if a timed shader is active?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm yeah, I think i'll have to tweak the timednode stuff a bit more. but yeah generally you would have to keep redrawing the screen if an time shader is active , meaning it won't go idle.

@@ -578,6 +589,9 @@ export class Stage {
// If the node is renderable and has a loaded texture, render it
if (node.isRenderable === true) {
node.renderQuads(this.renderer);
if (node.hasShaderTimeFn === true) {
this.timedNodes++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if a timer is stopped or a timed node removed? will this number ever go down?
or do we need to reset the timedNodes every cycle (might be expensive?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively you can also add the node itself to the timedNodes on create or get/set of the shader? and then remove it on destroy?

that would avoid you need to count every run on the hot path.

You could expose a function on stage that the corenode calls when it has a timed shader
OR
Add it from the shader itself?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah need to find a better way to keep track of the timedNodes.

@@ -1733,9 +1733,17 @@ export class CoreNode extends EventEmitter {
framebufferDimensions: this.parentHasRenderTexture
? this.parentFramebufferDimensions
: null,
time: this.hasShaderTimeFn === true ? this.getTimerValue() : null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks misaligned or is GH acting up? 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misaligned

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.

2 participants