Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/winex11.drv/display.c | 11 +++++++++++ dlls/winex11.drv/x11drv.h | 1 + dlls/winex11.drv/xrandr.c | 11 +++++++++++ 3 files changed, 23 insertions(+)
diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index bf32e82cb3e..c1d405ae951 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -464,6 +464,8 @@ static BOOL X11DRV_InitGpu(HDEVINFO devinfo, const struct x11drv_gpu *gpu, INT g WCHAR *driver, LUID *gpu_luid) { static const WCHAR adapter_stringW[] = {'H','a','r','d','w','a','r','e','I','n','f','o','r','m','a','t','i','o','n','.','A','d','a','p','t','e','r','S','t','r','i','n','g',0}; + static const WCHAR qw_mem_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 mem_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 bios_stringW[] = {'H','a','r','d','w','a','r','e','I','n','f','o','r','m','a','t','i','o','n','.','B','i','o','s','S','t','r','i','n','g',0}; 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 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}; @@ -566,6 +568,15 @@ static BOOL X11DRV_InitGpu(HDEVINFO devinfo, const struct x11drv_gpu *gpu, INT g if (RegSetValueExW(hkey, dac_typeW, 0, REG_BINARY, (const BYTE *)ramdacW, sizeof(ramdacW))) goto done;
+ if (gpu->vram_size) + { + size = min(0xfff00000, gpu->vram_size); + if (RegSetValueExW(hkey, mem_sizeW, 0, REG_DWORD, (const BYTE *)&size, sizeof(size))) + goto done; + if (RegSetValueExW(hkey, qw_mem_sizeW, 0, REG_QWORD, (const BYTE *)&gpu->vram_size, sizeof(gpu->vram_size))) + goto done; + } + RegCloseKey(hkey);
/* Retrieve driver value for adapters */ diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index e82ee921830..07f83b6a5fc 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -732,6 +732,7 @@ struct x11drv_gpu UINT revision_id; /* Vulkan device UUID */ GUID vulkan_uuid; + UINT64 vram_size; };
/* Represent an adapter in EnumDisplayDevices context */ diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 8faece9023a..3ce9d930784 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -650,8 +650,10 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro }; const struct vulkan_funcs *vulkan_funcs = get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION ); VkResult (*pvkGetRandROutputDisplayEXT)( VkPhysicalDevice, Display *, RROutput, VkDisplayKHR * ); + PFN_vkGetPhysicalDeviceMemoryProperties pvkGetPhysicalDeviceMemoryProperties; PFN_vkGetPhysicalDeviceProperties2KHR pvkGetPhysicalDeviceProperties2KHR; PFN_vkEnumeratePhysicalDevices pvkEnumeratePhysicalDevices; + VkPhysicalDeviceMemoryProperties memory_properties; uint32_t device_count, device_idx, output_idx; VkPhysicalDevice *vk_physical_devices = NULL; VkPhysicalDeviceProperties2 properties2; @@ -660,6 +662,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro VkInstance vk_instance = NULL; VkDisplayKHR vk_display; BOOL ret = FALSE; + unsigned int i; VkResult vr;
if (!vulkan_funcs) @@ -686,6 +689,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro
LOAD_VK_FUNC(vkEnumeratePhysicalDevices) LOAD_VK_FUNC(vkGetPhysicalDeviceProperties2KHR) + LOAD_VK_FUNC(vkGetPhysicalDeviceMemoryProperties) LOAD_VK_FUNC(vkGetRandROutputDisplayEXT) #undef LOAD_VK_FUNC
@@ -724,6 +728,13 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro
pvkGetPhysicalDeviceProperties2KHR( vk_physical_devices[device_idx], &properties2 ); memcpy( &gpu->vulkan_uuid, id.deviceUUID, sizeof(id.deviceUUID) ); + pvkGetPhysicalDeviceMemoryProperties( vk_physical_devices[device_idx], &memory_properties ); + gpu->vram_size = 0; + for (i = 0; i < memory_properties.memoryHeapCount; ++i) + { + if (memory_properties.memoryHeaps[i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) + gpu->vram_size = max( gpu->vram_size, memory_properties.memoryHeaps[i].size ); + } /* Ignore Khronos vendor IDs */ if (properties2.properties.vendorID < 0x10000) {
On 10/19/21 18:20, Paul Gofman wrote:
Signed-off-by: Paul Gofman pgofman@codeweavers.com
dlls/winex11.drv/display.c | 11 +++++++++++ dlls/winex11.drv/x11drv.h | 1 + dlls/winex11.drv/xrandr.c | 11 +++++++++++ 3 files changed, 23 insertions(+)
diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index bf32e82cb3e..c1d405ae951 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -464,6 +464,8 @@ static BOOL X11DRV_InitGpu(HDEVINFO devinfo, const struct x11drv_gpu *gpu, INT g WCHAR *driver, LUID *gpu_luid) { static const WCHAR adapter_stringW[] = {'H','a','r','d','w','a','r','e','I','n','f','o','r','m','a','t','i','o','n','.','A','d','a','p','t','e','r','S','t','r','i','n','g',0};
- static const WCHAR qw_mem_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 mem_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 bios_stringW[] = {'H','a','r','d','w','a','r','e','I','n','f','o','r','m','a','t','i','o','n','.','B','i','o','s','S','t','r','i','n','g',0}; 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 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};
@@ -566,6 +568,15 @@ static BOOL X11DRV_InitGpu(HDEVINFO devinfo, const struct x11drv_gpu *gpu, INT g if (RegSetValueExW(hkey, dac_typeW, 0, REG_BINARY, (const BYTE *)ramdacW, sizeof(ramdacW))) goto done;
if (gpu->vram_size)
{
size = min(0xfff00000, gpu->vram_size);
if (RegSetValueExW(hkey, mem_sizeW, 0, REG_DWORD, (const BYTE *)&size, sizeof(size)))
goto done;
if (RegSetValueExW(hkey, qw_mem_sizeW, 0, REG_QWORD, (const BYTE *)&gpu->vram_size, sizeof(gpu->vram_size)))
goto done;
}
RegCloseKey(hkey);
/* Retrieve driver value for adapters */
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index e82ee921830..07f83b6a5fc 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -732,6 +732,7 @@ struct x11drv_gpu UINT revision_id; /* Vulkan device UUID */ GUID vulkan_uuid;
- UINT64 vram_size;
};
/* Represent an adapter in EnumDisplayDevices context */ diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 8faece9023a..3ce9d930784 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -650,8 +650,10 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro }; const struct vulkan_funcs *vulkan_funcs = get_vulkan_driver( WINE_VULKAN_DRIVER_VERSION ); VkResult (*pvkGetRandROutputDisplayEXT)( VkPhysicalDevice, Display *, RROutput, VkDisplayKHR * );
- PFN_vkGetPhysicalDeviceMemoryProperties pvkGetPhysicalDeviceMemoryProperties; PFN_vkGetPhysicalDeviceProperties2KHR pvkGetPhysicalDeviceProperties2KHR; PFN_vkEnumeratePhysicalDevices pvkEnumeratePhysicalDevices;
- VkPhysicalDeviceMemoryProperties memory_properties; uint32_t device_count, device_idx, output_idx; VkPhysicalDevice *vk_physical_devices = NULL; VkPhysicalDeviceProperties2 properties2;
@@ -660,6 +662,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro VkInstance vk_instance = NULL; VkDisplayKHR vk_display; BOOL ret = FALSE;
unsigned int i; VkResult vr;
if (!vulkan_funcs)
@@ -686,6 +689,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro
LOAD_VK_FUNC(vkEnumeratePhysicalDevices) LOAD_VK_FUNC(vkGetPhysicalDeviceProperties2KHR)
- LOAD_VK_FUNC(vkGetPhysicalDeviceMemoryProperties) LOAD_VK_FUNC(vkGetRandROutputDisplayEXT)
#undef LOAD_VK_FUNC
@@ -724,6 +728,13 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro
pvkGetPhysicalDeviceProperties2KHR( vk_physical_devices[device_idx], &properties2 ); memcpy( &gpu->vulkan_uuid, id.deviceUUID, sizeof(id.deviceUUID) );
pvkGetPhysicalDeviceMemoryProperties( vk_physical_devices[device_idx], &memory_properties );
gpu->vram_size = 0;
for (i = 0; i < memory_properties.memoryHeapCount; ++i)
{
if (memory_properties.memoryHeaps[i].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT)
gpu->vram_size = max( gpu->vram_size, memory_properties.memoryHeaps[i].size );
}
I wonder if we can add all heaps with VK_MEMORY_HEAP_DEVICE_LOCAL_BIT together and get the total vram.
Also, what does Windows report for integrated graphics?
/* Ignore Khronos vendor IDs */ if (properties2.properties.vendorID < 0x10000) {
On 10/19/21 14:58, Zhiyi Zhang wrote:
I wonder if we can add all heaps with VK_MEMORY_HEAP_DEVICE_LOCAL_BIT together and get the total vram.
VK_MEMORY_HEAP_DEVICE_LOCAL_BIT is set nowadays in Vulkan for a heap corresponding to a real device local memory (or what integrated GPU driver things reasonable to expose as such) and also for a heap corresponding to BAR memory (which is much smaller).
My RX 580 has 8GB local video memory and that is exactly what I see on Windows 10 for it in this registry field. Vulkan reports 0x1f0000000 local heap and 0x10000000 (256MB) host coherent heap, so looking at this particular case adding those would make sense. However, this is different for Nvidia with 8GB here: Vulkan reports exactly 8GB as device local heap and additionally 256MB in host coherent heap. So, given those differences it seems more straightforward to me to report a single heap, even if with the current Vulkan drivers for AMD discrete card it ends up 256MB less.
Also, we could potentially distinguish between those heaps by exploring memory types corresponding to the heap (MEMORY_PROPERTY_HOST_VISIBLE_BIT on memory type suggests that is BAR memory), but I didn't go this way (checking memory types) as it might make things twisted for integrated GPUs.
Also, what does Windows report for integrated graphics?
I suppose it might be integrated graphics dependent. I only have Windows 7 laptop with (quite old) integrated Intel / discrete Nvidia and registry field reports around 2GB. I don't have Linux on the same machine but here with a newer Intel integrated GPU Linux Vulkan reports a single 2GB heap (VK_MEMORY_HEAP_DEVICE_LOCAL_BIT with a single memory type of MEMORY_PROPERTY_DEVICE_LOCAL_BIT | MEMORY_PROPERTY_HOST_VISIBLE_BIT | MEMORY_PROPERTY_HOST_COHERENT_BIT | MEMORY_PROPERTY_HOST_CACHED_BIT (that is, it is generally indistinguishable from BAR memory reporting on discrete GPU thus my unwillingness to guess the memory type explicitly).
It is less straightforward what is VRAM for integrated GPU but I believe it is (Vulkan and GL) driver responsibility to advertise a reasonable device local heap info which should match what system specs as "VRAM size" as a single value.
On 10/19/21 15:52, Paul Gofman wrote:
On 10/19/21 14:58, Zhiyi Zhang wrote:
I wonder if we can add all heaps with VK_MEMORY_HEAP_DEVICE_LOCAL_BIT together and get the total vram.
VK_MEMORY_HEAP_DEVICE_LOCAL_BIT is set nowadays in Vulkan for a heap corresponding to a real device local memory (or what integrated GPU driver things reasonable to expose as such) and also for a heap corresponding to BAR memory (which is much smaller).
My RX 580 has 8GB local video memory and that is exactly what I see on Windows 10 for it in this registry field. Vulkan reports 0x1f0000000 local heap and 0x10000000 (256MB) host coherent heap, so looking at this particular case adding those would make sense. However, this is different for Nvidia with 8GB here: Vulkan reports exactly 8GB as device local heap and additionally 256MB in host coherent heap. So, given those differences it seems more straightforward to me to report a single heap, even if with the current Vulkan drivers for AMD discrete card it ends up 256MB less.
Also, we could potentially distinguish between those heaps by exploring memory types corresponding to the heap (MEMORY_PROPERTY_HOST_VISIBLE_BIT on memory type suggests that is BAR memory), but I didn't go this way (checking memory types) as it might make things twisted for integrated GPUs.
Also, what does Windows report for integrated graphics?
I suppose it might be integrated graphics dependent. I only have Windows 7 laptop with (quite old) integrated Intel / discrete Nvidia and registry field reports around 2GB. I don't have Linux on the same machine but here with a newer Intel integrated GPU Linux Vulkan reports a single 2GB heap (VK_MEMORY_HEAP_DEVICE_LOCAL_BIT with a single memory type of MEMORY_PROPERTY_DEVICE_LOCAL_BIT | MEMORY_PROPERTY_HOST_VISIBLE_BIT | MEMORY_PROPERTY_HOST_COHERENT_BIT | MEMORY_PROPERTY_HOST_CACHED_BIT (that is, it is generally indistinguishable from BAR memory reporting on discrete GPU thus my unwillingness to guess the memory type explicitly).
It is less straightforward what is VRAM for integrated GPU but I believe it is (Vulkan and GL) driver responsibility to advertise a reasonable device local heap info which should match what system specs as "VRAM size" as a single value.
So in the end of the private discussion the decisive argument is that wined3d currently adds all the device local heaps, so we should probably do the same here to be consistent. I will resend this way.