games/NXDoom: Add RGB565, module support, and crash fixes. - #3644
games/NXDoom: Add RGB565, module support, and crash fixes.#3644aviralgarg05 wants to merge 1 commit into
Conversation
a0328da to
6fe6008
Compare
linguini1
left a comment
There was a problem hiding this comment.
The PR description needs to be revised and made more concise. It reads totally AI generated and is hard to follow, and also has some subtle mistakes (i.e. " happy to split further if any single commit above should be its own PR" when there is only one). Pretty much the entirety of this PR is just patches to NXDoom, we don't really need to know about the other module loading PRs here, just the build system change you made to load this as a module. You are expected to review the output of AI agents before submitting here, even as a draft :)
You should also use the Assisted-by: field in your commit messages, see the new updates to the contribution guide :)
Again, the testing section cannot just be a description of what you tested. Can you show the simulator playing DOOM after the changes, or your target device? Could you show some before/after output for the divide-by-zero and other issues reported here?
I don't see the need to malloc the arrays that were previously statically allocated. Using malloc on embedded devices is not a good practice and should be avoided where possible. I think those changes should be reverted.
|
Thanks for the thorough review @linguini1 going through each point: PR description: You're right, that was sloppy, I squashed the commits down but didn't re-read the description afterward, so it still had a line referring to multiple commits that no longer existed. Rewriting it now Assisted-by field: Didn't know this was now expected, will add it going forward, including updating this PR's commit message. Testing section: Fair — I have this on real hardware (ESP32-S3 board, RGB565 framebuffer) but didn't capture it for the PR. I'll get a screen recording of it running plus the crash logs from before the fixes and attach both. malloc vs static arrays: The reason was DRAM budget, these buffers (visplanes/openings/drawsegs/vissprites) are sized generously above vanilla DOOM's limits, and as static arrays they were eating into internal SRAM budget once this actually gets linked into a full firmware image alongside everything else. Heap allocation moves them onto this target's PSRAM-backed heap instead. But you're right that malloc-by-default isn't great practice, I'll put it behind a Kconfig option instead, so boards that don't need it keep static allocation as the default, and boards that are DRAM-constrained can opt in. Will push an update addressing all of this plus the inline comments one by one |
Can we resolve this with FAR designators? |
The actual problem here is static/BSS footprint at link time — a large static array is always-resident regardless of what pointer qualifier you put on it, |
6fe6008 to
9dd0915
Compare
9dd0915 to
1fbe5cc
Compare
|
Thanks for the detailed review. I went back through the PR and addressed the
The original exception log was not retained, and the Testing section now says |
1fbe5cc to
0899b14
Compare
|
Testing logs do not match what real output would look like. How come? |
Sorry, that wasn't a verbatim capture. I had trimmed the startup lines and mixed the build output into the same block as the serial log, which was a bad call. I've replaced it with the raw capture from the board. |
In the future, please always provide the exact output. That is what is meant by testing logs :) Also, when using AI to generate code, please review its comments and shorten them. This patch is full of very long comments that make reference to other applications and testing that you performed, which is not necessary information for a developer to read and understand the logic. |
729c326 to
3a12ffa
Compare
|
@linguini1 Four things I've left as they are, since I think changing them would reintroduce bugs: parse_int_parameter — upstream returns param without checking sscanf, so a value that doesn't parse returns an uninitialised stack variable straight into the config. That's what caused the divide-by-zero this PR fixes: a screenblocks line with no value set the view size to garbage. Returning success and writing through a pointer is the smallest way to leave the compiled default alone. Happy to reshape the signature if you'd prefer it done differently. viewheight in r_draw.c — r_init_buffer() only fills ylookup[] for [0, height), and r_main.c passes viewheight as that height, so indexing at SCREENHEIGHT reads an entry that was never set. viewheight is set in r_execute_set_view_size() before any drawing. The old check also used > rather than >=, so it let ds_y == SCREENHEIGHT through. Discarded characters — the line is longer than the buffer, so it can't be a valid setting; that loop drops the rest rather than parsing a truncated one. Empty check — reachable because the strip loop above removes non-printable characters, so a value that was only a tab or a stray \r ends up empty. Added comments for both. |
b555c0d to
8951e2a
Compare
|
Once again, stop replying to my review comments with AI. |
ccf98cc to
30862e1
Compare
|
@aviralgarg05 please reorg your patch to squash the temp change into the original patch |
84979d3 to
7abe4bf
Compare
Add RGB565 framebuffer output and module builds. Harden configuration parsing and renderer bounds, support supervised SIGTERM shutdown, and notify framebuffer drivers after drawing. Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
7abe4bf to
12f8b1e
Compare
| sector_t *frontsector; | ||
| sector_t *backsector; | ||
|
|
||
| #ifdef CONFIG_GAMES_NXDOOM_HEAP_BUFFERS |
There was a problem hiding this comment.
why not always use heap and remove CONFIG_GAMES_NXDOOM_HEAP_BUFFERS
There was a problem hiding this comment.
Is it not beneficial to use static buffers on some devices?
There was a problem hiding this comment.
i felt static buffers are still useful on some targets, so i kept both options
There was a problem hiding this comment.
if so, why do we need add the code to allocate from heap
There was a problem hiding this comment.
Some devices also lack static storage, I think Aviral ran into this issue on his board.
There was a problem hiding this comment.
but, there is no difference to define global variable or allocate from heap from the view of total memory consumption.
There was a problem hiding this comment.
But some targets are able to allocate more statically that they can't on heap, and vice versa
There was a problem hiding this comment.
so, what's problem to keep it as global variable. Before @aviralgarg05 could explain the real case, I prefer don't add the ugly code.
There was a problem hiding this comment.
It is still a global variable, isn't it? Just the allocation is different
Note: Please adhere to Contributing Guidelines.
Summary
Update NXDoom for RGB565 targets and loadable-module builds. The change also:
screenblocks;SIGTERMfrom the frame loop;FBIO_UPDATE.Impact
=yor=mand render to RGB565.CONFIG_GAMES_NXDOOMbecomes tristate.Testing
Build host: macOS 26.5 arm64 with
xtensa-esp-elf-gcc 14.2.0.Target: Waveshare ESP32-S3-Touch-LCD-7 with an RGB565 framebuffer.
nxstyle,git diff --check, and complete ESP32-S3 cross-build passed.SIGTERMreturned control to nxstore.The frontend stops waiting after two seconds, while NXDoom may still be writing
its configuration to FAT. A later
psshowed no NXDoom task.The framebuffer-origin and update fixes were also isolated on
sim:vncserver:(0,0)(80,40)in 800x480FBIO_UPDATEFBIO_UPDATEPR verification Self-Check