vulkan: dump most of the device information
authorMatthew Waters <matthew@centricular.com>
Wed, 11 Sep 2019 09:24:50 +0000 (19:24 +1000)
committerMatthew Waters <matthew@centricular.com>
Wed, 11 Sep 2019 10:22:56 +0000 (20:22 +1000)
Dump anything that can be queried using the physical device like features,
limits, queue properties, memory properties.

gst-libs/gst/vulkan/gstvkdebug-private.h [new file with mode: 0644]
gst-libs/gst/vulkan/gstvkdebug.c [new file with mode: 0644]
gst-libs/gst/vulkan/gstvkdebug.h [new file with mode: 0644]
gst-libs/gst/vulkan/gstvkdevice.c
gst-libs/gst/vulkan/gstvkmemory.c
gst-libs/gst/vulkan/meson.build
gst-libs/gst/vulkan/vulkan.h

diff --git a/gst-libs/gst/vulkan/gstvkdebug-private.h b/gst-libs/gst/vulkan/gstvkdebug-private.h
new file mode 100644 (file)
index 0000000..899749e
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * GStreamer
+ * Copyright (C) 2019 Matthew Waters <matthew@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_VULKAN_DEBUG_PRIVATE_H__
+#define __GST_VULKAN_DEBUG_PRIVATE_H__
+
+#include <gst/gst.h>
+#include <vulkan/vulkan.h>
+#include <gst/vulkan/vulkan-prelude.h>
+
+G_BEGIN_DECLS
+
+gchar *                     gst_vulkan_memory_property_flags_to_string      (VkMemoryPropertyFlags prop_bits);
+gchar *                     gst_vulkan_memory_heap_flags_to_string          (VkMemoryHeapFlags prop_bits);
+gchar *                     gst_vulkan_queue_flags_to_string                (VkQueueFlags queue_bits);
+gchar *                     gst_vulkan_sample_count_flags_to_string         (VkSampleCountFlags sample_count_bits);
+
+G_END_DECLS
+
+#endif /* __GST_VULKAN_DEBUG_PRIVATE_H__ */
diff --git a/gst-libs/gst/vulkan/gstvkdebug.c b/gst-libs/gst/vulkan/gstvkdebug.c
new file mode 100644 (file)
index 0000000..8f888e2
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * GStreamer
+ * Copyright (C) 2019 Matthew Waters <matthew@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib/gprintf.h>
+
+#include "gstvkerror.h"
+#include "gstvkdebug-private.h"
+
+#define FLAGS_TO_STRING(under_name, VkType)                                     \
+gchar * G_PASTE(G_PASTE(gst_vulkan_,under_name),_flags_to_string) (VkType flag_bits) \
+{                                                                               \
+  GString *s = g_string_new (NULL);                                             \
+  gboolean first = TRUE;                                                        \
+  int i;                                                                        \
+  for (i = 0; i < G_N_ELEMENTS (G_PASTE(G_PASTE(vk_,under_name),_flags_map)); i++) { \
+    if (flag_bits & G_PASTE(G_PASTE(vk_,under_name),_flags_map)[i].flag_bit) {  \
+      if (!first) {                                                             \
+        g_string_append (s, "|");                                               \
+      }                                                                         \
+      g_string_append (s, G_PASTE(G_PASTE(vk_,under_name),_flags_map)[i].str); \
+      first = FALSE;                                                            \
+    }                                                                           \
+  }                                                                             \
+  return g_string_free (s, FALSE);                                              \
+}
+
+/* *INDENT-OFF* */
+static const struct 
+{
+  VkMemoryPropertyFlagBits flag_bit;
+  const char *str;
+} vk_memory_property_flags_map[] = {
+  {VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, "device-local"},
+  {VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, "host-visible"},
+  {VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, "host-coherent"},
+  {VK_MEMORY_PROPERTY_HOST_CACHED_BIT, "host-cached"},
+  {VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT, "lazily-allocated"},
+  {VK_MEMORY_PROPERTY_PROTECTED_BIT, "protected"},
+#if VK_HEADER_VERSION >= 121
+  {VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD, "device-coherent"},
+  {VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD, "device-uncached"},
+#endif
+};
+FLAGS_TO_STRING(memory_property, VkMemoryPropertyFlags);
+
+static const struct 
+{
+  VkMemoryHeapFlagBits flag_bit;
+  const char *str;
+} vk_memory_heap_flags_map[] = {
+  {VK_MEMORY_HEAP_DEVICE_LOCAL_BIT, "device-local"},
+  {VK_MEMORY_HEAP_MULTI_INSTANCE_BIT, "multi-instance"},
+};
+FLAGS_TO_STRING(memory_heap, VkMemoryHeapFlagBits);
+
+static const struct 
+{
+  VkQueueFlagBits flag_bit;
+  const char *str;
+} vk_queue_flags_map[] = {
+  {VK_QUEUE_GRAPHICS_BIT, "graphics"},
+  {VK_QUEUE_COMPUTE_BIT, "compute"},
+  {VK_QUEUE_TRANSFER_BIT, "transfer"},
+  {VK_QUEUE_SPARSE_BINDING_BIT, "sparse-binding"},
+  {VK_QUEUE_PROTECTED_BIT, "protected"},
+};
+FLAGS_TO_STRING(queue, VkQueueFlags);
+
+static const struct 
+{
+  VkSampleCountFlagBits flag_bit;
+  const char *str;
+} vk_sample_count_flags_map[] = {
+  {VK_SAMPLE_COUNT_1_BIT, "1"},
+  {VK_SAMPLE_COUNT_2_BIT, "2"},
+  {VK_SAMPLE_COUNT_4_BIT, "4"},
+  {VK_SAMPLE_COUNT_8_BIT, "8"},
+  {VK_SAMPLE_COUNT_16_BIT, "16"},
+  {VK_SAMPLE_COUNT_32_BIT, "32"},
+  {VK_SAMPLE_COUNT_64_BIT, "64"},
+};
+FLAGS_TO_STRING(sample_count, VkSampleCountFlags);
+/* *INDENT-ON* */
diff --git a/gst-libs/gst/vulkan/gstvkdebug.h b/gst-libs/gst/vulkan/gstvkdebug.h
new file mode 100644 (file)
index 0000000..04345c0
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * GStreamer
+ * Copyright (C) 2019 Matthew Waters <matthew@centricular.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_VULKAN_DEBUG_H__
+#define __GST_VULKAN_DEBUG_H__
+
+#include <gst/gst.h>
+#include <vulkan/vulkan.h>
+#include <gst/vulkan/vulkan-prelude.h>
+
+G_BEGIN_DECLS
+
+#define GST_VULKAN_EXTENT3D_FORMAT G_GUINT32_FORMAT ", %" G_GUINT32_FORMAT ", %" G_GUINT32_FORMAT
+#define GST_VULKAN_EXTENT3D_ARGS(var) (var).width, (var).height, (var).depth
+
+G_END_DECLS
+
+#endif /* __GST_VULKAN_DEBUG_H__ */
index 2ffa915..05620e4 100644 (file)
@@ -24,6 +24,8 @@
 
 #include "gstvkdevice.h"
 
+#include "gstvkdebug-private.h"
+
 #include <string.h>
 
 /**
@@ -169,6 +171,346 @@ gst_vulkan_device_finalize (GObject * object)
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
+#define DEBUG_BOOL(prefix, name, value)                             \
+  GST_DEBUG_OBJECT (device, prefix " " G_STRINGIFY(name) ": %s",    \
+    value ? "YES" : "NO")
+
+static gboolean
+dump_features (GstVulkanDevice * device, GError ** error)
+{
+  VkPhysicalDeviceFeatures features;
+  VkPhysicalDevice gpu;
+
+  gpu = gst_vulkan_device_get_physical_device (device);
+
+  vkGetPhysicalDeviceFeatures (gpu, &features);
+
+#define DEBUG_BOOL_FEATURE(name) DEBUG_BOOL("support for", name, features.name)
+
+  DEBUG_BOOL_FEATURE (robustBufferAccess);
+  DEBUG_BOOL_FEATURE (fullDrawIndexUint32);
+  DEBUG_BOOL_FEATURE (imageCubeArray);
+  DEBUG_BOOL_FEATURE (independentBlend);
+  DEBUG_BOOL_FEATURE (geometryShader);
+  DEBUG_BOOL_FEATURE (tessellationShader);
+  DEBUG_BOOL_FEATURE (sampleRateShading);
+  DEBUG_BOOL_FEATURE (sampleRateShading);
+  DEBUG_BOOL_FEATURE (dualSrcBlend);
+  DEBUG_BOOL_FEATURE (logicOp);
+  DEBUG_BOOL_FEATURE (multiDrawIndirect);
+  DEBUG_BOOL_FEATURE (drawIndirectFirstInstance);
+  DEBUG_BOOL_FEATURE (depthClamp);
+  DEBUG_BOOL_FEATURE (depthBiasClamp);
+  DEBUG_BOOL_FEATURE (fillModeNonSolid);
+  DEBUG_BOOL_FEATURE (depthBounds);
+  DEBUG_BOOL_FEATURE (wideLines);
+  DEBUG_BOOL_FEATURE (largePoints);
+  DEBUG_BOOL_FEATURE (alphaToOne);
+  DEBUG_BOOL_FEATURE (multiViewport);
+  DEBUG_BOOL_FEATURE (samplerAnisotropy);
+  DEBUG_BOOL_FEATURE (textureCompressionETC2);
+  DEBUG_BOOL_FEATURE (textureCompressionASTC_LDR);
+  DEBUG_BOOL_FEATURE (textureCompressionBC);
+  DEBUG_BOOL_FEATURE (occlusionQueryPrecise);
+  DEBUG_BOOL_FEATURE (pipelineStatisticsQuery);
+  DEBUG_BOOL_FEATURE (vertexPipelineStoresAndAtomics);
+  DEBUG_BOOL_FEATURE (fragmentStoresAndAtomics);
+  DEBUG_BOOL_FEATURE (shaderTessellationAndGeometryPointSize);
+  DEBUG_BOOL_FEATURE (shaderImageGatherExtended);
+  DEBUG_BOOL_FEATURE (shaderStorageImageExtendedFormats);
+  DEBUG_BOOL_FEATURE (shaderStorageImageMultisample);
+  DEBUG_BOOL_FEATURE (shaderStorageImageReadWithoutFormat);
+  DEBUG_BOOL_FEATURE (shaderStorageImageWriteWithoutFormat);
+  DEBUG_BOOL_FEATURE (shaderUniformBufferArrayDynamicIndexing);
+  DEBUG_BOOL_FEATURE (shaderSampledImageArrayDynamicIndexing);
+  DEBUG_BOOL_FEATURE (shaderStorageBufferArrayDynamicIndexing);
+  DEBUG_BOOL_FEATURE (shaderStorageImageArrayDynamicIndexing);
+  DEBUG_BOOL_FEATURE (shaderClipDistance);
+  DEBUG_BOOL_FEATURE (shaderCullDistance);
+  DEBUG_BOOL_FEATURE (shaderFloat64);
+  DEBUG_BOOL_FEATURE (shaderInt64);
+  DEBUG_BOOL_FEATURE (shaderInt16);
+  DEBUG_BOOL_FEATURE (shaderResourceResidency);
+  DEBUG_BOOL_FEATURE (shaderResourceMinLod);
+  DEBUG_BOOL_FEATURE (sparseBinding);
+  DEBUG_BOOL_FEATURE (sparseResidencyBuffer);
+  DEBUG_BOOL_FEATURE (sparseResidencyImage2D);
+  DEBUG_BOOL_FEATURE (sparseResidencyImage3D);
+  DEBUG_BOOL_FEATURE (sparseResidency2Samples);
+  DEBUG_BOOL_FEATURE (sparseResidency4Samples);
+  DEBUG_BOOL_FEATURE (sparseResidency8Samples);
+  DEBUG_BOOL_FEATURE (sparseResidency16Samples);
+  DEBUG_BOOL_FEATURE (sparseResidencyAliased);
+  DEBUG_BOOL_FEATURE (variableMultisampleRate);
+  DEBUG_BOOL_FEATURE (inheritedQueries);
+
+#undef DEBUG_BOOL_FEATURE
+
+  return TRUE;
+}
+
+static gboolean
+dump_memory_properties (GstVulkanDevice * device, GError ** error)
+{
+  VkPhysicalDeviceMemoryProperties props;
+  VkPhysicalDevice gpu;
+  int i;
+
+  gpu = gst_vulkan_device_get_physical_device (device);
+
+  vkGetPhysicalDeviceMemoryProperties (gpu, &props);
+
+  GST_DEBUG_OBJECT (device, "found %" G_GUINT32_FORMAT " memory heaps",
+      props.memoryHeapCount);
+  for (i = 0; i < props.memoryHeapCount; i++) {
+    gchar *prop_flags_str =
+        gst_vulkan_memory_heap_flags_to_string (props.memoryHeaps[i].flags);
+    GST_LOG_OBJECT (device,
+        "memory heap at index %i has size %" G_GUINT64_FORMAT
+        " and flags (0x%x) \'%s\'", i, (guint64) props.memoryHeaps[i].size,
+        props.memoryHeaps[i].flags, prop_flags_str);
+    g_free (prop_flags_str);
+  }
+  GST_DEBUG_OBJECT (device, "found %" G_GUINT32_FORMAT " memory types",
+      props.memoryTypeCount);
+  for (i = 0; i < props.memoryTypeCount; i++) {
+    gchar *prop_flags_str =
+        gst_vulkan_memory_property_flags_to_string (props.
+        memoryTypes[i].propertyFlags);
+    GST_LOG_OBJECT (device,
+        "memory type at index %i is allocatable from "
+        "heap %i with flags (0x%x) \'%s\'", i, props.memoryTypes[i].heapIndex,
+        props.memoryTypes[i].propertyFlags, prop_flags_str);
+    g_free (prop_flags_str);
+  }
+
+  return TRUE;
+}
+
+static gboolean
+dump_queue_properties (GstVulkanDevice * device, GError ** error)
+{
+  VkQueueFamilyProperties *props;
+  guint32 n_props;
+  VkPhysicalDevice gpu;
+  int i;
+
+  gpu = gst_vulkan_device_get_physical_device (device);
+
+  vkGetPhysicalDeviceQueueFamilyProperties (gpu, &n_props, NULL);
+  props = g_alloca (sizeof (VkQueueFamilyProperties) * n_props);
+  vkGetPhysicalDeviceQueueFamilyProperties (gpu, &n_props, props);
+
+  GST_DEBUG_OBJECT (device, "found %" G_GUINT32_FORMAT " queue families",
+      n_props);
+  for (i = 0; i < n_props; i++) {
+    gchar *queue_flags_str =
+        gst_vulkan_queue_flags_to_string (props[i].queueFlags);
+    GST_LOG_OBJECT (device,
+        "queue family at index %i supports %i queues "
+        "with flags (0x%x) \'%s\', %" G_GUINT32_FORMAT " timestamp bits and "
+        "a minimum image transfer granuality of %" GST_VULKAN_EXTENT3D_FORMAT,
+        i, props[i].queueCount, props[i].queueFlags, queue_flags_str,
+        props[i].timestampValidBits,
+        GST_VULKAN_EXTENT3D_ARGS (props[i].minImageTransferGranularity));
+    g_free (queue_flags_str);
+  }
+
+  return TRUE;
+}
+
+static gboolean
+dump_limits (GstVulkanDevice * device, GError ** error)
+{
+  VkPhysicalDeviceProperties props;
+  VkPhysicalDevice gpu;
+
+  gpu = gst_vulkan_device_get_physical_device (device);
+  vkGetPhysicalDeviceProperties (gpu, &props);
+
+#define DEBUG_LIMIT(limit, format, type)                                \
+  GST_DEBUG_OBJECT (device, "limit " G_STRINGIFY(limit) ": %" format,   \
+    (type) props.limits.limit)
+#define DEBUG_LIMIT_2(limit, format, type)                                  \
+  GST_DEBUG_OBJECT (device, "limit " G_STRINGIFY(limit)                     \
+    ": %" format ", %" format,                                              \
+    (type) props.limits.limit[0],                                           \
+    (type) props.limits.limit[1])
+#define DEBUG_LIMIT_3(limit, format, type)                                  \
+  GST_DEBUG_OBJECT (device, "limit " G_STRINGIFY(limit)                     \
+    ": %" format ", %" format ", %" format,                                 \
+    (type) props.limits.limit[0],                                           \
+    (type) props.limits.limit[1],                                           \
+    (type) props.limits.limit[2])
+#define DEBUG_BOOL_LIMIT(limit) DEBUG_BOOL("limit", limit, props.limits.limit)
+
+#define DEBUG_UINT32_LIMIT(limit) DEBUG_LIMIT(limit, G_GUINT32_FORMAT, guint32)
+#define DEBUG_UINT32_2_LIMIT(limit) DEBUG_LIMIT_2(limit, G_GUINT32_FORMAT, guint32)
+#define DEBUG_UINT32_3_LIMIT(limit) DEBUG_LIMIT_3(limit, G_GUINT32_FORMAT, guint32)
+
+#define DEBUG_INT32_LIMIT(limit) DEBUG_LIMIT(limit, G_GINT32_FORMAT, gint32)
+
+#define DEBUG_UINT64_LIMIT(limit) DEBUG_LIMIT(limit, G_GUINT64_FORMAT, guint64)
+
+#define DEBUG_SIZE_LIMIT(limit) DEBUG_LIMIT(limit, G_GSIZE_FORMAT, gsize)
+
+#define DEBUG_FLOAT_LIMIT(limit) DEBUG_LIMIT(limit, "f", float)
+#define DEBUG_FLOAT_2_LIMIT(limit) DEBUG_LIMIT_2(limit, "f", float)
+
+#define DEBUG_FLAGS_LIMIT(limit, under_name_type)                           \
+  G_STMT_START {                                                            \
+    gchar *str = G_PASTE(G_PASTE(gst_vulkan_,under_name_type),_flags_to_string) (props.limits.limit); \
+    GST_DEBUG_OBJECT (device, "limit " G_STRINGIFY(limit) ": %s", str);     \
+    g_free (str);                                                           \
+  } G_STMT_END
+
+  DEBUG_UINT32_LIMIT (maxImageDimension1D);
+  DEBUG_UINT32_LIMIT (maxImageDimension2D);
+  DEBUG_UINT32_LIMIT (maxImageDimension3D);
+  DEBUG_UINT32_LIMIT (maxImageDimensionCube);
+  DEBUG_UINT32_LIMIT (maxImageArrayLayers);
+  DEBUG_UINT32_LIMIT (maxTexelBufferElements);
+  DEBUG_UINT32_LIMIT (maxUniformBufferRange);
+  DEBUG_UINT32_LIMIT (maxStorageBufferRange);
+  DEBUG_UINT32_LIMIT (maxPushConstantsSize);
+  DEBUG_UINT32_LIMIT (maxMemoryAllocationCount);
+  DEBUG_UINT32_LIMIT (maxSamplerAllocationCount);
+  DEBUG_UINT64_LIMIT (bufferImageGranularity);
+  DEBUG_UINT64_LIMIT (sparseAddressSpaceSize);
+  DEBUG_UINT32_LIMIT (maxBoundDescriptorSets);
+  DEBUG_UINT32_LIMIT (maxPerStageDescriptorSamplers);
+  DEBUG_UINT32_LIMIT (maxPerStageDescriptorUniformBuffers);
+  DEBUG_UINT32_LIMIT (maxPerStageDescriptorStorageBuffers);
+  DEBUG_UINT32_LIMIT (maxPerStageDescriptorSampledImages);
+  DEBUG_UINT32_LIMIT (maxPerStageDescriptorStorageImages);
+  DEBUG_UINT32_LIMIT (maxPerStageDescriptorInputAttachments);
+  DEBUG_UINT32_LIMIT (maxPerStageResources);
+  DEBUG_UINT32_LIMIT (maxDescriptorSetSamplers);
+  DEBUG_UINT32_LIMIT (maxDescriptorSetUniformBuffers);
+  DEBUG_UINT32_LIMIT (maxDescriptorSetUniformBuffersDynamic);
+  DEBUG_UINT32_LIMIT (maxDescriptorSetStorageBuffers);
+  DEBUG_UINT32_LIMIT (maxDescriptorSetStorageBuffersDynamic);
+  DEBUG_UINT32_LIMIT (maxDescriptorSetSampledImages);
+  DEBUG_UINT32_LIMIT (maxDescriptorSetStorageImages);
+  DEBUG_UINT32_LIMIT (maxDescriptorSetInputAttachments);
+  DEBUG_UINT32_LIMIT (maxVertexInputAttributes);
+  DEBUG_UINT32_LIMIT (maxVertexInputBindings);
+  DEBUG_UINT32_LIMIT (maxVertexInputBindings);
+  DEBUG_UINT32_LIMIT (maxVertexInputAttributeOffset);
+  DEBUG_UINT32_LIMIT (maxVertexInputBindingStride);
+  DEBUG_UINT32_LIMIT (maxVertexOutputComponents);
+  DEBUG_UINT32_LIMIT (maxTessellationGenerationLevel);
+  DEBUG_UINT32_LIMIT (maxTessellationPatchSize);
+  DEBUG_UINT32_LIMIT (maxTessellationControlPerVertexInputComponents);
+  DEBUG_UINT32_LIMIT (maxTessellationControlPerVertexOutputComponents);
+  DEBUG_UINT32_LIMIT (maxTessellationControlPerPatchOutputComponents);
+  DEBUG_UINT32_LIMIT (maxTessellationControlTotalOutputComponents);
+  DEBUG_UINT32_LIMIT (maxTessellationControlTotalOutputComponents);
+  DEBUG_UINT32_LIMIT (maxTessellationEvaluationInputComponents);
+  DEBUG_UINT32_LIMIT (maxTessellationEvaluationOutputComponents);
+  DEBUG_UINT32_LIMIT (maxGeometryShaderInvocations);
+  DEBUG_UINT32_LIMIT (maxGeometryInputComponents);
+  DEBUG_UINT32_LIMIT (maxGeometryOutputComponents);
+  DEBUG_UINT32_LIMIT (maxGeometryOutputVertices);
+  DEBUG_UINT32_LIMIT (maxGeometryTotalOutputComponents);
+  DEBUG_UINT32_LIMIT (maxFragmentInputComponents);
+  DEBUG_UINT32_LIMIT (maxFragmentOutputAttachments);
+  DEBUG_UINT32_LIMIT (maxFragmentDualSrcAttachments);
+  DEBUG_UINT32_LIMIT (maxFragmentCombinedOutputResources);
+  DEBUG_UINT32_LIMIT (maxComputeSharedMemorySize);
+  DEBUG_UINT32_3_LIMIT (maxComputeWorkGroupCount);
+  DEBUG_UINT32_LIMIT (maxComputeWorkGroupInvocations);
+  DEBUG_UINT32_3_LIMIT (maxComputeWorkGroupSize);
+  DEBUG_UINT32_LIMIT (subPixelPrecisionBits);
+  DEBUG_UINT32_LIMIT (subTexelPrecisionBits);
+  DEBUG_UINT32_LIMIT (mipmapPrecisionBits);
+  DEBUG_UINT32_LIMIT (maxDrawIndexedIndexValue);
+  DEBUG_UINT32_LIMIT (maxDrawIndirectCount);
+  DEBUG_FLOAT_LIMIT (maxSamplerLodBias);
+  DEBUG_FLOAT_LIMIT (maxSamplerAnisotropy);
+  DEBUG_UINT32_LIMIT (maxViewports);
+  DEBUG_UINT32_2_LIMIT (maxViewportDimensions);
+  DEBUG_FLOAT_2_LIMIT (viewportBoundsRange);
+  DEBUG_UINT32_LIMIT (viewportSubPixelBits);
+  DEBUG_SIZE_LIMIT (minMemoryMapAlignment);
+  DEBUG_UINT64_LIMIT (minTexelBufferOffsetAlignment);
+  DEBUG_UINT64_LIMIT (minUniformBufferOffsetAlignment);
+  DEBUG_UINT64_LIMIT (minStorageBufferOffsetAlignment);
+  DEBUG_INT32_LIMIT (minTexelOffset);
+  DEBUG_UINT32_LIMIT (maxTexelOffset);
+  DEBUG_INT32_LIMIT (minTexelGatherOffset);
+  DEBUG_UINT32_LIMIT (maxTexelGatherOffset);
+  DEBUG_FLOAT_LIMIT (minInterpolationOffset);
+  DEBUG_FLOAT_LIMIT (maxInterpolationOffset);
+  DEBUG_UINT32_LIMIT (subPixelInterpolationOffsetBits);
+  DEBUG_UINT32_LIMIT (maxFramebufferWidth);
+  DEBUG_UINT32_LIMIT (maxFramebufferHeight);
+  DEBUG_UINT32_LIMIT (maxFramebufferLayers);
+  DEBUG_FLAGS_LIMIT (framebufferColorSampleCounts, sample_count);
+  DEBUG_FLAGS_LIMIT (framebufferDepthSampleCounts, sample_count);
+  DEBUG_FLAGS_LIMIT (framebufferStencilSampleCounts, sample_count);
+  DEBUG_FLAGS_LIMIT (framebufferNoAttachmentsSampleCounts, sample_count);
+  DEBUG_UINT32_LIMIT (maxColorAttachments);
+  DEBUG_FLAGS_LIMIT (sampledImageColorSampleCounts, sample_count);
+  DEBUG_FLAGS_LIMIT (sampledImageIntegerSampleCounts, sample_count);
+  DEBUG_FLAGS_LIMIT (sampledImageDepthSampleCounts, sample_count);
+  DEBUG_FLAGS_LIMIT (sampledImageStencilSampleCounts, sample_count);
+  DEBUG_FLAGS_LIMIT (storageImageSampleCounts, sample_count);
+  DEBUG_BOOL_LIMIT (timestampComputeAndGraphics);
+  DEBUG_FLOAT_LIMIT (timestampPeriod);
+  DEBUG_UINT32_LIMIT (maxClipDistances);
+  DEBUG_UINT32_LIMIT (maxCullDistances);
+  DEBUG_UINT32_LIMIT (maxCombinedClipAndCullDistances);
+  DEBUG_UINT32_LIMIT (discreteQueuePriorities);
+  DEBUG_FLOAT_2_LIMIT (pointSizeRange);
+  DEBUG_FLOAT_2_LIMIT (lineWidthRange);
+  DEBUG_FLOAT_LIMIT (pointSizeGranularity);
+  DEBUG_FLOAT_LIMIT (lineWidthGranularity);
+  DEBUG_BOOL_LIMIT (strictLines);
+  DEBUG_BOOL_LIMIT (standardSampleLocations);
+  DEBUG_UINT64_LIMIT (optimalBufferCopyOffsetAlignment);
+  DEBUG_UINT64_LIMIT (optimalBufferCopyRowPitchAlignment);
+  DEBUG_UINT64_LIMIT (nonCoherentAtomSize);
+
+#undef DEBUG_LIMIT
+#undef DEBUG_LIMIT_2
+#undef DEBUG_LIMIT_3
+#undef DEBUG_BOOL_LIMIT
+#undef DEBUG_UINT32_LIMIT
+#undef DEBUG_UINT32_2_LIMIT
+#undef DEBUG_UINT32_3_LIMIT
+#undef DEBUG_INT32_LIMIT
+#undef DEBUG_UINT64_LIMIT
+#undef DEBUG_SIZE_LIMIT
+#undef DEBUG_FLOAT_LIMIT
+#undef DEBUG_FLOAT_2_LIMIT
+#undef DEBUG_FLAGS_LIMIT
+
+  return TRUE;
+}
+
+static gboolean
+dump_sparse_properties (GstVulkanDevice * device, GError ** error)
+{
+  VkPhysicalDeviceProperties props;
+  VkPhysicalDevice gpu;
+
+  gpu = gst_vulkan_device_get_physical_device (device);
+  vkGetPhysicalDeviceProperties (gpu, &props);
+
+#define DEBUG_BOOL_SPARSE_PROPERTY(name) DEBUG_BOOL("sparse property", name, props.sparseProperties.name)
+
+  DEBUG_BOOL_SPARSE_PROPERTY (residencyStandard2DBlockShape);
+  DEBUG_BOOL_SPARSE_PROPERTY (residencyStandard2DMultisampleBlockShape);
+  DEBUG_BOOL_SPARSE_PROPERTY (residencyStandard3DBlockShape);
+  DEBUG_BOOL_SPARSE_PROPERTY (residencyAlignedMipSize);
+  DEBUG_BOOL_SPARSE_PROPERTY (residencyNonResidentStrict);
+
+#undef DEBUG_BOOL_SPARSE_PROPERTY
+
+  return TRUE;
+}
+
 static const gchar *
 _device_type_to_string (VkPhysicalDeviceType type)
 {
@@ -203,15 +545,27 @@ _physical_device_info (GstVulkanDevice * device, GError ** error)
 
   vkGetPhysicalDeviceProperties (gpu, &props);
 
-  GST_INFO_OBJECT (device, "device name %s type %s api version %u.%u.%u, "
-      "driver version %u.%u.%u vendor ID 0x%x, device ID 0x%x",
-      props.deviceName, _device_type_to_string (props.deviceType),
+  GST_INFO_OBJECT (device, "pyhsical device %i name \'%s\' type \'%s\' "
+      "api version %u.%u.%u, driver version %u.%u.%u vendor ID 0x%x, "
+      "device ID 0x%x", device->device_index, props.deviceName,
+      _device_type_to_string (props.deviceType),
       VK_VERSION_MAJOR (props.apiVersion), VK_VERSION_MINOR (props.apiVersion),
       VK_VERSION_PATCH (props.apiVersion),
       VK_VERSION_MAJOR (props.driverVersion),
       VK_VERSION_MINOR (props.driverVersion),
       VK_VERSION_PATCH (props.driverVersion), props.vendorID, props.deviceID);
 
+  if (!dump_queue_properties (device, error))
+    return FALSE;
+  if (!dump_memory_properties (device, error))
+    return FALSE;
+  if (!dump_features (device, error))
+    return FALSE;
+  if (!dump_limits (device, error))
+    return FALSE;
+  if (!dump_sparse_properties (device, error))
+    return FALSE;
+
   return TRUE;
 }
 
index 4cc4529..d087aa0 100644 (file)
@@ -26,6 +26,8 @@
 
 #include "gstvkmemory.h"
 
+#include "gstvkdebug-private.h"
+
 /**
  * SECTION:vkmemory
  * @title: GstVulkanMemory
@@ -44,45 +46,6 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFUALT);
 
 static GstAllocator *_vulkan_memory_allocator;
 
-static gchar *
-_memory_properties_to_string (VkMemoryPropertyFlags prop_bits)
-{
-  GString *s;
-  gboolean first = TRUE;
-
-#define STR_APPEND(s,str) \
-  G_STMT_START { \
-    if (!first) \
-      g_string_append (s, "|"); \
-    g_string_append (s, str); \
-    first = FALSE; \
-  } G_STMT_END
-
-  s = g_string_new (NULL);
-  if (prop_bits & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) {
-    STR_APPEND (s, "device-local");
-  }
-  if (prop_bits & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) {
-    STR_APPEND (s, "host-visible");
-    if (prop_bits & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) {
-      STR_APPEND (s, "host-coherent");
-    } else {
-      STR_APPEND (s, "host-incoherent");
-    }
-    if (prop_bits & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) {
-      STR_APPEND (s, "host-cached");
-    } else {
-      STR_APPEND (s, "host-uncached");
-    }
-  }
-
-  if (prop_bits & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) {
-    STR_APPEND (s, "lazily-allocated");
-  }
-
-  return g_string_free (s, FALSE);
-}
-
 static void
 _vk_mem_init (GstVulkanMemory * mem, GstAllocator * allocator,
     GstMemory * parent, GstVulkanDevice * device, guint32 memory_type_index,
@@ -117,7 +80,7 @@ _vk_mem_init (GstVulkanMemory * mem, GstAllocator * allocator,
 
   g_mutex_init (&mem->lock);
 
-  props_str = _memory_properties_to_string (mem_prop_flags);
+  props_str = gst_vulkan_memory_property_flags_to_string (mem_prop_flags);
 
   GST_CAT_DEBUG (GST_CAT_VULKAN_MEMORY, "new Vulkan memory:%p size:%"
       G_GSIZE_FORMAT " properties:%s", mem, maxsize, props_str);
index c6f988e..d721197 100644 (file)
@@ -8,6 +8,7 @@ vulkan_sources = [
   'gstvkbufferpool.c',
   'gstvkcommandpool.c',
   'gstvkdevice.c',
+  'gstvkdebug.c',
   'gstvkdisplay.c',
   'gstvkerror.c',
   'gstvkfence.c',
index 6b047ad..9716810 100644 (file)
@@ -25,6 +25,7 @@
 
 #include <gst/vulkan/gstvkapi.h>
 
+#include <gst/vulkan/gstvkdebug.h>
 #include <gst/vulkan/gstvkerror.h>
 #include <gst/vulkan/gstvkinstance.h>
 #include <gst/vulkan/gstvkdevice.h>