Refactor material palette system with GPU indirection
Major overhaul of material palette management: - Added two-buffer indirection (PaletteOffsetBuffer, MaterialIndexBuffer) for GPU material lookup, with incremental upload and resizing. - MaterialPaletteStore now tracks dirty ranges, supports deferred slot reclamation, and exposes CPU-side arrays for upload. - ResourceManager manages persistent GPU buffers and uploads only dirty subranges per frame. - Updated HLSL and C# structs to use palette indices. - Refactored systems/components to use new palette index and release logic. - Added RenderContext.UploadBufferRange for partial uploads. Minor: Fixed StbIApi interop signatures, updated test namespaces, and performed code cleanups.
This commit is contained in:
@@ -35,6 +35,8 @@ public struct FrameData
|
||||
{
|
||||
public uint instanceBuffer;
|
||||
public uint userBuffer;
|
||||
public uint paletteOffsetBuffer; // bindless index into PaletteOffsetBuffer
|
||||
public uint materialIndexBuffer; // bindless index into MaterialIndexBuffer
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
@@ -42,7 +44,7 @@ public struct InstanceData
|
||||
{
|
||||
public float4x4 localToWorld;
|
||||
public uint meshBuffer;
|
||||
public uint materialBuffer;
|
||||
public uint materialPaletteIndex; // index into PaletteOffsetBuffer (from MaterialPaletteStore)
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
@@ -68,4 +70,5 @@ public struct MeshData
|
||||
public uint meshletBuffer;
|
||||
public uint meshletVerticesBuffer;
|
||||
public uint meshletTrianglesBuffer;
|
||||
public uint materialSlotCount; // number of material slots baked into this mesh's meshlets
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user