Skip to content

Meshlet based culling#1089

Merged
kristiker merged 28 commits into
masterfrom
multidraw2
Feb 24, 2026
Merged

Meshlet based culling#1089
kristiker merged 28 commits into
masterfrom
multidraw2

Conversation

@kristiker

@kristiker kristiker commented Feb 11, 2026

Copy link
Copy Markdown
Member
  • Pushed meshlet data to GPU
  • Majority of map geometry is now culled on GPU
    • Frustum
    • Backface
    • Occlusion

This lowers CPU usage.

image

Todo:

  • Fetch object data using gl_baseinstance
  • Make sure object selection works
  • Command buffer compacting
  • Occlusion culling

@kristiker kristiker added the Renderer Related to the 3D/2D rendering viewer label Feb 11, 2026
AggregateDrawBounds = 14,
MeshletInfo = 15,

// do not exceed 16

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

better explanation comment. also why did it jump from 3 to 8 anyway?

Comment thread Renderer/Renderer/Frustum.cs Outdated
public readonly struct Frustum
{
private Vector4[] Planes = new Vector4[6];
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it's not 6 when its empty?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed by making empty frustum have 6 planes as well

Comment thread Renderer/Renderer/RenderableMesh.cs Outdated
[StructLayout(LayoutKind.Sequential)]
public struct PackedAABB
{
//HACK HACK HACK

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what's the hack?

Comment thread Renderer/Renderer/RenderableMesh.cs Outdated

var m_CullingData = new MeshletInfo.CullingData()
{
m_ConeAxis0 = (sbyte)meshletCall.GetSubCollection("m_CullingData").GetIntegerArray("m_ConeAxis")[0],

@xPaw xPaw Feb 11, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GetSubCollection (above), GetIntegerArray once

Comment thread Renderer/Renderer/RenderableMesh.cs Outdated
m_nParentBoundIndex = (uint)i + (uint)preDrawBoundsCount
};
if (isAggregate)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is this loop even running for non-isAggregate

public List<Entity> Entities { get; } = [];
public WorldNode? MainWorldNode { get; private set; }

public HashSet<string> DefaultEnabledLayers { get; } = ["Entities", "Particles"];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

dont forget to revert

Comment thread Renderer/Shaders/picking.vert.slang
Comment thread Renderer/Renderer/RenderableMesh.cs Outdated
@kristiker kristiker force-pushed the multidraw2 branch 3 times, most recently from 1d01b30 to 5a243e7 Compare February 23, 2026 19:49
@kristiker kristiker marked this pull request as ready for review February 23, 2026 19:51
@kristiker kristiker merged commit 9afe21d into master Feb 24, 2026
13 checks passed
@kristiker kristiker deleted the multidraw2 branch February 24, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Renderer Related to the 3D/2D rendering viewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants