示例#1
0
        void OnRender(IntPtr resourcePtr, bool isNewSurface)
        {
            if (isNewSurface)
            {
                // a new surface has been created (e.g. after a resize)
                InitializeSharedBackBuffer(resourcePtr);
            }

            deviceContext.ClearRenderTargetView(renderTargetView, new RawColor4(0, 0, 0, 1));
            deviceContext.Draw(3, 0);
            deviceContext.Flush();
        }
示例#2
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);
            });
        }
        /// <summary>
        /// Called when RenderLoop wants to present its results.
        /// </summary>
        private void OnRenderLoopPresent(EngineDevice engineDevice)
        {
            D3D11.DeviceContext deviceContext = engineDevice.DeviceImmediateContextD3D11;

            // Copy all contents of the render target to the texture that is used for synchronization
            deviceContext.Flush();
            deviceContext.CopyResource(
                m_backBuffer,
                m_backBufferSynchronizing);

            // Request next frame
            m_drawingInterop.RequestNextFrame();
        }
示例#4
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
        }
示例#5
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);
        }
示例#6
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();
            }
        }
示例#7
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();
 }
示例#8
0
 public void Flush()
 {
     context.Flush();
 }