|
VisuTwin Canvas
C++ 3D Engine — Metal Backend
|
#include <platform/graphics/metal/metalInstanceCullPass.h>
Public Member Functions | |
| MTL::Buffer * | compactedBuffer () const |
| void | cull (MTL::Buffer *inputBuffer, const InstanceCullParams ¶ms) |
| MTL::Buffer * | indirectArgsBuffer () const |
| bool | isReady () const |
| True once ensureResources() has succeeded. | |
| MetalInstanceCullPass (const MetalInstanceCullPass &)=delete | |
| MetalInstanceCullPass (MetalGraphicsDevice *device) | |
| MetalInstanceCullPass & | operator= (const MetalInstanceCullPass &)=delete |
| void | reserve (uint32_t maxInstances) |
| ~MetalInstanceCullPass () | |
Static Public Member Functions | |
| static void | extractFrustumPlanes (const float *vpMatrix4x4ColMajor, float outPlanes[6][4]) |
GPU frustum culling for hardware-instanced draws via Metal compute kernels.
Owns compute pipelines, counter/uniform/indirect-args buffers, and the compacted instance output buffer. The compacted buffer is pre-allocated for a maximum instance count and reused across frames.
Thread-unsafe – call from the main rendering thread only.
Definition at line 55 of file metalInstanceCullPass.h.
|
explicit |
Definition at line 127 of file metalInstanceCullPass.cpp.
Referenced by MetalInstanceCullPass(), and operator=().
| visutwin::canvas::MetalInstanceCullPass::~MetalInstanceCullPass | ( | ) |
Definition at line 132 of file metalInstanceCullPass.cpp.
|
delete |
References MetalInstanceCullPass().
|
inlinenodiscard |
The compacted output buffer (visible instances only, 80 bytes each). Valid after a successful cull() call.
Definition at line 79 of file metalInstanceCullPass.h.
| void visutwin::canvas::MetalInstanceCullPass::cull | ( | MTL::Buffer * | inputBuffer, |
| const InstanceCullParams & | params ) |
Run frustum culling on the input instance buffer. After this call, compactedBuffer() contains only visible instances and indirectArgsBuffer() contains the draw arguments.
| inputBuffer | MTL::Buffer with packed InstanceData (80 bytes each). |
| params | Culling parameters (frustum planes, counts, etc.). |
Definition at line 269 of file metalInstanceCullPass.cpp.
References visutwin::canvas::InstanceCullParams::instanceCount, and reserve().
|
static |
Extract 6 frustum planes from a view-projection matrix (Gribb/Hartmann method). Each plane is (nx, ny, nz, d) with the convention: dot(n,p)+d >= 0 = inside.
Definition at line 354 of file metalInstanceCullPass.cpp.
|
inlinenodiscard |
The indirect draw arguments buffer (20 bytes: MTLDrawIndexedPrimitivesIndirectArguments). Valid after a successful cull() call.
Definition at line 83 of file metalInstanceCullPass.h.
|
inlinenodiscard |
True once ensureResources() has succeeded.
Definition at line 86 of file metalInstanceCullPass.h.
|
delete |
References MetalInstanceCullPass().
| void visutwin::canvas::MetalInstanceCullPass::reserve | ( | uint32_t | maxInstances | ) |
Ensure the compacted buffer can hold at least maxInstances. Re-allocates if the current capacity is smaller. Safe to call every frame.
Definition at line 241 of file metalInstanceCullPass.cpp.
Referenced by cull().