I’ve been testing the beta drivers (with Vulkan support) and noticed a difference compared to Linux & Windows behaviour, reproducible on a GTX 770 and a GTX 970.
When querying the heaps there’s one heap with the local bit, one heap with host access and possibly a third one. The heap with the local bit is of course the internal memory available on the card. The second one, just like it says, is basically host-memory mapped which is accessible to the card as well.
The size of that second heap is - on my FreeBSD system - always 1.5Gb. On Linux and Windows that heap is sized to half the RAM minus a constant (I think it’s 384Mb, not sure though). For reference vulkan stats for the GTX 970
It looks like the FreeBSD driver uses a constant or at least a different calculation than other OS’s. There are a few ways to get the amount of memory on FreeBSD, one of which is a simple sysctl ‘hw.realmem’.
It can be retrieved by something like
size_t size = sizeof(SIZE_T); SIZE_T mem = 0; sysctlbyname("hw.realmem", &mem, &size, NULL, 0);
Alternatively it’s possible to use the amount of pages on the system and the page size to calculate the amount of memory by using the KVM interface. This method is mainly useful if the amount of swap also matters.
It would really be useful if this constant were higher or better yet if the driver exposes a sysctl to set this ourselves. Is something like this possible and am I missing it or if not, is it a possibility for future drivers?