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

Can't upgrade to 0.14, impossible to render AlphaMask3d phase items without mesh #14004

Closed
djeedai opened this issue Jun 24, 2024 · 3 comments · Fixed by #14029
Closed

Can't upgrade to 0.14, impossible to render AlphaMask3d phase items without mesh #14004

djeedai opened this issue Jun 24, 2024 · 3 comments · Fixed by #14029
Labels
A-Rendering Drawing game state to the screen D-Domain-Expert Requires deep knowledge in a given domain P-High This is particularly urgent, and deserves immediate attention P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Milestone

Comments

@djeedai
Copy link
Contributor

djeedai commented Jun 24, 2024

Bevy version

main

What you did

Repro branch : https://github.com/djeedai/bevy_hanabi/tree/bevy_main

Run:

cargo --offline r --example billboard --no-default-features --features="bevy/zstd bevy/ktx2 bevy/bevy_winit bevy/bevy_pbr bevy/png 3d "

The billboard particles are missing. GPU debugger shows there's no draw call.

Discussion on Discord and comments on related migration guide bug.

Hanabi (bevy_hanabi) renders some particle effect through the AlphaMask3d pass via a custom render pipeline based on compute shaders and vertex/fragment shaders. There's no mesh involved (except from a single quad shared by all particles, which could even be removed). After migrating, I noted that AlphaMask3d uses BinnedRenderPhase, unlike all other phases Hanabi uses which go through SortedRenderPhase. The design of the 2 is quite different, and it seems BinnedRenderPhase is coupled with mesh asset rendering.

This makes it impossible to ugprade Hanabi.

What went wrong

Render phase items AlphaMask3d are silently discarded, because (I think) GetFullBatchData::get_binned_index() returns None, since the phase item enqueued doesn't have a mesh.

  • I've confirmed with a debugger the phase items get enqueued
  • I've confirmed with a debugger that gpu_processing::batch_and_prepare_binned_render_phase() gets called (I think, because it's all generic code and I can't see the concrete types)
@djeedai djeedai added A-Rendering Drawing game state to the screen P-High This is particularly urgent, and deserves immediate attention P-Regression Functionality that used to work but no longer does. Add a test for this! D-Domain-Expert Requires deep knowledge in a given domain S-Needs-SME Decision or review from an SME is required labels Jun 24, 2024
@djeedai djeedai added this to the 0.14 milestone Jun 24, 2024
@kurtkuehnert
Copy link
Contributor

I was trying to upgrade bevy terrain to Bevy 0.14 and I am facing the same issue. My pipeline uses a compute shader generated mesh, so my mesh asset ID is set to invalid in the Opaque3D phase item. This causes my items to not be drawn as well.

@djeedai
Copy link
Contributor Author

djeedai commented Jun 25, 2024

@kurtkuehnert there's a discussion happening on Discord now (see here and below messages, and can walk your way up from replies too). I think we'll post a recommendation here once the various folks discussing have reached a consensus on the best approach. So far there's I think 4+ crates facing the same issue. It's also considered a 0.14 blocker, so should get traction.

pcwalton added a commit to pcwalton/bevy that referenced this issue Jun 26, 2024
As reported in bevyengine#14004, many third-party plugins, such as Hanabi, enqueue
entities that don't have meshes into render phases. However, the
introduction of indirect mode added a dependency on mesh-specific data,
breaking this workflow. This is because GPU preprocessing requires that
the render phases manage indirect draw parameters, which don't apply to
objects that aren't meshes. The existing code skips over binned entities
that don't have indirect draw parameters, which causes the rendering to
be skipped for such objects.

To support this workflow, this commit adds a new field,
`non_mesh_items`, to `BinnedRenderPhase`.  This field contains a simple
list of (bin key, entity) pairs. After drawing batchable and unbatchable
objects, the non-mesh items are drawn one after another. Bevy itself
doesn't enqueue any items into this list; it exists solely for the
application and/or plugins to use.

Additionally, this commit switches the asset ID in the standard bin keys
to be an untyped asset ID rather than that of a mesh. This allows more
flexibility, allowing bins to be keyed off any type of asset.

This patch adds a new example, `custom_phase_item`, which simultaneously
serves to demonstrate how to use this new feature and to act as a
regression test so this doesn't break again.

Fixes bevyengine#14004.
pcwalton added a commit to pcwalton/bevy that referenced this issue Jun 26, 2024
As reported in bevyengine#14004, many third-party plugins, such as Hanabi, enqueue
entities that don't have meshes into render phases. However, the
introduction of indirect mode added a dependency on mesh-specific data,
breaking this workflow. This is because GPU preprocessing requires that
the render phases manage indirect draw parameters, which don't apply to
objects that aren't meshes. The existing code skips over binned entities
that don't have indirect draw parameters, which causes the rendering to
be skipped for such objects.

To support this workflow, this commit adds a new field,
`non_mesh_items`, to `BinnedRenderPhase`.  This field contains a simple
list of (bin key, entity) pairs. After drawing batchable and unbatchable
objects, the non-mesh items are drawn one after another. Bevy itself
doesn't enqueue any items into this list; it exists solely for the
application and/or plugins to use.

Additionally, this commit switches the asset ID in the standard bin keys
to be an untyped asset ID rather than that of a mesh. This allows more
flexibility, allowing bins to be keyed off any type of asset.

This patch adds a new example, `custom_phase_item`, which simultaneously
serves to demonstrate how to use this new feature and to act as a
regression test so this doesn't break again.

Fixes bevyengine#14004.
pcwalton added a commit to pcwalton/bevy that referenced this issue Jun 26, 2024
As reported in bevyengine#14004, many third-party plugins, such as Hanabi, enqueue
entities that don't have meshes into render phases. However, the
introduction of indirect mode added a dependency on mesh-specific data,
breaking this workflow. This is because GPU preprocessing requires that
the render phases manage indirect draw parameters, which don't apply to
objects that aren't meshes. The existing code skips over binned entities
that don't have indirect draw parameters, which causes the rendering to
be skipped for such objects.

To support this workflow, this commit adds a new field,
`non_mesh_items`, to `BinnedRenderPhase`.  This field contains a simple
list of (bin key, entity) pairs. After drawing batchable and unbatchable
objects, the non-mesh items are drawn one after another. Bevy itself
doesn't enqueue any items into this list; it exists solely for the
application and/or plugins to use.

Additionally, this commit switches the asset ID in the standard bin keys
to be an untyped asset ID rather than that of a mesh. This allows more
flexibility, allowing bins to be keyed off any type of asset.

This patch adds a new example, `custom_phase_item`, which simultaneously
serves to demonstrate how to use this new feature and to act as a
regression test so this doesn't break again.

Fixes bevyengine#14004.
@alice-i-cecile alice-i-cecile added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Needs-SME Decision or review from an SME is required labels Jun 26, 2024
github-merge-queue bot pushed a commit that referenced this issue Jun 27, 2024
As reported in #14004, many third-party plugins, such as Hanabi, enqueue
entities that don't have meshes into render phases. However, the
introduction of indirect mode added a dependency on mesh-specific data,
breaking this workflow. This is because GPU preprocessing requires that
the render phases manage indirect draw parameters, which don't apply to
objects that aren't meshes. The existing code skips over binned entities
that don't have indirect draw parameters, which causes the rendering to
be skipped for such objects.

To support this workflow, this commit adds a new field,
`non_mesh_items`, to `BinnedRenderPhase`. This field contains a simple
list of (bin key, entity) pairs. After drawing batchable and unbatchable
objects, the non-mesh items are drawn one after another. Bevy itself
doesn't enqueue any items into this list; it exists solely for the
application and/or plugins to use.

Additionally, this commit switches the asset ID in the standard bin keys
to be an untyped asset ID rather than that of a mesh. This allows more
flexibility, allowing bins to be keyed off any type of asset.

This patch adds a new example, `custom_phase_item`, which simultaneously
serves to demonstrate how to use this new feature and to act as a
regression test so this doesn't break again.

Fixes #14004.

## Changelog

### Added

* `BinnedRenderPhase` now contains a `non_mesh_items` field for plugins
to add custom items to.
mockersf pushed a commit that referenced this issue Jun 27, 2024
As reported in #14004, many third-party plugins, such as Hanabi, enqueue
entities that don't have meshes into render phases. However, the
introduction of indirect mode added a dependency on mesh-specific data,
breaking this workflow. This is because GPU preprocessing requires that
the render phases manage indirect draw parameters, which don't apply to
objects that aren't meshes. The existing code skips over binned entities
that don't have indirect draw parameters, which causes the rendering to
be skipped for such objects.

To support this workflow, this commit adds a new field,
`non_mesh_items`, to `BinnedRenderPhase`. This field contains a simple
list of (bin key, entity) pairs. After drawing batchable and unbatchable
objects, the non-mesh items are drawn one after another. Bevy itself
doesn't enqueue any items into this list; it exists solely for the
application and/or plugins to use.

Additionally, this commit switches the asset ID in the standard bin keys
to be an untyped asset ID rather than that of a mesh. This allows more
flexibility, allowing bins to be keyed off any type of asset.

This patch adds a new example, `custom_phase_item`, which simultaneously
serves to demonstrate how to use this new feature and to act as a
regression test so this doesn't break again.

Fixes #14004.

## Changelog

### Added

* `BinnedRenderPhase` now contains a `non_mesh_items` field for plugins
to add custom items to.
@djeedai
Copy link
Contributor Author

djeedai commented Jun 29, 2024

Confirming that Hanabi works again. Thanks for the fix!

zmbush pushed a commit to zmbush/bevy that referenced this issue Jul 3, 2024
…e#14029)

As reported in bevyengine#14004, many third-party plugins, such as Hanabi, enqueue
entities that don't have meshes into render phases. However, the
introduction of indirect mode added a dependency on mesh-specific data,
breaking this workflow. This is because GPU preprocessing requires that
the render phases manage indirect draw parameters, which don't apply to
objects that aren't meshes. The existing code skips over binned entities
that don't have indirect draw parameters, which causes the rendering to
be skipped for such objects.

To support this workflow, this commit adds a new field,
`non_mesh_items`, to `BinnedRenderPhase`. This field contains a simple
list of (bin key, entity) pairs. After drawing batchable and unbatchable
objects, the non-mesh items are drawn one after another. Bevy itself
doesn't enqueue any items into this list; it exists solely for the
application and/or plugins to use.

Additionally, this commit switches the asset ID in the standard bin keys
to be an untyped asset ID rather than that of a mesh. This allows more
flexibility, allowing bins to be keyed off any type of asset.

This patch adds a new example, `custom_phase_item`, which simultaneously
serves to demonstrate how to use this new feature and to act as a
regression test so this doesn't break again.

Fixes bevyengine#14004.

## Changelog

### Added

* `BinnedRenderPhase` now contains a `non_mesh_items` field for plugins
to add custom items to.
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 D-Domain-Expert Requires deep knowledge in a given domain P-High This is particularly urgent, and deserves immediate attention P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
3 participants