Example #1
0
        public void Render()
        {
            //inflightSemaphore.WaitOne();
            try
            {
                uint layerNo = mPresentationLayer.BeginDraw(mPostPresentBarrierCmd, null);

                Update();

                mConfiguration.Queue.QueueSubmit(
                    new[]
                {
                    new MgSubmitInfo
                    {
                        CommandBuffers = new []
                        {
                            mRenderCmdBuffers[layerNo],
                        }
                    }
                },
                    null);

                mConfiguration.Queue.QueueWaitIdle();

                //// The render assumes it can now increment the buffer index and that the previous index won't be touched
                ///  until we cycle back around to the same index
                constantDataBufferIndex = (constantDataBufferIndex + 1) % MaxInflightBuffers;

                //// Finalize rendering here & push the command buffer to the GPU
                //commandBuffer.Commit();

                mPresentationLayer.EndDraw(new[] { layerNo }, mPrePresentBarrierCmd, null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
        }
Example #2
0
        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 });
        }