[PATCH v5 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> -- v5: win32u: Add registry data for GPU memory size. 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 | 20 ++++++++++++++++++++ dlls/winex11.drv/xrandr.c | 15 ++++++++++++++- include/wine/gdi_driver.h | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 9d23c533049..db29f5cc8a3 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1210,6 +1210,8 @@ 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; + ULONGLONG gpu_qw_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 +1227,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}; @@ -1377,6 +1385,18 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) set_reg_value( hkey, chip_typeW, REG_BINARY, desc, size ); set_reg_value( hkey, dac_typeW, REG_BINARY, ramdacW, sizeof(ramdacW) ); + gpu_qw_memory_size = gpu->memory_size; + + /* We failed to retrieve the gpu memory size set a default of 1Gb */ + if (!gpu_qw_memory_size) + { + gpu_qw_memory_size = 1073741824; + } + + set_reg_value( hkey, qw_memory_sizeW, REG_QWORD, &gpu_qw_memory_size, sizeof(gpu_qw_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) { /* The last seven digits are the driver number. */ diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index cf3f911cf5b..74c2fa1372e 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,16 @@ 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; + } + } + 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/win32u/sysparams.c:
len = asciiz_to_unicode( buffer, "\\\\?\\" ) / sizeof(WCHAR) - 1; memcpy( buffer + len, instance, (instance_len + 1) * sizeof(WCHAR) ); len += instance_len;
We usually use the Wine-Bug: tag for bug links. So you can use "Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46624" to mention that this patch is for that bug. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4466#note_53810
Zhiyi Zhang (@zhiyi) commented about dlls/win32u/sysparams.c:
unsigned int gpu_index, size; HKEY hkey, subkey; LARGE_INTEGER ft; + ULONG gpu_memory_size;
You can remove the "gpu_" from gpu_memory_size and gpu_qw_memory_size. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4466#note_53811
Zhiyi Zhang (@zhiyi) commented about dlls/win32u/sysparams.c:
set_reg_value( hkey, chip_typeW, REG_BINARY, desc, size ); set_reg_value( hkey, dac_typeW, REG_BINARY, ramdacW, sizeof(ramdacW) );
+ gpu_qw_memory_size = gpu->memory_size; + + /* We failed to retrieve the gpu memory size set a default of 1Gb */ + if (!gpu_qw_memory_size) + {
Let's use "gpu_qw_memory_size = gpu->memory_size ? gpu->memory_size : 1073741824;" here. It's more compact. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4466#note_53812
Zhiyi Zhang (@zhiyi) commented about dlls/winex11.drv/xrandr.c:
} 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) + {
Let's remove the curly braces for if. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4466#note_53813
participants (3)
-
arilou (@arilou) -
Jon Doron -
Zhiyi Zhang (@zhiyi)