public void CreateDebugReportCallbackExt() { var createInfo = new InstanceCreateInfo( enabledLayerNames: new[] { InstanceLayer.LunarGStandardValidation }, enabledExtensionNames: new[] { InstanceExtension.ExtDebugReport }); using (var instance = new Instance(createInfo)) { var callbackArgs = new List <DebugReportCallbackInfo>(); int userData = 1; IntPtr userDataHandle = new IntPtr(&userData); var debugReportCallbackCreateInfo = new DebugReportCallbackCreateInfoExt( DebugReportFlagsExt.All, args => { callbackArgs.Add(args); return(false); }, userDataHandle); using (instance.CreateDebugReportCallbackExt(debugReportCallbackCreateInfo)) { instance.DebugReportMessageExt(DebugReportFlagsExt.Debug, "test"); Assert.NotEmpty(callbackArgs); Assert.Equal(1, *(int *)callbackArgs[0].UserData); } callbackArgs.Clear(); using (instance.CreateDebugReportCallbackExt(debugReportCallbackCreateInfo, CustomAllocator)) { instance.DebugReportMessageExt(DebugReportFlagsExt.Debug, "test"); Assert.NotEmpty(callbackArgs); Assert.Equal(1, *(int *)callbackArgs[0].UserData); } } }
private void CreateInstance() { AvailableInstanceExtensions = Instance.EnumerateExtensionProperties(); string[] selectExtensions = new[] { Constant.InstanceExtension.ExtDebugReport } .Where(AvailableInstanceExtensions.Contains) .ToArray(); // Specify standard validation layers. var createInfo = new InstanceCreateInfo { EnabledLayerNames = new[] { Constant.InstanceLayer.LunarGStandardValidation }, EnabledExtensionNames = selectExtensions }; Instance = new Instance(createInfo); // Attach debug callback and fail any test on any error or warning from validation layers. var debugReportCreateInfo = new DebugReportCallbackCreateInfoExt( DebugReportFlagsExt.Error | DebugReportFlagsExt.Warning | DebugReportFlagsExt.PerformanceWarning, args => { if ((args.Flags & (DebugReportFlagsExt.Error | DebugReportFlagsExt.PerformanceWarning | DebugReportFlagsExt.Warning)) > 0) { Assert.True(false, $"Validation layer error/warning:\n\n[{args.Flags}] {args.Message}"); } return(false); } ); _debugReportCallback = Instance.CreateDebugReportCallbackExt(debugReportCreateInfo); }
public void CreateDebugReportCallbackExt() { var createInfo = new InstanceCreateInfo( enabledLayerNames: new[] { InstanceLayer.LunarGStandardValidation }, enabledExtensionNames: new[] { InstanceExtension.ExtDebugReport }); using (var instance = new Instance(createInfo)) { var callbackArgs = new List <DebugReportCallbackInfo>(); int userData = 1; IntPtr userDataHandle = new IntPtr(&userData); var debugReportCallbackCreateInfo = new DebugReportCallbackCreateInfoExt( DebugReportFlagsExt.All, args => { callbackArgs.Add(args); return(false); }, userDataHandle); // Registering the callback should generate DEBUG messages. using (instance.CreateDebugReportCallbackExt(debugReportCallbackCreateInfo)) { } using (instance.CreateDebugReportCallbackExt(debugReportCallbackCreateInfo, CustomAllocator)) { } Assert.True(callbackArgs.Count > 0); Assert.Equal(1, *(int *)callbackArgs[0].UserData); } }
private void SetupDebugCallback(Instance instance) { data.debugCallbackDelegate = DebugCallback; var createInfo = new DebugReportCallbackCreateInfoExt { Flags = DebugReportFlagsExt.Error | DebugReportFlagsExt.Warning, PfnCallback = Marshal.GetFunctionPointerForDelegate(data.debugCallbackDelegate) }; data.debugCallback = instance.CreateDebugReportCallbackEXT(createInfo); }
internal static DebugReportCallbackExt CreateDebugReportCallback(Instance inst) { #if DEBUG // Attach debug callback. var debugReportCreateInfo = new DebugReportCallbackCreateInfoExt( DebugReportFlagsExt.All, args => { Console.WriteLine($"[{args.Flags}][{args.LayerPrefix}] {args.Message}"); return(args.Flags.HasFlag(DebugReportFlagsExt.Error)); } ); return(inst.CreateDebugReportCallbackExt(debugReportCreateInfo)); #else return(null); #endif }
private DebugReportCallbackExt CreateDebugReportCallback(bool debug) { if (!debug) { return(null); } // Attach debug callback. var debugReportCreateInfo = new DebugReportCallbackCreateInfoExt( DebugReportFlagsExt.All, args => { Debug.WriteLine($"[{args.Flags}][{args.LayerPrefix}] {args.Message}"); return(args.Flags.HasFlag(DebugReportFlagsExt.Error)); } ); return(Instance.CreateDebugReportCallbackExt(debugReportCreateInfo)); }
public void EnableDebug(DebugReportCallback d, DebugReportFlagsExt flags = DebugReportFlagsExt.Debug | DebugReportFlagsExt.Error | DebugReportFlagsExt.Information | DebugReportFlagsExt.PerformanceWarning | DebugReportFlagsExt.Warning) { if (vkCreateDebugReportCallbackEXT == null) { throw new InvalidOperationException("vkCreateDebugReportCallbackEXT is not available, possibly you might be missing VK_EXT_debug_report extension. Try to enable it when creating the Instance."); } var debugCreateInfo = new DebugReportCallbackCreateInfoExt() { Flags = flags, PfnCallback = Marshal.GetFunctionPointerForDelegate(d) }; if (debugCallback != null) { DestroyDebugReportCallbackEXT(debugCallback); } debugCallback = CreateDebugReportCallbackEXT(debugCreateInfo); }
private DebugReportCallbackExt CreateDebugReportCallback(bool debug) { //Currently MoltenVK (used for MacOS) doesn't support the debug layer. if (!debug || Host.Platform == Platform.MacOS) { return(null); } // Attach debug callback. var debugReportCreateInfo = new DebugReportCallbackCreateInfoExt( DebugReportFlagsExt.All, args => { Debug.WriteLine($"[{args.Flags}][{args.LayerPrefix}] {args.Message}"); return(args.Flags.HasFlag(DebugReportFlagsExt.Error)); } ); return(Instance.CreateDebugReportCallbackExt(debugReportCreateInfo)); }
public void DebugReportMessageExt() { const string message = "message õäöü"; const DebugReportObjectTypeExt objectType = DebugReportObjectTypeExt.DebugReportCallback; const long @object = long.MaxValue; var location = new IntPtr(int.MaxValue); const int messageCode = 1; const string layerPrefix = "prefix õäöü"; bool visitedCallback = false; var instanceCreateInfo = new InstanceCreateInfo( enabledExtensionNames: new[] { InstanceExtension.ExtDebugReport }); using (var instance = new Instance(instanceCreateInfo)) { var debugReportCallbackCreateInfo = new DebugReportCallbackCreateInfoExt( DebugReportFlagsExt.Error, args => { Assert.Equal(objectType, args.ObjectType); Assert.Equal(@object, args.Object); Assert.Equal(location, args.Location); Assert.Equal(messageCode, args.MessageCode); Assert.Equal(layerPrefix, args.LayerPrefix); Assert.Equal(message, args.Message); visitedCallback = true; return(false); }); using (instance.CreateDebugReportCallbackExt(debugReportCallbackCreateInfo)) { instance.DebugReportMessageExt(DebugReportFlagsExt.Error, message, objectType, @object, location, messageCode, layerPrefix); } } Assert.True(visitedCallback); }
public bool InitVulkan(string appName, VER appVer, bool bDebug) { Glfw.Init(); mInstance = new Instance(appName, EngineName, appVer, mEngineVer, mAPIVer, bDebug); if (!mInstance.IsValid()) { Misc.SafeInvoke(eErrorSpam, "Couldn't create Vulkan instance."); return(false); } if (bDebug) { //set up debug callback to talk to validation stuff DebugReportCallbackCreateInfoExt drcbci = new DebugReportCallbackCreateInfoExt( DebugReportFlagsExt.All, DebugReportCallback, IntPtr.Zero); mDebugCB = mInstance.AttachDebugCallback(drcbci); } return(true); }
internal DebugReportCallbackExt AttachDebugCallback(DebugReportCallbackCreateInfoExt drcbci) { return(mInstance.CreateDebugReportCallbackExt(drcbci)); }