Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Rework GPU #58

wants to merge 14 commits into from

Conversation

SwissalpS
Copy link
Contributor

Refactor of GPU code to avoid code duplications and generaly cleaner code.
Removes some bugs and only changes behaviour slightly.

  • less aborts as sizes and coordinates are clamped
  • e.g. when copy/pasting sections, instead of aborting because of overflow, the copied area is adjusted to source and destination real estate.

Fixes #45
Hopefully also fixes #44

@TheEt1234

This comment was marked as spam.

This was referenced Apr 28, 2024
@SwissalpS SwissalpS added the needs testing Possible compatibility issues label Apr 28, 2024
@SwissalpS
Copy link
Contributor Author

Output from observer mooncontroller:

10000
01000
00100
00010
00001

1
1
1
1
1

1000000
1100000
0110000
0010000
0001000
0001100
0000110
0000010
0000001

1
1
1
1
1
1
1
1
1
1
1

1000
1100
0110
0010
0001

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 ----
How does the new drawline implementation handle these 5 simple test cases:
1,1 to 5,5
1,1 to 1,5
1,1 to 7,9
1,1 to 1,11
1,1 to 4,5
... when those are also the corners of the buffer?

@TheEt1234
Copy link

From issue #44:

The original case that started the issue was fixed, so has the (65, 1, 1, 1) case when buffer size is 63x63

So the line bug is most likely patched

@SwissalpS SwissalpS marked this pull request as ready for review May 18, 2024 20:20
@SwissalpS
Copy link
Contributor Author

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.

Copy link
Member

@BuckarooBanzay BuckarooBanzay left a 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)

@cheapie
Copy link

cheapie commented Sep 19, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs testing Possible compatibility issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2nd crash w/ gpu crash w/ gpu
4 participants