GLQueueSubmission EnqueueSubmission(MgSubmitInfo sub) { var submit = new GLQueueSubmission(mSubmissionKey, sub); // JUST LOOP AROUND mSubmissionKey = (mSubmissionKey >= uint.MaxValue) ? 0 : mSubmissionKey + 1; mSubmissions.Add(submit.Key, submit); return(submit); }
void SetupGraphicsDevice() { try { var setupCommands = new IMgCommandBuffer[1]; var pAllocateInfo = new MgCommandBufferAllocateInfo { CommandPool = mConfiguration.Partition.CommandPool, CommandBufferCount = 1, Level = MgCommandBufferLevel.PRIMARY, }; var err = mConfiguration.Device.AllocateCommandBuffers(pAllocateInfo, setupCommands); Debug.Assert(err == Result.SUCCESS); var dsCreateInfo = new MgGraphicsDeviceCreateInfo { Color = MgFormat.B8G8R8A8_UNORM, DepthStencil = MgFormat.D32_SFLOAT_S8_UINT, Samples = MgSampleCountFlagBits.COUNT_1_BIT, Width = mWidth, Height = mHeight, }; var cmdBuf = setupCommands[0]; var cmdBufInfo = new MgCommandBufferBeginInfo { }; cmdBuf.BeginCommandBuffer(cmdBufInfo); mGraphicsDevice.Create(cmdBuf, mSwapchains, dsCreateInfo); cmdBuf.EndCommandBuffer(); var pSubmits = new MgSubmitInfo[] { new MgSubmitInfo { CommandBuffers = new IMgCommandBuffer[] { cmdBuf, }, } }; mConfiguration.Partition.Queue.QueueSubmit(pSubmits, null); mConfiguration.Partition.Queue.QueueWaitIdle(); mConfiguration.Partition.Device.FreeCommandBuffers( mConfiguration.Partition.CommandPool, setupCommands); } catch (Exception ex) { Console.WriteLine(ex.Message); throw ex; } }
public GLQueueSubmission(uint key, MgSubmitInfo sub) { Key = key; var waits = new List <IGLSemaphore> (); if (sub.WaitSemaphores != null) { foreach (var signal in sub.WaitSemaphores) { var semaphore = signal.WaitSemaphore as IGLSemaphore; if (semaphore != null) { waits.Add(semaphore); } } } Waits = waits.ToArray(); var signals = new List <IGLSemaphore> (); if (sub.SignalSemaphores != null) { foreach (var signal in sub.SignalSemaphores) { var semaphore = signal as IGLSemaphore; if (semaphore != null) { signals.Add(semaphore); } } } Signals = signals.ToArray(); var buffers = new List <IGLCommandBuffer> (); if (sub.CommandBuffers != null) { foreach (var buf in sub.CommandBuffers) { var glCmdBuf = (IGLCommandBuffer)buf; if (glCmdBuf != null) { buffers.Add(glCmdBuf); } } } CommandBuffers = buffers.ToArray(); }
AmtQueueSubmission EnqueueSubmission(MgSubmitInfo sub) { var submit = new AmtQueueSubmission(mSubmissionKey, sub); // JUST LOOP AROUND Interlocked.CompareExchange(ref mSubmissionKey, 0, long.MaxValue); Interlocked.Increment(ref mSubmissionKey); if (mSubmissions.TryAdd(submit.Key, submit)) { return(submit); } else { return(null); } }
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); }
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); }
void Draw() { var currentBufferIndex = mPresentationLayer.BeginDraw(mPostPresentCmdBuffer, mPresentCompleteSemaphore); var fence = mWaitFences[(int)currentBufferIndex]; var err = mConfiguration.Device.WaitForFences(new[] { fence }, true, ulong.MaxValue); Debug.Assert(err == Result.SUCCESS); err = mConfiguration.Device.ResetFences(new[] { fence }); var submitInfos = new MgSubmitInfo[] { new MgSubmitInfo { WaitSemaphores = new [] { new MgSubmitInfoWaitSemaphoreInfo { WaitDstStageMask = MgPipelineStageFlagBits.COLOR_ATTACHMENT_OUTPUT_BIT, WaitSemaphore = mPresentCompleteSemaphore, } }, CommandBuffers = new [] { drawCmdBuffers[currentBufferIndex] }, SignalSemaphores = new [] { mRenderCompleteSemaphore }, } }; err = mConfiguration.Queue.QueueSubmit(submitInfos, fence); Debug.Assert(err == Result.SUCCESS); mPresentationLayer.EndDraw(new[] { currentBufferIndex }, mPrePresentCmdBuffer, new[] { mRenderCompleteSemaphore }); }