예제 #1
0
        private unsafe uint DebugCallback(
            uint flags,
            VkDebugReportObjectTypeEXT objectType,
            ulong @object,
            UIntPtr location,
            int messageCode,
            byte *pLayerPrefix,
            byte *pMessage,
            void *pUserData
            )
        {
            int characters = 0;

            while (pMessage[characters] != 0)
            {
                characters++;
            }

            Console.WriteLine(
                Encoding.UTF8.GetString(
                    pMessage, characters
                    )
                );
            return(0);
        }
예제 #2
0
파일: Structs.cs 프로젝트: arakis/vk.net
 public VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT objectType, ulong handle)
 {
     sType           = VkStructureType.DebugMarkerObjectNameInfoEXT;
     pNext           = IntPtr.Zero;
     this.objectType = objectType;
     _object         = handle;
     pObjectName     = IntPtr.Zero;
 }
예제 #3
0
        private static uint DebugReportCallback(uint flags, VkDebugReportObjectTypeEXT objectType, ulong @object, UIntPtr location, int messageCode, sbyte *pLayerPrefix, sbyte *pMessage, void *pUserData)
        {
            var messageLength = new ReadOnlySpan <sbyte>(pMessage, int.MaxValue).IndexOf((sbyte)'\0') + 1;
            var message       = new string(pMessage, 0, messageLength);

            Debug.WriteLine(message);
            return(VK_FALSE);
        }
예제 #4
0
        public static uint DebugCallback(uint flags, VkDebugReportObjectTypeEXT objectType, ulong @object, UIntPtr location,
                                         int messageCode, byte *pLayerPrefix, byte *pMessage, void *pUserData)
        {
            string layerString   = System.Runtime.InteropServices.Marshal.PtrToStringAnsi((IntPtr)pLayerPrefix);
            string messageString = System.Runtime.InteropServices.Marshal.PtrToStringAnsi((IntPtr)pMessage);

            System.Console.WriteLine("DebugReport layer: {0} message: {1}", layerString, messageString);
            return(VkBool32.False);
        }
예제 #5
0
 public static extern void DebugReportMessageEXT(
     VkInstance instance,
     VkDebugReportFlagsEXT flags,
     VkDebugReportObjectTypeEXT objectType,
     ulong _object,
     ulong location,
     int messageCode,
     byte[] pLayerPrefix,
     byte[] pMessage
     );
예제 #6
0
        private static bool DebugReport(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, ulong @object, nuint location, int messageCode, string layerPrefix, string message, IntPtr userData)
        {
            string debugMessage = $"{flags}: {message} ([{messageCode}] {layerPrefix})";

            Debug.WriteLine(debugMessage);
            if (GraphicsAdapterFactory.adapterFlags == DeviceCreationFlags.DebugAndBreak)
            {
                Debugger.Break();
            }
            return(false);
        }
예제 #7
0
        void DebugCallback(
            VkDebugReportFlagsEXT flags,
            VkDebugReportObjectTypeEXT objectType,
            long _object, long location,
            int messageCode, string layerPrefix, string message)
        {
            string type = flags.ToString();

            type = type.Substring(0, type.Length - 6);  //strip "BitExt"

            Console.WriteLine("[{0}] {1}", type, message);
        }
예제 #8
0
        public bool DebugReportMessage(VkDebugReportFlagBitsEXT flags, VkDebugReportObjectTypeEXT objectType, object obj, int location, int messageCode, string pLayerPrefix, string pMessage)
        {
            bool abort = false;

            foreach (var callback in m_ReportCallbacks)
            {
                if ((callback.m_pCreateInfo.flags & flags) > 0)
                {
                    abort |= callback.m_pCreateInfo.pfnCallback(flags, objectType, obj, location, messageCode, pLayerPrefix, pMessage, callback.m_pCreateInfo.pUserData);
                }
            }
            return(abort);
        }
예제 #9
0
		public static uint MessageCallback(VkDebugReportFlagsEXT F, VkDebugReportObjectTypeEXT OT, ulong S, IntPtr L, int MsgCode,
			byte* LayerPrefixBytes, byte* MsgBytes, void* Userdata) {

			string LayerPrefix = Utils.ToStringAnsi(LayerPrefixBytes);
			string Msg = Utils.ToStringAnsi(MsgBytes);

			if ((F & (int)VkDebugReportFlagBitsEXT.VK_DEBUG_REPORT_ERROR_BIT_EXT) != 0)
				Dbg.WriteLine("ERR[{0}] Code {1}: {2}", LayerPrefix, MsgCode, Msg);
			else if ((F & (int)VkDebugReportFlagBitsEXT.VK_DEBUG_REPORT_WARNING_BIT_EXT) != 0)
				Dbg.WriteLine("WRN[{0}] Code {1}: {2}", LayerPrefix, MsgCode, Msg);

			return Vulkan.VK_FALSE;
		}
예제 #10
0
        /// <summary>
        /// Application-defined debug report callback function.
        /// </summary>
        /// <param name="flags">flags specifies the VkDebugReportFlagBitsEXT that triggered
        /// this callback</param>
        /// <param name="objectType">objectType is a VkDebugReportObjectTypeEXT value specifying
        /// the type of object being used or created at the time the event was
        /// triggered</param>
        /// <param name="objectHandle">object is the object where the issue was detected.
        /// If objectType is VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
        /// object is undefined</param>
        /// <param name="location">location is a component (layer, driver, loader) defined value that
        /// specifies the location of the trigger.
        /// This is an optional value</param>
        /// <param name="messageCode">summary>messageCode is a layer-defined value indicating what test
        /// triggered this callback</param>
        /// <param name="layerPrefix">pLayerPrefix is a null-terminated string that is an abbreviation
        /// of the name of the component making the callback.
        /// pLayerPrefix is only valid for the duration of the callback</param>
        /// <param name="message">pMessage is a null-terminated string detailing the trigger
        /// conditions.
        /// pMessage is only valid for the duration of the callback</param>
        /// <param name="userData">pUserData is the user data given when the
        /// VkDebugReportCallbackEXT was created</param>
        /// <returns></returns>
        private VkBool32 DebugCallback(VkDebugReportFlagBitsEXT flags,
                                       VkDebugReportObjectTypeEXT objectType,
                                       UInt64 objectHandle, Int32 location, Int32 messageCode,
                                       IntPtr layerPrefix, IntPtr message, IntPtr userData)
        {
            string text = $"{flags}: {Marshal.PtrToStringAnsi(message)}";

            Debug.WriteLine(text);
            using (var sw = new StreamWriter(debugFilename, true)) {
                sw.WriteLine(text);
            }
            return(true);
        }
예제 #11
0
 private uint DebugCallback(
     uint flags,
     VkDebugReportObjectTypeEXT objectType,
     ulong @object,
     UIntPtr location,
     int messageCode,
     byte *pLayerPrefix,
     byte *pMessage,
     void *pUserData)
 {
     Console.WriteLine($"[{(VkDebugReportFlagsEXT)flags}] ({objectType}) {Util.GetString(pMessage)}");
     return(0);
 }
예제 #12
0
        private VkBool32 DebugCallback(uint flags, VkDebugReportObjectTypeEXT objectType, ulong @object, UIntPtr location, int messageCode, byte *pLayerPrefix, byte *pMessage, void *pUserData)
        {
            string message = Marshal.PtrToStringAnsi((IntPtr)pMessage);
            VkDebugReportFlagBitsEXT debugReportFlags = (VkDebugReportFlagBitsEXT)flags;

            string fullMessage = $"[{debugReportFlags}] ({objectType}) {message}";

            if (debugReportFlags == VkDebugReportFlagBitsEXT.VK_DEBUG_REPORT_ERROR_BIT_EXT)
            {
                throw new InvalidOperationException(fullMessage);
            }

            return(false);
        }
예제 #13
0
        public static void vkDebugReportMessageEXT(
            VkInstance instance,
            VkDebugReportFlagBitsEXT flags,
            VkDebugReportObjectTypeEXT objectType,
            object obj,
            int location,
            int messageCode,
            string pLayerPrefix,
            string pMessage)
        {
            VkPreconditions.CheckNull(instance, nameof(instance));
            VkPreconditions.CheckString(pMessage, nameof(pMessage));

            GetInstance(instance).DebugReportMessage(flags, objectType, obj, location, messageCode, pLayerPrefix, pMessage);
        }
예제 #14
0
        private static VkBool32 DebugCallback(
            VkDebugReportFlagsEXT flags,
            VkDebugReportObjectTypeEXT objType,
            ulong obj,
            IntPtr location,
            int code,
            IntPtr layerPrefix,
            IntPtr msg,
            IntPtr userData)
        {
            var message = Marshal.PtrToStringAnsi(msg);

            Console.WriteLine($"Validation layer: {message}");
            return(VkDefines.VK_FALSE);
        }
예제 #15
0
        public void DebugReportMessageEXT(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, ulong obj, IntPtr location, int messageCode, string layerPrefix,
                                          string message)
        {
            var unmanagedSize =
                layerPrefix.SizeOfMarshalIndirect() +
                message.SizeOfMarshalIndirect();
            var unmanagedArray = new byte[unmanagedSize];

            fixed(byte *unmanagedStart = unmanagedArray)
            {
                var unmanaged    = unmanagedStart;
                var pLayerPrefix = layerPrefix.MarshalIndirect(ref unmanaged);
                var pMessage     = message.MarshalIndirect(ref unmanaged);

                Direct.DebugReportMessageEXT(Handle, flags, objectType, obj, location, messageCode, pLayerPrefix, pMessage);
            }
        }
예제 #16
0
        static VkBool32 debugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, ulong obj,
                                      UIntPtr location, int messageCode, IntPtr pLayerPrefix, IntPtr pMessage, IntPtr pUserData)
        {
            string prefix = "";

            switch (flags)
            {
            case 0:
                prefix = "?";
                break;

            case VkDebugReportFlagsEXT.InformationEXT:
                Console.ForegroundColor = ConsoleColor.Gray;
                prefix = "INFO";
                break;

            case VkDebugReportFlagsEXT.WarningEXT:
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                prefix = "WARN";
                break;

            case VkDebugReportFlagsEXT.PerformanceWarningEXT:
                Console.ForegroundColor = ConsoleColor.Yellow;
                prefix = "PERF";
                break;

            case VkDebugReportFlagsEXT.ErrorEXT:
                Console.ForegroundColor = ConsoleColor.DarkRed;
                prefix = "EROR";
                break;

            case VkDebugReportFlagsEXT.DebugEXT:
                Console.ForegroundColor = ConsoleColor.Red;
                prefix = "DBUG";
                break;
            }
            try {
                string   msg = Marshal.PtrToStringAnsi(pMessage);
                string[] tmp = msg.Split('|');
                Console.WriteLine($"{prefix}:{tmp[1]} |{Marshal.PtrToStringAnsi (pLayerPrefix)}({messageCode}){objectType}:{tmp[0]}");
            } catch (Exception ex) {
                Console.WriteLine("error parsing debug message: " + ex);
            }
            Console.ForegroundColor = ConsoleColor.White;
            return(VkBool32.False);
        }
예제 #17
0
        static VkBool32 debugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, ulong obj,
                                      UIntPtr location, int messageCode, IntPtr pLayerPrefix, IntPtr pMessage, IntPtr pUserData)
        {
            string prefix = "";

            switch (flags)
            {
            case 0:
                prefix = "?";
                break;

            case VkDebugReportFlagsEXT.InformationEXT:
                Console.ForegroundColor = ConsoleColor.Gray;
                prefix = "INFO";
                break;

            case VkDebugReportFlagsEXT.WarningEXT:
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                prefix = "WARN";
                break;

            case VkDebugReportFlagsEXT.PerformanceWarningEXT:
                Console.ForegroundColor = ConsoleColor.Yellow;
                prefix = "PERF";
                break;

            case VkDebugReportFlagsEXT.ErrorEXT:
                Console.ForegroundColor = ConsoleColor.DarkRed;
                prefix = "EROR";
                break;

            case VkDebugReportFlagsEXT.DebugEXT:
                Console.ForegroundColor = ConsoleColor.Red;
                prefix = "DBUG";
                break;
            }

            Console.WriteLine("{0} {1}: {2}", prefix, messageCode, Marshal.PtrToStringAnsi(pMessage));
            Console.ForegroundColor = ConsoleColor.White;
            return(VkBool32.False);
        }
예제 #18
0
        private void SetDebugMarkerName(VkDebugReportObjectTypeEXT type, ulong target, string name)
        {
            Debug.Assert(_setObjectNameDelegate != null);

            VkDebugMarkerObjectNameInfoEXT nameInfo = VkDebugMarkerObjectNameInfoEXT.New();

            nameInfo.objectType = type;
            nameInfo.@object    = target;

            int   byteCount = Encoding.UTF8.GetByteCount(name);
            byte *utf8Ptr   = stackalloc byte[byteCount];

            fixed(char *namePtr = name)
            {
                Encoding.UTF8.GetBytes(namePtr, name.Length, utf8Ptr, byteCount);
                nameInfo.pObjectName = utf8Ptr;
                VkResult result = _setObjectNameDelegate(_device, &nameInfo);

                CheckResult(result);
            }
        }
        private static bool DebugReport(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, ulong @object, nuint location, int messageCode, string layerPrefix, string message, IntPtr userData)
        {
            string debugMessage = $"{flags}, {@object}, {location}: {message} ([{messageCode}] {layerPrefix})";

            switch (GraphicsAdapterFactory.adapterFlags)
            {
            default:
                Debug.WriteLine(debugMessage);
                return(false);

            case DeviceCreationFlags.DebugAndBreak:
                Debug.WriteLine(debugMessage);
                Debugger.Break();
                return(false);

            case DeviceCreationFlags.DebugAndBreakUnique:
                int    start = message.IndexOf("[ ");
                int    end   = message.IndexOf(" ]");
                string key   = message.Substring(start, end - start);
                if (ErrorsAlready.TryGetValue(key, out _) == false)
                {
                    ErrorsAlready[key] = true;
                    Debug.WriteLine(debugMessage);
                    Debugger.Break();
                }
                return(false);

            case DeviceCreationFlags.DebugAndLogUnique:
                start = message.IndexOf("[ ");
                end   = message.IndexOf(" ]");
                key   = message.Substring(start, end - start);
                if (ErrorsAlready.TryGetValue(key, out _) == false)
                {
                    ErrorsAlready[key] = true;
                    debugMessage      += "\n\nStack Trace: " + (new StackTrace()).ToString();
                    ErrorFileLogger.WriteLogToFile(debugMessage);
                }
                return(false);
            }
        }
		public static extern void vkDebugReportMessageEXT(VkInstance instance, VkDebugReportFlagsEXT flags,
		   VkDebugReportObjectTypeEXT objectType, uint64_t _object, size_t location,
		   int32_t messageCode, byte* pLayerPrefix, byte* pMessage);
예제 #21
0
 public NativeResource(VkDebugReportObjectTypeEXT type, ulong handle)
 {
     this.type   = type;
     this.handle = handle;
 }
 private static VkBool32 DebugReport(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, ulong @object, VkPointerSize location, int messageCode, string layerPrefix, string message, IntPtr userData)
 {
     Debug.WriteLine($"{flags}: {message} ([{messageCode}] {layerPrefix})");
     return(false);
 }
예제 #23
0
 private static bool debugCallback(VkDebugReportFlagBitsEXT flags, VkDebugReportObjectTypeEXT objType, object obj, int location, int messageCode, string pLayerPrefix, string msg, object userData)
 {
     Debug.WriteLine(string.Format("ERROR: validation layer: {0}", msg));
     return(false);
 }