husker-dev / openglfx

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

Add Vulkan support #71

Open streamingdv opened 7 months ago

streamingdv commented 7 months ago

Just a suggestion for the future as it would be great, similar to what QT already offers, a Vulkan canvas can be created (similar to the Metal surface)

https://doc.qt.io/qt-6/qsurface.html#SurfaceType-enum.

If that is out of scope at the moment feel free to close this ticket.

husker-dev commented 7 months ago

I was planning to add rendering through Vulkan, but due to my lack of experience with it, I put it off for the future.

I also thought about DirectX 9/11 and Metal support. But for now these are just thoughts.

husker-dev commented 7 months ago

Theoretically, I can also make a kind of WebView from external browsers. Chromium for example uses OpenGL and DirectX to render content.

streamingdv commented 7 months ago

Theoretically yes, though I always prefer the more native approach. I really wish JavaFX would support surfaces as QT does but that's where your lib perfectly fills the gap 👍

streamingdv commented 5 months ago

I'm currently working on a native glfw window example which is rendering AVFrames via my custom JNI libplacebo wrapper (currently still a private project) with Vulkan. It works quite well but during my testing phase I found an interesting project

https://forums.developer.nvidia.com/t/vk-khr-external-memory-and-or-vk-khr-external-memory-win32/71876/3

It is written in Kotlin and it seems in the past it was experimenting as well with JavaFX support

https://github.com/search?q=repo%3Ascenerygraphics%2Fscenery%20avafx&type=code https://github.com/scenerygraphics/scenery-javafx

In theory I guess it could work very similar to your OpenGL approach. Just wanted to post it here as additional information.

husker-dev commented 5 months ago

I tried to start Vulkan integration in openglfx, but faced a lack of knowledge :) Currently OpenGL uses some tricks in some places that I can't imagine how to do in Vulkan.

The main problem may arise with Windows, because I will need texture sharing between DirectX 9 and Vulkan, which may not be supported.

streamingdv commented 5 months ago

Yes it is quite complex but what I read is that offscreen rendering is supported but you might be correct you need DirectX 11 for the interop stuff. At least all examples I found were using DirectX 11 textures.

Vulkan is quite complex that's why I'm using libplacebo, the wrapper I made for Java works with my h264 and h265 frames even HDR is supported. The only disadvantage is of course that I can't use JavaFX in the rendering window :/