internal DebugReportCallbackExt(Instance parent,
                                        ref DebugReportCallbackCreateInfoExt createInfo, ref AllocationCallbacks?allocator)
        {
            Parent    = parent;
            Allocator = allocator;

            Func <DebugReportCallbackInfo, bool> createInfoCallback = createInfo.Callback;
            IntPtr callbackHandle = IntPtr.Zero;

            if (createInfoCallback != null)
            {
                _callback = (flags, objectType, @object, location, messageCode, layerPrefix, message, userData)
                            => createInfoCallback(new DebugReportCallbackInfo
                {
                    Flags       = flags,
                    ObjectType  = objectType,
                    Object      = @object,
                    Location    = location,
                    MessageCode = messageCode,
                    LayerPrefix = Interop.String.FromPointer(layerPrefix),
                    Message     = Interop.String.FromPointer(message),
                    UserData    = userData
                });
                callbackHandle = Interop.GetFunctionPointerForDelegate(_callback);
            }
            createInfo.ToNative(out DebugReportCallbackCreateInfoExt.Native nativeCreateInfo, callbackHandle);

            long   handle;
            Result result = vkCreateDebugReportCallbackEXT(Parent)(Parent, &nativeCreateInfo, NativeAllocator, &handle);

            VulkanException.ThrowForInvalidResult(result);
            Handle = handle;
        }
示例#2
0
        private void CreateInstance()
        {
            var enabledLayers = new List <string>();

            if (Instance.EnumerateLayerProperties().Any(x => x.LayerName == "VK_LAYER_LUNARG_standard_validation"))
            {
                enabledLayers.Add("VK_LAYER_LUNARG_standard_validation");
            }

            var glfwExtensions = Glfw3.glfwGetRequiredInstanceExtensions();

            this.instance = Instance.Create(new InstanceCreateInfo
            {
                ApplicationInfo = new ApplicationInfo
                {
                    ApplicationName    = "Ludum Dare 38",
                    ApplicationVersion = new SharpVk.Version(1, 0, 0),
                    EngineName         = "SharpVk",
                    EngineVersion      = Constants.SharpVkVersion,
                    ApiVersion         = Constants.ApiVersion10
                },
                EnabledExtensionNames = glfwExtensions.Concat(new[] { ExtDebugReport.ExtensionName }).ToArray(),
                EnabledLayerNames     = enabledLayers.ToArray()
            }, null);

            this.reportCallback = this.instance.CreateDebugReportCallback(new DebugReportCallbackCreateInfo
            {
                Flags       = DebugReportFlags.Error | DebugReportFlags.Warning,
                PfnCallback = this.debugReportDelegate
            });
        }
 /// <summary>
 /// Destroy a debug report callback object.
 /// </summary>
 public override void Dispose()
 {
     if (!Disposed)
     {
         vkDestroyDebugReportCallbackEXT(Parent)(Parent, this, NativeAllocator);
         _callback = null;
     }
     base.Dispose();
 }
示例#4
0
 /// <summary>
 /// Destroy a debug report callback object.
 /// </summary>
 public override void Dispose()
 {
     if (!Disposed)
     {
         var destroyDelegate = Parent.GetProc <DestroyDebugReportCallbackExt>("vkDestroyDebugReportCallbackEXT");
         destroyDelegate?.Invoke(Parent, this, NativeAllocator);
         _callback = null;
     }
     base.Dispose();
 }
        /// <summary>
        ///
        /// </summary>
        public override void Dispose()
        {
            Debugger?.Dispose();
            Debugger = null;

            Instance?.Dispose();
            Instance = null;

            gch_.Free();
        }
示例#6
0
        public override void Stop()
        {
            this.updateLoop.Deregister(this);

            this.surface.Destroy();
            this.surface = null;

            this.reportCallback.Destroy();
            this.reportCallback = null;

            this.instance.Destroy();
            this.instance = null;
        }
 /// <summary>
 /// Create a new Vulkan instance.
 /// </summary>
 /// <param name="flags">
 /// Reserved for future use.
 /// </param>
 /// <param name="applicationInfo">
 /// Null or an instance of ApplicationInfo. If not Null, this
 /// information helps implementations recognize behavior inherent to
 /// classes of applications. ApplicationInfo is defined in detail
 /// below.
 /// </param>
 /// <param name="enabledLayerNames">
 /// An array of enabledLayerCount strings containing the names of
 /// layers to enable for the created instance. See the Layers section
 /// for further details.
 /// </param>
 /// <param name="enabledExtensionNames">
 /// An array of enabledExtensionCount strings containing the names of
 /// extensions to enable.
 /// </param>
 /// <param name="validationFlagsExt">
 /// </param>
 /// <param name="validationFeaturesExt"></param>
 /// <param name="allocator">
 /// An optional AllocationCallbacks instance that controls host memory
 /// allocation.
 /// </param>
 public unsafe override void CreateInstance(ArrayProxy <string>?enabledLayerNames, ArrayProxy <string>?enabledExtensionNames, SharpVk.InstanceCreateFlags?flags = null, SharpVk.ApplicationInfo?applicationInfo = null, SharpVk.Multivendor.ValidationFlags?validationFlagsExt = null, SharpVk.Multivendor.ValidationFeatures?validationFeaturesExt = null, AllocationCallbacks?allocator = null)
 {
     if (Instance != null)
     {
         return;
     }
     else if (Enabled)
     {
         Instance = SharpVk.Instance.Create(enabledLayerNames.GetValueOrDefault().AddUnique("VK_LAYER_KHRONOS_validation"), enabledExtensionNames.GetValueOrDefault().AddUnique(SharpVk.Multivendor.ExtExtensions.DebugReport), flags, applicationInfo, this, validationFlagsExt, validationFeaturesExt, null, allocator);
         Debugger = Instance.CreateDebugReportCallback(DebugReportCallbackDelegate, Flags, System.Runtime.InteropServices.GCHandle.ToIntPtr(gch_), allocator);
     }
     else
     {
         Instance = SharpVk.Instance.Create(enabledLayerNames, enabledExtensionNames, flags, applicationInfo, null, validationFlagsExt, validationFeaturesExt, null, allocator);
     }
 }
示例#8
0
        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);
        }
示例#9
0
        private void CreateInstance()
        {
            var enabledLayers = new List <string>();

            if (Instance.EnumerateLayerProperties().Any(x => x.LayerName == "VK_LAYER_LUNARG_standard_validation"))
            {
                enabledLayers.Add("VK_LAYER_LUNARG_standard_validation");
            }

            var glfwExtensions = Glfw3.GetRequiredInstanceExtensions();

            this.instance = Instance.Create(enabledLayers.ToArray(), glfwExtensions.Concat(new[] { ExtExtensions.DebugReport }).ToArray(), InstanceCreateFlags.None,
                                            new ApplicationInfo
            {
                ApplicationName    = "Tectonic",
                ApplicationVersion = new SharpVk.Version(1, 0, 0),
                EngineName         = "Tectonic",
                ApiVersion         = new SharpVk.Version(1, 0, 0)
            });

            this.reportCallback = this.instance.CreateDebugReportCallback(this.debugReportDelegate, DebugReportFlags.Error | DebugReportFlags.Warning);
        }
示例#10
0
        internal DebugReportCallbackExt(VkInstance parent, VkDebugReportFlagsEXT flags,
                                        Func <DebugReportCallbackInfo, bool> callback, IntPtr userData = default(IntPtr))
        {
            Parent = parent;

            Func <DebugReportCallbackInfo, bool> createInfoCallback = callback;
            IntPtr callbackHandle = IntPtr.Zero;

            if (createInfoCallback != null)
            {
                _callback = (flags, objectType, @object, location, messageCode, layerPrefix, message, userData)
                            => createInfoCallback(new DebugReportCallbackInfo
                {
                    Flags       = flags,
                    ObjectType  = objectType,
                    Object      = @object,
                    Location    = location,
                    MessageCode = messageCode,
                    LayerPrefix = Utilities.FromPointer(layerPrefix),
                    Message     = Utilities.FromPointer(message),
                    UserData    = userData
                });
                callbackHandle = Marshal.GetFunctionPointerForDelegate(_callback);
            }

            var nativeCreateInfo = new VkDebugReportCallbackCreateInfoEXT
            {
                sType       = VkStructureType.DebugReportCallbackCreateInfoEXT,
                flags       = flags,
                pfnCallback = callbackHandle,
                pUserData   = (void *)userData
            };

            long     handle;
            VkResult result = vkCreateDebugReportCallbackEXT(Parent)(Parent.Handle, &nativeCreateInfo, null, &handle);

            this.handle = (ulong)handle;
        }
示例#11
0
 protected override void Destroy(bool disposing)
 {
     Vulkan.vkDestroyDebugReportCallbackEXT(Parent, handle, null);
     _callback = null;
 }
示例#12
0
 internal static unsafe extern void vkDestroyDebugReportCallbackEXT(Instance instance, DebugReportCallback callback, AllocationCallbacks* allocator);
示例#13
0
 internal static unsafe extern Result vkCreateDebugReportCallbackEXT(Instance instance, DebugReportCallbackCreateInfo* createInfo, AllocationCallbacks* allocator, DebugReportCallback* callback);
示例#14
0
 public unsafe void DestroyDebugReportCallback(DebugReportCallback callback, AllocationCallbacks* allocator = null)
 {
     vkDestroyDebugReportCallbackEXT(this, callback, allocator);
 }