static void render(SwapChainPanel swapChainPanel)
        {
            ICommandListFactory commandListFactory = GetCommandListFactory(swapChainPanel);

            if (commandListFactory == null)
            {
                return;
            }

            RenderData _renderData = RenderData.Find(swapChainPanel, false);

            if (_renderData == null)
            {
                return;
            }

            Debug.WriteLine($"{nameof(SwapChainPanelPainter)}.{nameof(render)} _renderData={_renderData}");

            GraphicsDevice _graphicsDevice = _renderData.graphicsDevice;

            if (_graphicsDevice == null)
            {
                return;
            }

            Veldrid.Swapchain _swapchain = _renderData.swapchain;
            if (_swapchain == null)
            {
                return;
            }

            Framebuffer _framebuffer = _renderData.framebuffer;

            if (_framebuffer == null)
            {
                return;
            }

            {
                Veldrid.CommandList _commandList = null;
                try
                {
                    _commandList = commandListFactory.BuildCommandList(_graphicsDevice, _framebuffer);
                    if (_commandList == null)
                    {
                        return;
                    }

                    _graphicsDevice.SubmitCommands(_commandList);
                    _graphicsDevice.SwapBuffers(_swapchain);
                }
                catch (Exception E)
                {
                }
                finally
                {
                    _commandList?.Dispose();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// DI Constructor
        /// </summary>
        /// <param name="pmCommunicator">The communicator service</param>
        /// <param name="pmPollingService">The polling service</param>
        /// <param name="logger">The logger</param>
        public PMService(IPMCommunicator pmCommunicator, ICommandListFactory commandListFactory, IPMPollingService pmPollingService, ILogger <PMService> logger)
        {
            _logger             = logger;
            _pmCommunicator     = pmCommunicator;
            _commandListFactory = commandListFactory;
            _pmPollingService   = pmPollingService;

            _pmCommunicator.DeviceLost += OnDeviceLost;
        }
Exemplo n.º 3
0
        // NB: le traitement des events SizeChanged est inutile: il est fait en interne

        static void OnCommandListFactoryChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var veldridview = bindable as VeldridView;

            if (veldridview == null)
            {
                return;
            }

            if (oldValue != null)
            {
                bool _old = ViewData.Dispose(veldridview);
                if (_old)
                {
                    veldridview.OnRendererSet -= Veldridview_OnRendererSet;
                    veldridview.OnUpdate      -= Veldridview_OnUpdate;
                }
            }

            ICommandListFactory _newValue = newValue as ICommandListFactory;

            if (_newValue == null)
            {
                return;
            }

            ViewData viewData = ViewData.Find(veldridview);

            if (viewData == null)
            {
                return;
            }

            viewData.commandListFactory = _newValue;

            veldridview.OnRendererSet += Veldridview_OnRendererSet;
            veldridview.OnUpdate      += Veldridview_OnUpdate;
        }
Exemplo n.º 4
0
        static void paint(VeldridView veldridview)
        {
            CommandList _commandList = null;

            try
            {
                Debug.WriteLine($"{nameof(paint)}(-) veldridview.Width={veldridview.Width} .Height={veldridview.Height}");

                ViewData viewData = ViewData.Find(veldridview);
                if (viewData == null)
                {
                    return;
                }

                if (viewData.Enabled == false)
                {
                    return;
                }

                ICommandListFactory commandListFactory = viewData.commandListFactory;
                if (commandListFactory == null)
                {
                    return;
                }

                GraphicsDevice _graphicsDevice = veldridview?.VeldridView0Renderer?.GraphicsDevice;
                if (_graphicsDevice == null)
                {
                    return;
                }

                Swapchain swapchain = veldridview?.VeldridView0Renderer?.Swapchain;
                if (swapchain == null)
                {
                    return;
                }

                Framebuffer _framebuffer = swapchain.Framebuffer;
                if (_framebuffer == null)
                {
                    return;
                }

                Debug.WriteLine($"{nameof(paint)} veldridview.Width={veldridview.Width} .Height={veldridview.Height}");
                Debug.WriteLine($"{nameof(paint)} _framebuffer.Width={_framebuffer.Width} .Height={_framebuffer.Height}");

                _commandList = commandListFactory.BuildCommandList(_graphicsDevice, _framebuffer);
                if (_commandList == null)
                {
                    return;
                }

                _graphicsDevice.SubmitCommands(_commandList);
                _graphicsDevice.SwapBuffers(swapchain);
            }
            catch (Exception E)
            {
            }
            finally
            {
                _commandList?.Dispose();
                Debug.WriteLine($"{nameof(paint)}(+) veldridview.Width={veldridview.Width} .Height={veldridview.Height}");
            }
        }
Exemplo n.º 5
0
 public static void SetCommandListFactory(BindableObject bindable, ICommandListFactory value)
 {
     bindable.SetValue(CommandListFactoryProperty, value);
 }
        static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Debug.WriteLine($"{nameof(SwapChainPanelPainter)}.{nameof(PropertyChangedCallback)} d={d} e.OldValue={e.OldValue} e.NewValue={e.NewValue}");

            SwapChainPanel swapChainPanel = d as SwapChainPanel;

            if (swapChainPanel == null)
            {
                return;
            }

            ICommandListFactory commandListFactory = e.NewValue as ICommandListFactory;

            if (commandListFactory == null)
            {
                // 'déconnexion de swapChainPanel'
                bool _ok = RenderData.Dispose(swapChainPanel);
                if (_ok)
                {
                    // events
                    swapChainPanel.Loaded                  -= SwapChainPanel_Loaded;
                    swapChainPanel.Unloaded                -= SwapChainPanel_Unloaded;
                    swapChainPanel.SizeChanged             -= SwapChainPanel_SizeChanged;
                    swapChainPanel.CompositionScaleChanged -= SwapChainPanel_CompositionScaleChanged;
                }
            }
            else
            {
                RenderData _renderData = RenderData.Find(swapChainPanel, false);
                if (_renderData == null)
                {
                    _renderData = RenderData.Find(swapChainPanel, true);
                    if (_renderData == null)
                    {
                        return;
                    }

                    bool _ok = false;
                    try
                    {
                        GraphicsDevice _graphicsDevice = _renderData.graphicsDevice;
                        if (_graphicsDevice == null)
                        {
                            return;
                        }

                        // events
                        swapChainPanel.Loaded                  += SwapChainPanel_Loaded;
                        swapChainPanel.Unloaded                += SwapChainPanel_Unloaded;
                        swapChainPanel.SizeChanged             += SwapChainPanel_SizeChanged;
                        swapChainPanel.CompositionScaleChanged += SwapChainPanel_CompositionScaleChanged;

                        _ok = true;
                    }
                    finally
                    {
                        if (_ok == false)
                        {
                            RenderData.Dispose(swapChainPanel);
                        }
                    }
                }
            }
        }
 public static void SetCommandListFactory(DependencyObject obj, ICommandListFactory value)
 {
     obj.SetValue(CommandListFactoryProperty, value);
 }
Exemplo n.º 8
0
 /// <summary>
 /// DI Constructor
 /// </summary>
 /// <param name="pmCommunicator">The PM Communicator</param>
 /// <param name="commandListFactory">The command list factory</param>
 /// <param name="logger">The logger</param>
 public PMPollingService(IPMCommunicator pmCommunicator, ICommandListFactory commandListFactory, ILogger <PMPollingService> logger)
 {
     _logger             = logger;
     _pmCommunicator     = pmCommunicator;
     _commandListFactory = commandListFactory;
 }
Exemplo n.º 9
0
        static void PropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            D3D11Image d3D11Image = d as D3D11Image;

            if (d3D11Image == null)
            {
                return;
            }

            d3D11Image.OnRender = null;

            ICommandListFactory commandListFactory = e.NewValue as ICommandListFactory;

            if (commandListFactory == null)
            {
                return;
            }

            RenderData _renderData = RenderData.Find(d3D11Image, true);

            if (_renderData == null)
            {
                return;
            }

            GraphicsDevice _graphicsDevice = _renderData.graphicsDevice;

            if (_graphicsDevice == null)
            {
                return;
            }

            SharpDX.Direct3D11.Device _device = _renderData.device;
            if (_device == null)
            {
                return;
            }

            d3D11Image.OnRender = (IntPtr surface, bool isNewSurface) =>
            {
                #region --- OnRender
                Framebuffer _framebuffer = _renderData.FrameBuffer(surface, isNewSurface);
                if (_framebuffer == null)
                {
                    return;
                }

                Veldrid.CommandList commandList = null;
                try
                {
                    commandList = commandListFactory.BuildCommandList(_graphicsDevice, _framebuffer);
                    if (commandList == null)
                    {
                        return;
                    }
                    _graphicsDevice.SubmitCommands(commandList);
                }
                finally
                {
                    commandList?.Dispose();
                }

                _device.ImmediateContext.Flush();
                #endregion
            };
        }
Exemplo n.º 10
0
 public AddProgramViewModel(ICommandListFactory commandListFactory)
 {
     this.CommandListFactory = commandListFactory;
     changeState(CommandState);
 }