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

Fix the example regressions from packed growable buffers. #14375

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

pcwalton
Copy link
Contributor

The "uberbuffers" PR #14257 caused some examples to fail intermittently for different reasons:

  1. morph_targets could fail because vertex displacements for morph targets are keyed off the vertex index. With buffer packing, the vertex index can vary based on the position in the buffer, which caused the morph targets to be potentially incorrect. The solution is to include the first vertex index with the MeshUniform (and MeshInputUniform if GPU preprocessing is in use), so that the shader can calculate the true vertex index before performing the morph operation. This results in wasted space in MeshUniform, which is unfortunate, but we'll soon be filling in the padding with the ID of the material when bindless textures land, so this had to happen sooner or later anyhow.

    Including the vertex index in the MeshInputUniform caused an ordering problem. The MeshInputUniform was created during the extraction phase, before the allocations occurred, so the extraction logic didn't know where the mesh vertex data was going to end up. The solution is to move the MeshInputUniform creation (the collect_meshes_for_gpu_building system) to after the allocations phase. This should be better for parallelism anyhow, because it allows the extraction phase to finish quicker. It's also something we'll have to do for bindless in any event.

  2. The lines and fog_volumes examples could fail because their custom drawing nodes weren't updated to supply the vertex and index offsets in their draw_indexed and draw calls. This commit fixes this oversight.

Fixes #14366.

The "uberbuffers" PR bevyengine#14257 caused some examples to fail intermittently
for different reasons:

1. `morph_targets` could fail because vertex displacements for morph
   targets are keyed off the vertex index. With buffer packing, the
   vertex index can vary based on the position in the buffer, which
   caused the morph targets to be potentially incorrect. The solution is
   to include the first vertex index with the `MeshUniform` (and
   `MeshInputUniform` if GPU preprocessing is in use), so that the
   shader can calculate the true vertex index before performing the
   morph operation. This results in wasted space in `MeshUniform`, which
   is unfortunate, but we'll soon be filling in the padding with the ID
   of the material when bindless textures land, so this had to happen
   sooner or later anyhow.

   Including the vertex index in the `MeshInputUniform` caused an
   ordering problem. The `MeshInputUniform` was created during the
   extraction phase, before the allocations occurred, so the extraction
   logic didn't know where the mesh vertex data was going to end up. The
   solution is to move the `MeshInputUniform` creation (the
   `collect_meshes_for_gpu_building` system) to after the allocations
   phase. This should be better for parallelism anyhow, because it
   allows the extraction phase to finish quicker. It's also something
   we'll have to do for bindless in any event.

2. The `lines` and `fog_volumes` examples could fail because their
   custom drawing nodes weren't updated to supply the vertex and index
   offsets in their `draw_indexed` and `draw` calls. This commit fixes
   this oversight.

Fixes bevyengine#14366.
@pcwalton pcwalton added P-Regression Functionality that used to work but no longer does. Add a test for this! A-Rendering Drawing game state to the screen labels Jul 18, 2024
Copy link
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

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

LGTM assuming CI is fixed

@BD103
Copy link
Member

BD103 commented Jul 18, 2024

This is currently slated for 0.15 (in the issue), but should it be included in 0.14.1 as well?

@pcwalton
Copy link
Contributor Author

No version of 0.14 includes uberbuffers, right? This fix is specific to uberbuffers.

@IceSentry
Copy link
Contributor

Yup, 0.15 is right, uberbuffers will not be included in a point release of 0.14

Copy link
Contributor

@tychedelia tychedelia left a comment

Choose a reason for hiding this comment

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

Looks good. Nice that we got a potential performance improvement fixing this by moving uniform building out of extract.

@NthTensor NthTensor added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jul 18, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jul 22, 2024
Merged via the queue into bevyengine:main with commit d235d41 Jul 22, 2024
28 checks passed
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 P-Regression Functionality that used to work but no longer does. Add a test for this! 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.

Some examples are broken after packed growable buffers
6 participants