Improve error handling in graphics memory init
This commit is contained in:
@@ -34,7 +34,9 @@ D3D12SharedMemory::D3D12SharedMemory(D3D12CommandProcessor& command_processor,
|
|||||||
D3D12SharedMemory::~D3D12SharedMemory() { Shutdown(true); }
|
D3D12SharedMemory::~D3D12SharedMemory() { Shutdown(true); }
|
||||||
|
|
||||||
bool D3D12SharedMemory::Initialize() {
|
bool D3D12SharedMemory::Initialize() {
|
||||||
InitializeCommon();
|
if (!InitializeCommon()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const ui::d3d12::D3D12Provider& provider =
|
const ui::d3d12::D3D12Provider& provider =
|
||||||
command_processor_.GetD3D12Provider();
|
command_processor_.GetD3D12Provider();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ SharedMemory::SharedMemory(Memory& memory) : memory_(memory) {
|
|||||||
|
|
||||||
SharedMemory::~SharedMemory() { ShutdownCommon(); }
|
SharedMemory::~SharedMemory() { ShutdownCommon(); }
|
||||||
|
|
||||||
void SharedMemory::InitializeCommon() {
|
bool SharedMemory::InitializeCommon() {
|
||||||
size_t num_system_page_flags_entries =
|
size_t num_system_page_flags_entries =
|
||||||
((kBufferSize >> page_size_log2_) + 63) / 64;
|
((kBufferSize >> page_size_log2_) + 63) / 64;
|
||||||
num_system_page_flags_ = static_cast<uint32_t>(num_system_page_flags_entries);
|
num_system_page_flags_ = static_cast<uint32_t>(num_system_page_flags_entries);
|
||||||
@@ -36,6 +36,11 @@ void SharedMemory::InitializeCommon() {
|
|||||||
nullptr, num_system_page_flags_ * 3 * sizeof(uint64_t),
|
nullptr, num_system_page_flags_ * 3 * sizeof(uint64_t),
|
||||||
memory::AllocationType::kReserveCommit, memory::PageAccess::kReadWrite);
|
memory::AllocationType::kReserveCommit, memory::PageAccess::kReadWrite);
|
||||||
|
|
||||||
|
if (!system_page_flags_base) {
|
||||||
|
XELOGE("SharedMemory: Failed to allocate system page flags");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
system_page_flags_valid_ = system_page_flags_base,
|
system_page_flags_valid_ = system_page_flags_base,
|
||||||
system_page_flags_valid_and_gpu_resolved_ =
|
system_page_flags_valid_and_gpu_resolved_ =
|
||||||
system_page_flags_base + (num_system_page_flags_),
|
system_page_flags_base + (num_system_page_flags_),
|
||||||
@@ -49,6 +54,7 @@ void SharedMemory::InitializeCommon() {
|
|||||||
memory_invalidation_callback_handle_ =
|
memory_invalidation_callback_handle_ =
|
||||||
memory_.RegisterPhysicalMemoryInvalidationCallback(
|
memory_.RegisterPhysicalMemoryInvalidationCallback(
|
||||||
MemoryInvalidationCallbackThunk, this);
|
MemoryInvalidationCallbackThunk, this);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SharedMemory::InitializeSparseHostGpuMemory(uint32_t granularity_log2) {
|
void SharedMemory::InitializeSparseHostGpuMemory(uint32_t granularity_log2) {
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class SharedMemory {
|
|||||||
protected:
|
protected:
|
||||||
SharedMemory(Memory& memory);
|
SharedMemory(Memory& memory);
|
||||||
// Call in implementation-specific initialization.
|
// Call in implementation-specific initialization.
|
||||||
void InitializeCommon();
|
bool InitializeCommon();
|
||||||
void InitializeSparseHostGpuMemory(uint32_t granularity_log2);
|
void InitializeSparseHostGpuMemory(uint32_t granularity_log2);
|
||||||
// Call last in implementation-specific shutdown, also callable from the
|
// Call last in implementation-specific shutdown, also callable from the
|
||||||
// destructor.
|
// destructor.
|
||||||
|
|||||||
@@ -44,7 +44,9 @@ VulkanSharedMemory::VulkanSharedMemory(
|
|||||||
VulkanSharedMemory::~VulkanSharedMemory() { Shutdown(true); }
|
VulkanSharedMemory::~VulkanSharedMemory() { Shutdown(true); }
|
||||||
|
|
||||||
bool VulkanSharedMemory::Initialize() {
|
bool VulkanSharedMemory::Initialize() {
|
||||||
InitializeCommon();
|
if (!InitializeCommon()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const ui::vulkan::VulkanDevice* const vulkan_device =
|
const ui::vulkan::VulkanDevice* const vulkan_device =
|
||||||
command_processor_.GetVulkanDevice();
|
command_processor_.GetVulkanDevice();
|
||||||
|
|||||||
Reference in New Issue
Block a user