Esempio n. 1
0
 /// <summary>
 /// Create a debug report callback object.
 /// </summary>
 /// <param name="extendedHandle">
 /// The Instance handle to extend.
 /// </param>
 /// <param name="flags">
 /// flags indicate which event(s) will cause this callback to be
 /// called. Flags are interpreted as bitmasks and multiple may be set.
 /// Bits which can be set include: + --
 /// </param>
 /// <param name="allocator">
 /// An optional AllocationCallbacks instance that controls host memory
 /// allocation.
 /// </param>
 public static unsafe SharpVk.Multivendor.DebugReportCallback CreateDebugReportCallback(this SharpVk.Instance extendedHandle, SharpVk.Multivendor.DebugReportCallbackDelegate callback, SharpVk.Multivendor.DebugReportFlags?flags = default(SharpVk.Multivendor.DebugReportFlags?), IntPtr?userData = default(IntPtr?), SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?))
 {
     try
     {
         SharpVk.Multivendor.DebugReportCallback result = default(SharpVk.Multivendor.DebugReportCallback);
         CommandCache commandCache = default(CommandCache);
         SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *);
         void *nextPointer = default(void *);
         SharpVk.Interop.AllocationCallbacks *           marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *);
         SharpVk.Interop.Multivendor.DebugReportCallback marshalledCallback  = default(SharpVk.Interop.Multivendor.DebugReportCallback);
         commandCache                = extendedHandle.commandCache;
         marshalledCreateInfo        = (SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo>());
         marshalledCreateInfo->SType = StructureType.DebugReportCallbackCreateInfo;
         marshalledCreateInfo->Next  = nextPointer;
         if (flags != null)
         {
             marshalledCreateInfo->Flags = flags.Value;
         }
         else
         {
             marshalledCreateInfo->Flags = default(SharpVk.Multivendor.DebugReportFlags);
         }
         marshalledCreateInfo->Callback = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(callback);
         if (userData != null)
         {
             marshalledCreateInfo->UserData = userData.Value.ToPointer();
         }
         else
         {
             marshalledCreateInfo->UserData = default(void *);
         }
         if (allocator != null)
         {
             marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>());
             allocator.Value.MarshalTo(marshalledAllocator);
         }
         else
         {
             marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *);
         }
         SharpVk.Interop.Multivendor.VkInstanceCreateDebugReportCallbackDelegate commandDelegate = commandCache.Cache.vkCreateDebugReportCallbackEXT;
         Result methodResult = commandDelegate(extendedHandle.handle, marshalledCreateInfo, marshalledAllocator, &marshalledCallback);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         result = new SharpVk.Multivendor.DebugReportCallback(extendedHandle, marshalledCallback);
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
Esempio n. 2
0
 internal unsafe void MarshalTo(SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *pointer)
 {
     pointer->SType = StructureType.DebugReportCallbackCreateInfoExt;
     pointer->Next  = null;
     if (this.Flags != null)
     {
         pointer->Flags = this.Flags.Value;
     }
     else
     {
         pointer->Flags = default(SharpVk.Multivendor.DebugReportFlags);
     }
     pointer->Callback = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(this.Callback);
     if (this.UserData != null)
     {
         pointer->UserData = this.UserData.Value.ToPointer();
     }
     else
     {
         pointer->UserData = default(void *);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Create a new Vulkan instance.
 /// </summary>
 /// <param name="commandCache">
 /// </param>
 /// <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="debugReportCallbackCreateInfoExt">
 /// Extension struct
 /// </param>
 /// <param name="validationFlagsExt">
 /// Extension struct
 /// </param>
 /// <param name="validationFeaturesExt">
 /// Extension struct
 /// </param>
 /// <param name="debugUtilsMessengerCreateInfoExt">
 /// Extension struct
 /// </param>
 /// <param name="allocator">
 /// An optional AllocationCallbacks instance that controls host memory
 /// allocation.
 /// </param>
 public static unsafe SharpVk.Instance Create(CommandCache commandCache, ArrayProxy <string>?enabledLayerNames, ArrayProxy <string>?enabledExtensionNames, SharpVk.InstanceCreateFlags?flags = default(SharpVk.InstanceCreateFlags?), SharpVk.ApplicationInfo?applicationInfo = default(SharpVk.ApplicationInfo?), SharpVk.Multivendor.DebugReportCallbackCreateInfo?debugReportCallbackCreateInfoExt = null, SharpVk.Multivendor.ValidationFlags?validationFlagsExt = null, SharpVk.Multivendor.ValidationFeatures?validationFeaturesExt = null, SharpVk.Multivendor.DebugUtilsMessengerCreateInfo?debugUtilsMessengerCreateInfoExt = null, SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?))
 {
     try
     {
         SharpVk.Instance result = default(SharpVk.Instance);
         SharpVk.Interop.InstanceCreateInfo *marshalledCreateInfo = default(SharpVk.Interop.InstanceCreateInfo *);
         void *vkInstanceCreateInfoNextPointer = default(void *);
         SharpVk.Interop.AllocationCallbacks *marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *);
         SharpVk.Interop.Instance             marshalledInstance  = default(SharpVk.Interop.Instance);
         if (debugReportCallbackCreateInfoExt != null)
         {
             SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *extensionPointer = default(SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *);
             extensionPointer = (SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.DebugReportCallbackCreateInfo>());
             debugReportCallbackCreateInfoExt.Value.MarshalTo(extensionPointer);
             extensionPointer->Next          = vkInstanceCreateInfoNextPointer;
             vkInstanceCreateInfoNextPointer = extensionPointer;
         }
         if (validationFlagsExt != null)
         {
             SharpVk.Interop.Multivendor.ValidationFlags *extensionPointer = default(SharpVk.Interop.Multivendor.ValidationFlags *);
             extensionPointer = (SharpVk.Interop.Multivendor.ValidationFlags *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.ValidationFlags>());
             validationFlagsExt.Value.MarshalTo(extensionPointer);
             extensionPointer->Next          = vkInstanceCreateInfoNextPointer;
             vkInstanceCreateInfoNextPointer = extensionPointer;
         }
         if (validationFeaturesExt != null)
         {
             SharpVk.Interop.Multivendor.ValidationFeatures *extensionPointer = default(SharpVk.Interop.Multivendor.ValidationFeatures *);
             extensionPointer = (SharpVk.Interop.Multivendor.ValidationFeatures *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.ValidationFeatures>());
             validationFeaturesExt.Value.MarshalTo(extensionPointer);
             extensionPointer->Next          = vkInstanceCreateInfoNextPointer;
             vkInstanceCreateInfoNextPointer = extensionPointer;
         }
         if (debugUtilsMessengerCreateInfoExt != null)
         {
             SharpVk.Interop.Multivendor.DebugUtilsMessengerCreateInfo *extensionPointer = default(SharpVk.Interop.Multivendor.DebugUtilsMessengerCreateInfo *);
             extensionPointer = (SharpVk.Interop.Multivendor.DebugUtilsMessengerCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.DebugUtilsMessengerCreateInfo>());
             debugUtilsMessengerCreateInfoExt.Value.MarshalTo(extensionPointer);
             extensionPointer->Next          = vkInstanceCreateInfoNextPointer;
             vkInstanceCreateInfoNextPointer = extensionPointer;
         }
         marshalledCreateInfo        = (SharpVk.Interop.InstanceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.InstanceCreateInfo>());
         marshalledCreateInfo->SType = StructureType.InstanceCreateInfo;
         marshalledCreateInfo->Next  = vkInstanceCreateInfoNextPointer;
         if (flags != null)
         {
             marshalledCreateInfo->Flags = flags.Value;
         }
         else
         {
             marshalledCreateInfo->Flags = default(SharpVk.InstanceCreateFlags);
         }
         if (applicationInfo != null)
         {
             marshalledCreateInfo->ApplicationInfo = (SharpVk.Interop.ApplicationInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.ApplicationInfo>());
             applicationInfo.Value.MarshalTo(marshalledCreateInfo->ApplicationInfo);
         }
         else
         {
             marshalledCreateInfo->ApplicationInfo = default(SharpVk.Interop.ApplicationInfo *);
         }
         marshalledCreateInfo->EnabledLayerCount     = (uint)(Interop.HeapUtil.GetLength(enabledLayerNames));
         marshalledCreateInfo->EnabledLayerNames     = Interop.HeapUtil.MarshalTo(enabledLayerNames);
         marshalledCreateInfo->EnabledExtensionCount = (uint)(Interop.HeapUtil.GetLength(enabledExtensionNames));
         marshalledCreateInfo->EnabledExtensionNames = Interop.HeapUtil.MarshalTo(enabledExtensionNames);
         if (allocator != null)
         {
             marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>());
             allocator.Value.MarshalTo(marshalledAllocator);
         }
         else
         {
             marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *);
         }
         SharpVk.Interop.VkInstanceCreateDelegate commandDelegate = commandCache.Cache.vkCreateInstance;
         Result methodResult = commandDelegate(marshalledCreateInfo, marshalledAllocator, &marshalledInstance);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         result = new SharpVk.Instance(commandCache, marshalledInstance);
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }