[PATCH 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> -- 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 | 4 ++++ dlls/winex11.drv/xrandr.c | 15 ++++++++++++++- include/wine/gdi_driver.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 9d23c533049..4d5a2c6e268 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1225,6 +1225,9 @@ 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 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 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 +1379,7 @@ 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, memory_sizeW, REG_BINARY, &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..2ac1a93c109 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; + break; + } + } 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:
} 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; + break;
I think you should add all heap sizes with VK_MEMORY_HEAP_DEVICE_LOCAL_BIT together instead of breaking at the first heap with the flag. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4466#note_53255
Zhiyi Zhang (@zhiyi) commented about dlls/win32u/sysparams.c:
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, memory_sizeW, REG_BINARY, &gpu->memory_size, sizeof(gpu->memory_size) );
Let set a default value if gpu->memory_size is zero. Something like 4G should be enough. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4466#note_53256
Zhiyi Zhang (@zhiyi) commented about dlls/win32u/sysparams.c:
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, memory_sizeW, REG_BINARY, &gpu->memory_size, sizeof(gpu->memory_size) );
The type should be REG_QWORD. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4466#note_53257
Zhiyi Zhang (@zhiyi) commented about dlls/win32u/sysparams.c:
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 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};
Let's add HardwareInformation.MemorySize as well. Note that HardwareInformation.MemorySize is of type REG_DWORD and has a 4GB limit. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4466#note_53258
Zhiyi Zhang (@zhiyi) commented about dlls/win32u/sysparams.c:
static const WCHAR chip_typeW[] =
Change the subject to "win32u: Add registry data for GPU memory size." -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4466#note_53259
participants (3)
-
arilou (@arilou) -
Jon Doron -
Zhiyi Zhang (@zhiyi)