-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework GPU #58
base: master
Are you sure you want to change the base?
Rework GPU #58
Conversation
reducing repetative code and some more whitespace changes
TODO: check formname JIC
to reduce repetative code
This comment was marked as spam.
This comment was marked as spam.
Output from observer mooncontroller:
in observer mooncontroller I have this code: local sET = event.type
if 'digiline' == sET then
local sO
mem.sBM = mem.sBM .. '\n'
for y, t in ipairs(event.msg) do
mem.sBM = mem.sBM .. '\n'
for x, s in ipairs(t) do
sO = 'f' == s:sub(1, 1) and '0' or '1'
mem.sBM = mem.sBM .. sO
end
end
elseif 'terminal' == sET then
print(mem.sBM)
elseif 'program' == sET then
mem.sBM = ''
end In master lua/moon-controller I have: if 'program' == event.type then
local d = digiline_send
local tDB = {
{ 1, 1, 5, 5 },
{ 1, 1, 1, 5 },
{ 1, 1, 7, 9 },
{ 1, 1, 1, 11 },
{ 1, 1, 4, 5 },
}
local sI, iB
for i, t in ipairs(tDB) do
sI = tostring(i)
iB = i - 1
d('g', {
{
command = 'createbuffer',
buffer = iB,
xsize = t[3],
ysize = t[4],
fill = 'ffffff',
},
{
command = 'drawline', --rect',
buffer = iB,
x2 = t[3],
y2 = t[4],
x1 = t[1],
y1 = t[2],
color = 'aa00aa'
--edge = "332211",
--fill = "010101",
--antialias = true
},
{
command = 'sendregion',
buffer = iB,
x2 = t[3],
y2 = t[4],
x1 = t[1],
y1 = t[2],
channel = sI,
},
})
end
end ---- Original message ---- |
From issue #44: The original case that started the issue was fixed, so has the So the line bug is most likely patched |
Thanks for testing. It has been three weeks and nobody has asked for any other fixes, so I've marked this PR as ready for review/merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code changes look good but i haven't tested anything (i haven't used that part of the mod that much anyway :D)
I tested this with a few of my more demanding programs and it seems to be working fine, but I didn't explicitly try to break it so I can't comment on the validation parts... not that the validation was much good in my original. I think it might also be a little faster, although I've updated MT since the last time I did much performance testing - I was able to hit 56 FPS in my donut ad (32x32, copies about three 16x16 areas per frame) and 25 FPS in my wireframe 3D cube (64x64, 12 lines drawn per frame) when outputting to digiscreen, of course with Luacontroller overheating disabled. |
local packeddata = "" | ||
for y=1,buffer.ysize,1 do | ||
for x=1,buffer.xsize,1 do | ||
packeddata = packeddata..packpixel(buffer[y][x]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this would be laggy to do this with string concatination (though, remains to be tested)
edit: i put up the comment in the wrong (but still relevant) place, sorry
I suggest (pseudocode):
packeddata = {}
for each pixel:
table.insert(packeddata, packpixel(pixel))
end
packeddata = table.concat(packeddata)
-- rest of the code can work as normal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt there would be much difference either way, not that I've observed a sendpacked command taking non-negligible time anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, the loops are so short I doubt a difference can be noticed. That's partly why I hadn't touched it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I am considering to add the suggested change for "good practice" reasons. It might be faster without string concat but there will probably be more overhead constructing table and then looping it again to table.concat :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packpixel() also uses string.concat. I don't want to go and change that too without actual proof that there is benifit. If we really want to optimize at that level, we'd better not call packpixel() in the loop but add that code directly in the loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the longest the old method took was half a millisecond with 4x the maximum data size it would usually handle and it's for a command this infrequently-used... I think you'd be hard-pressed to call any variant here "slow".
(random thought experiment, though: at what point does the discussion here end up using more CPU time than the change would actually ever save?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some players build big. Arrays upon arrays of RGB-glass etc. ;)
But yes, we are splitting small hairs here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea I probably shouldnt have nitpicked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also it says here
Unresolved conversations
1 conversation must be resolved before merging.
I didnt intend on this to block merging, is me "resolving the conversation" just approving the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you "resolve the conversation" the blocking vanishes. Nothing more. The PR will still need to be merged by one of us maintainers.
when packing packed pixels
Please re-test. I didn't have the time to do so. |
Refactor of GPU code to avoid code duplications and generaly cleaner code.
Removes some bugs and only changes behaviour slightly.
Fixes #45
Hopefully also fixes #44