Skip to content

RT1#1

Open
magicseb wants to merge 10000 commits intomagicseb:masterfrom
libretro:master
Open

RT1#1
magicseb wants to merge 10000 commits intomagicseb:masterfrom
libretro:master

Conversation

@magicseb
Copy link
Owner

@magicseb magicseb commented Nov 5, 2019

No description provided.

gouchi and others added 29 commits January 28, 2026 02:35
This patch implements functionality (safe-shutdown, reset) to Lakka for
Raspberry Pi devices using various RetroFlags cases for various
Raspberry Pi models.

Additional guards added to makefile to make sure that make options
specific to Lakka are only used with Lakka.

Co-authored-by: Shigeaki Asai <y-asai.0816@docomonet.jp>
Co-authored-by: hunterk <hunter_kaller@yahoo.com>
Co-authored-by: PoloniumRain <poloniumrain@users.noreply.github.com>
#18678)

Set explicit blend factors (src=ONE, dst=ONE_MINUS_SRC_ALPHA) on
the HDR pipeline blend attachment for correct alpha compositing.

Refactor vulkan_run_hdr_pipeline to check the return value of
vulkan_buffer_chain_alloc before writing vertices, replace the
VULKAN_WRITE_QUAD_VBO macro with explicit vertex definitions for
clarity, and move vkCmdBindVertexBuffers/vkCmdDraw inside the
allocation success block to avoid drawing with invalid buffers.
This was causing RGUI to flicker and Ozone menu to randomly crash. Unfortunately, this re-breaks mipmaps on this driver, but the instability is a bigger problem.
LibretroAdmin and others added 30 commits March 8, 2026 21:45
1. Early-exit in the borders draw loop (ozone_draw_entries)
2. Deduplicated gfx_display_set_alpha calls in the borders loop
3. Early-exit in the icons+text draw loop (ozone_draw_entries)
4. Sidebar console tab culling (ozone_draw_sidebar)
5. Eliminated redundant menu_entry_get calls in ozone_compute_entries_position
1) input_joypad_axis — Removed the redundant (1.0f / 0x7fff) * val * sensitivity round-trip through normalized
2) input_joypad_analog_button — Hoisted joypad_info->joy_idx into a local joy_idx
3) input_state_wrap axis comparison — Replaced two /0x8000 float divisions (one per joypad) with a single precomputed inv_0x8000 = 1.0f / 0x8000 multiplied in.
4) Analog-to-digital mapping loop — The inner (float)ret_axis / 0x7fff was computed up to 4 times per axis value (once per direction comparison). Now it's computed once as norm
5) input_state_internal - expression hoisted Hoisted into a single kb_blocked bool in an enclosing scope block.
6) input_keys_pressed — Same flag check was evaluated 3–4 times across the function body plus once per iteration of the meta-key for loop. Hoisted into a single kb_blocked local
7) input_keyboard_event accessibility path — Eliminated a malloc(2) + free() call per keypress for a 2-byte string
1. Eliminated massive calloc over-allocation for uints settings (biggest win)
2. Replaced all 7 sizeof-based size calculations with compile-time constants
3. Fixed strdup memory leak in populate_settings_array
- new_file[32768] — downsized to PATH_MAX_LENGTH
- win32_clip_window — WINDOWINFO was heap-allocated with malloc for no reason.
Changed to stack variable with correct sizeof(WINDOWINFO)
- DragQueryFileW - Correct size argument now
- win32_meta_key_to_name — returns NULL for unmapped keys, but strlen was called on its return value unconditionally. Added a NULL guard
- win32_get_refresh_rate — removed GetVersionEx (deprecated since Vista, absent in some SDKs) since the whole block is already #if-gated on Win7+. Also fixed a missing Denominator != 0 guard before the division
- win32_get_metrics — previously opened and released a HDC once per case branch (5 separate GetDC/ReleaseDC round-trips). Now opens one HDC, queries what's needed, and releases it once
- win32_get_refresh_rate — the two GetModuleHandle("user32.dll") calls (one per function pointer) each hit a hash-table lookup. Combined them so user32 is retrieved once only when either pointer is missing
- win32_load_content_from_gui — the if/else block around DialogBoxParam was identical in both branches (the only difference was showing the mouse cursor). Deduplicated into a single dialog call with conditional cursor show/hide around it
- pick_core_proc — removed shadowed const core_info_t *info variables and redundant &array[i]-to-pointer casts
- win32_resize_after_display_change — abs() on monitor RECT deltas is unnecessary (right ≥ left always); removed the call
* Float division replaced with integer multiply (dinput_joypad_inl.h —
* Rumble destroy loop deduplicated (dinput_joypad_inl.h)
* Duplicated axis switch eliminated (dinput_joypad_inl.h)
* Fixed: POV centered-sentinel not guarded (dinput_joypad_inl.h)
* lZ never zeroed in poll (dinput_joypad_excl.h)
* Rumble strong/weak index inverted (dinput_joypad_inl.h)
* port_idx bounds-check after array dereference (dinput_joypad_inl.h
* TCHAR* cast breaks Unicode builds (dinput_joypad_excl.h)
- Fix 1: wasapi_error — thread-safe per-call buffer instead of static
- Fix 2: wasapi_is_format_suitable — remove double negation
- Fix 3: wasapi_init_client_ex — clarify confusing AUDCLNT_E_UNSUPPORTED_FORMAT guard
- Fix 4: wasapi_write_avail — fix unit mismatch (padding is frames, not bytes)
- Fix 5: wasapi_microphone_read — remove dead if (mic->exclusive) branch duplication
- Fix 6: wasapi_free — w->device is never NULLed before free(w), but w->client and w->device are used in cleanup after free in the error path. Audit the ordering in wasapi_free.
- Fix 7: Performance — wasapi_write flag check uses > 0 comparisons on bitmask, simplify to direct mask test throughout
- Fix 8: Performance — wasapi_init flag check > 0 and wasapi_alive
- Fix 9: Performance — wasapi_write_avail exclusive path also has redundant > 0
* string_split / string_split_noalloc — pre-count tokens and pre-allocate the elem array in one shot, eliminating repeated realloc doublings (the biggest win for typical split-heavy workloads).
* string_list_append — grow check happens before strdup, so a failed realloc doesn't waste a malloc+free cycle on the string copy.
* new function string_list_append_n - and remove static function from archive_file
1. config_file_parse_line key parsing — Saves 1 malloc + up to N reallocs per config line
2. config_file_extract_value empty value — Saves 1 byte per empty-value entry.
3. config_file_load_internal deferred alloc — Saves 1 malloc + 1 free for every blank line, empty line, and comment line in a config file.
4. config_file_from_string_internal deferred alloc — Same saving as #3 but for the string-parsing path. Same magnitude.
5. config_file_add_child_list tail — No memory saving, but avoids an O(n) linked-list walk per #include merge by using the already-tracked tail pointer. Also eliminates duplicated readonly-loop code.
6. config_file_write stack setvbuf — Saves 1 calloc(16384) + 1 free per config write. That's 16 KB of heap allocation eliminated on every save, replaced with a stack-local buffer that costs zero allocator overhead.
7. strtol instead of strtod — No memory saving; avoids unnecessary FPU work when parsing integer arrays.
1. leading_ones() → 256-byte lookup table (utf8_lut[])
2. utf8_conv_utf32() — ASCII fast-path + unrolled switch
3. utf16_conv_utf8() — split counting vs. encoding passes
4. utf8cpy(), utf8skip(), utf8len() — LUT-based character skipping
1. sthread_detach NULL dereference
2. scond_broadcast missing critical section
3. PS2 nanosecond calculation
4. Gekko nanosecond calculation
5. tv_nsec overflow check off-by-one
6. Racy static locals in _scond_wait_win32
7. Renamed _scond_wait_win32 → scond_wait_win32
8. Fixed tab/space inconsistencies in thread_wrap and sthread_create
9. Fixed "immplementing" typo, "get get" duplication in comments.
10. Removed stale TODO/FIXME - broken for UCRT comments from the TLS functions (they aren't broken; the comment was misleading).
11. Wrapped mid-block declarations (struct timeval tm, const uint64_t tickms, int tickms) in compound statement blocks {} for strict C89 compliance.
1. New helper: content_information_ctx_init() (lines 641–737)
Centralises the repeated ~40-line init pattern into one function.
2. New helper: content_information_ctx_free() (lines 738–756)
Centralises the repeated free-all-fields teardown
3. Removed dead NULL checks in content_file_list_set_info()
4. Fixed memory leak in content_file_get_path() Android SAF path (line 940)
5. Fixed unchecked malloc in content_add_subsystem() (line 2932)
6. Fixed resource leak in task_push_load_contentless_core_from_menu() (line 2220)
7. Refactored content_init() (line 2798)
8. Refactored task_push_start_dummy_core() (line 2004)
9. Refactored task_push_load_content_from_playlist_from_menu() (line 2041)
10. Refactored task_push_start_current_core() (line 2137)
11. Refactored task_push_load_content_with_new_core_from_menu() (line 2297)
12. Refactored task_load_content_internal() (line 2365)
Bugfixes:
1. Off-by-one in video_shader_combine_shaders — i <= GFX_MAX_SHADERS → i < GFX_MAX_SHADERS for both pass-copy loops, preventing an out-of-bounds write at index 64
2. Missing LUT bounds check in video_shader_combine_shaders
3. NULL dereference in override application loop
4. NULL dereference in video_shader_gather_reference_path_list
5. NULL dereference in video_shader_check_reference_chain_for_save
6. NULL dereference in video_shader_load_preset_into_shader
7. NULL dereference in video_shader_write_referenced_preset
8. Division by zero — viewport aspect ratio now guards against viewport_height == 0
Memory safety:
1. Added malloc/calloc NULL checks throughout: video_shader_gather_reference_path_list, video_shader_get_root_preset_config, video_shader_check_reference_chain_for_save, video_shader_write_referenced_preset, video_shader_combine_preset_and_apply, video_shader_override_values, and the reference-chain crawl loop
2. Fixed path_to_ref memory leak in video_shader_load_preset_into_shader — the pointer was allocated inside the loop but never freed on goto end paths
Performance:
1. Eliminated redundant O(n) parameter lookups in video_shader_load_current_parameter_values and video_shader_override_values — both used video_shader_parse_find_parameter to search for shader->parameters[i] by ID when they already had the index i
2. Eliminated double calls to video_shader_parse_find_parameter in video_shader_combine_shaders — the find result is now cached in a local pointer
3. wildcard_tokens array marked static const for read-only placement
Code quality:
1. memcmp(str, "", sizeof("")) replaced with idiomatic str[0] != '\0' checks (6 occurrences)
2. Fixed %u format specifier with (int) cast → (unsigned) cast
3. Fixed inconsistent tab indentation (lines 723–724)
4. Removed unused outer _len variable shadowing in video_shader_apply_shader
5. Removed redundant if (path) null check after string_is_empty(path) already returned false
6. Fixed return 0 → return false type mismatch in video_shader_override_values
7. Fixed char* → char * pointer declaration style consistency
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.