-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
SKIA for Android: GPU SkImage Rendering Failure on TGLCanvas vs. Vulkan #296
Comments
In the context of OpenGL, the problem probably stems from the absence of the "Flush()" and "Submit()" calls, which depending on the layout should be executed synchronously when the backend is OpenGL. Unfortunately, OpenGL doesn't have a robust design for multi-threading operations. This contrasts with Vulkan and Metal/Apple, where a single context can be shared between several threads. OpenGL relies heavily on synchronization mechanisms even though it uses shared contexts. Skia is currently developing a backend called Graphite, which promises significant performance improvements in multi-threaded systems. However, I believe that before long the vast majority of devices in use will all be Vulkan or Metal/Apple compatible. |
Thanks! but even with Flush() and Submit() the textures are still not drawed :( Here i m not even in multithread as all operations are made in the main thread. Also when working directly with an OpenGL canvas (not Skia), I am able to create and manage textures in the background without encountering significant issues. This leads me to believe that the problem might not solely lie with OpenGL's architecture. Given this, I suspect the issue may be more specifically related to how Skia creates and manages the shared context in OpenGL. |
@Zeus64 we'll be a bit overwhelmed with work over the next few days, but I'll look into your problem as soon as possible. However, I can provide some preliminary insights. I'll have to look into it when time permits, I had some examples of this, I remember I had problems sharing texture between contexts (even if OpenGL contexts are created in a shared way) through Skia. Texture creation should use the same color type, number of samples (I see you used 1). |
@viniciusfbb Thanks a lot for your help and your precious work ! I will try also to dig into as soon as possible, right now I m fighting with skparagraph and I need to finish this before to study why GPU image do not work with skia in openGL. |
@Zeus64 You can check the implementation of FMX.Skia.Canvas.TSkTextLayout, which uses SkParagraph. However, the TSkTextLayout source has complexities that were only necessary to emulate the exact behavior of other TTextLayout implementations. |
@viniciusfbb yes the work you have done is my bible right now :) :) |
Just a small comment Zeus64
// IF you set GlobalUseVulkan := True;
// in Project1.dpr then everything work
// fine but with GlobalUseVulkan := False
// nothing is draw :(
procedure TForm1.Button1Click(Sender: TObject);
begin
var LImageInfo: sk_imageinfo_t;
LImageInfo.width := 150;
LImageInfo.height := 150; Backquote characters are available with the <> button when writing a comment |
I'm closing this topic due to inactivity but feel free to open new ones. |
@viniciusfbb I will come back a little later regarding this, because the implementation of the OpenGL canvas in skia4delphi is little wrong, i made the correction the the skia units |
@Zeus64 I'm very anxious for improvements! You can open a PR if you want. Someone reported that it seems to have a memory leak on Android when closing the forms, something like that. So we have to investigate this too. eglSwapInterval(TGlSharedContext(SharedContext).Display, 1); |
I'm using SKIA4delphi with Android and I want to draw a GPU SkImage directly onto a GPU SkSurface (IE: the canvas of the main form). Currently, the skia framework utilizes TBitmap, which employs a CPU SkImage. This approach is 4-5 times slower than using a GPU image.
When I switch to the default Skia Vulkan canvas (TVKCanvas), everything functions correctly, but the framerate is still 2-5 times slower compared to using the older TCanvasGpu with TTexture. I now want to evaluate the performance using the OpenGL canvas (TGLCanvas) to determine if the reduced speed is related to Vulkan. However, I'm facing an issue where I can't seem to draw a GPU SkImage on the TGLCanvas. There are no errors, but the image doesn't appear on the form.
I've attached a demo for reference. It's set with GlobalUseVulkan := False. When this is changed to GlobalUseVulkan := true, the rectangle is painted as expected.
Demo.ZIP
The text was updated successfully, but these errors were encountered: