Example #1
0
        private unsafe uint DebugCallback
        (
            DebugUtilsMessageSeverityFlagsEXT messageSeverity,
            DebugUtilsMessageTypeFlagsEXT messageTypes,
            DebugUtilsMessengerCallbackDataEXT *pCallbackData,
            void *pUserData
        )
        {
            LogEventLevel level = LogEventLevel.Error;

            switch (messageSeverity)
            {
            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityErrorBitExt:
                level = LogEventLevel.Error;
                break;

            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityWarningBitExt:
                level = LogEventLevel.Warning;
                break;

            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityInfoBitExt:
                level = LogEventLevel.Information;
                break;

            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityVerboseBitExt:
                level = LogEventLevel.Verbose;
                break;
            }

            _api.Logger.Write(level, $"{messageSeverity} {messageTypes}" + Marshal.PtrToStringAnsi((nint)pCallbackData->PMessage));

            return(Vk.False);
        }
Example #2
0
        private static unsafe uint DebugCallback(DebugUtilsMessageSeverityFlagsEXT messageSeverity, DebugUtilsMessageTypeFlagsEXT messageType,
                                                 DebugUtilsMessengerCallbackDataEXT *callbackData, void *userData)
        {
            string messageFormat = $"({nameof(VKAPI)}) {{0}}: {{1}}";

            switch (messageSeverity)
            {
            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityVerboseBitExt:
                Log.Verbose(string.Format(messageFormat, messageType, Marshal.PtrToStringAnsi((IntPtr)callbackData->PMessage)));
                break;

            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityInfoBitExt:
                Log.Information(string.Format(messageFormat, messageType, Marshal.PtrToStringAnsi((IntPtr)callbackData->PMessage)));
                break;

            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityWarningBitExt:
                Log.Warning(string.Format(messageFormat, messageType, Marshal.PtrToStringAnsi((IntPtr)callbackData->PMessage)));
                break;

            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityErrorBitExt:
                Log.Error(string.Format(messageFormat, messageType, Marshal.PtrToStringAnsi((IntPtr)callbackData->PMessage)));
                break;

            default: throw new ArgumentOutOfRangeException(nameof(messageSeverity), messageSeverity, null);
            }

            return(Vk.False);
        }
        private unsafe uint DebugCallback(
            DebugUtilsMessageSeverityFlagsEXT messageSeverity,
            DebugUtilsMessageTypeFlagsEXT messageTypes,
            DebugUtilsMessengerCallbackDataEXT *pCallbackData,
            void *pUserData
            )
        {
            string sev     = messageSeverity.ToReadableString();
            string type    = messageTypes.ToReadableString();
            string message = Marshal.PtrToStringAnsi((IntPtr)pCallbackData->PMessage);
            string log     = $"Severity: [{sev}]\nType: {type}\nMessage: {message}";

            Console.WriteLine(log);

            return(Vk.False);
        }
Example #4
0
 public DebugUtilsMessengerCreateInfoEXT
 (
     StructureType sType = StructureType.DebugUtilsMessengerCreateInfoExt,
     void *pNext         = default,
     uint flags          = default,
     DebugUtilsMessageSeverityFlagsEXT messageSeverity = default,
     DebugUtilsMessageTypeFlagsEXT messageType         = default,
     FuncPtr pfnUserCallback = default,
     void *pUserData         = default
 )
 {
     SType           = sType;
     PNext           = pNext;
     Flags           = flags;
     MessageSeverity = messageSeverity;
     MessageType     = messageType;
     PfnUserCallback = pfnUserCallback;
     PUserData       = pUserData;
 }
        public static string ToReadableString(this DebugUtilsMessageSeverityFlagsEXT severity)
        {
            switch (severity)
            {
            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityVerboseBitExt:
                return("Verbose");

            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityInfoBitExt:
                return("Information");

            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityWarningBitExt:
                return("Warning");

            case DebugUtilsMessageSeverityFlagsEXT.DebugUtilsMessageSeverityErrorBitExt:
                return("Error");

            default:
                return(severity.ToString());
            }
        }
 /// <summary>To be documented.</summary>
 public static unsafe void SubmitDebugUtilsMessage(this ExtDebugUtils thisApi, [Count(Count = 0)] Instance instance, [Count(Count = 0)] DebugUtilsMessageSeverityFlagsEXT messageSeverity, [Count(Count = 0)] DebugUtilsMessageTypeFlagsEXT messageTypes, [Count(Count = 0), Flow(FlowDirection.In)] ReadOnlySpan <DebugUtilsMessengerCallbackDataEXT> pCallbackData)
 {
     // SpanOverloader
     thisApi.SubmitDebugUtilsMessage(instance, messageSeverity, messageTypes, in pCallbackData.GetPinnableReference());
 }
Example #7
0
 public abstract void SubmitDebugUtilsMessage([Count(Count = 0)] Instance instance, [Count(Count = 0)] DebugUtilsMessageSeverityFlagsEXT messageSeverity, [Count(Count = 0)] DebugUtilsMessageTypeFlagsEXT messageTypes, [Count(Count = 0), Flow(FlowDirection.In)] ref DebugUtilsMessengerCallbackDataEXT pCallbackData);