Skip to content
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

Make FOG_ENABLED a shader_def instead of material flag #13783

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

IceSentry
Copy link
Contributor

Objective

  • If the fog is disabled it still generates a useless branch which can hurt performance

Solution

  • Make the flag a shader_def instead

Testing

  • I tested enabling/disabling fog works as expected per-material in the fog example
  • I also tested that scenes that don't add the FogSettings resource still work correctly

Review notes

I'm not sure how to handle the removed material flag. Right now I just commented it out and added a not to reuse it instead of creating a new one.

@IceSentry IceSentry added A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 9, 2024
@alice-i-cecile alice-i-cecile added this to the 0.14 milestone Jun 9, 2024
Copy link
Contributor

@robtfm robtfm left a comment

Choose a reason for hiding this comment

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

makes sense, fog tends to be all or nothing so this is unlikely to make more shader variants in any real world scenarios, and saves some registers when not used.

i think keeping the other flags unchanged and commenting the old fog flag as unused is the right call as well.

@IceSentry IceSentry added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 10, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jun 10, 2024
Merged via the queue into bevyengine:main with commit 5134272 Jun 10, 2024
32 checks passed
mockersf pushed a commit that referenced this pull request Jun 10, 2024
# Objective

- If the fog is disabled it still generates a useless branch which can
hurt performance

## Solution

- Make the flag a shader_def instead

## Testing

- I tested enabling/disabling fog works as expected per-material in the
fog example
- I also tested that scenes that don't add the FogSettings resource
still work correctly

## Review notes

I'm not sure how to handle the removed material flag. Right now I just
commented it out and added a not to reuse it instead of creating a new
one.
@pcwalton
Copy link
Contributor

This wasn't done the right way, I don't think. What I suggested was to make the FOG_ENABLED shader def contingent on whether the view has fog, not whether the material had a flag that disables it.

@alice-i-cecile alice-i-cecile removed this from the 0.14 milestone Jun 10, 2024
alice-i-cecile pushed a commit to alice-i-cecile/bevy that referenced this pull request Jun 10, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jun 10, 2024
…" (#13803)

This reverts commit 3ced49f.

Relevant to #13802. This wasn't
done quite right and partially broke fog.

Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com>
mockersf pushed a commit that referenced this pull request Jun 11, 2024
…" (#13803)

This reverts commit 3ced49f.

Relevant to #13802. This wasn't
done quite right and partially broke fog.

Co-authored-by: Alice Cecile <alice.i.cecil@gmail.com>
@mockersf mockersf added this to the 0.14 milestone Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants