Exemplo n.º 1
0
 /// <summary>
 /// Create a new debug utils messenger with default message callback outputing to Console.
 /// </summary>
 /// <param name="instance">Vulkan Instance.</param>
 /// <param name="typeMask">Type mask.</param>
 /// <param name="severityMask">Severity mask.</param>
 public Messenger(Instance instance,
                  VkDebugUtilsMessageTypeFlagsEXT typeMask =
                  VkDebugUtilsMessageTypeFlagsEXT.ValidationEXT,
                  VkDebugUtilsMessageSeverityFlagsEXT severityMask =
                  VkDebugUtilsMessageSeverityFlagsEXT.ErrorEXT |
                  VkDebugUtilsMessageSeverityFlagsEXT.WarningEXT) : this(instance, onMessage, typeMask, severityMask)
 {
 }
Exemplo n.º 2
0
        /// <summary>
        /// Create a new debug utils messenger providing a PFN_vkDebugUtilsMessengerCallbackEXT delegate.
        /// </summary>
        /// <param name="instance">Vulkan Instance.</param>
        /// <param name="onMessageDelegate">Message callback.</param>
        /// <param name="typeMask">Type mask.</param>
        /// <param name="severityMask">Severity mask.</param>
        public Messenger(Instance instance, PFN_vkDebugUtilsMessengerCallbackEXT onMessageDelegate,
                         VkDebugUtilsMessageTypeFlagsEXT typeMask =
                         VkDebugUtilsMessageTypeFlagsEXT.ValidationEXT,
                         VkDebugUtilsMessageSeverityFlagsEXT severityMask =
                         VkDebugUtilsMessageSeverityFlagsEXT.ErrorEXT |
                         VkDebugUtilsMessageSeverityFlagsEXT.WarningEXT)
        {
            inst = instance;
            VkDebugUtilsMessengerCreateInfoEXT info = VkDebugUtilsMessengerCreateInfoEXT.New();

            info.messageType     = typeMask;
            info.messageSeverity = severityMask;
            info.pfnUserCallback = Marshal.GetFunctionPointerForDelegate(onMessageDelegate);
            info.pUserData       = IntPtr.Zero;

            Utils.CheckResult(vkCreateDebugUtilsMessengerEXT(inst.VkInstance, ref info, IntPtr.Zero, out handle));
        }
Exemplo n.º 3
0
        private static VkBool32 DebugMessengerCallback(
            VkDebugUtilsMessageSeverityFlagsEXT messageSeverity,
            VkDebugUtilsMessageTypeFlagsEXT messageTypes,
            VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
            IntPtr userData)
        {
            var message = Vortice.Vulkan.Interop.GetString(pCallbackData->pMessage);

            if (messageTypes == VkDebugUtilsMessageTypeFlagsEXT.Validation)
            {
                Debug.WriteLine($"[Vulkan]: Validation: {messageSeverity} - {message}");
            }
            else
            {
                Debug.WriteLine($"[Vulkan]: {messageSeverity} - {message}");
            }

            return(VkBool32.False);
        }
Exemplo n.º 4
0
        private static VkBool32 DebugMessengerCallback(VkDebugUtilsMessageSeverityFlagsEXT messageSeverity,
                                                       VkDebugUtilsMessageTypeFlagsEXT messageTypes,
                                                       VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
                                                       IntPtr userData)
        {
            string?message = Interop.GetString(pCallbackData->pMessage);

            if (messageTypes == VkDebugUtilsMessageTypeFlagsEXT.Validation)
            {
                if (messageSeverity == VkDebugUtilsMessageSeverityFlagsEXT.Error)
                {
                    Log.Error($"[Vulkan]: Validation: {messageSeverity} - {message}");
                }
                else if (messageSeverity == VkDebugUtilsMessageSeverityFlagsEXT.Warning)
                {
                    Log.Warn($"[Vulkan]: Validation: {messageSeverity} - {message}");
                }

                Debug.WriteLine($"[Vulkan]: Validation: {messageSeverity} - {message}");
            }
            else
            {
                if (messageSeverity == VkDebugUtilsMessageSeverityFlagsEXT.Error)
                {
                    Log.Error($"[Vulkan]: {messageSeverity} - {message}");
                }
                else if (messageSeverity == VkDebugUtilsMessageSeverityFlagsEXT.Warning)
                {
                    Log.Warn($"[Vulkan]: {messageSeverity} - {message}");
                }

                Debug.WriteLine($"[Vulkan]: {messageSeverity} - {message}");
            }

            return(VkBool32.False);
        }
Exemplo n.º 5
0
        private unsafe static VkBool32 DebugReport(VkDebugUtilsMessageSeverityFlagsEXT severity, VkDebugUtilsMessageTypeFlagsEXT types, VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, IntPtr userData)
        {
            var message = Vortice.Vulkan.Interop.GetString(pCallbackData->pMessage);

            // Redirect to log
            if (severity == VkDebugUtilsMessageSeverityFlagsEXT.Error)
            {
                Log.Error(message);
            }
            else if (severity == VkDebugUtilsMessageSeverityFlagsEXT.Warning)
            {
                Log.Warning(message);
            }
            else if (severity == VkDebugUtilsMessageSeverityFlagsEXT.Info)
            {
                Log.Info(message);
            }
            else if (severity == VkDebugUtilsMessageSeverityFlagsEXT.Verbose)
            {
                Log.Verbose(message);
            }

            return(false);
        }
Exemplo n.º 6
0
        static VkBool32 HandlePFN_vkDebugUtilsMessengerCallbackEXT(VkDebugUtilsMessageSeverityFlagsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, IntPtr pCallbackData, IntPtr pUserData)
        {
            VkDebugUtilsMessengerCallbackDataEXT data = Marshal.PtrToStructure <VkDebugUtilsMessengerCallbackDataEXT> (pCallbackData);
            ConsoleColor curColor = Console.ForegroundColor;

            switch (messageSeverity)
            {
            case VkDebugUtilsMessageSeverityFlagsEXT.VerboseEXT:
                Console.ForegroundColor = ConsoleColor.White;
                break;

            case VkDebugUtilsMessageSeverityFlagsEXT.InfoEXT:
                Console.ForegroundColor = ConsoleColor.DarkCyan;
                break;

            case VkDebugUtilsMessageSeverityFlagsEXT.WarningEXT:
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                break;

            case VkDebugUtilsMessageSeverityFlagsEXT.ErrorEXT:
                Console.ForegroundColor = ConsoleColor.Red;
                break;
            }

            switch (messageTypes)
            {
            case VkDebugUtilsMessageTypeFlagsEXT.GeneralEXT:
                Console.Write("GEN:");
                break;

            case VkDebugUtilsMessageTypeFlagsEXT.PerformanceEXT:
                Console.Write("PERF:");
                break;
            }

            byte [] tmp = new byte [1024];

            if (data.pMessage != IntPtr.Zero)
            {
                byte b = Marshal.ReadByte(data.pMessage);
                int  i = 1;
                while (b != 0)
                {
                    tmp [i] = b;
                    b       = Marshal.ReadByte(data.pMessage, i);
                    i++;
                }
                Console.WriteLine(Encoding.UTF8.GetString(tmp));
                Console.ForegroundColor = curColor;
            }
            return(false);
        }
Exemplo n.º 7
0
 public static VkBool32 DebugCallback(VkDebugUtilsMessageSeverityFlagsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageType, VkDebugUtilsMessengerCallbackDataEXT pCallbackData, void *pUserData)
 {
     Debug.WriteLine($"<<Vulkan Validation Layer>> {Helpers.GetString(pCallbackData.pMessage)}");
     return(false);
 }
Exemplo n.º 8
0
        private static bool DebugCallback(VkDebugUtilsMessageSeverityFlagsEXT severity, VkDebugUtilsMessageTypeFlagsEXT type, IntPtr callbackData, IntPtr userData)
        {
            var cbkData      = Marshal.PtrToStructure <VkDebugUtilsMessengerCallbackDataEXT>(callbackData);
            var consoleCol   = Console.BackgroundColor;
            var fgconsoleCol = Console.ForegroundColor;

            switch (severity)
            {
            case VkDebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityErrorBitExt:
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.White;
                break;

            case VkDebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityVerboseBitExt:
                Console.BackgroundColor = ConsoleColor.Blue;
                Console.ForegroundColor = ConsoleColor.White;
                break;

            case VkDebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityWarningBitExt:
                Console.BackgroundColor = ConsoleColor.Yellow;
                Console.ForegroundColor = ConsoleColor.Black;
                break;

            case VkDebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityInfoBitExt:
                Console.BackgroundColor = ConsoleColor.Green;
                Console.ForegroundColor = ConsoleColor.Black;
                break;
            }
            var typeStr = type switch
            {
                VkDebugUtilsMessageTypeFlagsEXT.DebugUtilsMessageTypeGeneralBitExt => "General",
                VkDebugUtilsMessageTypeFlagsEXT.DebugUtilsMessageTypePerformanceBitExt => "Perf",
                VkDebugUtilsMessageTypeFlagsEXT.DebugUtilsMessageTypeValidationBitExt => "Validation",
                _ => "Unknown"
            };

            Console.Write($"[{typeStr}]");
            Console.ForegroundColor = fgconsoleCol;
            Console.BackgroundColor = consoleCol;
            Console.WriteLine($" {cbkData.pMessage}");
            return(false);
        }