[PATCH v2 0/1] MR4466: win32u/winex11: Add the GPU device physical memory registry
Starcraft Remastered is looking up for the GPU physical memory size to check for minimum requirements to enable RealTime Lighting. This patch should solve the bug: https://bugs.winehq.org/show_bug.cgi?id=46624 Signed-off-by: Jon Doron <arilou(a)gmail.com> -- v2: win32u/winex11: Add the GPU device physical memory registry https://gitlab.winehq.org/wine/wine/-/merge_requests/4466
From: Jon Doron <arilou(a)gmail.com> Starcraft Remastered is looking up for the GPU physical memory size to check for minimum requirements to enable RealTime Lighting. This patch should solve the bug: https://bugs.winehq.org/show_bug.cgi?id=46624 Signed-off-by: Jon Doron <arilou(a)gmail.com> --- dlls/win32u/sysparams.c | 10 ++++++++++ dlls/winex11.drv/xrandr.c | 21 ++++++++++++++++++++- include/wine/gdi_driver.h | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 9d23c533049..87c42b1f736 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1210,6 +1210,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) unsigned int gpu_index, size; HKEY hkey, subkey; LARGE_INTEGER ft; + ULONG gpu_memory_size; static const BOOL present = TRUE; static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0}; @@ -1225,6 +1226,12 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) static const WCHAR chip_typeW[] = {'H','a','r','d','w','a','r','e','I','n','f','o','r','m','a','t','i','o','n','.', 'C','h','i','p','T','y','p','e',0}; + static const WCHAR qw_memory_sizeW[] = + {'H','a','r','d','w','a','r','e','I','n','f','o','r','m','a','t','i','o','n','.', + 'q','w','M','e','m','o','r','y','S','i','z','e',0}; + static const WCHAR memory_sizeW[] = + {'H','a','r','d','w','a','r','e','I','n','f','o','r','m','a','t','i','o','n','.', + 'M','e','m','o','r','y','S','i','z','e',0}; static const WCHAR dac_typeW[] = {'H','a','r','d','w','a','r','e','I','n','f','o','r','m','a','t','i','o','n','.', 'D','a','c','T','y','p','e',0}; @@ -1376,6 +1383,9 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) set_reg_value( hkey, bios_stringW, REG_BINARY, desc, size ); set_reg_value( hkey, chip_typeW, REG_BINARY, desc, size ); set_reg_value( hkey, dac_typeW, REG_BINARY, ramdacW, sizeof(ramdacW) ); + set_reg_value( hkey, qw_memory_sizeW, REG_QWORD, &gpu->memory_size, sizeof(gpu->memory_size) ); + gpu_memory_size = (ULONG)min( gpu->memory_size, (ULONGLONG)ULONG_MAX ); + set_reg_value( hkey, memory_sizeW, REG_DWORD, &gpu_memory_size, sizeof(gpu_memory_size) ); if (gpu->vendor_id && gpu->device_id) { diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index cf3f911cf5b..02969854eca 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -643,9 +643,11 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid VkResult (*pvkGetRandROutputDisplayEXT)( VkPhysicalDevice, Display *, RROutput, VkDisplayKHR * ); PFN_vkGetPhysicalDeviceProperties2KHR pvkGetPhysicalDeviceProperties2KHR; PFN_vkEnumeratePhysicalDevices pvkEnumeratePhysicalDevices; - uint32_t device_count, device_idx, output_idx, i; + PFN_vkGetPhysicalDeviceMemoryProperties pvkGetPhysicalDeviceMemoryProperties; + uint32_t device_count, device_idx, output_idx, heap_idx, i; VkPhysicalDevice *vk_physical_devices = NULL; VkPhysicalDeviceProperties2 properties2; + VkPhysicalDeviceMemoryProperties mem_properties; VkInstanceCreateInfo create_info; VkPhysicalDeviceIDProperties id; VkInstance vk_instance = NULL; @@ -679,6 +681,7 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid LOAD_VK_FUNC(vkEnumeratePhysicalDevices) LOAD_VK_FUNC(vkGetPhysicalDeviceProperties2KHR) LOAD_VK_FUNC(vkGetRandROutputDisplayEXT) + LOAD_VK_FUNC(vkGetPhysicalDeviceMemoryProperties) #undef LOAD_VK_FUNC vr = pvkEnumeratePhysicalDevices( vk_instance, &device_count, NULL ); @@ -738,6 +741,22 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid } RtlUTF8ToUnicodeN( gpu->name, sizeof(gpu->name), &len, properties2.properties.deviceName, strlen( properties2.properties.deviceName ) + 1 ); + + pvkGetPhysicalDeviceMemoryProperties( vk_physical_devices[device_idx], &mem_properties ); + for (heap_idx = 0; heap_idx < mem_properties.memoryHeapCount; heap_idx++) + { + if (mem_properties.memoryHeaps[heap_idx].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) + { + gpu->memory_size += mem_properties.memoryHeaps[heap_idx].size; + } + } + + /* We failed to retrieve the gpu memory size set a default of 4Gb */ + if (!gpu->memory_size) + { + gput->memory_size = 4294967296LL; + } + ret = TRUE; goto done; } diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index aa59a256482..fd27266068f 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -249,6 +249,7 @@ struct gdi_gpu UINT subsys_id; UINT revision_id; GUID vulkan_uuid; /* Vulkan device UUID */ + ULONGLONG memory_size; }; struct gdi_adapter -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4466
Zhiyi Zhang (@zhiyi) commented about dlls/winex11.drv/xrandr.c:
{ if (mem_properties.memoryHeaps[heap_idx].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) { - gpu->memory_size = mem_properties.memoryHeaps[heap_idx].size; - break; + gpu->memory_size += mem_properties.memoryHeaps[heap_idx].size; } } + + /* We failed to retrieve the gpu memory size set a default of 4Gb */
The default should be set in add_gpu(). Otherwise, we need to set the default for all other graphics drivers, e.g., winemac.drv. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4466#note_53266
participants (3)
-
arilou (@arilou) -
Jon Doron -
Zhiyi Zhang (@zhiyi)