Skip to content

reject frames larger than the Update buffers (fixes #65)#116

Open
francisdb wants to merge 1 commit into
vpinball:masterfrom
francisdb:fix-update-bounds
Open

reject frames larger than the Update buffers (fixes #65)#116
francisdb wants to merge 1 commit into
vpinball:masterfrom
francisdb:fix-update-bounds

Conversation

@francisdb

@francisdb francisdb commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

The Update frame buffers are fixed at 256 * 64 pixels; larger frames (e.g. a 512x128 FlexDMD or the 192x256 video screen of pinball/video hybrids) overflowed the heap in the Update* memcpy calls. Reject them with an error log instead.

see also vpinball/vpinball@713a5f6

fixes #65

The Update frame buffers are fixed at 256 * 64 pixels; larger frames
(e.g. a 512x128 FlexDMD or the 192x256 video screen of pinball/video
hybrids) overflowed the heap in the Update* memcpy calls. Reject them
with an error log instead.
@francisdb francisdb force-pushed the fix-update-bounds branch from 190f25f to 3f9f7af Compare June 12, 2026 18:45
@francisdb

Copy link
Copy Markdown
Contributor Author

Once this is merged we could switch to DMDUTIL_MAX_FRAME_PIXELS on the vpinball side

@jsm174 jsm174 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling this function every single frame seems like it could introduce extra latency. Maybe it should be inlined or static, but I will defer to @mkalkbrenner / @toxieainc as I don't really know compilers like they do.

@francisdb

Copy link
Copy Markdown
Contributor Author

I would be surprised that a multiplication and compare add any measurable overhead but optimizing of course makes sense.

Also this will probably flood logs, do I add a flag to log only once?

@jsm174

jsm174 commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

It's not just a multiplication and compare, you're pushing the current address onto the stack, pushing two variables onto the stack, jumping to the function, popping the variables from the stack, popping the address from the stack, X however many times a second this function gets called. But I remember being told modern compilers can be smart enough to realize that, and automatically handle it. All I know is we want this stuff to be as fast as possible.

@mkalkbrenner

Copy link
Copy Markdown
Collaborator

@francisdb thanks for pointing that out.

I think that the simple multiplication width x hight is wrong, because the aspect ratio matters as well.
I think that we have checks for the dimension at a different place. maybe they have to happen earlier.

For 512x128 FlexDMD, it would make sense to downscale the frame instead of rejecting it.

What is a 192x256 video screen of pinball/video hybrids?

@francisdb

Copy link
Copy Markdown
Contributor Author

What is a 192x256 video screen of pinball/video hybrids?

image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LibDMDUtil segfaults if DMD is bigger than 256 * 64

3 participants