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

Replace instance index vertex output with mesh flags #10308

Closed
wants to merge 3 commits into from

Conversation

JMS55
Copy link
Contributor

@JMS55 JMS55 commented Oct 29, 2023

Objective

  • Fragment shaders are currently coupled to our specific vertex shaders, as the mesh flags are read from the mesh bindings in the fragment shader. This prevents reusing the fragment shaders in alternative renderers that do not use the mesh bindings, such as Meshlet rendering (initial feature) #10164.

Solution

  • Vertex shaders now return the mesh flags directly, replacing the previous instance_index output.

Changelog

  • Vertex shaders now output mesh flags directly instead of the instance index.
    • The VERTEX_OUTPUT_INSTANCE_INDEX shader def has been replaced by VERTEX_OUTPUT_MESH_FLAGS.
    • VertexOutput instance_index fields have been replaced by the new mesh_flags field.

Migration Guide

  • Fragment shaders using VertexOutput::instance_index to fetch the mesh flags should now use VertexOutput::mesh_flags directly.
  • Vertex shaders that were outputting VertexOutput::instance_index for use with fragment shaders that read the mesh flags via the instance index should now read the mesh flags and output the flags themselves via VertexOutput::mesh_flags.

@JMS55 JMS55 added A-Rendering Drawing game state to the screen M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Oct 29, 2023
@JMS55 JMS55 added this to the 0.13 milestone Oct 29, 2023
@JMS55
Copy link
Contributor Author

JMS55 commented Oct 29, 2023

@Elabajaba brought up that we should probably profile with NSight to confirm this doesn't impact performance.

@superdump
Copy link
Contributor

One other reason to pass the instance index through was for custom fragment shaders to be able to use it to index into things.

@JMS55
Copy link
Contributor Author

JMS55 commented Nov 10, 2023

I no longer need this for meshlets, so the only reason to change this would be perf.

@JMS55 JMS55 closed this Jan 1, 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 M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants