Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 internal unsafe void MarshalTo(SharpVk.Interop.Khronos.PresentInfo *pointer)
 {
     pointer->SType = StructureType.PresentInfo;
     pointer->Next  = null;
     pointer->WaitSemaphoreCount = (uint)(Interop.HeapUtil.GetLength(this.WaitSemaphores));
     if (this.WaitSemaphores != null)
     {
         var fieldPointer = (SharpVk.Interop.Semaphore *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.Semaphore>(this.WaitSemaphores.Length).ToPointer());
         for (int index = 0; index < (uint)(this.WaitSemaphores.Length); index++)
         {
             fieldPointer[index] = this.WaitSemaphores[index]?.handle ?? default(SharpVk.Interop.Semaphore);
         }
         pointer->WaitSemaphores = fieldPointer;
     }
     else
     {
         pointer->WaitSemaphores = null;
     }
     pointer->SwapchainCount = (uint)(Interop.HeapUtil.GetLength(this.Swapchains));
     if (this.Swapchains != null)
     {
         var fieldPointer = (SharpVk.Interop.Khronos.Swapchain *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.Khronos.Swapchain>(this.Swapchains.Length).ToPointer());
         for (int index = 0; index < (uint)(this.Swapchains.Length); index++)
         {
             fieldPointer[index] = this.Swapchains[index]?.handle ?? default(SharpVk.Interop.Khronos.Swapchain);
         }
         pointer->Swapchains = fieldPointer;
     }
     else
     {
         pointer->Swapchains = null;
     }
     if (this.ImageIndices != null)
     {
         var fieldPointer = (uint *)(Interop.HeapUtil.AllocateAndClear <uint>(this.ImageIndices.Length).ToPointer());
         for (int index = 0; index < (uint)(this.ImageIndices.Length); index++)
         {
             fieldPointer[index] = this.ImageIndices[index];
         }
         pointer->ImageIndices = fieldPointer;
     }
     else
     {
         pointer->ImageIndices = null;
     }
     if (this.Results != null)
     {
         var fieldPointer = (SharpVk.Result *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Result>(this.Results.Length).ToPointer());
         for (int index = 0; index < (uint)(this.Results.Length); index++)
         {
             fieldPointer[index] = this.Results[index];
         }
         pointer->Results = fieldPointer;
     }
     else
     {
         pointer->Results = null;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 public static unsafe void Present(this SharpVk.Queue extendedHandle, SharpVk.Semaphore[] waitSemaphores, SharpVk.Khronos.Swapchain[] swapchains, uint[] imageIndices, SharpVk.Result[] results)
 {
     try
     {
         CommandCache commandCache = default(CommandCache);
         SharpVk.Interop.Khronos.PresentInfo *marshalledPresentInfo = default(SharpVk.Interop.Khronos.PresentInfo *);
         commandCache                 = extendedHandle.commandCache;
         marshalledPresentInfo        = (SharpVk.Interop.Khronos.PresentInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.PresentInfo>());
         marshalledPresentInfo->SType = StructureType.PresentInfoKhr;
         marshalledPresentInfo->Next  = null;
         marshalledPresentInfo->WaitSemaphoreCount = (uint)(waitSemaphores?.Length ?? 0);
         if (waitSemaphores != null)
         {
             var fieldPointer = (SharpVk.Interop.Semaphore *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.Semaphore>(waitSemaphores.Length).ToPointer());
             for (int index = 0; index < (uint)(waitSemaphores.Length); index++)
             {
                 fieldPointer[index] = waitSemaphores[index]?.handle ?? default(SharpVk.Interop.Semaphore);
             }
             marshalledPresentInfo->WaitSemaphores = fieldPointer;
         }
         else
         {
             marshalledPresentInfo->WaitSemaphores = null;
         }
         marshalledPresentInfo->SwapchainCount = (uint)(swapchains?.Length ?? 0);
         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);
             }
             marshalledPresentInfo->Swapchains = fieldPointer;
         }
         else
         {
             marshalledPresentInfo->Swapchains = null;
         }
         if (imageIndices != null)
         {
             var fieldPointer = (uint *)(Interop.HeapUtil.AllocateAndClear <uint>(imageIndices.Length).ToPointer());
             for (int index = 0; index < (uint)(imageIndices.Length); index++)
             {
                 fieldPointer[index] = imageIndices[index];
             }
             marshalledPresentInfo->ImageIndices = fieldPointer;
         }
         else
         {
             marshalledPresentInfo->ImageIndices = null;
         }
         if (results != null)
         {
             var fieldPointer = (SharpVk.Result *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Result>(results.Length).ToPointer());
             for (int index = 0; index < (uint)(results.Length); index++)
             {
                 fieldPointer[index] = results[index];
             }
             marshalledPresentInfo->Results = fieldPointer;
         }
         else
         {
             marshalledPresentInfo->Results = null;
         }
         SharpVk.Interop.Khronos.VkQueuePresentDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.Khronos.VkQueuePresentDelegate>("vkQueuePresentKHR", "instance");
         Result methodResult = commandDelegate(extendedHandle.handle, marshalledPresentInfo);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Queue an image for presentation.
 /// </summary>
 /// <param name="extendedHandle">
 /// The Queue handle to extend.
 /// </param>
 /// <param name="waitSemaphores">
 /// </param>
 /// <param name="swapchains">
 /// </param>
 /// <param name="imageIndices">
 /// </param>
 /// <param name="results">
 /// </param>
 /// <param name="displayPresentInfoKhr">
 /// Extension struct
 /// </param>
 /// <param name="presentRegionsKhr">
 /// Extension struct
 /// </param>
 /// <param name="deviceGroupPresentInfoKhr">
 /// Extension struct
 /// </param>
 /// <param name="presentTimesInfoGoogle">
 /// Extension struct
 /// </param>
 /// <param name="presentFrameTokenGgp">
 /// Extension struct
 /// </param>
 public static unsafe Result Present(this SharpVk.Queue extendedHandle, ArrayProxy <SharpVk.Semaphore>?waitSemaphores, ArrayProxy <SharpVk.Khronos.Swapchain>?swapchains, ArrayProxy <uint>?imageIndices, ArrayProxy <SharpVk.Result>?results = null, SharpVk.Khronos.DisplayPresentInfo?displayPresentInfoKhr = null, SharpVk.Khronos.PresentRegions?presentRegionsKhr = null, SharpVk.Khronos.DeviceGroupPresentInfo?deviceGroupPresentInfoKhr = null, SharpVk.Google.PresentTimesInfo?presentTimesInfoGoogle = null, SharpVk.Ggp.PresentFrameToken?presentFrameTokenGgp = null)
 {
     try
     {
         Result       result       = default(Result);
         CommandCache commandCache = default(CommandCache);
         SharpVk.Interop.Khronos.PresentInfo *marshalledPresentInfo = default(SharpVk.Interop.Khronos.PresentInfo *);
         void *nextPointer = default(void *);
         if (displayPresentInfoKhr != null)
         {
             SharpVk.Interop.Khronos.DisplayPresentInfo *extensionPointer = default(SharpVk.Interop.Khronos.DisplayPresentInfo *);
             extensionPointer = (SharpVk.Interop.Khronos.DisplayPresentInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.DisplayPresentInfo>());
             displayPresentInfoKhr.Value.MarshalTo(extensionPointer);
             extensionPointer->Next = nextPointer;
             nextPointer            = extensionPointer;
         }
         if (presentRegionsKhr != null)
         {
             SharpVk.Interop.Khronos.PresentRegions *extensionPointer = default(SharpVk.Interop.Khronos.PresentRegions *);
             extensionPointer = (SharpVk.Interop.Khronos.PresentRegions *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.PresentRegions>());
             presentRegionsKhr.Value.MarshalTo(extensionPointer);
             extensionPointer->Next = nextPointer;
             nextPointer            = extensionPointer;
         }
         if (deviceGroupPresentInfoKhr != null)
         {
             SharpVk.Interop.Khronos.DeviceGroupPresentInfo *extensionPointer = default(SharpVk.Interop.Khronos.DeviceGroupPresentInfo *);
             extensionPointer = (SharpVk.Interop.Khronos.DeviceGroupPresentInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.DeviceGroupPresentInfo>());
             deviceGroupPresentInfoKhr.Value.MarshalTo(extensionPointer);
             extensionPointer->Next = nextPointer;
             nextPointer            = extensionPointer;
         }
         if (presentTimesInfoGoogle != null)
         {
             SharpVk.Interop.Google.PresentTimesInfo *extensionPointer = default(SharpVk.Interop.Google.PresentTimesInfo *);
             extensionPointer = (SharpVk.Interop.Google.PresentTimesInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Google.PresentTimesInfo>());
             presentTimesInfoGoogle.Value.MarshalTo(extensionPointer);
             extensionPointer->Next = nextPointer;
             nextPointer            = extensionPointer;
         }
         if (presentFrameTokenGgp != null)
         {
             SharpVk.Interop.Ggp.PresentFrameToken *extensionPointer = default(SharpVk.Interop.Ggp.PresentFrameToken *);
             extensionPointer = (SharpVk.Interop.Ggp.PresentFrameToken *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Ggp.PresentFrameToken>());
             presentFrameTokenGgp.Value.MarshalTo(extensionPointer);
             extensionPointer->Next = nextPointer;
             nextPointer            = extensionPointer;
         }
         commandCache                 = extendedHandle.commandCache;
         marshalledPresentInfo        = (SharpVk.Interop.Khronos.PresentInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.PresentInfo>());
         marshalledPresentInfo->SType = StructureType.PresentInfo;
         marshalledPresentInfo->Next  = nextPointer;
         marshalledPresentInfo->WaitSemaphoreCount = (uint)(Interop.HeapUtil.GetLength(waitSemaphores));
         if (waitSemaphores.IsNull())
         {
             marshalledPresentInfo->WaitSemaphores = null;
         }
         else
         {
             if (waitSemaphores.Value.Contents == ProxyContents.Single)
             {
                 marshalledPresentInfo->WaitSemaphores = (SharpVk.Interop.Semaphore *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Semaphore>());
                 *(SharpVk.Interop.Semaphore *)(marshalledPresentInfo->WaitSemaphores) = waitSemaphores.Value.GetSingleValue()?.handle ?? default(SharpVk.Interop.Semaphore);
             }
             else
             {
                 var fieldPointer = (SharpVk.Interop.Semaphore *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.Semaphore>(Interop.HeapUtil.GetLength(waitSemaphores.Value)).ToPointer());
                 for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(waitSemaphores.Value)); index++)
                 {
                     fieldPointer[index] = waitSemaphores.Value[index]?.handle ?? default(SharpVk.Interop.Semaphore);
                 }
                 marshalledPresentInfo->WaitSemaphores = fieldPointer;
             }
         }
         marshalledPresentInfo->SwapchainCount = (uint)(Interop.HeapUtil.GetLength(swapchains));
         if (swapchains.IsNull())
         {
             marshalledPresentInfo->Swapchains = null;
         }
         else
         {
             if (swapchains.Value.Contents == ProxyContents.Single)
             {
                 marshalledPresentInfo->Swapchains = (SharpVk.Interop.Khronos.Swapchain *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.Swapchain>());
                 *(SharpVk.Interop.Khronos.Swapchain *)(marshalledPresentInfo->Swapchains) = 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);
                 }
                 marshalledPresentInfo->Swapchains = fieldPointer;
             }
         }
         if (imageIndices.IsNull())
         {
             marshalledPresentInfo->ImageIndices = null;
         }
         else
         {
             if (imageIndices.Value.Contents == ProxyContents.Single)
             {
                 marshalledPresentInfo->ImageIndices            = (uint *)(Interop.HeapUtil.Allocate <uint>());
                 *(uint *)(marshalledPresentInfo->ImageIndices) = imageIndices.Value.GetSingleValue();
             }
             else
             {
                 var fieldPointer = (uint *)(Interop.HeapUtil.AllocateAndClear <uint>(Interop.HeapUtil.GetLength(imageIndices.Value)).ToPointer());
                 for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(imageIndices.Value)); index++)
                 {
                     fieldPointer[index] = imageIndices.Value[index];
                 }
                 marshalledPresentInfo->ImageIndices = fieldPointer;
             }
         }
         if (results.IsNull())
         {
             marshalledPresentInfo->Results = null;
         }
         else
         {
             if (results.Value.Contents == ProxyContents.Single)
             {
                 marshalledPresentInfo->Results = (SharpVk.Result *)(Interop.HeapUtil.Allocate <SharpVk.Result>());
                 *(SharpVk.Result *)(marshalledPresentInfo->Results) = results.Value.GetSingleValue();
             }
             else
             {
                 var fieldPointer = (SharpVk.Result *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Result>(Interop.HeapUtil.GetLength(results.Value)).ToPointer());
                 for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(results.Value)); index++)
                 {
                     fieldPointer[index] = results.Value[index];
                 }
                 marshalledPresentInfo->Results = fieldPointer;
             }
         }
         SharpVk.Interop.Khronos.VkQueuePresentDelegate commandDelegate = commandCache.Cache.vkQueuePresentKHR;
         result = commandDelegate(extendedHandle.handle, marshalledPresentInfo);
         if (SharpVkException.IsError(result))
         {
             throw SharpVkException.Create(result);
         }
         return(result);
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Queue an image for presentation.
 /// </summary>
 /// <param name="extendedHandle">
 /// The Queue handle to extend.
 /// </param>
 public static unsafe void Present(this SharpVk.Queue extendedHandle, ArrayProxy <SharpVk.Semaphore>?waitSemaphores, ArrayProxy <SharpVk.Khronos.Swapchain>?swapchains, ArrayProxy <uint>?imageIndices, ArrayProxy <SharpVk.Result>?results = null)
 {
     try
     {
         CommandCache commandCache = default(CommandCache);
         SharpVk.Interop.Khronos.PresentInfo *marshalledPresentInfo = default(SharpVk.Interop.Khronos.PresentInfo *);
         commandCache                 = extendedHandle.commandCache;
         marshalledPresentInfo        = (SharpVk.Interop.Khronos.PresentInfo *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.PresentInfo>());
         marshalledPresentInfo->SType = StructureType.PresentInfoKhr;
         marshalledPresentInfo->Next  = null;
         marshalledPresentInfo->WaitSemaphoreCount = (uint)(Interop.HeapUtil.GetLength(waitSemaphores));
         if (waitSemaphores.IsNull())
         {
             marshalledPresentInfo->WaitSemaphores = null;
         }
         else
         {
             if (waitSemaphores.Value.Contents == ProxyContents.Single)
             {
                 marshalledPresentInfo->WaitSemaphores = (SharpVk.Interop.Semaphore *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Semaphore>());
                 *(SharpVk.Interop.Semaphore *)(marshalledPresentInfo->WaitSemaphores) = waitSemaphores.Value.GetSingleValue()?.handle ?? default(SharpVk.Interop.Semaphore);
             }
             else
             {
                 var fieldPointer = (SharpVk.Interop.Semaphore *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Interop.Semaphore>(Interop.HeapUtil.GetLength(waitSemaphores.Value)).ToPointer());
                 for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(waitSemaphores.Value)); index++)
                 {
                     fieldPointer[index] = waitSemaphores.Value[index]?.handle ?? default(SharpVk.Interop.Semaphore);
                 }
                 marshalledPresentInfo->WaitSemaphores = fieldPointer;
             }
         }
         marshalledPresentInfo->SwapchainCount = (uint)(Interop.HeapUtil.GetLength(swapchains));
         if (swapchains.IsNull())
         {
             marshalledPresentInfo->Swapchains = null;
         }
         else
         {
             if (swapchains.Value.Contents == ProxyContents.Single)
             {
                 marshalledPresentInfo->Swapchains = (SharpVk.Interop.Khronos.Swapchain *)(Interop.HeapUtil.Allocate <SharpVk.Interop.Khronos.Swapchain>());
                 *(SharpVk.Interop.Khronos.Swapchain *)(marshalledPresentInfo->Swapchains) = 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);
                 }
                 marshalledPresentInfo->Swapchains = fieldPointer;
             }
         }
         if (imageIndices.IsNull())
         {
             marshalledPresentInfo->ImageIndices = null;
         }
         else
         {
             if (imageIndices.Value.Contents == ProxyContents.Single)
             {
                 marshalledPresentInfo->ImageIndices            = (uint *)(Interop.HeapUtil.Allocate <uint>());
                 *(uint *)(marshalledPresentInfo->ImageIndices) = imageIndices.Value.GetSingleValue();
             }
             else
             {
                 var fieldPointer = (uint *)(Interop.HeapUtil.AllocateAndClear <uint>(Interop.HeapUtil.GetLength(imageIndices.Value)).ToPointer());
                 for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(imageIndices.Value)); index++)
                 {
                     fieldPointer[index] = imageIndices.Value[index];
                 }
                 marshalledPresentInfo->ImageIndices = fieldPointer;
             }
         }
         if (results.IsNull())
         {
             marshalledPresentInfo->Results = null;
         }
         else
         {
             if (results.Value.Contents == ProxyContents.Single)
             {
                 marshalledPresentInfo->Results = (SharpVk.Result *)(Interop.HeapUtil.Allocate <SharpVk.Result>());
                 *(SharpVk.Result *)(marshalledPresentInfo->Results) = results.Value.GetSingleValue();
             }
             else
             {
                 var fieldPointer = (SharpVk.Result *)(Interop.HeapUtil.AllocateAndClear <SharpVk.Result>(Interop.HeapUtil.GetLength(results.Value)).ToPointer());
                 for (int index = 0; index < (uint)(Interop.HeapUtil.GetLength(results.Value)); index++)
                 {
                     fieldPointer[index] = results.Value[index];
                 }
                 marshalledPresentInfo->Results = fieldPointer;
             }
         }
         SharpVk.Interop.Khronos.VkQueuePresentDelegate commandDelegate = commandCache.GetCommandDelegate <SharpVk.Interop.Khronos.VkQueuePresentDelegate>("vkQueuePresentKHR", "instance");
         Result methodResult = commandDelegate(extendedHandle.handle, marshalledPresentInfo);
         if (SharpVkException.IsError(methodResult))
         {
             throw SharpVkException.Create(methodResult);
         }
     }
     finally
     {
         Interop.HeapUtil.FreeAll();
     }
 }