Parallel: send only the atlas rows changed since an Actor's copy (instead of the whole texture per update)
Build & Release / build (push) Canceled after 0s
Build & Release / build (push) Canceled after 0s
This commit is contained in:
1 parent
cd826cf3ca
commit
4c9bac2117
6 files changed
+83
-11
No files matched your search
@@ -272,14 +272,37 @@ function M.Flush()
|
||||
local tex, s = NO_TEX, sent[a]
|
||||
for rec, id in used[a] do
|
||||
local v = rec.V or 0
|
||||
if s[rec] ~= v then
|
||||
local had = s[rec]
|
||||
if had ~= v then
|
||||
if tex == NO_TEX then
|
||||
tex = {}
|
||||
end
|
||||
s[rec] = v
|
||||
tex[#tex + 1] = { id, rec.Buffer, rec.Width, rec.Height }
|
||||
-- the Actor has version `had`: send only the rows changed since then when the log covers them
|
||||
local y0, y1, log = math.huge, -1, rec.Log
|
||||
if had and log then
|
||||
for k = had + 1, v do
|
||||
local e = log[k]
|
||||
if not e then y0 = nil; break end
|
||||
if e[2] > e[1] then
|
||||
if e[1] < y0 then y0 = e[1] end
|
||||
if e[2] > y1 then y1 = e[2] end
|
||||
end
|
||||
end
|
||||
else
|
||||
y0 = nil
|
||||
end
|
||||
if y0 == nil then
|
||||
tex[#tex + 1] = { id, rec.Buffer, rec.Width, rec.Height }
|
||||
Stats.TexBytes += buffer.len(rec.Buffer)
|
||||
elseif y1 > y0 then
|
||||
local row = rec.Width * 4
|
||||
local patch = buffer.create((y1 - y0) * row)
|
||||
copy(patch, 0, rec.Buffer, y0 * row, (y1 - y0) * row)
|
||||
tex[#tex + 1] = { id, false, rec.Width, rec.Height, y0 * row, patch }
|
||||
Stats.TexBytes += buffer.len(patch)
|
||||
end
|
||||
Stats.TexSends += 1
|
||||
Stats.TexBytes += buffer.len(rec.Buffer)
|
||||
end
|
||||
end
|
||||
Stats.SendBytes += Pn[a] + tl
|
||||
|
||||
Reference in new issue
Block a user