Ejemplo n.º 1
0
        /// <summary>
        /// Called when RenderLoop wants to present its results.
        /// </summary>
        void IRenderLoopHost.OnRenderLoop_Present(EngineDevice device)
        {
            // Finish rendering of all render tasks
            m_deviceContext.Flush();
            m_deviceContext.ClearState();

            // Notify all render awaitors (callers of AwaitRenderAsync method)
            m_renderAwaitors.DequeueAll().ForEachInEnumeration(actAwaitor =>
            {
                actAwaitor.SetResult(null);
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GorgonGraphics"/> class.
        /// </summary>
        /// <param name="graphics">The immediate graphics context.</param>
        internal GorgonGraphics(GorgonGraphics graphics)
        {
            // Inherit the object tracker from the immediate context.
            _trackedObjects = graphics._trackedObjects;

            Context = new D3D.DeviceContext(graphics.D3DDevice);
            Context.ClearState();
            ImmediateContext = graphics;

            VideoDevice = graphics.VideoDevice;
            GIFactory   = graphics.GIFactory;
            Adapter     = graphics.Adapter;
            D3DDevice   = graphics.D3DDevice;

            CreateStates();

            graphics.AddTrackedObject(this);
        }
Ejemplo n.º 3
0
        public void Dispose()
        {
            lock (device)
            {
                player.Control.Resize -= ResizeBuffers;

                Utilities.Dispose(ref rtv);
                Utilities.Dispose(ref backBuffer);
                Utilities.Dispose(ref swapChain);
                Utilities.Dispose(ref vertexLayout);
                Utilities.Dispose(ref vertexBuffer);

                context.Flush();
                context.ClearState();
                Utilities.Dispose(ref context);
            }

            Utilities.Dispose(ref device);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Called when RenderLoop wants to present its results.
        /// </summary>
        void IRenderLoopHost.OnRenderLoop_Present(EngineDevice engineDevice)
        {
            if (m_d3dImageSource == null)
            {
                return;
            }
            if (!this.IsLoaded)
            {
                return;
            }

            bool isLocked = false;

            GraphicsCore.Current.PerformanceCalculator.ExecuteAndMeasureActivityDuration(
                "Render.Lock",
                () => isLocked = m_d3dImageSource.TryLock(MAX_IMAGE_LOCK_DURATION));
            if (!isLocked)
            {
                return;
            }
            try
            {
                // Draw current 3d scene to wpf
                D3D11.DeviceContext deviceContext = engineDevice.DeviceImmediateContextD3D11;
                deviceContext.ResolveSubresource(m_backBufferD3D11, 0, m_backBufferForWpf, 0, DXGI.Format.B8G8R8A8_UNorm);
                deviceContext.Flush();
                deviceContext.ClearState();

                // Apply true background texture if a cached bitmap was applied before
                if (this.Source != m_d3dImageSource)
                {
                    this.Source = m_d3dImageSource;
                }

                // Invalidate the D3D image
                m_d3dImageSource.InvalidateD3DImage();
            }
            finally
            {
                m_d3dImageSource.Unlock();
            }
        }
Ejemplo n.º 5
0
 public void Dispose()
 {
     _shaderSignature?.Dispose();
     _vertexShaderByteCode?.Dispose();
     _vertexShader?.Dispose();
     _pixelShaderByteCode?.Dispose();
     _pixelShader?.Dispose();
     _verticesBuffer?.Dispose();
     _inputLayout?.Dispose();
     _contantBuffer?.Dispose();
     _depthBuffer?.Dispose();
     _depthView?.Dispose();
     _context?.ClearState();
     _context?.Flush();
     _swapChain?.Dispose();
     _renderView?.Dispose();
     _backBuffer?.Dispose();
     _device?.Dispose();
     _context?.Dispose();
     _factory?.Dispose();
 }
Ejemplo n.º 6
0
        public void DisposeFrames()
        {
            DrawContext.Dispose();
            Brush?.Dispose();
            DeviceContext.Target = null;
            DeviceContext3D.OutputMerger.SetRenderTargets((RenderTargetView)null);
            DeviceContext3D.ClearState();

            foreach (var resource in FrameResources)
            {
                resource.Bitmap.Dispose();
                resource.Surface.Dispose();
                resource.WrappedBackBuffer.Dispose();
                resource.RenderTarget.Dispose();
            }

            DeviceContext3D.Flush();

#if false
            DeviceDebug debug = Device3D11.QueryInterface <DeviceDebug>();
            debug.ReportLiveDeviceObjects(ReportingLevel.Detail);
            debug.Dispose();
#endif
        }