Commit Graph
60 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 8265044a79 Add Hashmaps unit tests, stop tombstones from filling the table
DenseHashMap and PrehashMap are the open-addressed, linear-probing maps behind
the texture cache, the shader managers and the software renderer's
sampler/drawpixel caches, and had no coverage.

Writing the tests turned up a latent hang. Removal leaves tombstones, which
occupy probe slots exactly like live entries, but the load factor check only
looked at count_. So a workload that inserts and removes distinct keys keeps
count_ low forever while REMOVED fills the table, and no Grow is ever triggered.
Once there is no FREE bucket left, a lookup for a missing key has nothing to
terminate on - and the probe loops don't break out after their "Hit full"
assert, which is compiled out in release builds. The test reproduced it as a
hard hang in about a second.

Two fixes: count tombstones towards the load factor (rebuilding in place when
the load is mostly tombstones, growing otherwise), and make the probe loops
return instead of spinning if they ever do wrap all the way around.

Not reachable today - nothing in GPU/ calls Remove() on these maps, and
Maintain(), which exists to rebuild when tombstones pile up, is never called
anywhere. But Remove() is public API and the first caller to use it in a loop
would have hit an unexplained freeze.

Tests cover insert/get/miss/remove/size, tombstones not cutting a probe chain,
Iterate visiting exactly the live entries, Clear, growth past the initial
capacity, Rebuild compacting, a 20000-operation differential test against
std::unordered_map, and the tombstone churn above. PrehashMap gets the same
treatment.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-17 14:50:57 +02:00
Henrik RydgårdandClaude Sonnet 5 b0ab7fbaf7 FastVec::insert: fix off-by-one moving one element too many
The memmove length was computed from size_ after ExtendByOne() had
already bumped it, so it moved (oldSize - pos + 1) elements instead of
(oldSize - pos) - reading one uninitialized element past the old data
and writing one element past the new logical size. Currently masked
by ExtendByOne()'s growth policy always leaving capacity slack, but
a real overflow waiting for that assumption to not hold. Now captures
the old size before extending.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L4QAoxV2KY7ek4PcZw3WvY
2026-08-09 19:31:03 +02:00
Henrik RydgårdandClaude Sonnet 5 2360705a43 CharQueue: don't assert when '\r' is buffered but '\n' hasn't arrived yet
next_crlf_offset() called peek() one byte past the currently buffered
data whenever a '\r' was the very last byte received (a normal TCP
fragmentation boundary) - peek() has no way to signal "not enough
data yet" and just asserts. Now checks there's actually a next byte
before peeking.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L4QAoxV2KY7ek4PcZw3WvY
2026-08-09 19:31:03 +02:00
Henrik Rydgård b5a880568d Fix some latent bugs, delete some code. 2026-08-07 14:45:45 +02:00
Ren 3abb56e7f5 Savestate: store only live audio queue data (AudioChannel section v3)
FixedSizeQueue::DoState serializes the entire fixed backing store. For
the sceAudio channel queues that is 512KB per channel (32768*8 s16
samples), or ~4.6MB of mostly dead bytes in every savestate across the
nine channels - the live sample count at any moment is normally a few
KB. This addresses the existing TODO in DoState.

Add DoStateCompact(), which stores only the live [head, head+count)
region and restores it linearized at the front of storage. A wrapped
live region is written as its two pieces in pop order; since the POD
DoArray path writes raw bytes with no per-element or per-call header,
the single linear read on load consumes them identically. The count is
validated on load and a bad value fails the load cleanly via
p.SetError.

AudioChannel bumps its section to v3 to use the compact form; old
states still load through the unchanged full-storage path. This shrinks
every savestate by several MB uncompressed and cuts the copy/compress
cost of each save, including the rewind feature's periodic states.
2026-07-27 16:20:49 +02:00
Henrik Rydgård 5a5c7028b9 Assorted warning fixes and data initialization to please valgrind 2026-02-19 11:24:46 +01:00
Henrik Rydgård d8c40eefe8 Windows: Use a different window title for debug asserts
Fix bug in FastVec.h
2026-02-05 13:26:20 +01:00
Henrik Rydgård 841e4c8564 Add various checks trying to avoid various crashes found in Google Play crash reports. 2026-02-05 11:12:53 +01:00
Henrik Rydgård 3f747e6292 MSVC debugger: Add natvis file for FastVec so you can see contents in the debugger. 2025-05-16 18:51:45 +02:00
Henrik Rydgård 5260be6f69 Warning fixes, alignment checks 2025-05-15 09:48:23 +02:00
Sergio Martin e47a86e4b4 Adding missing include in CyclicBuffer.h
I found I had to do this to prevent a compilation error in a Windows build.
2025-04-10 21:41:16 +02:00
Henrik Rydgård b32c0b461a Very minor VulkanImage optimization 2025-03-30 11:22:19 +02:00
Henrik Rydgård 8a58f50caf Fix some compiler warnings 2025-01-29 11:13:48 +01:00
Henrik Rydgård b3346df646 ImDebugger: Add a window to inspect upcoming CoreTiming events 2024-12-07 16:28:27 +01:00
Henrik Rydgård 305453b52d Buffer: Optimize scanning for the next crlf 2024-11-22 10:31:07 +01:00
Henrik Rydgård dacdb0c6c2 Buildfix 2024-11-22 01:27:37 +01:00
Henrik Rydgård cb27df02f3 Implement new fast queue data structure CharQueue 2024-11-22 00:02:47 +01:00
Nemoumbra d1b49cf03b Moved the CyclicBuffer to the Collections dir 2024-09-20 16:19:24 +03:00
Herman Semenov 3c66f149d3 [Common/Core/Windows] Removed excess check pointer before delete or free() 2024-09-17 11:34:42 +02:00
Francisco Javier Trujillo Mata ffcab114a1 Fix debug compilation error 2024-07-29 17:54:06 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Herman Semenov 36b7875644 Fixed to free() C version, since memory block was allocated using malloc() 2024-04-02 16:35:13 +03:00
Henrik Rydgård 148ae0dd4a FastVec: Assert on the malloc to get better crash reports 2024-01-31 09:36:55 +01:00
Henrik Rydgård a22450320b Some minor changes and comments after memory profiling 2023-12-08 12:22:12 +01:00
Henrik Rydgård dde13b448f Use FastVec in VulkanBarrier 2023-12-07 17:30:18 +01:00
Henrik Rydgård 8dbcbe4ecf Align the APIs of the various vectors slightly 2023-12-07 17:30:16 +01:00
Henrik Rydgård 183d49329a Allow writing directly into the packed descriptor buffer, saving a memcpy. 2023-10-11 11:02:17 +02:00
Henrik Rydgård 8a4d84d82b Simplest possible de-duplication of descriptor set writes 2023-10-10 09:02:35 +02:00
Henrik Rydgård f0ee3b8daa Fill in descriptors on the render thread in the PPSSPP UI. 2023-10-10 09:00:29 +02:00
Henrik Rydgård d31ba393af Don't load the shader cache on a separate thread - all it does is already async 2023-09-24 10:53:23 +02:00
Henrik Rydgård 964f606a9c Fix some issues around geometry shaders - like, loading them from shader cache while disabled 2023-09-24 01:29:38 +02:00
Henrik Rydgård 10f93875c6 Fix the semantics of DenseHashMap to be consistent even when inserting nulls 2023-09-11 12:07:18 +02:00
Henrik Rydgård 691c8b8d8d Write to the frame time history from the other backends too. Needed for the upcoming timing code. 2023-08-16 12:22:49 +02:00
Henrik Rydgård 572595cc7b Refactor: Lift the frame time history data up one level into thin3d 2023-08-16 11:45:26 +02:00
Henrik Rydgård cda59e8510 Vulkan: Keep track of some timestamps in a frame 2023-08-02 16:25:17 +02:00
Henrik Rydgård eb14c87a71 Allow configuring the game language separately from the PPSSPP UI language, with a new setting. 2023-07-23 11:30:04 +02:00
Henrik Rydgård 93de74144e Add basic achievement rendering 2023-06-26 10:01:41 +02:00
Henrik Rydgård fbd10e4722 FastVec: Add capacity lock, fix bug (extracted from a coming PR) 2023-06-14 09:06:25 +02:00
Henrik Rydgård 234c1f05b8 Apply the same optimizations to the Vulkan backend. Smaller effect than for OpenGL. 2023-05-23 08:54:41 +02:00
Henrik Rydgård ab34d20058 Add more methods to FastVec 2023-05-23 08:54:41 +02:00
Henrik Rydgård 47931deda7 Switch to FastVec for commands. Slower than std::vector! 2023-05-23 08:54:41 +02:00
Henrik Rydgård 558e29a9bb Switch to the copy-free method of initializing initsteps 2023-05-23 08:54:41 +02:00
Henrik Rydgård 956d784bde Add FastVec, start using it for InitSteps 2023-05-23 08:54:40 +02:00
Henrik Rydgård fcd11dfd4c Update a comment 2023-05-04 09:49:14 +02:00
Henrik Rydgård f45a7cf06b Some semantic cleanup 2023-04-24 12:04:34 +02:00
Henrik Rydgård f178d1bd85 Add an even cheaper version of TinySet called FixedTinyVec that's, well, fixed. 2023-04-01 12:01:27 +02:00
Henrik Rydgård 67cba831dd Slightly more useful assert message in Hashmaps.h 2022-12-29 00:39:59 +01:00
Henrik Rydgård e30e45fa26 Minor cleanup in TinySet 2022-09-25 23:23:53 +02:00
Unknown W. Brackets 56e30495aa Common: Fix some type compare warnings on 32-bit. 2022-09-12 22:14:48 -07:00
Henrik Rydgård 77819c6f80 Lifetime fixes, cleanups 2022-09-08 00:38:32 +02:00