3 * Copyright (C) 2019 Matthew Waters <matthew@centricular.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
25 #include <glib/gprintf.h>
27 #include "gstvkerror.h"
28 #include "gstvkdebug.h"
29 #include "gstvkdebug-private.h"
33 * @title: GstVulkanDebug
34 * @short_description: Vulkan debugging utilities
35 * @see_also: #GstVulkanDevice
38 #define FLAGS_TO_STRING(under_name, VkType) \
39 gchar * G_PASTE(G_PASTE(gst_vulkan_,under_name),_flags_to_string) (VkType flag_bits) \
41 GString *s = g_string_new (NULL); \
42 gboolean first = TRUE; \
44 for (i = 0; i < G_N_ELEMENTS (G_PASTE(G_PASTE(vk_,under_name),_flags_map)); i++) { \
45 if (flag_bits & G_PASTE(G_PASTE(vk_,under_name),_flags_map)[i].flag_bit) { \
47 g_string_append (s, "|"); \
49 g_string_append (s, G_PASTE(G_PASTE(vk_,under_name),_flags_map)[i].str); \
53 return g_string_free (s, FALSE); \
59 VkMemoryPropertyFlagBits flag_bit;
61 } vk_memory_property_flags_map[] = {
62 {VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, "device-local"},
63 {VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, "host-visible"},
64 {VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, "host-coherent"},
65 {VK_MEMORY_PROPERTY_HOST_CACHED_BIT, "host-cached"},
66 {VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT, "lazily-allocated"},
67 #if VK_HEADER_VERSION >= 70
68 {VK_MEMORY_PROPERTY_PROTECTED_BIT, "protected"},
70 #if VK_HEADER_VERSION >= 121
71 {VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD, "device-coherent"},
72 {VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD, "device-uncached"},
76 * gst_vulkan_memory_property_flags_to_string:
80 FLAGS_TO_STRING(memory_property, VkMemoryPropertyFlags);
84 VkMemoryHeapFlagBits flag_bit;
86 } vk_memory_heap_flags_map[] = {
87 {VK_MEMORY_HEAP_DEVICE_LOCAL_BIT, "device-local"},
88 #if VK_HEADER_VERSION >= 70
89 {VK_MEMORY_HEAP_MULTI_INSTANCE_BIT, "multi-instance"},
93 * gst_vulkan_memory_heap_flags_to_string:
97 FLAGS_TO_STRING(memory_heap, VkMemoryHeapFlagBits);
101 VkQueueFlagBits flag_bit;
103 } vk_queue_flags_map[] = {
104 {VK_QUEUE_GRAPHICS_BIT, "graphics"},
105 {VK_QUEUE_COMPUTE_BIT, "compute"},
106 {VK_QUEUE_TRANSFER_BIT, "transfer"},
107 {VK_QUEUE_SPARSE_BINDING_BIT, "sparse-binding"},
108 #if VK_HEADER_VERSION >= 70
109 {VK_QUEUE_PROTECTED_BIT, "protected"},
113 * gst_vulkan_queue_flags_to_string:
117 FLAGS_TO_STRING(queue, VkQueueFlags);
121 VkSampleCountFlagBits flag_bit;
123 } vk_sample_count_flags_map[] = {
124 {VK_SAMPLE_COUNT_1_BIT, "1"},
125 {VK_SAMPLE_COUNT_2_BIT, "2"},
126 {VK_SAMPLE_COUNT_4_BIT, "4"},
127 {VK_SAMPLE_COUNT_8_BIT, "8"},
128 {VK_SAMPLE_COUNT_16_BIT, "16"},
129 {VK_SAMPLE_COUNT_32_BIT, "32"},
130 {VK_SAMPLE_COUNT_64_BIT, "64"},
133 * gst_vulkan_sample_count_flags_to_string:
137 FLAGS_TO_STRING(sample_count, VkSampleCountFlags);
141 * gst_vulkan_physical_device_type_to_string:
142 * @type: a `VkPhysicalDeviceType
144 * Returns: name of @type
149 gst_vulkan_physical_device_type_to_string (VkPhysicalDeviceType type)
152 case VK_PHYSICAL_DEVICE_TYPE_OTHER:
154 case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU:
156 case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU:
158 case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU:
160 case VK_PHYSICAL_DEVICE_TYPE_CPU: