Skip to content

Add string feature 'VulkanExternalMemoryMode' to override the memoryMode#111

Open
aaron-ruby wants to merge 4 commits intogoogle:mainfrom
aaron-ruby:qnx-opaquefd
Open

Add string feature 'VulkanExternalMemoryMode' to override the memoryMode#111
aaron-ruby wants to merge 4 commits intogoogle:mainfrom
aaron-ruby:qnx-opaquefd

Conversation

@aaron-ruby
Copy link
Collaborator

…ver using OpaqueFd memoryMode. And add OpaqueFd as a supported externalMemory mode on QNX.

"When enabled, allows host to use VK_KHR_external_memory_fd for Vulkan emulation and "
"memory sharing. "
"This corresponds to the externalMemoryMode that the host VkEmulation chooses."
"By default, this option is enabled. However, some platforms may explicitly choose not to "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is the desired behavior just that screen buffer is selected over opaque fd in some cases?

I guess I'm just curious if would make more sense to just introduce some kind of "ExternalMemoryMode" feature that is a string where you can explicitly specify the mode you want (or potentially a "SupportedExternalMemoryModes" feature that is like a list of supported modes in the preferred order). Then we can add like a

GFXSTREAM_SET_FEATURE(&features, ExternalMemoryMode, 
#if defined(ANDROID)
   "ahb"
#elif defined(QNX)
  "screenbuffer"
#elif ...

#endif
   );

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah exactly, you got it.

Yeah I was trying to figure out how to do this in the most universal way. Right now, i guess calculateMode() prioritizes based on the order in this list, but you're right; we basically just want a way to change that order, otherwise default to what is already there.

What you've suggested is a great idea! I will prototype that ...

@aaron-ruby aaron-ruby force-pushed the qnx-opaquefd branch 2 times, most recently from fe43e69 to a922b6d Compare March 18, 2026 21:55
@aaron-ruby
Copy link
Collaborator Author

@jmacnak updated the review ... allows for some features to specify a string value, instead of just their enabled/disabled boolean. That's the "features" part of the change. Then the rest is actually using that string value (as a optional<string>) as input to the calculateMode() function.

This is a bit of an extension of the "Features" functionality ... so maybe I went to heavy-handed. Please let me know.

@aaron-ruby aaron-ruby force-pushed the qnx-opaquefd branch 2 times, most recently from 95a89da to a3f1caf Compare March 18, 2026 22:34
@aaron-ruby
Copy link
Collaborator Author

Some testing:

With VulkanExternalMemoryMode:badValue

[a16-aarch64-auto.conf:140] [virtio-gpu] [vulkan_dispatch.cpp(189)] Added library: libvulkan.so
[a16-aarch64-auto.conf:140] [virtio-gpu] [external_memory.cpp(92)] calculateMode(): Could not find an ExternalMemoryMode matching the provided VulkanExternalMemoryMode string: badValue 
[a16-aarch64-auto.conf:140] [virtio-gpu] [external_memory.cpp(199)] getDeviceExtensionsForMode: Invalid external memory mode Unknown!

With VulkanExternalMemoryMode:HostAllocation, but the Vulkan driver does not have the required features:

[a16-aarch64-auto.conf:140] [virtio-gpu] [external_memory.cpp(84)] calculateMode(): Vulkan driver does not support the memory mode provided by the VulkanExternalMemoryMode string: HostAllocation
[a16-aarch64-auto.conf:140] [virtio-gpu] [vk_common_operations.cpp(1289)] Selecting Vulkan device: V3D 7.1.7.0, Version: 1.3.311
[a16-aarch64-auto.conf:140] [virtio-gpu] [vk_common_operations.cpp(1293)] Using Vulkan externalMemoryMode: NotSupported for VkEmulation
...
(eventually ...)
[virtio-gpu] [external_memory.cpp(154)] getHandleType: Unhandled external memory mode 'NotSupported'
[virtio-gpu] [external_memory.cpp(154)] getHandleType: Unhandled external memory mode 'NotSupported'
...

With VulkanExternalMemoryMode:OpaqueFd, and it's supported by the Vulkan driver!

[a16-aarch64-auto.conf:140] [virtio-gpu] [vulkan_dispatch.cpp(189)] Added library: libvulkan.so
[a16-aarch64-auto.conf:140] [virtio-gpu] [vk_common_operations.cpp(1289)] Selecting Vulkan device: V3D 7.1.7.0, Version: 1.3.311
[a16-aarch64-auto.conf:140] [virtio-gpu] [vk_common_operations.cpp(1293)] Using Vulkan externalMemoryMode: OpaqueFd for VkEmulation
[a16-aarch64-auto.conf:140] [virtio-gpu] [vk_common_operations.cpp(260)] Warning: using non-cached HOST_VISIBLE type for staging memory
[a16-aarch64-auto.conf:140] [virtio-gpu] [vk_common_operations.cpp(1586)] Initializing VkEmulation features:
[a16-aarch64-auto.conf:140] [virtio-gpu] [vk_common_operations.cpp(1587)]     glInteropSupported: false
[a16-aarch64-auto.conf:140] [virtio-gpu] [vk_common_operations.cpp(1589)]     useDeferredCommands: true
...

@aaron-ruby aaron-ruby requested a review from jmacnak March 19, 2026 16:34
@aaron-ruby aaron-ruby changed the title Add VulkanAllowOpaqueFdExternalMemory for platform-specific control o… Add string feature 'VulkanExternalMemoryMode' to override the memoryMode Mar 23, 2026
@aaron-ruby
Copy link
Collaborator Author

Latest patchset includes:

  • Split FeatureInfo into BoolFeatureInfo and StringFeatureInfo
  • Move featureString parsing/processing to the FeatureSet class
  • Add string feature 'VulkanExternalMemoryMode' to override the memoryMode
  • Enable OpaqueFd as a secondary-supported externalMemoryMode on QNX

If desired, please review invidual commits to see grouped/related changes.

... to allow for features specified as string values, not just "enabled"/"disabled".
@aaron-ruby
Copy link
Collaborator Author

@jmacnak ready for review.

@aaron-ruby aaron-ruby requested a review from jmacnak March 23, 2026 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants