/// <summary> /// /// </summary> /// <param name="extendedHandle"> /// The Device handle to extend. /// </param> /// <param name="swapchains"> /// </param> /// <param name="metadata"> /// </param> public static unsafe void SetHdrMetadata(this SharpVk.Device extendedHandle, ArrayProxy <SharpVk.Khronos.Swapchain>?swapchains, ArrayProxy <SharpVk.Multivendor.HdrMetadata>?metadata) { try { CommandCache commandCache = default(CommandCache); SharpVk.Interop.Khronos.Swapchain * marshalledSwapchains = default(SharpVk.Interop.Khronos.Swapchain *); SharpVk.Interop.Multivendor.HdrMetadata *marshalledMetadata = default(SharpVk.Interop.Multivendor.HdrMetadata *); commandCache = extendedHandle.commandCache; if (swapchains.IsNull()) { marshalledSwapchains = null; } else { if (swapchains.Value.Contents == ProxyContents.Single) { marshalledSwapchains = (SharpVk.Interop.Khronos.Swapchain *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.Swapchain>()); *(SharpVk.Interop.Khronos.Swapchain *)(marshalledSwapchains) = swapchains.Value.GetSingleValue()?.handle ?? default(SharpVk.Interop.Khronos.Swapchain); } else { var fieldPointer = (SharpVk.Interop.Khronos.Swapchain *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.Khronos.Swapchain>(Interop.HeapUtil.GetLength(swapchains.Value)).ToPointer()); for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(swapchains.Value)); index++) { fieldPointer[index] = swapchains.Value[index]?.handle ?? default(SharpVk.Interop.Khronos.Swapchain); } marshalledSwapchains = fieldPointer; } } if (metadata.IsNull()) { marshalledMetadata = null; } else { if (metadata.Value.Contents == ProxyContents.Single) { marshalledMetadata = (SharpVk.Interop.Multivendor.HdrMetadata *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.HdrMetadata>()); metadata.Value.GetSingleValue().MarshalTo(&*(SharpVk.Interop.Multivendor.HdrMetadata *)(marshalledMetadata)); } else { var fieldPointer = (SharpVk.Interop.Multivendor.HdrMetadata *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.Multivendor.HdrMetadata>(Interop.HeapUtil.GetLength(metadata.Value)).ToPointer()); for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(metadata.Value)); index++) { metadata.Value[index].MarshalTo(&fieldPointer[index]); } marshalledMetadata = fieldPointer; } } SharpVk.Interop.Multivendor.VkDeviceSetHdrMetadataDelegate commandDelegate = commandCache.Cache.vkSetHdrMetadataEXT; commandDelegate(extendedHandle.handle, (uint)(Interop.HeapUtil.GetLength(swapchains)), marshalledSwapchains, marshalledMetadata); } finally { Interop.HeapUtil.FreeAll(); } }
/// <summary> /// /// </summary> public static unsafe void SetHdrMetadata(this SharpVk.Device extendedHandle, SharpVk.Khronos.Swapchain[] swapchains, SharpVk.Multivendor.HdrMetadata[] metadata) { try { CommandCache commandCache = default(CommandCache); SharpVk.Interop.Khronos.Swapchain * marshalledSwapchains = default(SharpVk.Interop.Khronos.Swapchain *); SharpVk.Interop.Multivendor.HdrMetadata *marshalledMetadata = default(SharpVk.Interop.Multivendor.HdrMetadata *); commandCache = extendedHandle.commandCache; if (swapchains != null) { var fieldPointer = (SharpVk.Interop.Khronos.Swapchain *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.Khronos.Swapchain>(swapchains.Length).ToPointer()); for (int index = 0; index < (uint)(swapchains.Length); index++) { fieldPointer[index] = swapchains[index]?.handle ?? default(SharpVk.Interop.Khronos.Swapchain); } marshalledSwapchains = fieldPointer; } else { marshalledSwapchains = null; } if (metadata != null) { var fieldPointer = (SharpVk.Interop.Multivendor.HdrMetadata *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.Multivendor.HdrMetadata>(metadata.Length).ToPointer()); for (int index = 0; index < (uint)(metadata.Length); index++) { metadata[index].MarshalTo(&fieldPointer[index]); } marshalledMetadata = fieldPointer; } else { marshalledMetadata = null; } SharpVk.Interop.Multivendor.VkDeviceSetHdrMetadataDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.Multivendor.VkDeviceSetHdrMetadataDelegate>("vkSetHdrMetadataEXT", "instance"); commandDelegate(extendedHandle.handle, (uint)(swapchains?.Length ?? 0), marshalledSwapchains, marshalledMetadata); } finally { Interop.HeapUtil.FreeAll(); } }
/// <summary> /// /// </summary> public static unsafe SharpVk.Khronos.Swapchain[] CreateSharedSwapchains(this SharpVk.Device extendedHandle, SharpVk.Khronos.SwapchainCreateInfo[] createInfos, SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Khronos.Swapchain[] result = default(SharpVk.Khronos.Swapchain[]); CommandCache commandCache = default(CommandCache); uint swapchainCount = default(uint); SharpVk.Interop.Khronos.SwapchainCreateInfo *marshalledCreateInfos = default(SharpVk.Interop.Khronos.SwapchainCreateInfo *); SharpVk.Interop.AllocationCallbacks * marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); SharpVk.Interop.Khronos.Swapchain * marshalledSwapchains = default(SharpVk.Interop.Khronos.Swapchain *); commandCache = extendedHandle.commandCache; swapchainCount = (uint)(createInfos?.Length ?? 0); if (createInfos != null) { var fieldPointer = (SharpVk.Interop.Khronos.SwapchainCreateInfo *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.Khronos.SwapchainCreateInfo>(createInfos.Length).ToPointer()); for (int index = 0; index < (uint)(createInfos.Length); index++) { createInfos[index].MarshalTo(&fieldPointer[index]); } marshalledCreateInfos = fieldPointer; } else { marshalledCreateInfos = null; } if (allocator != null) { marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>()); allocator.Value.MarshalTo(marshalledAllocator); } else { marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); } marshalledSwapchains = (SharpVk.Interop.Khronos.Swapchain *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.Swapchain>(swapchainCount)); SharpVk.Interop.Khronos.VkDeviceCreateSharedSwapchainsDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.Khronos.VkDeviceCreateSharedSwapchainsDelegate>("vkCreateSharedSwapchainsKHR", "instance"); Result methodResult = commandDelegate(extendedHandle.handle, swapchainCount, marshalledCreateInfos, marshalledAllocator, marshalledSwapchains); if (SharpVkException.IsError(methodResult)) { throw SharpVkException.Create(methodResult); } if (marshalledSwapchains != null) { var fieldPointer = new SharpVk.Khronos.Swapchain[(uint)(swapchainCount)]; for (int index = 0; index < (uint)(swapchainCount); index++) { fieldPointer[index] = new SharpVk.Khronos.Swapchain(extendedHandle, marshalledSwapchains[index]); } result = fieldPointer; } else { result = null; } return(result); } finally { Interop.HeapUtil.FreeAll(); } }
/// <summary> /// Create multiple swapchains that share presentable images. /// </summary> /// <param name="extendedHandle"> /// The Device handle to extend. /// </param> /// <param name="flags"> /// A bitmask indicating parameters of swapchain creation. Bits which /// can be set include: + -- /// </param> /// <param name="queueFamilyIndices"> /// </param> /// <param name="swapchainCounterCreateInfoExt"> /// Extension struct /// </param> /// <param name="deviceGroupSwapchainCreateInfoKhr"> /// Extension struct /// </param> /// <param name="imageFormatListCreateInfoKhr"> /// Extension struct /// </param> /// <param name="allocator"> /// An optional AllocationCallbacks instance that controls host memory /// allocation. /// </param> public static unsafe SharpVk.Khronos.Swapchain CreateSharedSwapchain(this SharpVk.Device extendedHandle, SharpVk.Khronos.Surface surface, uint minImageCount, SharpVk.Format imageFormat, SharpVk.Khronos.ColorSpace imageColorSpace, SharpVk.Extent2D imageExtent, uint imageArrayLayers, SharpVk.ImageUsageFlags imageUsage, SharpVk.SharingMode imageSharingMode, ArrayProxy <uint>?queueFamilyIndices, SharpVk.Khronos.SurfaceTransformFlags preTransform, SharpVk.Khronos.CompositeAlphaFlags compositeAlpha, SharpVk.Khronos.PresentMode presentMode, bool clipped, SharpVk.Khronos.Swapchain oldSwapchain, SharpVk.Khronos.SwapchainCreateFlags?flags = default(SharpVk.Khronos.SwapchainCreateFlags?), SharpVk.Multivendor.SwapchainCounterCreateInfo?swapchainCounterCreateInfoExt = null, SharpVk.Khronos.DeviceGroupSwapchainCreateInfo?deviceGroupSwapchainCreateInfoKhr = null, SharpVk.Khronos.ImageFormatListCreateInfo?imageFormatListCreateInfoKhr = null, SharpVk.AllocationCallbacks?allocator = default(SharpVk.AllocationCallbacks?)) { try { SharpVk.Khronos.Swapchain result = default(SharpVk.Khronos.Swapchain); CommandCache commandCache = default(CommandCache); uint swapchainCount = default(uint); SharpVk.Interop.Khronos.SwapchainCreateInfo *marshalledCreateInfos = default(SharpVk.Interop.Khronos.SwapchainCreateInfo *); void *nextPointer = default(void *); SharpVk.Interop.AllocationCallbacks *marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); SharpVk.Interop.Khronos.Swapchain * marshalledSwapchains = default(SharpVk.Interop.Khronos.Swapchain *); if (swapchainCounterCreateInfoExt != null) { SharpVk.Interop.Multivendor.SwapchainCounterCreateInfo *extensionPointer = default(SharpVk.Interop.Multivendor.SwapchainCounterCreateInfo *); extensionPointer = (SharpVk.Interop.Multivendor.SwapchainCounterCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Multivendor.SwapchainCounterCreateInfo>()); swapchainCounterCreateInfoExt.Value.MarshalTo(extensionPointer); extensionPointer->Next = nextPointer; nextPointer = extensionPointer; } if (deviceGroupSwapchainCreateInfoKhr != null) { SharpVk.Interop.Khronos.DeviceGroupSwapchainCreateInfo *extensionPointer = default(SharpVk.Interop.Khronos.DeviceGroupSwapchainCreateInfo *); extensionPointer = (SharpVk.Interop.Khronos.DeviceGroupSwapchainCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.DeviceGroupSwapchainCreateInfo>()); deviceGroupSwapchainCreateInfoKhr.Value.MarshalTo(extensionPointer); extensionPointer->Next = nextPointer; nextPointer = extensionPointer; } if (imageFormatListCreateInfoKhr != null) { SharpVk.Interop.Khronos.ImageFormatListCreateInfo *extensionPointer = default(SharpVk.Interop.Khronos.ImageFormatListCreateInfo *); extensionPointer = (SharpVk.Interop.Khronos.ImageFormatListCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.ImageFormatListCreateInfo>()); imageFormatListCreateInfoKhr.Value.MarshalTo(extensionPointer); extensionPointer->Next = nextPointer; nextPointer = extensionPointer; } commandCache = extendedHandle.commandCache; swapchainCount = 1; marshalledCreateInfos = (SharpVk.Interop.Khronos.SwapchainCreateInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.SwapchainCreateInfo>()); marshalledCreateInfos->SType = StructureType.SwapchainCreateInfo; marshalledCreateInfos->Next = nextPointer; if (flags != null) { marshalledCreateInfos->Flags = flags.Value; } else { marshalledCreateInfos->Flags = default(SharpVk.Khronos.SwapchainCreateFlags); } marshalledCreateInfos->Surface = surface?.handle ?? default(SharpVk.Interop.Khronos.Surface); marshalledCreateInfos->MinImageCount = minImageCount; marshalledCreateInfos->ImageFormat = imageFormat; marshalledCreateInfos->ImageColorSpace = imageColorSpace; marshalledCreateInfos->ImageExtent = imageExtent; marshalledCreateInfos->ImageArrayLayers = imageArrayLayers; marshalledCreateInfos->ImageUsage = imageUsage; marshalledCreateInfos->ImageSharingMode = imageSharingMode; marshalledCreateInfos->QueueFamilyIndexCount = (uint)(Interop.HeapUtil.GetLength(queueFamilyIndices)); if (queueFamilyIndices.IsNull()) { marshalledCreateInfos->QueueFamilyIndices = null; } else { if (queueFamilyIndices.Value.Contents == ProxyContents.Single) { marshalledCreateInfos->QueueFamilyIndices = (uint *)(Interop.HeapUtil.Allocate <uint>()); *(uint *)(marshalledCreateInfos->QueueFamilyIndices) = queueFamilyIndices.Value.GetSingleValue(); } else { var fieldPointer = (uint *)(Interop.HeapUtil.AllocateAndClear <uint>(Interop.HeapUtil.GetLength(queueFamilyIndices.Value)).ToPointer()); for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(queueFamilyIndices.Value)); index++) { fieldPointer[index] = queueFamilyIndices.Value[index]; } marshalledCreateInfos->QueueFamilyIndices = fieldPointer; } } marshalledCreateInfos->PreTransform = preTransform; marshalledCreateInfos->CompositeAlpha = compositeAlpha; marshalledCreateInfos->PresentMode = presentMode; marshalledCreateInfos->Clipped = clipped; marshalledCreateInfos->OldSwapchain = oldSwapchain?.handle ?? default(SharpVk.Interop.Khronos.Swapchain); if (allocator != null) { marshalledAllocator = (SharpVk.Interop.AllocationCallbacks *)(Interop.HeapUtil.Allocate <SharpVk.Interop.AllocationCallbacks>()); allocator.Value.MarshalTo(marshalledAllocator); } else { marshalledAllocator = default(SharpVk.Interop.AllocationCallbacks *); } marshalledSwapchains = (SharpVk.Interop.Khronos.Swapchain *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.Swapchain>(1)); SharpVk.Interop.Khronos.VkDeviceCreateSharedSwapchainsDelegate commandDelegate = commandCache.Cache.vkCreateSharedSwapchainsKHR; Result methodResult = commandDelegate(extendedHandle.handle, swapchainCount, marshalledCreateInfos, marshalledAllocator, marshalledSwapchains); if (SharpVkException.IsError(methodResult)) { throw SharpVkException.Create(methodResult); } result = new SharpVk.Khronos.Swapchain(extendedHandle, *marshalledSwapchains); return(result); } finally { Interop.HeapUtil.FreeAll(); } }