Skip to content

feat(rendering): GPU frustum culling via compute shader + vkDrawIndirectCountKHR #663

Description

@JeanPhilippeKernel

Context

The engine currently uses `VkDrawIndirect` with a CPU-built command list. CPU frustum culling (#644) filters the command list on the render thread before submission — adequate for scenes up to ~10K instances.

For large open-world scenes (virtual geometry streaming, streaming chunks, dense foliage), GPU-side culling is required.

Desired design

A compute dispatch runs before the G-buffer pass each frame:

CPU: upload full InstanceData[] + BoundsData[] to GPU
   → dispatch ComputeCull(N threads, 1 per instance)
GPU: each thread tests instance bounding sphere vs. frustum planes
   → atomically appends visible VkDrawIndirectCommand to output buffer
   → writes visible count to counter buffer
   → barrier: compute write → indirect draw read
G-Buffer Pass: vkDrawIndirectCountKHR(output_buf, counter_buf, MAX_DRAWS)

Prerequisites

  • vkDrawIndirectCountKHR wired in AppRenderPipeline (or core Vulkan 1.2 vkDrawIndirectCount)
  • Per-instance bounding sphere uploaded to a GPU storage buffer (BoundsData SB)
  • Per-instance transform already in TransformSB
  • Compute pass added to the render graph before Depth Pre-Pass
  • Frustum planes pushed as a small UBO (6 × vec4) per frame

Notes

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions