Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73ab0acc authored by Jesse Hall's avatar Jesse Hall
Browse files

vulkan: add memory property queries to nulldrv and vkinfo

Change-Id: Ib3ceb46ff4e46a25787d8c980b8339328b471925
(cherry picked from commit 6c5ee23b92f420387f46da97714780f9ce12681a)
parent 04f4f474
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ include $(CLEAR_VARS)

LOCAL_CLANG := true
LOCAL_CFLAGS := -std=c99 -fvisibility=hidden -fstrict-aliasing
LOCAL_CFLAGS += -DLOG_TAG=\"vk_nulldrv\"
LOCAL_CFLAGS += -DLOG_TAG=\"vknulldrv\"
LOCAL_CFLAGS += -Weverything -Werror -Wno-padded -Wno-undef
LOCAL_CPPFLAGS := -std=c++1y \
	-Wno-c++98-compat-pedantic \
+133 −8

File changed.

Preview size limit exceeded, changes collapsed.

+37 −0
Original line number Diff line number Diff line
#include <inttypes.h>
#include <sstream>
#include <stdlib.h>
#include <vector>

@@ -78,6 +80,7 @@ const char* VkPhysicalDeviceTypeStr(VkPhysicalDeviceType type) {

void DumpPhysicalDevice(uint32_t idx, VkPhysicalDevice pdev) {
    VkResult result;
    std::ostringstream strbuf;

    VkPhysicalDeviceProperties props;
    result = vkGetPhysicalDeviceProperties(pdev, &props);
@@ -88,6 +91,40 @@ void DumpPhysicalDevice(uint32_t idx, VkPhysicalDevice pdev) {
           (props.apiVersion >> 22) & 0x3FF, (props.apiVersion >> 12) & 0x3FF,
           (props.apiVersion >> 0) & 0xFFF, props.driverVersion, props.vendorId,
           props.deviceId);

    VkPhysicalDeviceMemoryProperties mem_props;
    result = vkGetPhysicalDeviceMemoryProperties(pdev, &mem_props);
    if (result != VK_SUCCESS)
        die("vkGetPhysicalDeviceMemoryProperties", result);
    for (uint32_t heap = 0; heap < mem_props.memoryHeapCount; heap++) {
        if ((mem_props.memoryHeaps[heap].flags & VK_MEMORY_HEAP_HOST_LOCAL) !=
            0)
            strbuf << "HOST_LOCAL";
        printf("     Heap %u: 0x%" PRIx64 " %s\n", heap,
               mem_props.memoryHeaps[heap].size, strbuf.str().c_str());
        strbuf.str(std::string());

        for (uint32_t type = 0; type < mem_props.memoryTypeCount; type++) {
            if (mem_props.memoryTypes[type].heapIndex != heap)
                continue;
            VkMemoryPropertyFlags flags =
                mem_props.memoryTypes[type].propertyFlags;
            if (flags == VK_MEMORY_PROPERTY_DEVICE_ONLY)
                strbuf << "DEVICE_ONLY";
            if ((flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0)
                strbuf << "HOST_VISIBLE";
            if ((flags & VK_MEMORY_PROPERTY_HOST_NON_COHERENT_BIT) != 0)
                strbuf << " NON_COHERENT";
            if ((flags & VK_MEMORY_PROPERTY_HOST_UNCACHED_BIT) != 0)
                strbuf << " UNCACHED";
            if ((flags & VK_MEMORY_PROPERTY_HOST_WRITE_COMBINED_BIT) != 0)
                strbuf << " WRITE_COMBINED";
            if ((flags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) != 0)
                strbuf << " LAZILY_ALLOCATED";
            printf("        Type %u: %s\n", type, strbuf.str().c_str());
            strbuf.str(std::string());
        }
    }
}

}  // namespace