From c4ef5d4eb8584d6b8e9b91d9d1b6ba2c06143a15 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Fri, 29 May 2015 21:47:19 -0700 Subject: [PATCH] Allow AllocFixed of unreserved ranges. --- src/xenia/gpu/gl4/command_processor.cc | 5 ++++- src/xenia/memory.cc | 14 +++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/xenia/gpu/gl4/command_processor.cc b/src/xenia/gpu/gl4/command_processor.cc index 5692b8878..848d13231 100644 --- a/src/xenia/gpu/gl4/command_processor.cc +++ b/src/xenia/gpu/gl4/command_processor.cc @@ -484,7 +484,10 @@ void CommandProcessor::UpdateWritePointer(uint32_t value) { void CommandProcessor::WriteRegister(uint32_t index, uint32_t value) { RegisterFile* regs = register_file_; - assert_true(index < RegisterFile::kRegisterCount); + if (index >= RegisterFile::kRegisterCount) { + XELOGW("CommandProcessor::WriteRegister index out of bounds: %d", index); + return; + } regs->values[index].u32 = value; diff --git a/src/xenia/memory.cc b/src/xenia/memory.cc index de26209f5..b98290e9a 100644 --- a/src/xenia/memory.cc +++ b/src/xenia/memory.cc @@ -560,7 +560,7 @@ bool BaseHeap::AllocFixed(uint32_t base_address, uint32_t size, uint32_t end_page_number = start_page_number + page_count - 1; if (start_page_number >= page_table_.size() || end_page_number > page_table_.size()) { - XELOGE("BaseHeap::Alloc passed out of range address range"); + XELOGE("BaseHeap::AllocFixed passed out of range address range"); return false; } @@ -575,14 +575,18 @@ bool BaseHeap::AllocFixed(uint32_t base_address, uint32_t size, uint32_t state = page_table_[page_number].state; if ((allocation_type == kMemoryAllocationReserve) && state) { // Already reserved. - XELOGE("BaseHeap::Alloc attempting to reserve an already reserved range"); + XELOGE( + "BaseHeap::AllocFixed attempting to reserve an already reserved " + "range"); return false; } if ((allocation_type == kMemoryAllocationCommit) && !(state & kMemoryAllocationReserve)) { // Attempting a commit-only op on an unreserved page. - XELOGE("BaseHeap::Alloc attempting commit on unreserved page"); - return false; + // This may be OK. + XELOGW("BaseHeap::AllocFixed attempting commit on unreserved page"); + allocation_type |= kMemoryAllocationReserve; + break; } } @@ -599,7 +603,7 @@ bool BaseHeap::AllocFixed(uint32_t base_address, uint32_t size, page_count * page_size_, flAllocationType, ToWin32ProtectFlags(protect)); if (!result) { - XELOGE("BaseHeap::Alloc failed to alloc range from host"); + XELOGE("BaseHeap::AllocFixed failed to alloc range from host"); return false; }