Perf: ImDrawList vertices in a flat buffer (f64 pos/uv + u32 col); backend reads it directly and skips draw lists identical to last frame

This commit is contained in:
4DBug
2026-10-08 12:11:36 -05:00
parent b19fe61236
commit 0e06d846cf
8 changed files with 396 additions and 258 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ RunService.Stepped:Connect(function()
local want = ImGui.GetColorU32(G.ImGuiCol.WindowBg)
local found = false
for _, l in ImGui.GetDrawData().CmdLists:iter() do
for i = 1, l.VtxBuffer.Size do if l.VtxBuffer.Data[i][3] == want then found = true break end end
for i = 1, l.VtxBuffer.Size do if G.ImDrawVtx_Col(l.VtxBuffer.Buf, i) == want then found = true break end end
end
assert(found, "docked windows must draw a WindowBg background")
print("MOVE OK")
+2 -2
View File
@@ -19,8 +19,8 @@ game:GetService("RunService").Stepped:Connect(function()
ImGui.ShowDemoWindow(true)
ImGui.Render()
for _, dl in ImGui.GetDrawData().CmdLists:iter() do
local vd, id = dl.VtxBuffer.Data, dl.IdxBuffer.Data
for i = 1, dl.VtxBuffer.Size do local v = vd[i]; mix(v[1].x); mix(v[1].y); mix(v[2].x * 4096); mix(v[2].y * 4096); mix(v[3] / 64) end
local vb, id = dl.VtxBuffer.Buf, dl.IdxBuffer.Data
for i = 1, dl.VtxBuffer.Size do local o = (i - 1) * 36; mix(buffer.readf64(vb, o)); mix(buffer.readf64(vb, o + 8)); mix(buffer.readf64(vb, o + 16) * 4096); mix(buffer.readf64(vb, o + 24) * 4096); mix(buffer.readu32(vb, o + 32) / 64) end
for i = 1, dl.IdxBuffer.Size do mix(id[i]) end
for _, c in dl.CmdBuffer:iter() do mix(c.ClipRect.x); mix(c.ClipRect.y); mix(c.ClipRect.z); mix(c.ClipRect.w); mix(c.ElemCount) end
end