165 Commits
Author SHA1 Message Date
osy be4c36b52a Pass detection of emulated extensions on macOS
Just like QNX, macOS does not natively support DMA buffers.
Also indicate that VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME is
emulated in `vkEnumerateDeviceExtensionProperties`.
2025-10-06 13:55:00 -07:00
osy 5c119efce6 Add supportsPortabilityEnumeration flag
On macOS MoltenVK can be installed as part of Vulkan SDK or as standalone.
If standalone, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME will not be
supported. Therefore, we decouple the detection of portability enumeration
from detection of MoltenVK.
2025-10-05 17:08:32 -07:00
Serdar Kocdemir 3b71710325 Add YcbcrSamplerPool class for managing ycbcr samplers
YCbCr samplers and conversion objects will be required for Vulkan
composition of video layers, this utility class will allow using
the same object on composition side without extra access to the
color buffer info. The pool allocates new samplers and conversion
objects on demand based on the vulkan format.

Note that this CL also fixes the conversion object parameters to
render videos correctly.

Bug: 442396541
Bug: 389646068
Test: render video with -feature VulkanNativeSwapchain
Change-Id: I6d55588e4fb92cd03cb82119e5caef60184f295a
2025-09-16 16:06:52 +00:00
Serdar Kocdemir 74647db33f Add mipLevels argument to vulkan color buffer creation
Android Hardware Buffers can be created with mip levels and
the mismatch is causing errors when importing vulkan images.

Bug: 406456167
Test: CtsNativeHardwareTestCases
Change-Id: I3634bd400574453bf4ff123c149cb5f95409a42f
2025-09-11 08:25:45 +00:00
Serdar Kocdemir b46388a3e9 Provide more info on missing extension errors
Bug: 389646068
Test: CI
Change-Id: I6b052cc2378f6a07f7bc3b5251c5001741cd6f48
2025-09-04 19:31:59 +00:00
Serdar Kocdemir c1c19c7810 Separate external memory metal usage from MoltenVK
Bug: 433496880
Change-Id: I3639bfe9ca555c16c2954bcf96f3703933d0b51f
2025-07-25 22:20:02 +00:00
Serdar Kocdemir f8f789e175 Add extra validation for color buffer creation
Creating larger textures than the physical device limits can lead to
crashes on some drivers which then crashes the emulator. Validate
the dimensions requested earlier to report and avoid such cases.

Bug: 432837154
Change-Id: Id461f7878a3a6e489e013660f11f9e1d51d6f825
2025-07-25 22:20:02 +00:00
Serdar Kocdemir 2a57853ab7 Fixes for buffer to image transfer barriers
Fixes pipeline stage bit usage for correct access masks.
Also use variable values rather than constants to ensure correctness
over old/new access masks and layouts.

Bug: 432572558
Change-Id: Ie33c1d56268784cda31d433b5f3bef2db3e66503
2025-07-25 22:20:02 +00:00
Aaron Ruby c7ceec9357 Support guest-side SCREEN_BUFFER_BIT_QNX extMem handleTypes in
translations
2025-07-16 20:05:15 +00:00
Serdar Kocdemir 037d82440c Add missing transfer flag for image barrier
vkCmdCopyBufferToImage also requires transfer write for the image
memory barrier.

Bug: 390345102
Bug: 389637419
Test: emulator with VVL
Change-Id: I5651221afa50a247478151243a983e2353a8a337
2025-06-24 23:54:43 +00:00
Gurchetan Singh ca371e068d gfxstream: use UdmabufCreator
Make sure it's available to the Vulkan decoder if it
is available on the platform.

BUG=423003060
TEST=CI
2025-06-24 00:51:06 +00:00
Jason Macnak 3adb8882e4 Pimpl-ify the host headers
... to break up the circular header imports between the main host
server headers and the underlying GL/VK backend headers. This is
needed to support further imports to internal which is stricter
about header includes.

Additional android CI on ag/33941257

Bug: b/423634910
Test: android build
Test: bazel build
Test: cmake build
Test: meson build
Change-Id: I378640034bc665c07dec5edbd396074d79e94cd6
2025-06-10 20:10:09 +00:00
Serdar Kocdemir 2dec9b9a7c Fix transfer read access for CopyImageToBuffer
Bug: 389637419
Test: run emulator with VVL
Change-Id: Ifcb1cb40e9aceb3a6d4ff81088a75dca2d8879e1
2025-06-04 22:40:43 +00:00
Jason Macnak 12c5235c55 More cleanups for internal build
* Avoid using chrono literals

 * More explicit dependencies

 * Avoid a runtime array in GLEScmContext

 * Fix some usage of std::unordered_set<const char*> which would
   hash the pointer value but not the underlying string contents

 * Adds a couple more files for stubbing android headers

Bug: b/421190493
Test: internal build
Change-Id: I1df7a853e8f20f70b186a3eed68e29b47283e8bd
2025-05-29 16:45:04 -07:00
Gurchetan Singh 0d1f083a7b gfxstream: fix X11 apps again
Follow-up to aosp/3560867.

The current exportMemoryHandle(..) doesn't use the correct Vk
device.  This leads to failures in the export flow.

BUG=406513306
TEST=X11 apps work again

Change-Id: I83ab73a0334481f3226853f4d822267d88db1c71
2025-05-19 13:35:41 -07:00
Jason Macnak c2b159afd1 Move logging to common
and add Android support which uses __android_log_print to
the default callback. This will allow us to eventually build
and run the guest libs in a standalone bazel environment without
Android libs (no "liblog", "libcutils", etc).

Misc notes:

 * Updates some cases of ANDROID vs __ANDROID__. The former is
   set when building with Soong (either host or guest) while the
   latter is set specifically when targeting the Android platform.
   Some places that were using ANDROID needed to be fixed to use
   __ANDROID__ to properly detect when to use ANativeWindow.

 * Updates the EGL platform header to address something similar
   to the above where we may want to use X11 display when building
   host binaries with Soong where ANDROID may still be defined.

Bug: b/416342919

Test: cd hardware/google/gfxstream
      bazel build ...
      bazel test ...

Test: cd hardware/google/gfxstream
      mma

Test: cd hardware/google/gfxstream
      mkdir build && cd build
      cmake .. -G Ninja
      ninja

Test: meson setup \
        -Ddefault_library=static \
        -Dgfxstream-build=host \
        build

      meson compile -C build

Test: cd <emu main dev repo>
      cd external/qemu
      python android/build/python/cmake.py --gfxstream

Test: cd <emu main next repo>
      prebuilts/bazel/linux-x86_64/bazel test \
      --platforms=@//build/bazel/platforms:linux_x64 \
     @gfxstream//...
Change-Id: I4db669047f3900392d50509c470ea350d94a64ba
2025-05-14 16:51:19 -07:00
Jason Macnak af353cc3ad Split utils in host/decoder_common and host/renderdoc
Bug: b/416342919
Test: cd hardware/google/gfxstream
      mma

Test: cd hardware/google/gfxstream
      mkdir build && cd build
      cmake .. -G Ninja
      ninja

Test: meson setup \
        -Ddefault_library=static \
        -Dgfxstream-build=host \
        build

      meson compile -C build

Test: cd <emu main dev repo>
      cd external/qemu
      python android/build/python/cmake.py --gfxstream

Test: cd <emu main next repo>
      prebuilts/bazel/linux-x86_64/bazel test \
      --platforms=@//build/bazel/platforms:linux_x64 \
     @gfxstream//...
Change-Id: I69d93e21e21a53b6f82e336d54bc27381b778ddd
2025-05-13 04:06:40 +00:00
Jeongik Cha 752ac2aba1 gfxstream-vk for Android host
which refers to ag/27239140, added AHardwareBuffer-related code

Flag: com.android.system.virtualmachine.flags.terminal_gui_support
Bug: 400803753
Test: gfxstream
Change-Id: Iaba7636a6fef17d272eb3c00ca646746a2e76040
2025-05-08 06:23:51 -07:00
Jason Macnak cd95e6c655 Move unmap on main looper into AEMU
... as this is AEMU specific.

Bug: b/403363880

Test: cd hardware/google/gfxstream
      mma

Test: cd hardware/google/gfxstream
      mkdir build && cd build
      cmake .. -G Ninja
      ninja

Test: meson setup \
        -Ddefault_library=static \
        -Dgfxstream-build=host \
        build

      meson compile -C build

Test: cd <emu main dev repo>
      cd external/qemu
      python android/build/python/cmake.py --gfxstream

Test: cd <emu main next repo>
      prebuilts/bazel/linux-x86_64/bazel test \
      --platforms=@//build/bazel/platforms:linux_x64 \
     @gfxstream//...
Change-Id: Id9d3cd0fae1b7b8cd1f681b5134a4f43f7e6378b
2025-05-07 02:27:54 +00:00
Jason Macnak b001c743d3 Update non interface parts of Gfxstream to use new base lib
NO_IFTTT=existing field covered with type change

Bug: b/403363880

Test: cd hardware/google/gfxstream
      mma

Test: cd hardware/google/gfxstream
      mkdir build && cd build
      cmake .. -G Ninja
      ninja

Test: meson setup \
        -Ddefault_library=static \
        -Dgfxstream-build=host \
        build

      meson compile -C build

Test: cd <emu master dev repo>
      cd external/qemu
      python android/build/python/cmake.py --gfxstream

Test: cd <emu main next repo>
      prebuilts/bazel/linux-x86_64/bazel test \
      --platforms=@//build/bazel/platforms:linux_x64 \
     @gfxstream//...
Change-Id: I6bfb2c4ef8368799d9f99f6293d9762b7dcb4c7f
2025-05-01 16:29:17 +00:00
Jason Macnak f790204a2f Move vm operations from h/g/aemu to h/g/gfxstream
and split type declarations off into render-utils as this is a
part of the RenderLib interface.

Note: Makes hostmem register/unregister a no-op. These functions connect
to `HostmemIdMapping`. `HostmemIdMapping` has been effectively replaced by
`ExternalObjectManager` (originally `BlobManager`) starting in aosp/2571451
(and that change description even calls out `HostmemIdMapping` should no
longer be needed).

Bug: b/403363880

Test: cd hardware/google/gfxstream
      mma

Test: cd hardware/google/gfxstream
      mkdir build && cd build
      cmake .. -G Ninja
      ninja

Test: meson setup \
        -Ddefault_library=static \
        -Dgfxstream-build=host \
        build

      meson compile -C build

Test: cd <emu master dev repo>
      cd external/qemu
      python android/build/python/cmake.py --gfxstream

Test: cd <emu main next repo>
      prebuilts/bazel/linux-x86_64/bazel test \
      --platforms=@//build/bazel/platforms:linux_x64 \
     @gfxstream//...
Change-Id: Iee4d0dca2143377b266972d2d38ec727a90c3deb
2025-04-22 16:50:16 +00:00
Jason Macnak 1c33a8d747 Update to new logging
Bug: b/403363880
Test: m
Change-Id: I931edf878a023864c7208f69e1eba7393cfce8b6
2025-04-11 14:34:57 -07:00
Jason Macnak a43dfa9f3c Add gfxstream host logging lib
... to eventually replace the existing host-common/logging. This
is needed to break up the circular dependency between aemu-base and
aemu-host-common, so that we can move parts of aemu-base and
aemu-host-common into hardware/google/gfxstream, in order to make
Gfxstream a self contained library for building.

Hooks up the existing host-common/logging via the
RenderLibImpl::setLogger() call.

Bug: b/403363880

Test: cd hardware/google/gfxstream
      mma

Test: cd hardware/google/gfxstream
      mkdir build && cd build
      cmake .. -G Ninja
      ninja

Test: meson setup \
        -Ddefault_library=static \
        -Dgfxstream-build=host \
        build
      meson compile -C build

Test: cd <emu master dev repo>
      cd external/qemu
      python android/build/python/cmake.py --gfxstream

Test: cd <emu main next repo>
      prebuilts/bazel/linux-x86_64/bazel test \
      --platforms=@//build/bazel/platforms:linux_x64 \
     @gfxstream//...

Change-Id: Id52c6f756f85d0a5fb948601228234d7a84a14c2
2025-04-09 13:11:08 -07:00
Serdar Kocdemir ebdb687ca7 Merge changes I6b22f603,Id0497637,I9a964dbb,I9eb0bdea into main
* changes:
  Remove estimation and caching from getStagingMemoryTypeIndex
  Invalidate/flush fixes
  Remove actuallyExternal argument from allocExternalMemory
  Cleanup StagingBuffer usage in VkEmulation
2025-03-31 10:31:58 -07:00
Serdar Kocdemir c6863e5b11 Merge "Refactor ExternalHandleInfo" into main 2025-03-31 10:18:17 -07:00
Serdar Kocdemir 15656e19b6 Remove estimation and caching from getStagingMemoryTypeIndex
This function is generally called only a few times per app and
caching the result can cause issues when the driver requests a
different memory type based on the buffer flags or size.

Bug: 389637419
Bug: 394187789
Test: CI
Change-Id: I6b22f60356a49de1de5add90d888bf37b0d0abd6
2025-03-31 09:20:23 +01:00
Joshua Duong fc1c8b6f14 Merge "[aemu]: do vm unmap in main looper" into main 2025-03-28 17:29:55 -07:00
Serdar Kocdemir 19036727e5 Invalidate/flush fixes
Only invalidate memory ranges when the staging buffer
memory is not coherent.
Add missing vkFlushMappedMemoryRanges call after the
non-coherent memory is updated from the host and remove
unnecessary vkInvalidateMappedMemoryRanges call after
vkCmdCopyBufferToImage is completed.

Bug: 394187789
Bug: 389637419
Test: run XR emulator on AMD, nvidia and moltenvk
Change-Id: Id049763729ae79f01f9673c25fc14bbd37585413
2025-03-28 21:18:00 +00:00
Serdar Kocdemir ded6e028d6 Remove actuallyExternal argument from allocExternalMemory
allocExternalMemory should always allocate external memory.

Bug: 389637419
Test: CI
Change-Id: I9a964dbb47e5d08bf23ca1c7d38576de9638a8fd
2025-03-28 20:33:43 +00:00
Serdar Kocdemir 2daed856d3 Cleanup StagingBuffer usage in VkEmulation
Staging buffer in VkEmulation is used for reading back
and updating color buffer data, and is not actually
allocated as an external memory. CL makes buffer creation
and usage cleaner with a self contained structure, which
can later be used for other staging buffers, or for
implementing multiple staging buffers when needed.

Bug: 389637419
Test: run XR emulator on multiple platforms
Change-Id: I9eb0bdea496539407abb908360414f72c28acba6
2025-03-28 20:27:50 +00:00
Serdar Kocdemir 4f0bcb55cc Refactor ExternalHandleInfo
.. to increase readability and reduce duplicated
functionality around the code base.

Bug: 389637419
Test: CI
Change-Id: Ib838b166a7629f00375cad6beb0a1630d2041986
2025-03-28 16:29:15 +00:00
Bo Hu abd459e84a [aemu]: do vm unmap in main looper
Android Emulator has lockup problem if the vm unmap
is not done on its main looper.

Bug: 405345461

Change-Id: I1ea50df4c2d91ccd829b4cbc9b870f808a782a01
2025-03-27 15:30:36 -07:00
Serdar Kocdemir 550ddd6600 Use reference type for FeatureSet arguments
FeautreSet is a large structure with lots of strings, better
to not copy around unnecessarily.

Bug: N/A
Test: build
Change-Id: I604b4ad7af01f222b54dcda4cd2299e350324f50
2025-03-27 14:47:51 +00:00
Treehugger Robot c6d064d0ab Merge "Fix src access masks for colorbuffer readbacks" into main 2025-03-25 08:15:15 -07:00
Serdar Kocdemir 43400e27fd Fix src access masks for colorbuffer readbacks
Image memory barrier with layout transition should wait for writes to
complete to avoid graphical glitches.

Bug: 405893721
Bug: 394187789
Bug: 390345102
Test: run XR emulator with VVL
Change-Id: I1781cbb5d5c94285c7c2f753f3c116b2c0004165
2025-03-25 06:41:46 -07:00
Serdar Kocdemir 5c89a57836 Enable robustBufferAccess with robustBufferAccess2
Spec requires the device feature to be enabled when using
VK_EXT_robustness2.

Bug: 390345102
Test: CI
Change-Id: I8f702e7b2924a41c850606b80b54736302021538
2025-03-25 13:36:57 +00:00
Treehugger Robot fbf7434421 Merge "Support rgba4 formats for vk color buffers" into main 2025-03-18 21:01:05 -07:00
Serdar Kocdemir 2a6086d347 Support rgba4 formats for vk color buffers
Fixes errors when new system images use rgba4 color buffers.
When using lavapipe, where it doesn't support RGBA4 vulkan format
it uses swizzling on copy to provide the support.

Bug: 389637419
Test: CI
Change-Id: I628f3d1f2a78d5751e1b802f1f2463aa9c515e10
2025-03-19 00:34:10 +00:00
Serdar Kocdemir cea64c0474 Merge "Adjust color buffer log messages" into main 2025-03-18 11:15:48 -07:00
Serdar Kocdemir a4e88ac1f7 Add VulkanRobustness feature
Enables all supported VK_EXT_robustness2 features to avoid
emulator crashes due to invalid application behavior on the
GPU.

Bug: 389637419
Test: -feature VulkanRobustness
Change-Id: I9ae2273cd5f0660a0a739a903ed69f73398027f2
2025-03-17 17:27:46 -07:00
Serdar Kocdemir 9f17ec993d Adjust color buffer log messages
Bug: 399753034
Test: build
Change-Id: Icceaa1c16b1a7db5ed8ce13e5d824e2c5f21dadc
2025-03-14 17:40:45 +00:00
Serdar Kocdemir 35db18236b Enable warnings as errors on cmake builds
And fix various compilation warnings.

Bug: N/A
Test: rebuild
Change-Id: Ife3489b29b1f2822f69d77ce4305b6b31b19d1cf
2025-03-14 14:01:26 +00:00
Serdar Kocdemir 2d6334f949 Fix invalid bind offset calculation
Device alignment should only be used when allocation is
made with extra alignment offset.

Bug: 390345102
Bug: 373601997
Test: CI
Change-Id: I340391f0c448b96ecdeb1f11c58c2841bc385111
2025-03-11 02:02:40 -07:00
Serdar Kocdemir df027e394e Merge "Add AMD into block list for dma_buf" into main 2025-03-06 04:55:26 -08:00
Serdar Kocdemir 35554e6837 Add AMD into block list for dma_buf
Current dma_buf extension usage is invalid and throws
VVL errors on color buffer creation due to usage of
dma_buf external memory handle bit on unsupported
formats. Until we fix the issue, adding AMD into block
list to avoid crash and hang issues.

Bug: 373601997
Bug: 391128661
Bug: 400999642
Test: run XR emulator on AMD linux
Change-Id: Ieac4c12b854d246798922e918d2bebf15d321854
2025-03-05 13:14:46 -08:00
Jason Macnak 4e379d810e Remove the global VkEmulation variable
... and move into FrameBuffer.

Bug: b/383139165
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: Iab139a0793564b21126a66946031caab8a8a6456
2025-03-04 13:03:38 -08:00
Jason Macnak 2df603573d Add GUARDED_BY annotations to VkEmulation
Bug: b/383139165
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: Ic9b393722b971998af62604ea6e4ee1d6d65b7bf
2025-03-04 12:59:49 -08:00
Jason Macnak 17b4107260 Make VkEmulation a class w/ VkCommonOperations funcs
... so that members can start to be protected with GUARDED_BY
annotations and potentially can start to eliminate having a
global `sVkEmulation`.

Bug: b/383139165
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: Iae4dd859991015e386fcc30ef091ccdb7ed1aeb6
2025-03-04 12:56:10 -08:00
Treehugger Robot 1128075474 Merge "Revert "Revert "Revert "gfxstream: stream-renderer: add waitSyncResource...""" into main 2025-03-04 12:22:47 -08:00
Jason Macnak 0d291de9e7 Address some -Wshadow errors
Bug: b/399867568
Test: build
Change-Id: Icfd24779906bea0eb9030705e9b98aed5ffff402
2025-03-03 16:32:43 -08:00