public static bool Dispose(VeldridView veldridView) { if (veldridView == null) { return(false); } lock (s_apViewData) { ViewData viewData = s_apViewData.FirstOrDefault(vd => vd.veldridView == veldridView); if (viewData == null) { return(false); } s_apViewData.Remove(viewData); return(true); } }
public static ViewData Find(VeldridView veldridView, bool createIfNotFound = true) { if (veldridView == null) { return(null); } lock (s_apViewData) { ViewData viewData = s_apViewData.FirstOrDefault(vd => vd.veldridView == veldridView); if (viewData != null) { return(viewData); } if (createIfNotFound == false) { return(null); } s_apViewData.Add(viewData = new ViewData(veldridView)); return(viewData); } }
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}"); } }
ViewData(VeldridView veldridView) { m_veldridView = veldridView; }
public static void Update(VeldridView veldridview) { paint(veldridview); }