ladybird icon indicating copy to clipboard operation
ladybird copied to clipboard

LibGfx+LibWeb: Support DirectX-based WebGL on Windows

Open ayeteadoe opened this issue 7 months ago • 2 comments

I initially tried to build off of the recent Vulkan work for Linux WebGL by using the VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME device extension and VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT_KHR handle type when creating the VkImage. That was all working; however, I was unable to create the acutal EGL surface (or image) with EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE from the vulkan-created shared handle.

It seems to only work with getting the shared handle from a D3D11 texture (https://github.com/Microsoft/angle/wiki/Interop-with-other-DirectX-code). So I switched to Direct 3D on Windows for skia to get a painting surface compatible with the texture, and it seems to just work™

Demo

https://github.com/user-attachments/assets/ef8d101a-5f7d-4efe-b1b3-662781f48d13

ayeteadoe avatar Sep 06 '25 03:09 ayeteadoe

Oops, I just realized when I switched to using the D3D backend context for navigables, I missed updating BackingStoreManager to handle Windows now, as USE_VULKAN in reallocate_backing_stores is no longer used. This means we were falling back to bitmap wrapped backing stores.

So one more rebase incoming that will change that check to #if defined(USE_VULKAN) || defined(AK_OS_WINDOWS) in the LibWeb: Use D3D12 SkiaBackendContext for Navigables on Windows commit.

I initially missed this because I was only testing https://webglsamples.org on this branch. But the performance slowdown with the bitmap wrapped backing stores was very noticable when I finally tested https://ladybird.org compared to current master.

ayeteadoe avatar Nov 20 '25 04:11 ayeteadoe

Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.

github-actions[bot] avatar Nov 22 '25 12:11 github-actions[bot]