[D3D12] Redesigned page access for gpu buffer allocation
This commit is contained in:
parent
320102db34
commit
1864f3d9f2
|
@ -421,6 +421,22 @@ bool D3D12SharedMemory::UploadRanges(
|
||||||
trace_writer_.WriteMemoryRead(upload_range_start << page_size_log2(),
|
trace_writer_.WriteMemoryRead(upload_range_start << page_size_log2(),
|
||||||
upload_range_length << page_size_log2());
|
upload_range_length << page_size_log2());
|
||||||
while (upload_range_length != 0) {
|
while (upload_range_length != 0) {
|
||||||
|
// Hacky handling for certain games (494707D4, 55530874) that crashes due
|
||||||
|
// to accessing unallocated pages
|
||||||
|
const uint32_t upload_range_last_page =
|
||||||
|
upload_range_start + upload_range_length - 1;
|
||||||
|
|
||||||
|
memory::PageAccess page_access =
|
||||||
|
memory().GetPhysicalHeap()->QueryRangeAccess(
|
||||||
|
upload_range_last_page << page_size_log2(),
|
||||||
|
(upload_range_last_page
|
||||||
|
<< page_size_log2())); // Check only last page
|
||||||
|
|
||||||
|
if (page_access == xe::memory::PageAccess::kNoAccess) {
|
||||||
|
XELOGE("Invalid upload range for GPU: {:08X}", upload_range_start);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ID3D12Resource* upload_buffer;
|
ID3D12Resource* upload_buffer;
|
||||||
size_t upload_buffer_offset, upload_buffer_size;
|
size_t upload_buffer_offset, upload_buffer_size;
|
||||||
uint8_t* upload_buffer_mapping = upload_buffer_pool_->RequestPartial(
|
uint8_t* upload_buffer_mapping = upload_buffer_pool_->RequestPartial(
|
||||||
|
@ -435,21 +451,6 @@ bool D3D12SharedMemory::UploadRanges(
|
||||||
MakeRangeValid(upload_range_start << page_size_log2(),
|
MakeRangeValid(upload_range_start << page_size_log2(),
|
||||||
uint32_t(upload_buffer_size), false, false);
|
uint32_t(upload_buffer_size), false, false);
|
||||||
|
|
||||||
// Handling for certain games that crashes due to accessing unallocated
|
|
||||||
// pages. It's usually happens with base_page that is completely different
|
|
||||||
// that any previously used ones. It always is completely not allocated.
|
|
||||||
// Additionally these requests are usually quite small 1-2 pages.
|
|
||||||
memory::PageAccess page_access =
|
|
||||||
memory().GetPhysicalHeap()->QueryRangeAccess(
|
|
||||||
upload_range_start << page_size_log2(),
|
|
||||||
(upload_range_start << page_size_log2()) +
|
|
||||||
(uint32_t)1); // Check only first page
|
|
||||||
|
|
||||||
if (page_access == xe::memory::PageAccess::kNoAccess) {
|
|
||||||
XELOGE("Invalid upload range for GPU: {:08X}", upload_range_start);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (upload_buffer_size < (1ULL << 32) && upload_buffer_size > 8192) {
|
if (upload_buffer_size < (1ULL << 32) && upload_buffer_size > 8192) {
|
||||||
memory::vastcpy(
|
memory::vastcpy(
|
||||||
upload_buffer_mapping,
|
upload_buffer_mapping,
|
||||||
|
|
Loading…
Reference in New Issue