-
-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Gpu Acceleration for Uno #2630
Conversation
Mapsui.UI.WinUI/MapControl.cs
Outdated
RunOnUIThread(() => | ||
{ | ||
_canvas?.Invalidate(); | ||
#if HAS_UNO_WINUI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea behind UseGPU was to select CPU or GPU while runtime. If you set UseGPU before creating MapControl, then it would select the right view. If you do it by your way, you have to select it at compiletime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is here to remove this code from the WinUI target. Because the Code is shared here with Uno.
The Conditional Compiliation is used only for setting the default values of useGpu.
Currently it is supported in Android iOS and WebAssembly on Windows it isn't supported yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this isn't correct. You use the conditional compilation also for adding code. Eg. in this case you add or remove the code for invalidation of the GPU view by conditional compilation and not by checking the flag UseGPU. This makes it harder to add the functionality later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I have changed the Code now can you have again a Look at it.
#if HAS_UNO_WINUI is used for code that is only valid in Uno.Winui because the Control is shared between Uno.WinUI and WinUI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. I have one remark wrt the #ifs
|
||
Children.Add(_canvas); | ||
#if HAS_UNO_WINUI | ||
if (UseGPU) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #if
s make the code hard to read. The indentation problem makes it worse. I propose to keep the UseGPU field outside the #if
scope so that it is available on all platforms and would throw an exception if not available. The main code would be the same. Also from the users perspective this may be better, the exception can inform the developer. I was already considering moving UseGPU to the shared project so that it is available everywhere (but not implemented everywhere).
Perhaps there are also other ways to rewrite this to reduce the invasiveness of the #if
s. The way things is split up in methods may need to be altered. The main code should be easy to read, the different implementations should be some differences in the details.
…tion on WinUI where it doesn't exist isn't implemented.
@@ -0,0 +1,24 @@ | |||
#if !HAS_UNO_WINUI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a lot better like this!
Added UseGpu to Uno so that it can run on Gpu on Android, Wasm and iOS