From 472832f8848495f881adc6da1a3b9bebcce990cb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Sat, 20 Nov 2021 04:04:02 +0100 Subject: [PATCH] debug utils buffer overflow debug, print enabled layers in DEBUG mode with toolsProperties in SampleBase --- samples/common/SampleBase.cs | 13 ++++++++++++- vke/src/base/DebugUtilsMessenger.cs | 6 +++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/samples/common/SampleBase.cs b/samples/common/SampleBase.cs index 76a85f3..4f22dca 100644 --- a/samples/common/SampleBase.cs +++ b/samples/common/SampleBase.cs @@ -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 + } } } diff --git a/vke/src/base/DebugUtilsMessenger.cs b/vke/src/base/DebugUtilsMessenger.cs index 4c47867..67f13d9 100644 --- a/vke/src/base/DebugUtilsMessenger.cs +++ b/vke/src/base/DebugUtilsMessenger.cs @@ -41,15 +41,15 @@ namespace vke.DebugUtils { break; case VkDebugUtilsMessageTypeFlagsEXT.PerformanceEXT: Console.Write ("PERF:"); - break; + break; } - byte [] tmp = new byte [1024]; + Span 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