]> O.S.I.I.S - jp/vke.net.git/commitdiff
debug utils buffer overflow debug, print enabled layers in DEBUG mode with toolsPrope...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 20 Nov 2021 03:04:02 +0000 (04:04 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sat, 20 Nov 2021 03:04:02 +0000 (04:04 +0100)
samples/common/SampleBase.cs
vke/src/base/DebugUtilsMessenger.cs

index 76a85f3fc4b1c5e6ee58b29b7838c6fb61aed785..4f22dca7ea821ff8c3c050745fa6ea72080e050b 100644 (file)
@@ -3,11 +3,22 @@ using System.IO;
 using System.Linq;
 using System.Reflection;
 using System.Runtime.InteropServices;
-
+using Vulkan;
 
 namespace vke {
        public abstract class SampleBase : VkWindow {
                public SampleBase (string name = "VkWindow", uint _width = 800, uint _height = 600, bool vSync = true) :
                        base (name, _width, _height, vSync){}
+               protected override void initVulkan()
+               {
+                       base.initVulkan();
+#if DEBUG
+                       foreach (VkPhysicalDeviceToolPropertiesEXT toolProp in phy.GetToolProperties()) {
+                               Console.ForegroundColor = ConsoleColor.DarkYellow;
+                               Console.WriteLine ($"Enabled Tool: {toolProp.name}({toolProp.version})");
+                               Console.ResetColor ();
+                       }
+#endif
+               }
        }
 }
index 4c4786764c2b8ce01847b9096a3d365ac7bf8bfd..67f13d95a5891cc7d9822edc459a14acd95ed45b 100644 (file)
@@ -41,15 +41,15 @@ namespace vke.DebugUtils {
                                break;
                        case VkDebugUtilsMessageTypeFlagsEXT.PerformanceEXT:
                                Console.Write ("PERF:");
-                               break;                  
+                               break;
                        }
 
-                       byte [] tmp = new byte [1024];
+                       Span<byte> tmp = stackalloc byte [2048];
 
                        if (data.pMessage != IntPtr.Zero) {
                                byte b = Marshal.ReadByte (data.pMessage);
                                int i = 1;
-                               while (b != 0) {
+                               while (b != 0 && i<tmp.Length) {
                                        tmp [i] = b;
                                        b = Marshal.ReadByte (data.pMessage, i);
                                        i++;