picoe / eto.veldrid Goto Github PK
View Code? Open in Web Editor NEWVeldrid control for Eto.Forms
License: MIT License
Veldrid control for Eto.Forms
License: MIT License
Keyboard events are passed to the viewport when focus is set.
Focus not grabbed and the keyboard events go to a different control.
Hi Curtis,
with Big Sur the point of serious consideration has come. Our apps build with Eto are using OpenGL for the graphics and now its starting to become funny and strange with new macOS.
Just from first impression Veldred seems to be a good way to go for portable graphics on .Net for Windows, Mac, iOS and Droid.
But three years ago I thought the same with OpenGL.
You are supporting Veldred with a Eto-lib. How serious is this? What is your impression about Veldred?
Tom
Under WIndows, for WinForms or WPF, I get an error if I try to use the OpenGL backend by forcing it in the MainForm constructor :
public MainForm(GraphicsBackend backend)
{
InitializeComponent();
backend = GraphicsBackend.OpenGL;
Shown += (sender, e) => FormReady = true;
Hardware tested is a laptop targeted 3070 running 471.96 drivers, and also a desktop 1070 with the same drivers. Both fail in the same manner. Direct3D11 and Vulkan backends work without issue, I see the same crash for the PR that attempts to make OpenGL work with GTK
Crash is :
System.InvalidCastException: Unable to cast object of type 'Eto.Veldrid.Wpf.WpfVeldridSurfaceHandler' to type 'IOpenGL'.
at Eto.Veldrid.VeldridSurface.get_OpenGL() in D:\development\git\Eto.Veldrid\src\Eto.Veldrid\VeldridSurface.cs:line 54
at Eto.Veldrid.VeldridSurface.InitializeGraphicsBackend(InitializeEventArgs e) in D:\development\git\Eto.Veldrid\src\Eto.Veldrid\VeldridSurface.cs:line 154
at Eto.Veldrid.VeldridSurface.Callback.OnInitializeBackend(VeldridSurface s, InitializeEventArgs e) in D:\development\git\Eto.Veldrid\src\Eto.Veldrid\VeldridSurface.cs:line 33
at Eto.Veldrid.Wpf.WpfVeldridSurfaceHandler.Control_Loaded(Object sender, RoutedEventArgs e) in D:\development\git\Eto.Veldrid\src\Eto.Veldrid.Wpf\WpfVeldridSurfaceHandler.cs:line 58
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)
at System.Windows.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
Testing this under macOS 10.14.4 on a Hackintosh (i7-7600U), I only get the pink background for the metal backend. Vulkan throws an exception; OpenGL works fine.
Just reporting in case this might be an issue in the implementation.
Vulkan/Linux seems to work now and I'm not sure that the etoViewport related notes make sense - I think that was dropped.
CommandList.SetVertexBuffer(0, LinesVertexBuffer);
can yield an exception under certain drivers, it seems:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Under .NET Framework, this kind of violation can be caught with some extra work (try/catch is not enough by itself - the runtime defaults to managing these exceptions) and with some configuration, it may allow for recovery. .NET Core lacks the ability to manage these exceptions : the runtime catches and silently exits the application.
This looks like an issue within Veldrid itself in terms of driver handling and may well be intentional and/or a bug.
Noting here because I run into this primarily with intel drivers and only ever with Vulkan.
I can't get this working for GL or Vulkan under Wayland. I wonder if GTK4 might improve things, but I'm not sure if that's scheduled.
Vulkan seems to be supported on my host system.
The Vulkan smoketest also runs happily.
Post-build, the library look-up fails because it's seeking 'libvulkan.so' where 'libvulkan.so.1' is available. I made a symlink to sort this out. Now forcing the backend to Vulkan (because it seems to fall to OpenGL otherwise), and trying to run with Vulkan under Linux Mint :
{System.NullReferenceException: Object reference not set to an instance of an object
" at PlaceholderName.GtkVeldridSurfaceHandler.InitializeOtherApi () [0x00001] in /home/phil/Desktop/Eto.Veldrid-master/src/gui/Eto.Veldrid.Gtk/Program.cs:256 \n at PlaceholderName.VeldridSurface.InitializeOtherApi () [0x000aa] in /home/phil/Desktop/Eto.Veldrid-master/src/Eto.VeldridSurface/VeldridSurface.cs:341 \n at PlaceholderName.VeldridSurface.InitializeGraphicsApi () [0x00040] in /home/phil/Desktop/Eto.Veldrid-master/src/Eto.VeldridSurface/VeldridSurface.cs:302 \n at PlaceholderName.VeldridSurface.set_ControlReady (System.Boolean value) [0x00008] in /home/phil/Desktop/Eto.Veldrid-master/src/Eto.VeldridSurface/VeldridSurface.cs:248 \n at PlaceholderName.VeldridSurface.<.ctor>b__44_0 (System.Object sender, System.EventArgs e) [0x00000] in /home/phil/Desktop/Eto.Veldrid-master/src/Eto.VeldridSurface/VeldridSurface.cs:284 \n at Eto.PropertyStore.TriggerEvent[T] (System.Object key, System.Object sender, T args) [0x0000e] in <6db481985cca4510b36c8dbd12852b82>:0 \n at Eto.Forms.Control.OnLoadComplete (System.EventArgs e) [0x00006] in <6db481985cca4510b36c8dbd12852b82>:0 \n at Eto.Forms.Control.TriggerLoadComplete (System.EventArgs e) [0x0000c] in <6db481985cca4510b36c8dbd12852b82>:0 \n at Eto.Forms.Container.OnLoadComplete (System.EventArgs e) [0x00028] in <6db481985cca4510b36c8dbd12852b82>:0 \n at Eto.Forms.Form.Show () [0x0001e] in <6db481985cca4510b36c8dbd12852b82>:0 \n at Eto.Forms.Application+<>c__DisplayClass47_0.b__0 (System.Object sender, System.EventArgs e) [0x0001c] in <6db481985cca4510b36c8dbd12852b82>:0 \n at Eto.PropertyStore.TriggerEvent[T] (System.Object key, System.Object sender, T args) [0x0000e] in <6db481985cca4510b36c8dbd12852b82>:0 \n at Eto.Forms.Application.OnInitialized (System.EventArgs e) [0x00006] in <6db481985cca4510b36c8dbd12852b82>:0 \n at Eto.Forms.Application+Callback.OnInitialized (Eto.Forms.Application widget, System.EventArgs e) [0x0000c] in <6db481985cca4510b36c8dbd12852b82>:0 \n at Eto.GtkSharp.Forms.ApplicationHandler.Run () [0x0002c] in <5067fd7d51d748d8bac94326932fe67c>:0 \n at Eto.Forms.Application.Run (Eto.Forms.Form mainForm) [0x0002c] in <6db481985cca4510b36c8dbd12852b82>:0 \n at PlaceholderName.MainClass.Main (System.String[] args) [0x0004c] in /home/phil/Desktop/Eto.Veldrid-master/src/gui/Eto.Veldrid.Gtk/Program.cs:287 "
Test case here : https://github.com/philstopford/EtoVeldrid_Test
This test case has a tweaked version of Veldrid that avoids some glthread related crashes from recent mesa changes.
OpenGL:
Vulkan:
Arbatel looks to have some updates in the Veldrid components, so I wanted to ask whether those changes could be merged here (assuming they are relevant). I've just started working on my fork of this to create a version similar (in terms of end usage) to etoViewport.
Trying to use this inside my previously-OpenTK.Eto project :
"C:\Users\phil.nuget\packages\veldrid.spirv\1.0.9\runtimes\native" to the destination file "bin\Debug\netstandard2.0", because the destination is a folder instead of a file. To copy the source file into a folder, consider using the DestinationFolder parameter instead of DestinationFiles.
I can't see why $(RuntimeID) isn't defined (which seems to be the issue above):
Ubuntu 20.10, high DPI, forcing vulkan gives me several different results depending on situation :
Curiously, I don't see this problem with the intel drivers for the intel 620 GPU in my 7600U based laptop. The above is for my nVidia 1080 with 460 and earlier series drivers.
Take the existing MainForm() constructor and make it :
`
public MainForm(GraphicsBackend backend, string executableDirectory, string shaderSubdirectory)
{
InitializeComponent();
Shown += (sender, e) => FormReady = true;
PixelLayout mpl = new PixelLayout();
Content = mpl;
TabControl tc = new TabControl();
TabPage tp = new TabPage();
tc.Pages.Add(tp);
TabPage tp2 = new TabPage();
tc.Pages.Add(tp2);
PixelLayout pl = new PixelLayout();
tp.Content = pl;
Panel p = new Panel();
p.Size = new Size(100, 100);
pl.Add(p, 1, 1);
mpl.Add(tc, 1, 1);
Surface = new VeldridSurface(backend);
Surface.VeldridInitialized += (sender, e) => VeldridReady = true;
p.Content = Surface;
ovpSettings = new OVPSettings();
ovpSettings.enableFilledPolys = true;
ovpSettings.drawPoints = true;
PointF[] testPoly = new PointF[6];
testPoly[0] = new PointF(2.0f, 2.0f);
testPoly[1] = new PointF(15.0f, 12.0f);
testPoly[2] = new PointF(8.0f, 24.0f);
testPoly[3] = new PointF(8.0f, 15.0f);
testPoly[4] = new PointF(3.0f, 2.0f);
testPoly[5] = new PointF(2.0f, 2.0f);
PointF[] testPoly2 = new PointF[6];
testPoly2[0] = new PointF(12.0f, 2.0f);
testPoly2[1] = new PointF(25.0f, 12.0f);
testPoly2[2] = new PointF(18.0f, 24.0f);
testPoly2[3] = new PointF(18.0f, 15.0f);
testPoly2[4] = new PointF(13.0f, 2.0f);
testPoly2[5] = new PointF(12.0f, 2.0f);
ovpSettings.addPolygon(testPoly2, Color.FromArgb(0, 255, 255), 1.0f, true);
ovpSettings.addPolygon(testPoly, Color.FromArgb(255, 0, 0), 1.0f, true);
ovpSettings.addPolygon(testPoly2, Color.FromArgb(0, 255, 255), 1.0f, false);
ovpSettings.addPolygon(testPoly, Color.FromArgb(255, 0, 0), 1.0f, false);
Driver = new VeldridDriver(ref ovpSettings, ref Surface)
{
Surface = Surface,
ExecutableDirectory = executableDirectory,
ShaderSubdirectory = shaderSubdirectory
};
}
`
Change to the second tab and then back to the first. A crash will occur:
{"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."}'
in the SwapChain call below:
`
public void InitializeOtherApi()
{
Control.Loaded += (sender, e) =>
{
// To embed Veldrid in an Eto control, all these platform-specific
// versions of InitializeOtherApi use the technique outlined here:
//
// veldrid/veldrid#155
//
var source = SwapchainSource.CreateWin32(
WinFormsControl.Handle,
Marshal.GetHINSTANCE(typeof(VeldridSurface).Module));
Widget.Swapchain = Widget.GraphicsDevice.ResourceFactory.CreateSwapchain(
new SwapchainDescription(
source,
(uint)RenderWidth,
(uint)RenderHeight,
PixelFormat.R32_Float,
false));
Callback.OnVeldridInitialized(Widget, EventArgs.Empty);
};
}
}
`
Trying to run the test under a variety of Linux distributions and drivers, I see a fail of the form :
{{{
(TestEtoVeldrid.Gtk:5684): Gdk-ERROR **: 17:36:39.434: The program 'TestEtoVeldrid.Gtk' received an X Window System error.
This probably reflects a bug in the program.
The error was 'GLXBadContextTag'.
(Details: serial 446 error_code 162 request_code 151 (GLX) minor_code 26)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the GDK_SYNCHRONIZE environment
variable to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
}}}
forcing Vulkan avoids this, but there are some issues there as well
Hi I'm new to Eto and Veldrid , I want to develop interactive mobile apps using these two libraries the reason is to use one UI codebase with shader powered UI (game development approach ) , Is there a way to compile this into android application . or at least a way to integrate it into dotnet MAUI , thanks .
I hunted around to see what might be possible here, but couldn't find a good answer up to now. The etoViewport/Eto.OpenTK code allows for points to be overlaid on the underlying polygons (using a separate draw). Is there a way to reproduce this in Veldrid?
I forked this to try and get an etoViewport clone working (grid, etc.). Veldrid is confusing me slightly (I don't get multiple lines drawn, although the buffer seems to contain them). I wondered whether you might be able to spot my error in the forked repo. No urgency, and no obligation - just a request for hand-holding, if possible :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.