mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-28 18:46:06 +00:00
texture_cache: protection flags re-worked
* actually I gave up on clang fmt
This commit is contained in:
parent
d2c53d0fde
commit
249373bf0d
|
@ -12,14 +12,11 @@
|
|||
#include <signal.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#define PROT_READ_WRITE
|
||||
(PROT_READ | PROT_WRITE) // There is no option to combine bitflags like this on Windows
|
||||
#define PAGE_NOACCESS PROT_NONE
|
||||
#define PAGE_READWRITE (PROT_READ | PROT_WRITE)
|
||||
#else
|
||||
#include <Windows.h>
|
||||
|
||||
#define PROT_NONE PAGE_NOACCESS
|
||||
#define PROT_READ_WRITE PAGE_READWRITE
|
||||
|
||||
void mprotect(void* addr, size_t len, int prot) {
|
||||
DWORD old_prot{};
|
||||
BOOL result = VirtualProtect(addr, len, prot, &old_prot);
|
||||
|
@ -228,9 +225,9 @@ void TextureCache::UpdatePagesCachedCount(VAddr addr, u64 size, s32 delta) {
|
|||
const u32 interval_size = interval_end_addr - interval_start_addr;
|
||||
void* addr = reinterpret_cast<void*>(interval_start_addr);
|
||||
if (delta > 0 && count == delta) {
|
||||
mprotect(addr, interval_size, PROT_NONE);
|
||||
mprotect(addr, interval_size, PAGE_NOACCESS);
|
||||
} else if (delta < 0 && count == -delta) {
|
||||
mprotect(addr, interval_size, PROT_READ_WRITE);
|
||||
mprotect(addr, interval_size, PAGE_READWRITE);
|
||||
} else {
|
||||
ASSERT(count >= 0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue