hal/vulkan: add OpenHarmony surface support - #9908
Merged
Merged
Conversation
The Vulkan backend has no OpenHarmony window-system integration, so surface creation fails there and GLES is the only usable backend. That rules out anything needing `VERTEX_STORAGE` or compute, even though OpenHarmony devices ship a working Vulkan driver. `ash` generates no OpenHarmony bindings, so `vkCreateSurfaceOHOS` is resolved via `get_instance_proc_addr` and `VkSurfaceCreateInfoOHOS` is declared locally, matching the OpenHarmony SDK's `vulkan_ohos.h`. OpenHarmony is also excluded from the X11/Wayland extension list: it is unix and reports `target_os = "linux"`, but has neither. Surfaces are created from the `OHNativeWindow` an XComponent hands out, which `raw-window-handle` already exposes as `RawWindowHandle::OhosNdk` and the GLES backend already consumes. Tested on a HUAWEI MatePad Air (Maleoon 920, HarmonyOS 6.1): the Vulkan adapter is selected and storage-buffer/compute pipelines build, which the GLES backend could not do.
ErichDonGubler
left a comment
Member
There was a problem hiding this comment.
Hey there! Welcome to wgpu! ❤️
This basically LGTM. I had some feedback that I wanted to be addressed before merging. I took the liberty of pushing my opinions on how to fix things as FIXUP commits on top of what you changed, and will plan on squashing them down on merge if everything looks good to you. WDYT?
ozongzi
commented
Jul 23, 2026
ozongzi
left a comment
Contributor
Author
There was a problem hiding this comment.
Thanks for the review and for pushing the FIXUPs! The SAFETY comments and doc links look good to me.
cursor
Bot
force-pushed
the
ohos-vulkan-wsi
branch
2 times, most recently
from
July 23, 2026 07:30
6bb6cef to
0e519b4
Compare
cursor
Bot
force-pushed
the
ohos-vulkan-wsi
branch
from
July 23, 2026 07:31
0e519b4 to
367ab17
Compare
ErichDonGubler
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Connections
Related to #9158 (GLES sRGB issues, mainly on OpenHarmony). This does not fix that
issue, but it gives OpenHarmony users a Vulkan path instead of leaving them stuck on
the GLES backend.
Description
The Vulkan backend has no OpenHarmony window-system integration, so
create_surfacefails there and GLES is the only backend that works. That rules out anything needing
VERTEX_STORAGEor compute, even though OpenHarmony devices ship a working Vulkandriver and the platform provides
VK_OHOS_surface.Three changes:
desired_extensionsnow asks forVK_OHOS_surfaceontarget_env = "ohos". Thatlist already gets filtered against the available instance extensions, so a driver
without the extension just drops it and surface creation fails later with a clear
message, rather than breaking instance creation.
create_surface_ohosbuilds the surface from theOHNativeWindowthat anXComponent hands out.
raw-window-handlealready exposes it asRawWindowHandle::OhosNdk, and the GLES backend already consumes it.target_os = "linux", but has neither.ashhas no OpenHarmony bindings, so this resolvesvkCreateSurfaceOHOSthroughget_instance_proc_addrand declaresVkSurfaceCreateInfoOHOSlocally, copied fromthe OpenHarmony SDK's
vulkan_ohos.h. Same situation as the existingEntry::load_from("libvulkan.so")call on ohos. Onceashships bindings, both cango away.
Testing
Nothing automated. CI has no OpenHarmony runner, and creating a surface needs a real
XComponent, so none of the existing test suites can reach this path.
I tested it by hand on a HUAWEI MatePad Air (Maleoon 920, HarmonyOS 6.1), running a
renderer that uses storage buffers and compute. Before the patch, Vulkan surface
creation fails, the adapter comes back as
backend: Gl(OpenGL ES 3.2), and anybind group layout with a storage buffer in the vertex stage dies with
DownlevelFlags(VERTEX_STORAGE) are required but not supported. After it, the Vulkanadapter gets picked and those pipelines build and render.
I have not tried the ohos emulator or any non-Huawei OpenHarmony device.
Squash or Rebase?
Single commit, ready to rebase onto
trunkas it stands.Checklist
wgpumay be affected behaviorally.(Only on OpenHarmony, where Vulkan becomes usable instead of GLES-only.)
(All of it sits behind
cfg(target_env = "ohos"). Extension availability ischecked at runtime and reported as a normal
InstanceError.)Not done, for the reasons under Testing. If there is a pattern for covering
platform WSI code that I have missed, I am happy to add it.
CHANGELOG.mdentries for the user-facing effects of this change are present.