Skip to content
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

Merged
merged 11 commits into from
May 20, 2024
Merged

Conversation

inforithmics
Copy link
Contributor

Added UseGpu to Uno so that it can run on Gpu on Android, Wasm and iOS

RunOnUIThread(() =>
{
_canvas?.Invalidate();
#if HAS_UNO_WINUI
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@inforithmics inforithmics changed the title WIP Feature: Gpu Acceleration for Uno Feature: Gpu Acceleration for Uno May 10, 2024
Copy link
Member

@pauldendulk pauldendulk left a 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The #ifs 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 #ifs. 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.

@@ -0,0 +1,24 @@
#if !HAS_UNO_WINUI
Copy link
Member

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!

@pauldendulk pauldendulk merged commit 9622244 into Mapsui:main May 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants