diff options
| author | MrPurple666 <mrpurple666@noreply.localhost> | 2025-05-18 17:45:32 +0000 |
|---|---|---|
| committer | CamilleLaVey <camillelavey@noreply.localhost> | 2025-05-18 17:45:32 +0000 |
| commit | ce5d5d2aff50f9ce8159d609824eb2391bed9ef2 (patch) | |
| tree | 9d61c37db089ef8fed4fb9feda62f665aeebecd4 /src/common/free_region_manager.h | |
| parent | 049cc54f4c3c1c4c38f4b308fca37e507a32f35f (diff) | |
THIS NEEDS TO BE CHECKED BEFORE MERGE: RAII fix, initial MSAA, some fixes for memory misallocation (#116)
• MSAA Fixes: Fixes upload/download for MSAA textures using temporary non-MSAA images. Ensures compatibility with color formats and adds fallbacks for depth/stencil.
• Memory fix misallocation: Adds checks for null/zero-length operations in memory management and improves cleanup to avoid crashes (Related to crash issues due to misallocation, RP5 and 865)
• Vulkan Initialization (RAII): this almost rewrites the way vulkan initializes to avoid crashes, using a correct order now (thanks @crueter for the initial fix)
•Please check before merging:
- Test MSAA workflows (especially color/depth transitions and low memory cases).
- Verify memory operations (e.g., unmapping zero-length regions).
- Check Vulkan object lifetimes and platform-specific behavior.
- Check others plataforms beyond android
Why is everything in one PR? Otherwise, this is all a big fix, by checking the points above we can create a branch for each one and check them by themselves. I'm not standing still while I'm away, I'm just out of time for now.
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/116
Co-authored-by: MrPurple666 <mrpurple666@noreply.localhost>
Co-committed-by: MrPurple666 <mrpurple666@noreply.localhost>
Diffstat (limited to 'src/common/free_region_manager.h')
| -rw-r--r-- | src/common/free_region_manager.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/free_region_manager.h b/src/common/free_region_manager.h index 2e590d6094..2ff629b359 100644 --- a/src/common/free_region_manager.h +++ b/src/common/free_region_manager.h @@ -12,12 +12,22 @@ class FreeRegionManager { public: explicit FreeRegionManager() = default; ~FreeRegionManager() = default; + + // Clear all free regions + void Clear() { + std::scoped_lock lk(m_mutex); + m_free_regions.clear(); + } void SetAddressSpace(void* start, size_t size) { this->FreeBlock(start, size); } std::pair<void*, size_t> FreeBlock(void* block_ptr, size_t size) { + if (block_ptr == nullptr || size == 0) { + return {nullptr, 0}; + } + std::scoped_lock lk(m_mutex); // Check to see if we are adjacent to any regions. @@ -41,6 +51,11 @@ public: } void AllocateBlock(void* block_ptr, size_t size) { + // Skip if pointer is null or size is zero + if (block_ptr == nullptr || size == 0) { + return; + } + std::scoped_lock lk(m_mutex); auto address = reinterpret_cast<uintptr_t>(block_ptr); |
