コード例 #1
0
ファイル: Swapchain.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Retrieve the index of the next available presentable image.
 /// </summary>
 public uint AcquireNextImage(ulong timeout, Semaphore semaphore, Fence fence)
 {
     unsafe
     {
         try
         {
             var               commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkAcquireNextImageKHR>("vkAcquireNextImageKHR", "device");
             uint              result          = default(uint);
             Result            commandResult;
             Interop.Semaphore marshalledSemaphore = default(Interop.Semaphore);
             semaphore?.MarshalTo(&marshalledSemaphore);
             Interop.Fence marshalledFence = default(Interop.Fence);
             fence?.MarshalTo(&marshalledFence);
             commandResult = commandDelegate(this.associated.handle, this.handle, timeout, marshalledSemaphore, marshalledFence, &result);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #2
0
ファイル: Swapchain.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Obtain the array of presentable images associated with a swapchain.
 /// </summary>
 public Image[] GetImages()
 {
     unsafe
     {
         try
         {
             var            commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkGetSwapchainImagesKHR>("vkGetSwapchainImagesKHR", "device");
             Image[]        result          = default(Image[]);
             Result         commandResult;
             uint           swapchainImageCount;
             Interop.Image *marshalledSwapchainImages = null;
             commandResult = commandDelegate(this.associated.handle, this.handle, &swapchainImageCount, null);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             marshalledSwapchainImages = (Interop.Image *)Interop.HeapUtil.Allocate <Interop.Image>((uint)swapchainImageCount);
             commandResult             = commandDelegate(this.associated.handle, this.handle, &swapchainImageCount, marshalledSwapchainImages);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new Image[(uint)swapchainImageCount];
             for (int index = 0; index < (uint)swapchainImageCount; index++)
             {
                 result[index] = new Image(marshalledSwapchainImages[index], this.associated, this.commandCache);
             }
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #3
0
 /// <summary>
 ///
 /// </summary>
 public unsafe void FreeDescriptorSets(SharpVk.DescriptorSet[] descriptorSets)
 {
     try
     {
         SharpVk.Interop.DescriptorSet *marshalledDescriptorSets = default(SharpVk.Interop.DescriptorSet *);
         if (descriptorSets != null)
         {
             var fieldPointer = (SharpVk.Interop.DescriptorSet *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.DescriptorSet>(descriptorSets.Length).ToPointer());
             for (int index = 0; index < (uint)(descriptorSets.Length); index++)
             {
                 fieldPointer[index] = descriptorSets[index]?.handle ?? default(SharpVk.Interop.DescriptorSet);
             }
             marshalledDescriptorSets = fieldPointer;
         }
         else
         {
             marshalledDescriptorSets = null;
         }
         Result methodResult = Interop.Commands.vkFreeDescriptorSets(this.parent.handle, this.handle, (uint)(descriptorSets?.Length ?? 0), marshalledDescriptorSets);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #4
0
ファイル: PipelineCache.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Get the data store from a pipeline cache.
 /// </summary>
 public byte[] GetData()
 {
     unsafe
     {
         try
         {
             byte[] result = default(byte[]);
             Result commandResult;
             Size   dataSize;
             byte * marshalledData = null;
             commandResult = Interop.Commands.vkGetPipelineCacheData(this.parent.handle, this.handle, &dataSize, null);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             marshalledData = (byte *)Interop.HeapUtil.Allocate <byte>((uint)dataSize);
             commandResult  = Interop.Commands.vkGetPipelineCacheData(this.parent.handle, this.handle, &dataSize, marshalledData);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new byte[(uint)dataSize];
             for (int index = 0; index < (uint)dataSize; index++)
             {
                 result[index] = marshalledData[index];
             }
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #5
0
 /// <summary>
 /// Lists physical device's image format capabilities.
 /// </summary>
 public ImageFormatProperties2 GetImageFormatProperties2(PhysicalDeviceImageFormatInfo2 imageFormatInfo)
 {
     unsafe
     {
         try
         {
             var commandDelegate           = this.commandCache.GetCommandDelegate <Interop.vkGetPhysicalDeviceImageFormatProperties2KHR>("vkGetPhysicalDeviceImageFormatProperties2KHR", "instance");
             ImageFormatProperties2 result = default(ImageFormatProperties2);
             Result commandResult;
             Interop.PhysicalDeviceImageFormatInfo2 marshalledImageFormatInfo;
             imageFormatInfo.MarshalTo(&marshalledImageFormatInfo);
             Interop.ImageFormatProperties2 marshalledImageFormatProperties;
             commandResult = commandDelegate(this.handle, &marshalledImageFormatInfo, &marshalledImageFormatProperties);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = ImageFormatProperties2.MarshalFrom(&marshalledImageFormatProperties);
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #6
0
 /// <summary>
 ///
 /// </summary>
 public unsafe void MergePipelineCaches(SharpVk.PipelineCache[] sourceCaches)
 {
     try
     {
         SharpVk.Interop.PipelineCache *marshalledSourceCaches = default(SharpVk.Interop.PipelineCache *);
         if (sourceCaches != null)
         {
             var fieldPointer = (SharpVk.Interop.PipelineCache *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.PipelineCache>(sourceCaches.Length).ToPointer());
             for (int index = 0; index < (uint)(sourceCaches.Length); index++)
             {
                 fieldPointer[index] = sourceCaches[index]?.handle ?? default(SharpVk.Interop.PipelineCache);
             }
             marshalledSourceCaches = fieldPointer;
         }
         else
         {
             marshalledSourceCaches = null;
         }
         Result methodResult = Interop.Commands.vkMergePipelineCaches(this.parent.handle, this.handle, (uint)(sourceCaches?.Length ?? 0), marshalledSourceCaches);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #7
0
 /// <summary>
 /// Create a display mode.
 /// </summary>
 public DisplayMode CreateDisplayMode(Display display, DisplayModeCreateInfo createInfo)
 {
     unsafe
     {
         try
         {
             var             commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkCreateDisplayModeKHR>("vkCreateDisplayModeKHR", "instance");
             DisplayMode     result          = default(DisplayMode);
             Result          commandResult;
             Interop.Display marshalledDisplay = default(Interop.Display);
             display?.MarshalTo(&marshalledDisplay);
             Interop.DisplayModeCreateInfo marshalledCreateInfo;
             createInfo.MarshalTo(&marshalledCreateInfo);
             Interop.AllocationCallbacks marshalledAllocator;
             this.parent.Allocator?.MarshalTo(&marshalledAllocator);
             Interop.DisplayMode marshalledMode;
             commandResult = commandDelegate(this.handle, marshalledDisplay, &marshalledCreateInfo, this.parent.Allocator == null ? null : &marshalledAllocator, &marshalledMode);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new DisplayMode(marshalledMode, this, this.commandCache);
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #8
0
 /// <summary>
 /// Query the list of displays a plane supports.
 /// </summary>
 public Display[] GetDisplayPlaneSupportedDisplays(uint planeIndex)
 {
     unsafe
     {
         try
         {
             var              commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkGetDisplayPlaneSupportedDisplaysKHR>("vkGetDisplayPlaneSupportedDisplaysKHR", "instance");
             Display[]        result          = default(Display[]);
             Result           commandResult;
             uint             displayCount;
             Interop.Display *marshalledDisplays = null;
             commandResult = commandDelegate(this.handle, planeIndex, &displayCount, null);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             marshalledDisplays = (Interop.Display *)Interop.HeapUtil.Allocate <Interop.Display>((uint)displayCount);
             commandResult      = commandDelegate(this.handle, planeIndex, &displayCount, marshalledDisplays);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new Display[(uint)displayCount];
             for (int index = 0; index < (uint)displayCount; index++)
             {
                 result[index] = new Display(marshalledDisplays[index], this.Allocator, this.commandCache);
             }
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #9
0
 /// <summary>
 /// Query the plane properties.
 /// </summary>
 public DisplayPlaneProperties[] GetDisplayPlaneProperties()
 {
     unsafe
     {
         try
         {
             var commandDelegate             = this.commandCache.GetCommandDelegate <Interop.vkGetPhysicalDeviceDisplayPlanePropertiesKHR>("vkGetPhysicalDeviceDisplayPlanePropertiesKHR", "instance");
             DisplayPlaneProperties[] result = default(DisplayPlaneProperties[]);
             Result commandResult;
             uint   propertyCount;
             Interop.DisplayPlaneProperties *marshalledProperties = null;
             commandResult = commandDelegate(this.handle, &propertyCount, null);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             marshalledProperties = (Interop.DisplayPlaneProperties *)Interop.HeapUtil.Allocate <Interop.DisplayPlaneProperties>((uint)propertyCount);
             commandResult        = commandDelegate(this.handle, &propertyCount, marshalledProperties);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new DisplayPlaneProperties[(uint)propertyCount];
             for (int index = 0; index < (uint)propertyCount; index++)
             {
                 result[index] = DisplayPlaneProperties.MarshalFrom(&marshalledProperties[index]);
             }
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #10
0
ファイル: Instance.gen.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Returns up to requested number of global layer properties.
 /// </summary>
 public static unsafe SharpVk.LayerProperties[] EnumerateLayerProperties()
 {
     try
     {
         SharpVk.LayerProperties[] result = default(SharpVk.LayerProperties[]);
         uint propertyCount = default(uint);
         SharpVk.Interop.LayerProperties *marshalledProperties = default(SharpVk.Interop.LayerProperties *);
         Result methodResult = Interop.Commands.vkEnumerateInstanceLayerProperties(&propertyCount, marshalledProperties);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         marshalledProperties = (SharpVk.Interop.LayerProperties *)(Interop.HeapUtil.Allocate <SharpVk.Interop.LayerProperties>((uint)(propertyCount)));
         Interop.Commands.vkEnumerateInstanceLayerProperties(&propertyCount, marshalledProperties);
         if (marshalledProperties != null)
         {
             var fieldPointer = new SharpVk.LayerProperties[(uint)(propertyCount)];
             for (int index = 0; index < (uint)(propertyCount); index++)
             {
                 fieldPointer[index] = SharpVk.LayerProperties.MarshalFrom(&marshalledProperties[index]);
             }
             result = fieldPointer;
         }
         else
         {
             result = null;
         }
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #11
0
ファイル: Instance.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Enumerates the physical devices accessible to a Vulkan instance.
 /// </summary>
 public PhysicalDevice[] EnumeratePhysicalDevices()
 {
     unsafe
     {
         try
         {
             PhysicalDevice[]        result = default(PhysicalDevice[]);
             Result                  commandResult;
             uint                    physicalDeviceCount;
             Interop.PhysicalDevice *marshalledPhysicalDevices = null;
             commandResult = Interop.Commands.vkEnumeratePhysicalDevices(this.handle, &physicalDeviceCount, null);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             marshalledPhysicalDevices = (Interop.PhysicalDevice *)Interop.HeapUtil.Allocate <Interop.PhysicalDevice>((uint)physicalDeviceCount);
             commandResult             = Interop.Commands.vkEnumeratePhysicalDevices(this.handle, &physicalDeviceCount, marshalledPhysicalDevices);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new PhysicalDevice[(uint)physicalDeviceCount];
             for (int index = 0; index < (uint)physicalDeviceCount; index++)
             {
                 result[index] = new PhysicalDevice(marshalledPhysicalDevices[index], this, this.commandCache);
             }
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #12
0
ファイル: PhysicalDevice.gen.cs プロジェクト: yaram/SharpVk
 /// <summary>
 /// Lists physical device's image format capabilities.
 /// </summary>
 public unsafe SharpVk.ImageFormatProperties GetImageFormatProperties(SharpVk.Format format, SharpVk.ImageType type, SharpVk.ImageTiling tiling, SharpVk.ImageUsageFlags usage, SharpVk.ImageCreateFlags?flags = default(SharpVk.ImageCreateFlags?))
 {
     try
     {
         SharpVk.ImageFormatProperties result          = default(SharpVk.ImageFormatProperties);
         SharpVk.ImageCreateFlags      marshalledFlags = default(SharpVk.ImageCreateFlags);
         SharpVk.ImageFormatProperties marshalledImageFormatProperties = default(SharpVk.ImageFormatProperties);
         if (flags != null)
         {
             marshalledFlags = flags.Value;
         }
         else
         {
             marshalledFlags = default(SharpVk.ImageCreateFlags);
         }
         SharpVk.Interop.VkPhysicalDeviceGetImageFormatPropertiesDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.VkPhysicalDeviceGetImageFormatPropertiesDelegate>("vkGetPhysicalDeviceImageFormatProperties", "");
         Result methodResult = commandDelegate(this.handle, format, type, tiling, usage, marshalledFlags, &marshalledImageFormatProperties);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         result = marshalledImageFormatProperties;
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #13
0
 /// <summary>
 /// Map a memory object into application address space.
 /// </summary>
 public unsafe IntPtr Map(DeviceSize offset, DeviceSize size, SharpVk.MemoryMapFlags?flags = default(SharpVk.MemoryMapFlags?))
 {
     try
     {
         IntPtr result = default(IntPtr);
         SharpVk.MemoryMapFlags marshalledFlags = default(SharpVk.MemoryMapFlags);
         void *marshalledData = default(void *);
         if (flags != null)
         {
             marshalledFlags = flags.Value;
         }
         else
         {
             marshalledFlags = default(SharpVk.MemoryMapFlags);
         }
         Result methodResult = Interop.Commands.vkMapMemory(this.parent.handle, this.handle, offset, size, marshalledFlags, &marshalledData);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         result = new IntPtr(marshalledData);
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #14
0
 /// <summary>
 ///
 /// </summary>
 public unsafe void BindSparse(SharpVk.BindSparseInfo[] bindInfo, SharpVk.Fence fence)
 {
     try
     {
         SharpVk.Interop.BindSparseInfo *marshalledBindInfo = default(SharpVk.Interop.BindSparseInfo *);
         if (bindInfo != null)
         {
             var fieldPointer = (SharpVk.Interop.BindSparseInfo *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.BindSparseInfo>(bindInfo.Length).ToPointer());
             for (int index = 0; index < (uint)(bindInfo.Length); index++)
             {
                 bindInfo[index].MarshalTo(&fieldPointer[index]);
             }
             marshalledBindInfo = fieldPointer;
         }
         else
         {
             marshalledBindInfo = null;
         }
         Result methodResult = Interop.Commands.vkQueueBindSparse(this.handle, (uint)(bindInfo?.Length ?? 0), marshalledBindInfo, fence?.handle ?? default(SharpVk.Interop.Fence));
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #15
0
 /// <summary>
 ///
 /// </summary>
 public unsafe void Submit(SharpVk.SubmitInfo[] submits, SharpVk.Fence fence)
 {
     try
     {
         SharpVk.Interop.SubmitInfo *marshalledSubmits = default(SharpVk.Interop.SubmitInfo *);
         if (submits != null)
         {
             var fieldPointer = (SharpVk.Interop.SubmitInfo *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.SubmitInfo>(submits.Length).ToPointer());
             for (int index = 0; index < (uint)(submits.Length); index++)
             {
                 submits[index].MarshalTo(&fieldPointer[index]);
             }
             marshalledSubmits = fieldPointer;
         }
         else
         {
             marshalledSubmits = null;
         }
         Result methodResult = Interop.Commands.vkQueueSubmit(this.handle, (uint)(submits?.Length ?? 0), marshalledSubmits, fence?.handle ?? default(SharpVk.Interop.Fence));
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #16
0
ファイル: CommandPool.gen.cs プロジェクト: bp-tags/SharpVk
 /// <summary>
 /// Reset a command pool.
 /// </summary>
 public unsafe void Reset(SharpVk.CommandPoolResetFlags?flags = default(SharpVk.CommandPoolResetFlags?))
 {
     try
     {
         SharpVk.CommandPoolResetFlags marshalledFlags = default(SharpVk.CommandPoolResetFlags);
         if (flags != null)
         {
             marshalledFlags = flags.Value;
         }
         else
         {
             marshalledFlags = default(SharpVk.CommandPoolResetFlags);
         }
         SharpVk.Interop.VkCommandPoolResetDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.VkCommandPoolResetDelegate>("vkResetCommandPool", "");
         Result methodResult = commandDelegate(this.parent.handle, this.handle, marshalledFlags);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #17
0
 /// <summary>
 /// Get the data store from a pipeline cache.
 /// </summary>
 public unsafe byte[] GetData()
 {
     try
     {
         byte[]   result         = default(byte[]);
         HostSize dataSize       = default(HostSize);
         byte *   marshalledData = default(byte *);
         SharpVk.Interop.VkPipelineCacheGetDataDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.VkPipelineCacheGetDataDelegate>("vkGetPipelineCacheData", "");
         Result methodResult = commandDelegate(this.parent.handle, this.handle, &dataSize, marshalledData);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         marshalledData = (byte *)(Interop.HeapUtil.Allocate <byte>((uint)(dataSize)));
         commandDelegate(this.parent.handle, this.handle, &dataSize, marshalledData);
         if (marshalledData != null)
         {
             var fieldPointer = new byte[(uint)(dataSize)];
             for (int index = 0; index < (uint)(dataSize); index++)
             {
                 fieldPointer[index] = marshalledData[index];
             }
             result = fieldPointer;
         }
         else
         {
             result = null;
         }
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #18
0
ファイル: Instance.gen.cs プロジェクト: harry-cpp/SharpVk
 /// <summary>
 /// Enumerates the physical devices accessible to a Vulkan instance.
 /// </summary>
 public unsafe SharpVk.PhysicalDevice[] EnumeratePhysicalDevices()
 {
     try
     {
         SharpVk.PhysicalDevice[] result    = default(SharpVk.PhysicalDevice[]);
         uint marshalledPhysicalDeviceCount = default(uint);
         SharpVk.Interop.PhysicalDevice *marshalledPhysicalDevices = default(SharpVk.Interop.PhysicalDevice *);
         SharpVk.Interop.VkInstanceEnumeratePhysicalDevicesDelegate commandDelegate = commandCache.Cache.vkEnumeratePhysicalDevices;
         Result methodResult = commandDelegate(this.handle, &marshalledPhysicalDeviceCount, marshalledPhysicalDevices);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         marshalledPhysicalDevices = (SharpVk.Interop.PhysicalDevice *)(Interop.HeapUtil.Allocate <SharpVk.Interop.PhysicalDevice>((uint)(marshalledPhysicalDeviceCount)));
         commandDelegate(this.handle, &marshalledPhysicalDeviceCount, marshalledPhysicalDevices);
         if (marshalledPhysicalDevices != null)
         {
             var fieldPointer = new SharpVk.PhysicalDevice[(uint)(marshalledPhysicalDeviceCount)];
             for (int index = 0; index < (uint)(marshalledPhysicalDeviceCount); index++)
             {
                 fieldPointer[index] = new SharpVk.PhysicalDevice(this, marshalledPhysicalDevices[index]);
             }
             result = fieldPointer;
         }
         else
         {
             result = null;
         }
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #19
0
ファイル: DeviceMemory.gen.cs プロジェクト: harry-cpp/SharpVk
 /// <summary>
 /// Map a memory object into application address space.
 /// </summary>
 /// <param name="offset">
 /// </param>
 /// <param name="size">
 /// </param>
 /// <param name="flags">
 /// </param>
 public unsafe IntPtr Map(ulong offset, ulong size, SharpVk.MemoryMapFlags?flags = default(SharpVk.MemoryMapFlags?))
 {
     try
     {
         IntPtr result = default(IntPtr);
         SharpVk.MemoryMapFlags marshalledFlags = default(SharpVk.MemoryMapFlags);
         void *marshalledData = default(void *);
         if (flags != null)
         {
             marshalledFlags = flags.Value;
         }
         else
         {
             marshalledFlags = default(SharpVk.MemoryMapFlags);
         }
         SharpVk.Interop.VkDeviceMemoryMapDelegate commandDelegate = commandCache.Cache.vkMapMemory;
         Result methodResult = commandDelegate(this.parent.handle, this.handle, offset, size, marshalledFlags, &marshalledData);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         result = new IntPtr(marshalledData);
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #20
0
ファイル: Instance.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Create a slink:VkSurfaceKHR object for a VI layer.
 /// </summary>
 public Surface CreateViSurface(ViSurfaceCreateInfo createInfo)
 {
     unsafe
     {
         try
         {
             var     commandDelegate = this.commandCache.GetCommandDelegate <Interop.vkCreateViSurfaceNN>("vkCreateViSurfaceNN", "instance");
             Surface result          = default(Surface);
             Result  commandResult;
             Interop.ViSurfaceCreateInfo marshalledCreateInfo;
             createInfo.MarshalTo(&marshalledCreateInfo);
             Interop.AllocationCallbacks marshalledAllocator;
             this.allocator?.MarshalTo(&marshalledAllocator);
             Interop.Surface marshalledSurface;
             commandResult = commandDelegate(this.handle, &marshalledCreateInfo, this.allocator == null ? null : &marshalledAllocator, &marshalledSurface);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new Surface(marshalledSurface, this, this.commandCache);
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #21
0
ファイル: Instance.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Create a new Vulkan instance.
 /// </summary>
 public static Instance Create(InstanceCreateInfo createInfo, AllocationCallbacks?allocator = null)
 {
     unsafe
     {
         try
         {
             Instance result = default(Instance);
             Result   commandResult;
             Interop.InstanceCreateInfo marshalledCreateInfo;
             createInfo.MarshalTo(&marshalledCreateInfo);
             Interop.AllocationCallbacks marshalledAllocator;
             allocator?.MarshalTo(&marshalledAllocator);
             Interop.Instance marshalledInstance;
             commandResult = Interop.Commands.vkCreateInstance(&marshalledCreateInfo, allocator == null ? null : &marshalledAllocator, &marshalledInstance);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new Instance(marshalledInstance, allocator);
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #22
0
ファイル: Instance.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Returns up to requested number of global layer properties.
 /// </summary>
 public static LayerProperties[] EnumerateLayerProperties()
 {
     unsafe
     {
         try
         {
             LayerProperties[] result = default(LayerProperties[]);
             Result            commandResult;
             uint propertyCount;
             Interop.LayerProperties *marshalledProperties = null;
             commandResult = Interop.Commands.vkEnumerateInstanceLayerProperties(&propertyCount, null);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             marshalledProperties = (Interop.LayerProperties *)Interop.HeapUtil.Allocate <Interop.LayerProperties>((uint)propertyCount);
             commandResult        = Interop.Commands.vkEnumerateInstanceLayerProperties(&propertyCount, marshalledProperties);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new LayerProperties[(uint)propertyCount];
             for (int index = 0; index < (uint)propertyCount; index++)
             {
                 result[index] = LayerProperties.MarshalFrom(&marshalledProperties[index]);
             }
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #23
0
ファイル: Instance.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Create a debug report callback object.
 /// </summary>
 public DebugReportCallback CreateDebugReportCallback(DebugReportCallbackCreateInfo createInfo)
 {
     unsafe
     {
         try
         {
             var commandDelegate        = this.commandCache.GetCommandDelegate <Interop.vkCreateDebugReportCallbackEXT>("vkCreateDebugReportCallbackEXT", "instance");
             DebugReportCallback result = default(DebugReportCallback);
             Result commandResult;
             Interop.DebugReportCallbackCreateInfo marshalledCreateInfo;
             createInfo.MarshalTo(&marshalledCreateInfo);
             Interop.AllocationCallbacks marshalledAllocator;
             this.allocator?.MarshalTo(&marshalledAllocator);
             Interop.DebugReportCallback marshalledCallback;
             commandResult = commandDelegate(this.handle, &marshalledCreateInfo, this.allocator == null ? null : &marshalledAllocator, &marshalledCallback);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new DebugReportCallback(marshalledCallback, this, this.commandCache);
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #24
0
ファイル: Instance.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Returns up to requested number of global extension properties.
 /// </summary>
 public static ExtensionProperties[] EnumerateExtensionProperties(string layerName)
 {
     unsafe
     {
         try
         {
             ExtensionProperties[] result = default(ExtensionProperties[]);
             Result commandResult;
             char * marshalledLayerName = Interop.HeapUtil.MarshalTo(layerName);
             uint   propertyCount;
             Interop.ExtensionProperties *marshalledProperties = null;
             commandResult = Interop.Commands.vkEnumerateInstanceExtensionProperties(marshalledLayerName, &propertyCount, null);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             marshalledProperties = (Interop.ExtensionProperties *)Interop.HeapUtil.Allocate <Interop.ExtensionProperties>((uint)propertyCount);
             commandResult        = Interop.Commands.vkEnumerateInstanceExtensionProperties(marshalledLayerName, &propertyCount, marshalledProperties);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new ExtensionProperties[(uint)propertyCount];
             for (int index = 0; index < (uint)propertyCount; index++)
             {
                 result[index] = ExtensionProperties.MarshalFrom(&marshalledProperties[index]);
             }
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #25
0
 /// <summary>
 /// Create a new device instance.
 /// </summary>
 public Device CreateDevice(DeviceCreateInfo createInfo)
 {
     unsafe
     {
         try
         {
             Device result = default(Device);
             Result commandResult;
             Interop.DeviceCreateInfo marshalledCreateInfo;
             createInfo.MarshalTo(&marshalledCreateInfo);
             Interop.AllocationCallbacks marshalledAllocator;
             this.parent.Allocator?.MarshalTo(&marshalledAllocator);
             Interop.Device marshalledDevice;
             commandResult = Interop.Commands.vkCreateDevice(this.handle, &marshalledCreateInfo, this.parent.Allocator == null ? null : &marshalledAllocator, &marshalledDevice);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new Device(marshalledDevice, this);
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #26
0
ファイル: Instance.gen.cs プロジェクト: harry-cpp/SharpVk
 /// <summary>
 /// Returns up to requested number of global extension properties.
 /// </summary>
 /// <param name="commandCache">
 /// </param>
 /// <param name="layerName">
 /// </param>
 public static unsafe SharpVk.ExtensionProperties[] EnumerateExtensionProperties(CommandCache commandCache, string layerName)
 {
     try
     {
         SharpVk.ExtensionProperties[] result = default(SharpVk.ExtensionProperties[]);
         uint marshalledPropertyCount         = default(uint);
         SharpVk.Interop.ExtensionProperties *marshalledProperties = default(SharpVk.Interop.ExtensionProperties *);
         SharpVk.Interop.VkInstanceEnumerateExtensionPropertiesDelegate commandDelegate = commandCache.Cache.vkEnumerateInstanceExtensionProperties;
         Result methodResult = commandDelegate(Interop.HeapUtil.MarshalTo(layerName), &marshalledPropertyCount, marshalledProperties);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         marshalledProperties = (SharpVk.Interop.ExtensionProperties *)(Interop.HeapUtil.Allocate <SharpVk.Interop.ExtensionProperties>((uint)(marshalledPropertyCount)));
         commandDelegate(Interop.HeapUtil.MarshalTo(layerName), &marshalledPropertyCount, marshalledProperties);
         if (marshalledProperties != null)
         {
             var fieldPointer = new SharpVk.ExtensionProperties[(uint)(marshalledPropertyCount)];
             for (int index = 0; index < (uint)(marshalledPropertyCount); index++)
             {
                 fieldPointer[index] = SharpVk.ExtensionProperties.MarshalFrom(&marshalledProperties[index]);
             }
             result = fieldPointer;
         }
         else
         {
             result = null;
         }
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #27
0
ファイル: PhysicalDevice.gen.cs プロジェクト: yaram/SharpVk
 /// <summary>
 /// Returns properties of available physical device layers.
 /// </summary>
 public unsafe SharpVk.LayerProperties[] EnumerateDeviceLayerProperties()
 {
     try
     {
         SharpVk.LayerProperties[] result = default(SharpVk.LayerProperties[]);
         uint propertyCount = default(uint);
         SharpVk.Interop.LayerProperties *marshalledProperties = default(SharpVk.Interop.LayerProperties *);
         SharpVk.Interop.VkPhysicalDeviceEnumerateDeviceLayerPropertiesDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.VkPhysicalDeviceEnumerateDeviceLayerPropertiesDelegate>("vkEnumerateDeviceLayerProperties", "");
         Result methodResult = commandDelegate(this.handle, &propertyCount, marshalledProperties);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         marshalledProperties = (SharpVk.Interop.LayerProperties *)(Interop.HeapUtil.Allocate <SharpVk.Interop.LayerProperties>((uint)(propertyCount)));
         commandDelegate(this.handle, &propertyCount, marshalledProperties);
         if (marshalledProperties != null)
         {
             var fieldPointer = new SharpVk.LayerProperties[(uint)(propertyCount)];
             for (int index = 0; index < (uint)(propertyCount); index++)
             {
                 fieldPointer[index] = SharpVk.LayerProperties.MarshalFrom(&marshalledProperties[index]);
             }
             result = fieldPointer;
         }
         else
         {
             result = null;
         }
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
コード例 #28
0
        /// <summary>
        /// Creates and returns a new, specifically-typed exception that
        /// represents the given result code.
        /// </summary>
        public static SharpVkException Create(Result resultCode)
        {
            if (!SharpVkException.IsError(resultCode))
            {
                return(null);
            }
            switch (resultCode)
            {
            case Result.ErrorOutOfHostMemory:
                return(new OutOfHostMemoryException());

            case Result.ErrorOutOfDeviceMemory:
                return(new OutOfDeviceMemoryException());

            case Result.ErrorInitializationFailed:
                return(new InitializationFailedException());

            case Result.ErrorDeviceLost:
                return(new DeviceLostException());

            case Result.ErrorMemoryMapFailed:
                return(new MemoryMapFailedException());

            case Result.ErrorLayerNotPresent:
                return(new LayerNotPresentException());

            case Result.ErrorExtensionNotPresent:
                return(new ExtensionNotPresentException());

            case Result.ErrorFeatureNotPresent:
                return(new FeatureNotPresentException());

            case Result.ErrorIncompatibleDriver:
                return(new IncompatibleDriverException());

            case Result.ErrorTooManyObjects:
                return(new TooManyObjectsException());

            case Result.ErrorFormatNotSupported:
                return(new FormatNotSupportedException());

            case Result.ErrorFragmentedPool:
                return(new FragmentedPoolException());
                //case Result.ErrorSurfaceLost:
                //    return new SurfaceLostException();
                //case Result.ErrorNativeWindowInUse:
                //    return new NativeWindowInUseException();
                //case Result.ErrorOutOfDate:
                //    return new OutOfDateException();
                //case Result.ErrorIncompatibleDisplay:
                //    return new IncompatibleDisplayException();
                //case Result.ErrorValidationFailed:
                //    return new ValidationFailedException();
                //case Result.ErrorInvalidShader:
                //    return new InvalidShaderException();
                //case Result.ErrorOutOfPoolMemory:
                //    return new OutOfPoolMemoryException();
            }
            return(new UnknownSharpVkException(resultCode));
        }
コード例 #29
0
 /// <summary>
 /// Query surface capabilities.
 /// </summary>
 public SurfaceCapabilities2 GetSurfaceCapabilities2(Surface surface)
 {
     unsafe
     {
         try
         {
             var commandDelegate         = this.commandCache.GetCommandDelegate <Interop.vkGetPhysicalDeviceSurfaceCapabilities2EXT>("vkGetPhysicalDeviceSurfaceCapabilities2EXT", "instance");
             SurfaceCapabilities2 result = default(SurfaceCapabilities2);
             Result          commandResult;
             Interop.Surface marshalledSurface = default(Interop.Surface);
             surface?.MarshalTo(&marshalledSurface);
             Interop.SurfaceCapabilities2 marshalledSurfaceCapabilities;
             commandResult = commandDelegate(this.handle, marshalledSurface, &marshalledSurfaceCapabilities);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = SurfaceCapabilities2.MarshalFrom(&marshalledSurfaceCapabilities);
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #30
0
ファイル: Instance.gen.cs プロジェクト: yongweisun/SharpVk
 /// <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="allocator">
 /// An optional AllocationCallbacks instance that controls host memory
 /// allocation.
 /// </param>
 public static unsafe SharpVk.Instance Create(ArrayProxy <string>?enabledLayerNames, ArrayProxy <string>?enabledExtensionNames, SharpVk.InstanceCreateFlags?flags = default(SharpVk.InstanceCreateFlags?), SharpVk.ApplicationInfo?applicationInfo = default(SharpVk.ApplicationInfo?), SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?))
 {
     try
     {
         SharpVk.Instance result = default(SharpVk.Instance);
         SharpVk.Interop.InstanceCreateInfo * marshalledCreateInfo = default(SharpVk.Interop.InstanceCreateInfo *);
         SharpVk.Interop.AllocationCallbacks *marshalledAllocator  = default(SharpVk.Interop.AllocationCallbacks *);
         SharpVk.Interop.Instance             marshalledInstance   = default(SharpVk.Interop.Instance);
         marshalledCreateInfo        = (SharpVk.Interop.InstanceCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.InstanceCreateInfo>());
         marshalledCreateInfo->SType = StructureType.InstanceCreateInfo;
         marshalledCreateInfo->Next  = null;
         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 *);
         }
         Result methodResult = Interop.Commands.vkCreateInstance(marshalledCreateInfo, marshalledAllocator, &marshalledInstance);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
         result = new SharpVk.Instance(marshalledInstance);
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }