Commit 0f6a3e2
committed
gfx/gl1: reuse menu frame and POT buffers across set_texture_frame calls
gl1_set_texture_frame unconditionally free'd menu_frame and set it to
NULL before a subsequent size-comparison check, making the
"only reallocate if size changed" branch dead. Every menu frame
triggered a full free+malloc+memcpy round-trip on menu_frame.
Because GL1_FLAG_MENU_SIZE_CHANGED was also set unconditionally on
every successful call, the downstream frame path in gl1_frame
additionally reallocated the POT-sized menu_video_buf every single
frame — so the bug was compounded: two per-frame allocations, not one.
The inner 'if (gl1->menu_frame) free(gl1->menu_frame);' at the top of
the allocation branch was also unreachable dead code (menu_frame had
just been set to NULL directly above it).
Replace with a cached-capacity realloc pattern for menu_frame, and
gate GL1_FLAG_MENU_SIZE_CHANGED on actual dimension changes rather
than setting it on every call. menu_video_buf is now correctly
reused between frames when the menu dimensions don't change.
On realloc failure the previous frame is kept intact (the original
free+malloc sequence would have lost it). A transient NULL window
that existed between the free and malloc is also closed.
Thread-safety: set_texture_frame and the frame read-site both run on
the video thread (threaded video) or main thread (non-threaded),
sequentially within the same loop iteration. No synchronization
required, none added. gl1_t is calloc'd at init and the entire struct
is freed on teardown, so the new menu_frame_cap field starts at zero
on every re-init — no explicit reset needed in gl1_free.
With this commit the full cluster of drivers sharing the broken
set_texture_frame pattern (caca, fpga, sixel, network, gdi, vga,
gl1) is fixed.1 parent e7bb95f commit 0f6a3e2
1 file changed
Lines changed: 29 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
2011 | 2012 | | |
2012 | 2013 | | |
2013 | 2014 | | |
2014 | | - | |
| 2015 | + | |
2015 | 2016 | | |
| 2017 | + | |
2016 | 2018 | | |
2017 | | - | |
| 2019 | + | |
2018 | 2020 | | |
2019 | 2021 | | |
2020 | 2022 | | |
2021 | 2023 | | |
2022 | 2024 | | |
2023 | 2025 | | |
2024 | 2026 | | |
2025 | | - | |
2026 | | - | |
2027 | | - | |
2028 | | - | |
2029 | | - | |
2030 | | - | |
| 2027 | + | |
2031 | 2028 | | |
2032 | | - | |
2033 | | - | |
2034 | | - | |
2035 | | - | |
| 2029 | + | |
2036 | 2030 | | |
2037 | | - | |
2038 | | - | |
2039 | | - | |
2040 | | - | |
2041 | | - | |
2042 | | - | |
2043 | | - | |
2044 | | - | |
2045 | | - | |
2046 | | - | |
2047 | | - | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
2048 | 2041 | | |
2049 | 2042 | | |
2050 | | - | |
2051 | | - | |
2052 | | - | |
2053 | | - | |
2054 | | - | |
2055 | | - | |
2056 | | - | |
2057 | | - | |
2058 | | - | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
2059 | 2056 | | |
2060 | 2057 | | |
2061 | 2058 | | |
| |||
0 commit comments