From 3b86c57d0e7dcbf3c212fdba7dd0cd7dc7bd2636 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Mon, 9 Dec 2019 13:17:58 +0100 Subject: [PATCH] texture corruptions with some wince games vram wasn't protected in some cases Worms World Party, Tomb Raider - Final Revelation, Hundred Swords --- core/rend/TexCache.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/core/rend/TexCache.cpp b/core/rend/TexCache.cpp index 21e1e1302..eec652c83 100644 --- a/core/rend/TexCache.cpp +++ b/core/rend/TexCache.cpp @@ -1,3 +1,4 @@ +#include #ifndef TARGET_NO_OPENMP #include #endif @@ -154,30 +155,17 @@ void vramlock_list_add(vram_block* block) u32 base = block->start / PAGE_SIZE; u32 end = block->end / PAGE_SIZE; - for (u32 i = base; i <= end; i++) { vector& list = VramLocks[i]; // If the list is empty then we need to protect vram, otherwise it's already been done - if (list.empty()) - { + if (list.empty() || std::all_of(list.begin(), list.end(), [](vram_block *block) { return block == nullptr; })) _vmem_protect_vram(i * PAGE_SIZE, PAGE_SIZE); - } + auto it = std::find(list.begin(), list.end(), nullptr); + if (it != list.end()) + *it = block; else - { - for (u32 j = 0; j < list.size(); j++) - { - if (list[j] == nullptr) - { - list[j] = block; - goto added_it; - } - } - } - - list.push_back(block); -added_it: - i=i; + list.push_back(block); } }