Пример #1
0
        public Result QueuePresentKHR(MgPresentInfoKHR pPresentInfo)
        {
            if (pPresentInfo == null)
            {
                throw new ArgumentNullException(nameof(pPresentInfo));
            }

            var attachedItems = new List <IntPtr>();

            try
            {
                uint waitSemaphoreCount;
                var  pWaitSemaphores = ExtractSemaphores(attachedItems, pPresentInfo.WaitSemaphores, out waitSemaphoreCount);

                IntPtr pSwapchains;
                IntPtr pImageIndices;
                uint   swapchainCount = ExtractSwapchains(attachedItems, pPresentInfo.Images, out pSwapchains, out pImageIndices);

                var pResults = ExtractResults(attachedItems, pPresentInfo.Results);

                var presentInfo = new VkPresentInfoKHR
                {
                    sType = VkStructureType.StructureTypePresentInfoKhr,
                    pNext = IntPtr.Zero,
                    waitSemaphoreCount = waitSemaphoreCount,
                    pWaitSemaphores    = pWaitSemaphores,
                    swapchainCount     = swapchainCount,
                    pSwapchains        = pSwapchains,
                    pImageIndices      = pImageIndices,
                    pResults           = pResults,
                };

                var result = Interops.vkQueuePresentKHR(Handle, ref presentInfo);

                // MUST ABLE TO RETURN
                if (pResults != IntPtr.Zero)
                {
                    var stride     = Marshal.SizeOf(typeof(Result));
                    var swapChains = new Result[swapchainCount];
                    var offset     = 0;
                    for (var i = 0; i < swapchainCount; ++i)
                    {
                        var src = IntPtr.Add(pResults, offset);
                        swapChains[i] = (Magnesium.Result)Marshal.PtrToStructure(src, typeof(Magnesium.Result));
                        offset       += stride;
                    }

                    pPresentInfo.Results = swapChains;
                }

                return(result);
            }
            finally
            {
                foreach (var item in attachedItems)
                {
                    Marshal.FreeHGlobal(item);
                }
            }
        }
Пример #2
0
        public void EndDraw(uint[] nextImage, IMgCommandBuffer prePresent, IMgSemaphore[] renderComplete)
        {
            Result err;

            var presentImages = new List <MgPresentInfoKHRImage>();

            foreach (var image in nextImage)
            {
                var currentBuffer = mLayers[image];
                //submitPrePresentBarrier(prePresent, currentBuffer.Image);

                presentImages.Add(new MgPresentInfoKHRImage
                {
                    ImageIndex = image,
                    Swapchain  = mCollection.Swapchain,
                });
            }

            var presentInfo = new MgPresentInfoKHR
            {
                WaitSemaphores = renderComplete,
                Images         = presentImages.ToArray(),
            };

            //err = swapChain.queuePresent(queue, currentBuffer, semaphores.renderComplete);
            err = mPartition.Queue.QueuePresentKHR(presentInfo);
            Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");
            err = mPartition.Queue.QueueWaitIdle();
            Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");
        }
Пример #3
0
        public Result QueuePresentKHR(MgPresentInfoKHR pPresentInfo)
        {
            if (pPresentInfo == null)
            {
                return(Result.SUCCESS);
            }

            var signalInfos = new List <MgSubmitInfoWaitSemaphoreInfo> ();

            if (pPresentInfo.WaitSemaphores != null)
            {
                foreach (var signal in pPresentInfo.WaitSemaphores)
                {
                    if (signal != null)
                    {
                        signalInfos.Add(new MgSubmitInfoWaitSemaphoreInfo {
                            WaitDstStageMask = 0,
                            WaitSemaphore    = signal,
                        });
                    }
                }
            }

            var sub = new MgSubmitInfo {
                WaitSemaphores = signalInfos.ToArray(),
            };
            var submission = EnqueueSubmission(sub);

            var swapchains = new List <AmtQueueSwapchainInfo>();

            foreach (var image in pPresentInfo.Images)
            {
                swapchains.Add(new AmtQueueSwapchainInfo
                {
                    ImageIndex = image.ImageIndex,
                    Swapchain  = (IAmtSwapchainKHR)image.Swapchain,
                });
            }
            submission.Swapchains = swapchains.ToArray();

            return(Result.SUCCESS);
        }
Пример #4
0
        public Result QueuePresentKHR(MgPresentInfoKHR pPresentInfo)
        {
            // EARLY EXIT
            if (pPresentInfo == null)
            {
                return(Result.SUCCESS);
            }

            var signalInfos = new List <MgSubmitInfoWaitSemaphoreInfo> ();

            if (pPresentInfo.WaitSemaphores != null)
            {
                foreach (var signal in pPresentInfo.WaitSemaphores)
                {
                    if (signal != null)
                    {
                        signalInfos.Add(new MgSubmitInfoWaitSemaphoreInfo {
                            WaitDstStageMask = 0,
                            WaitSemaphore    = signal,
                        });
                    }
                }
            }

            var sub = new MgSubmitInfo {
                WaitSemaphores = signalInfos.ToArray(),
            };

            EnqueueSubmission(sub);

            foreach (var image in pPresentInfo.Images)
            {
                var sc = image.Swapchain as IGLSwapchainKHR;
                if (sc != null)
                {
                    sc.SwapBuffers();
                }
            }

            return(Result.SUCCESS);
        }