From aa4b7c9f92f229a082d853a4215a1b7762bf3da5 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Fri, 1 Oct 2021 14:18:42 +0200 Subject: [PATCH] [dxvk] Rework 32-bit check --- src/dxgi/dxgi_adapter.cpp | 14 +++++++------- src/dxvk/dxvk_memory.cpp | 8 ++++---- src/util/util_env.h | 7 +++++++ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/dxgi/dxgi_adapter.cpp b/src/dxgi/dxgi_adapter.cpp index 4766017ee..cd5f3370f 100644 --- a/src/dxgi/dxgi_adapter.cpp +++ b/src/dxgi/dxgi_adapter.cpp @@ -302,13 +302,13 @@ namespace dxvk { && options->maxSharedMemory < sharedMemory) sharedMemory = options->maxSharedMemory; - #ifndef _WIN64 - // The value returned by DXGI is a 32-bit value - // on 32-bit platforms, so we need to clamp it - VkDeviceSize maxMemory = 0xC0000000; - deviceMemory = std::min(deviceMemory, maxMemory); - sharedMemory = std::min(sharedMemory, maxMemory); - #endif + if (env::is32BitHostPlatform()) { + // The value returned by DXGI is a 32-bit value + // on 32-bit platforms, so we need to clamp it + VkDeviceSize maxMemory = 0xC0000000; + deviceMemory = std::min(deviceMemory, maxMemory); + sharedMemory = std::min(sharedMemory, maxMemory); + } pDesc->VendorId = deviceProp.vendorID; pDesc->DeviceId = deviceProp.deviceID; diff --git a/src/dxvk/dxvk_memory.cpp b/src/dxvk/dxvk_memory.cpp index 3f2525276..9a0656a85 100644 --- a/src/dxvk/dxvk_memory.cpp +++ b/src/dxvk/dxvk_memory.cpp @@ -432,10 +432,10 @@ namespace dxvk { // Try to waste a bit less system memory in 32-bit // applications due to address space constraints - #ifndef _WIN64 - if (type.propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) - chunkSize = 32 << 20; - #endif + if (env::is32BitHostPlatform()) { + if (type.propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) + chunkSize = 32 << 20; + } // Reduce the chunk size on small heaps so // we can at least fit in 15 allocations diff --git a/src/util/util_env.h b/src/util/util_env.h index e4a1020da..cb4aa2a08 100644 --- a/src/util/util_env.h +++ b/src/util/util_env.h @@ -4,6 +4,13 @@ namespace dxvk::env { + /** + * \brief Checks whether the host platform is 32-bit + */ + constexpr bool is32BitHostPlatform() { + return sizeof(void*) == 4; + } + /** * \brief Gets environment variable *