husker-dev / openglfx

OpenGL implementation for JavaFX
Apache License 2.0
80 stars 10 forks source link

Multi-thread rendering #41

Closed qq1053831109 closed 7 months ago

qq1053831109 commented 9 months ago

Opengl latency can affect fx latency. Can they run on different threads? And provide a synchronization mechanism after rendering is completed

husker-dev commented 9 months ago

In theory this is possible. I'll look into ways to implement it soon.

husker-dev commented 8 months ago

I did some tests. They show that rendering on another thread is not as efficient as it might seem. Perhaps it's a matter of synchronizing internal data in OpenGL.

@qq1053831109 Why do you need this functionality?

qq1053831109 commented 8 months ago

You can learn Javafx. The logical thread is n+1 frames.Efficient synchronization mechanism requires excellent design。My opengl panel is for rendering games. Each frame consumes 10ms

qq1053831109 commented 8 months ago

And I need to render multiple opengl panels in one Javafx, such as batch viewing models. I don't want them to share a thread for rendering. This can lead to delays. The client software has a low tolerance for latency.

husker-dev commented 8 months ago

@qq1053831109 I've added multi-thread support to the d3d pipeline (i.e. Windows only). Also, for now it works only with lwjgl.


You can build openglfx by yourself and test performance in your case.

  1. Clone project
  2. ./gradlew :compileJars
  3. Add libraries from ./build/libs to your project
  4. Change canvas creation:
    val canvas = OpenGLCanvas.create(LWJGL_MODULE, multiThread = true)
qq1053831109 commented 8 months ago

Need ES2 pipeline, can double buffering be considered? In situations where rendering time is high, synchronization time is less important

husker-dev commented 8 months ago

Added es2 support. Tomorrow I'll try to do it for sw. There are currently some artifacts when resizing the Canvas. I'll try to solve them soon.

husker-dev commented 7 months ago

Added sw support. There is a new interop for macOS is coming, so the issue is not closed.

husker-dev commented 7 months ago

Added async IOSurface interop. I will close this issue.