mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-03 21:29:05 +00:00
games/NXDoom: validate framebuffer pixel format, not just depth.
blit_screen() branches purely on pinfo.bpp (16 vs 32) to decide between the RGB565 and RGB32 conversion paths, but bit depth alone doesn't determine pixel layout - multiple incompatible formats share the same depth. i_init_graphics() now checks vinfo.fmt against the one format blit_screen() actually emits for each depth (FB_FMT_RGB16_565 for 16bpp, FB_FMT_RGB32 for 32bpp) and fails loudly via i_error() on any mismatch or unsupported depth, instead of silently misinterpreting the framebuffer's actual pixel layout. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: aviralgarg05 <gargaviral99@gmail.com>
This commit is contained in:
parent
5a3d77b65a
commit
b51959ea77
1 changed files with 16 additions and 0 deletions
|
|
@ -772,6 +772,22 @@ void i_init_graphics(void)
|
|||
i_error("ioctl(FBIOGET_PLANEINFO) failed: %d\n", errno);
|
||||
}
|
||||
|
||||
/* Depth alone is not enough: several incompatible pixel layouts use 16
|
||||
* or 32 bits. The conversion in blit_screen() emits RGB565 or RGB32.
|
||||
*/
|
||||
|
||||
if ((g_graphics_state.pinfo.bpp == 16 &&
|
||||
g_graphics_state.vinfo.fmt != FB_FMT_RGB16_565) ||
|
||||
(g_graphics_state.pinfo.bpp == 32 &&
|
||||
g_graphics_state.vinfo.fmt != FB_FMT_RGB32) ||
|
||||
(g_graphics_state.pinfo.bpp != 16 &&
|
||||
g_graphics_state.pinfo.bpp != 32))
|
||||
{
|
||||
i_error("Unsupported framebuffer format: fmt=%u, bpp=%u",
|
||||
g_graphics_state.vinfo.fmt,
|
||||
g_graphics_state.pinfo.bpp);
|
||||
}
|
||||
|
||||
/* Initialize frame buffer memory for actual rendering */
|
||||
|
||||
g_graphics_state.fbmem =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue