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.