print more info about vulkan memory and allocations
This commit is contained in:
parent
7f846eaddd
commit
8b7ff39efb
|
@ -440,6 +440,30 @@ static int enumerateDevices( vk_available_device_t **available_devices ) {
|
|||
return this_device - *available_devices;
|
||||
}
|
||||
|
||||
static void devicePrintMemoryInfo(const VkPhysicalDeviceMemoryProperties *props, const VkPhysicalDeviceMemoryBudgetPropertiesEXT *budget) {
|
||||
gEngine.Con_Printf("Memory heaps: %d\n", props->memoryHeapCount);
|
||||
for (int i = 0; i < (int)props->memoryHeapCount; ++i) {
|
||||
const VkMemoryHeap* const heap = props->memoryHeaps + i;
|
||||
gEngine.Con_Printf(" %d: size=%dMb used=%dMb avail=%dMb device_local=%d\n", i,
|
||||
(int)(heap->size / (1024 * 1024)),
|
||||
(int)(budget->heapUsage[i] / (1024 * 1024)),
|
||||
(int)(budget->heapBudget[i] / (1024 * 1024)),
|
||||
!!(heap->flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT));
|
||||
}
|
||||
|
||||
gEngine.Con_Printf("Memory types: %d\n", props->memoryTypeCount);
|
||||
for (int i = 0; i < (int)props->memoryTypeCount; ++i) {
|
||||
const VkMemoryType* const type = props->memoryTypes + i;
|
||||
gEngine.Con_Printf(" %d: heap=%d flags=%c%c%c%c%c\n", i, type->heapIndex,
|
||||
type->propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT ? 'D' : '.',
|
||||
type->propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT ? 'V' : '.',
|
||||
type->propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT ? 'C' : '.',
|
||||
type->propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT ? '$' : '.',
|
||||
type->propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT ? 'L' : '.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static qboolean createDevice( void ) {
|
||||
void *head = NULL;
|
||||
vk_available_device_t *available_devices;
|
||||
|
@ -531,13 +555,20 @@ static qboolean createDevice( void ) {
|
|||
.ppEnabledExtensionNames = device_extensions,
|
||||
};
|
||||
|
||||
// FIXME do only once
|
||||
vkGetPhysicalDeviceMemoryProperties(candidate_device->device, &vk_core.physical_device.memory_properties);
|
||||
{
|
||||
vk_core.physical_device.memory_properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2;
|
||||
vk_core.physical_device.memory_properties2.pNext = &vk_core.physical_device.memory_budget;
|
||||
vk_core.physical_device.memory_budget.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT;
|
||||
vk_core.physical_device.memory_budget.pNext = NULL;
|
||||
vkGetPhysicalDeviceMemoryProperties2(candidate_device->device, &vk_core.physical_device.memory_properties2);
|
||||
}
|
||||
|
||||
gEngine.Con_Printf("Trying device #%d: %04x:%04x %d %s %u.%u.%u %u.%u.%u\n",
|
||||
i, candidate_device->props.vendorID, candidate_device->props.deviceID, candidate_device->props.deviceType, candidate_device->props.deviceName,
|
||||
XVK_PARSE_VERSION(candidate_device->props.driverVersion), XVK_PARSE_VERSION(candidate_device->props.apiVersion));
|
||||
|
||||
devicePrintMemoryInfo(&vk_core.physical_device.memory_properties2.memoryProperties, &vk_core.physical_device.memory_budget);
|
||||
|
||||
{
|
||||
const VkResult result = vkCreateDevice(candidate_device->device, &create_info, NULL, &vk_core.device);
|
||||
if (result != VK_SUCCESS) {
|
||||
|
@ -873,11 +904,11 @@ void destroyFence(VkFence fence) {
|
|||
}
|
||||
|
||||
static uint32_t findMemoryWithType(uint32_t type_index_bits, VkMemoryPropertyFlags flags) {
|
||||
for (uint32_t i = 0; i < vk_core.physical_device.memory_properties.memoryTypeCount; ++i) {
|
||||
for (uint32_t i = 0; i < vk_core.physical_device.memory_properties2.memoryProperties.memoryTypeCount; ++i) {
|
||||
if (!(type_index_bits & (1 << i)))
|
||||
continue;
|
||||
|
||||
if ((vk_core.physical_device.memory_properties.memoryTypes[i].propertyFlags & flags) == flags)
|
||||
if ((vk_core.physical_device.memory_properties2.memoryProperties.memoryTypes[i].propertyFlags & flags) == flags)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -900,6 +931,15 @@ device_memory_t allocateDeviceMemory(VkMemoryRequirements req, VkMemoryPropertyF
|
|||
.memoryTypeIndex = findMemoryWithType(req.memoryTypeBits, props),
|
||||
};
|
||||
|
||||
gEngine.Con_Reportf("allocateDeviceMemory size=%zu memoryTypeBits=0x%x memoryProperties=%c%c%c%c%c flags=0x%x => typeIndex=%d\n", req.size, req.memoryTypeBits,
|
||||
props & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT ? 'D' : '.',
|
||||
props & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT ? 'V' : '.',
|
||||
props & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT ? 'C' : '.',
|
||||
props & VK_MEMORY_PROPERTY_HOST_CACHED_BIT ? '$' : '.',
|
||||
props & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT ? 'L' : '.',
|
||||
flags,
|
||||
mai.memoryTypeIndex);
|
||||
|
||||
ASSERT(mai.memoryTypeIndex != UINT32_MAX);
|
||||
XVK_CHECK(vkAllocateMemory(vk_core.device, &mai, NULL, &ret.device_memory));
|
||||
return ret;
|
||||
|
|
|
@ -38,7 +38,8 @@ typedef struct vk_buffer_s
|
|||
|
||||
typedef struct physical_device_s {
|
||||
VkPhysicalDevice device;
|
||||
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||
VkPhysicalDeviceMemoryProperties2 memory_properties2;
|
||||
VkPhysicalDeviceMemoryBudgetPropertiesEXT memory_budget;
|
||||
VkPhysicalDeviceProperties properties;
|
||||
VkPhysicalDeviceProperties2 properties2;
|
||||
VkPhysicalDeviceAccelerationStructurePropertiesKHR properties_accel;
|
||||
|
@ -133,7 +134,7 @@ do { \
|
|||
X(vkGetPhysicalDeviceFeatures2) \
|
||||
X(vkGetPhysicalDeviceQueueFamilyProperties) \
|
||||
X(vkGetPhysicalDeviceSurfaceSupportKHR) \
|
||||
X(vkGetPhysicalDeviceMemoryProperties) \
|
||||
X(vkGetPhysicalDeviceMemoryProperties2) \
|
||||
X(vkGetPhysicalDeviceSurfacePresentModesKHR) \
|
||||
X(vkGetPhysicalDeviceSurfaceFormatsKHR) \
|
||||
X(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \
|
||||
|
|
Loading…
Reference in New Issue