Ejemplo n.º 1
0
        private void RunPendingDraws()
        {
            lock (PendingDrawQueue)
                if (PendingDrawQueue.Count == 0)
                {
                    return;
                }

            int        i  = 0;
            BatchGroup bg = null;

            while (true)
            {
                PendingDraw pd;
                lock (PendingDrawQueue) {
                    if (PendingDrawQueue.Count == 0)
                    {
                        return;
                    }
                    pd = PendingDrawQueue.DangerousGetItem(0);
                    PendingDrawQueue.DangerousRemoveAt(0);
                }

                ExceptionDispatchInfo excInfo = null;
                try {
                    if (!AutoRenderTarget.IsRenderTargetValid(pd.RenderTarget))
                    {
                        throw new Exception("Render target for pending draw was disposed between queue and prepare");
                    }

                    if (!DoSynchronousDrawToRenderTarget(pd.RenderTarget, pd.Materials, pd.Handler, pd.UserData, ref pd.ViewTransform, "Pending Draw"))
                    {
                        throw new Exception("Unknown failure performing pending draw");
                    }
                } catch (Exception exc) {
                    excInfo = ExceptionDispatchInfo.Capture(exc);
                }
                // throw new Exception("Unexpected error performing pending draw");

                if (pd.OnComplete != null)
                {
                    lock (CompletedPendingDrawQueue)
                        CompletedPendingDrawQueue.Add(new CompletedPendingDraw {
                            UserData     = pd.UserData,
                            Exception    = excInfo,
                            OnComplete   = pd.OnComplete,
                            RenderTarget = pd.RenderTarget
                        });
                }
                else if (excInfo != null)
                {
                }
                else
                {
                }
            }
        }
Ejemplo n.º 2
0
        private void PendingDrawSetupHandler(DeviceManager dm, object _pd)
        {
            var pd = (PendingDraw)_pd;

            if (!AutoRenderTarget.IsRenderTargetValid(pd.RenderTarget))
            {
                throw new ObjectDisposedException("Render target for pending draw was disposed between prepare and issue");
            }

            var vt = pd.ViewTransform ??
                     ViewTransform.CreateOrthographic(pd.RenderTarget.Width, pd.RenderTarget.Height);

            pd.Materials.PushViewTransform(in vt);
            dm.Device.Clear(Color.Transparent);
        }