Skip to content

Reduced shader program state changes & property uploads#814

Merged
adriengivry merged 4 commits into
mainfrom
optim/shader_program_state_changes
May 18, 2026
Merged

Reduced shader program state changes & property uploads#814
adriengivry merged 4 commits into
mainfrom
optim/shader_program_state_changes

Conversation

@adriengivry
Copy link
Copy Markdown
Member

@adriengivry adriengivry commented May 18, 2026

Description

Supersedes #811.

This PR aims to reduce shader program state changes & property uploads by:

  • Re-ordering opaque pass draw calls by material key
  • Reducing unnecessary shader program changes by keeping track of the last used program
  • Keeping track of property changes, to efficiently skip uploads if the data didn't change
  • Re-writing the GetVariant method
  • Added a defaultValue to MaterialProperty instead of calling the expensive UniformToPropertyValue every time a single use property need to be reset

Related Issue(s)

Fixes #445

Review Guidance

Write here.

Screenshots/GIFs

DrawFrame (Cargo)

  • RTX 2080 ti
  • Ryzen 9 3900X
  • 1920x1080p editor, default layout

Went from ~7.79ms to 3.78ms.

Before After
image image

DrawEntity

Went from expensive draws...

image

to one initial draw, and cheap subsequent draws, thanks to property caching.

image

AI Usage Disclosure

None

Checklist

  • My code follows the project's code style guidelines
  • When applicable, I have commented my code, particularly in hard-to-understand areas
  • When applicable, I have updated the documentation accordingly
  • My changes don't generate new warnings or errors
  • I have reviewed and take responsibility for all code in this PR (including any AI-assisted contributions)

@adriengivry adriengivry self-assigned this May 18, 2026
@adriengivry adriengivry added the Optimization Optimization related stuff label May 18, 2026
@adriengivry adriengivry force-pushed the optim/shader_program_state_changes branch from f4de93d to 98d7266 Compare May 18, 2026 19:50
@adriengivry adriengivry marked this pull request as ready for review May 18, 2026 19:51
@adriengivry adriengivry merged commit 2af4c9a into main May 18, 2026
8 checks passed
@adriengivry adriengivry deleted the optim/shader_program_state_changes branch May 18, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Optimization Optimization related stuff

Development

Successfully merging this pull request may close these issues.

Material batching: reduce redundant Material::Bind invocations

1 participant