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

Implement GPU frustum culling. #12889

Merged
merged 13 commits into from
Apr 28, 2024
Merged

Commits on Apr 10, 2024

  1. Implement GPU frustum culling.

    This commit implements opt-in GPU frustum culling, built on top of the
    infrastructure in bevyengine#12773. To enable it on a camera, add the `GpuCulling`
    component to it. To additionally disable CPU frustum culling, add the
    `NoCpuCulling` component. Note that adding `GpuCulling` without
    `NoCpuCulling` *currently* does nothing useful. The reason why
    `GpuCulling` doesn't automatically imply `NoCpuCulling` is that I intend
    to follow this patch up with GPU two-phase occlusion culling, and CPU
    frustum culling plus GPU occlusion culling seems like a very
    commonly-desired mode.
    
    Adding the `GpuCulling` component frustum to a view puts that view into
    *indirect mode*. This mode makes all drawcalls indirect, relying on the
    mesh preprocessing shader to allocate instances dynamically. In indirect
    mode, the `PreprocessWorkItem` `output_index` points not to a
    `MeshUniform` instance slot but instead to a set of `wgpu`
    `IndirectParameters`, from which it allocates an instance slot
    dynamically if frustum culling succeeds. Batch building has been updated
    to allocate and track indirect parameter slots, and the AABBs are now
    supplied to the GPU as `MeshCullingData`.
    
    A small amount of code relating to the frustum culling has been borrowed
    from meshlets and moved into `maths.wgsl`. Note that standard Bevy
    frustum culling uses AABBs, while meshlets use bounding spheres; this
    means that not as much code can be shared as one might think.
    
    This patch doesn't provide any way to perform GPU culling on shadow
    maps, to avoid making this patch bigger than it already is. That can be
    a followup.
    pcwalton committed Apr 10, 2024
    Configuration menu
    Copy the full SHA
    37ab4de View commit details
    Browse the repository at this point in the history

Commits on Apr 11, 2024

  1. Configuration menu
    Copy the full SHA
    2816333 View commit details
    Browse the repository at this point in the history

Commits on Apr 23, 2024

  1. Configuration menu
    Copy the full SHA
    808358c View commit details
    Browse the repository at this point in the history

Commits on Apr 24, 2024

  1. Configuration menu
    Copy the full SHA
    295ebb8 View commit details
    Browse the repository at this point in the history

Commits on Apr 26, 2024

  1. Configuration menu
    Copy the full SHA
    0fa6875 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e70ca83 View commit details
    Browse the repository at this point in the history
  3. Warning police

    pcwalton committed Apr 26, 2024
    Configuration menu
    Copy the full SHA
    6ff883f View commit details
    Browse the repository at this point in the history

Commits on Apr 28, 2024

  1. Configuration menu
    Copy the full SHA
    808fb3e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    907106f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    60ed39c View commit details
    Browse the repository at this point in the history
  4. Revert example modifications

    pcwalton committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    e4954ad View commit details
    Browse the repository at this point in the history
  5. Address review comments

    pcwalton committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    4fa60ea View commit details
    Browse the repository at this point in the history
  6. Rustfmt police

    pcwalton committed Apr 28, 2024
    Configuration menu
    Copy the full SHA
    af60424 View commit details
    Browse the repository at this point in the history