49 Commits
Author SHA1 Message Date
Serdar Kocdemir bce675f8d8 Add getBytesPerPixel to format utils
And use in ANB buffer, to cover newly added CTS formats.

Bug: 406456167
Test: CtsNativeHardwareTestCases
Change-Id: I7c254564cc9631e78288737563c6eabb20134e91
2025-09-11 08:25:45 +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
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 479fe517fa Add warning message for unhandled format
Bug: 389637419
Test: CI
Change-Id: I400c32f625ae04faffdfd870cc5adefeee684800
2025-05-06 05:47:39 -07: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 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 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
Serdar Kocdemir 8aaa9f112e Add debug labels to ANB resources
Also initialize rest of the member variables to
sensible defaults.

Bug: 389637419
Test: -feature VulkanDebugUtils && CI
Change-Id: I1e9e72e12fa76e56c4dd58537ce041830fb2b2be
2025-03-28 16:59:35 +00:00
Serdar Kocdemir 5f1d7c9c99 Merge "Fix image creation flags for ANB" into main 2025-03-18 11:13:29 -07:00
Treehugger Robot fbcb607617 Merge "Enable warnings as errors on cmake builds" into main 2025-03-17 16:43:39 -07:00
Serdar Kocdemir aa6f253653 Fix image creation flags for ANB
.. to match the color buffer image creation flags.

And re-introduce the memory requirement size check when
importing the color buffer.

Bug: 399753034
Test: run XR emulator on Mac
Change-Id: Idde9b2c3133e8af8755ac4fd940b2bea651e7341
2025-03-14 17:34:22 +00:00
Bo Hu 09bf0a40ca avoid using un-initialized queue family index in VkAndroidNativeBuffer
The uninitialized queue index value 0xffffffff will cause memory allocation
error, and chain effect afterwards.

Test: deqp wsi.

Bug: 403543880

Change-Id: I6c05472ef3803329de7bcebc067cad0b79d83a7d
2025-03-14 09:46:02 -07: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
Treehugger Robot 94bde73556 Merge "Adjust level of some log messages" into main 2025-03-11 07:53:29 -07:00
Serdar Kocdemir 4a835a1d49 Adjust level of some log messages
Bug: N/A
Test: build
Change-Id: I02f2b8a34ac2a81dc6e0ea4a245aa8cf350d7eae
2025-03-11 08:57:23 +00:00
Jason Macnak fbf28d2e20 Convert AndroidNativeBufferInfo to a class
... and use `m<VARIABLE_NAME>` for members to avoid a bunch of
compile errors when building with `-Wshadow`.

Bug: b/399867568
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: I1084a6db63090a0db5917f4e138902b3b452a642
2025-03-05 09:11:05 -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
JP Cottin 0f7cdc9ba1 Workaround the issue in b/399729237 instead of reverting the complete CL
Bug: 399729237
Change-Id: I5143d0d51557dbddd35737a278769245fccf5866
2025-02-27 18:10:26 -08:00
Jason Macnak bea594a41e Validate memory size on color buffer import
... to make Gfxstream more resilient to issues like b/397754921
where an invalid AHB was being included in a swapchain.

Bug: b/397754921
Test: cts -m CtsUiRenderingTestCases
Change-Id: Ic8087abbcab0cb884ece30cce7aca71576dfeb6c
2025-02-26 11:58:03 -08:00
Erwin Jansen b91d745f66 Fix: Address c++11-narrowing warning
Explicitly cast getDefaultExternalMemoryHandleType() to
VkExternalMemoryHandleTypeFlags to resolve the c++11-narrowing
warning.

This makes sure we can complete the qemu-next presubmit.

Change-Id: I80dfb1cf87521e0f95524698e0bef25d2f5fd345
2024-12-18 12:59:01 -08:00
Aaron Ruby de3627544f Revert^2 "Remove VK_EXT_MEMORY_HANDLE_TYPE_BIT entirely"
ef4e6b9b10

Change-Id: I059433a5edb56624ea52f2f041ddbe56465d885d
2024-12-18 10:46:19 -05:00
Aaron Ruby 4202c1bd5d Revert "Revert "Simplify the Vulkan external memory import code ..."
Revert submission 3414268-revert-3393388-extmem-refactor-dec-5-BQXYSDRQMH

Reason for revert: Fixing the MacOS issue that required the original revert of the recent changes.

Reverted changes: /q/submissionid:3414268-revert-3393388-extmem-refactor-dec-5-BQXYSDRQMH

Change-Id: I81fbb3263488f69aec16e5ffd9c6008d9ac670bf
2024-12-18 10:46:19 -05:00
Lars Harrison ce92b04fb0 Merge changes from topic "revert-3393388-extmem-refactor-dec-5-BQXYSDRQMH" into main
* changes:
  Revert "Use a common GenericDescriptorInfo struct"
  Revert "Add new STREAM_MEM_HANDLE_TYPE_SCREEN_BUFFER_QNX handle_type"
  Revert "Simplify the Vulkan external memory import code for all ..."
  Revert "Remove VK_EXT_MEMORY_HANDLE_INVALID entirely"
  Revert "Remove VK_EXT_MEMORY_HANDLE_TYPE_BIT entirely"
2024-12-13 19:04:35 -08:00
Lars Harrison 8cc2109d82 Revert "Simplify the Vulkan external memory import code for all ..."
Revert submission 3393388-extmem-refactor-dec-5

Reason for revert: b/384041851 (+gap in test coverage)

Reverted changes: /q/submissionid:3393388-extmem-refactor-dec-5

Change-Id: I8cdfdfd5042dadac4a8c8a76a79a6c8f3451bcda
2024-12-13 14:53:16 -08:00
Lars Harrison ef4e6b9b10 Revert "Remove VK_EXT_MEMORY_HANDLE_TYPE_BIT entirely"
Revert submission 3393388-extmem-refactor-dec-5

Reason for revert: b/384041851 (+gap in test coverage)

Reverted changes: /q/submissionid:3393388-extmem-refactor-dec-5

Change-Id: I84ee3a84f289530f2c9713b0330f14b6eadb18e8
2024-12-13 14:53:16 -08:00
Jason Macnak 56ccd57341 Use std::mutex for queue locks
... and drop "physical" from the name as queues are not physical
things.

Bug: b/383139165
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: Ie04098d37f732d4a1d2973925ee7155e704f3c34
2024-12-12 11:34:59 -08:00
Aaron Ruby 003eaba5dd Remove VK_EXT_MEMORY_HANDLE_TYPE_BIT entirely
Replace with a helper function to determine the default handleTypeBits
to use for external memory

BUG=382442209
TEST=sanity on Android14, Yocto w/ gfxstream
NO_IFTTT=doesn't affect snapshot

Change-Id: Ie1f6fe1e093154b80f82ec436c1510baf8782187
2024-12-09 13:39:23 -05:00
Aaron Ruby bdc03cb155 Simplify the Vulkan external memory import code for all platforms
- Use ExternalMemoryHandle instead of VK_EXT_MEMORY_HANDLE, wherever
possible
- Make the dupExternalMemory internal to VkCommonOperations
- Make the Buffer and ColorBuffer getExtMem functions do the dup instead
- Resolve references and nomenclature for handleType/streamHandleType

BUG=382442209
TEST=Sanity on Android14 (ANGLE and gfxstream-gles backend), Yocto w/ gfxstream-vulkan
NO_IFTTT=doesn't affect snapshot

Change-Id: I9d56d058ed891ec036220aca90a54bd7a1dbaaa6
2024-12-09 13:35:59 -05:00
Serdar Kocdemir db0a4fe098 Do resource teardown after the queues
Ensure we wait for queue idle before destroying vulkan resources for
Android native buffers.

Bug: 379178011
Test: presubmit, run with -feature GuestAngle
Change-Id: Ic67e04d10d2c4df795557fa49e915b8c46f6f53d
2024-11-26 20:14:35 +00:00
Serdar Kocdemir f5c82b12c7 Merge "Replace stderr logging with appropriate logger routines" into main 2024-10-28 10:38:42 +00:00
Serdar Kocdemir 79a5203c74 Use VK_EXT_external_memory_metal on MoltenVK mode
Use the new external memory extension for the management of
external images and buffers. Previous extension and usage was
depending on some workarounds on managing metal objects which
was causing issues with the usage of VVL.

Requires a new version of MoltenVK prebuilts/binaries.

Bug: 349066492
Bug: 368409646
Bug: 351765838
Test: -gpu host -feature GuestAngle
Change-Id: I47f0f13bde9d7e3dc95da1af3673deac649745d7
2024-10-25 12:16:13 +01:00
Serdar Kocdemir 3d6cf83caa Replace stderr logging with appropriate logger routines
Usages of fprintf(stderr,..) causes various issues when dealing with
bugs. Replacing them with appropriate versions to ensure they are
collected with any extra information needed and to avoid AS thinking
there were a crash.

Bug: 374311144
Test: build and presubmit
Change-Id: I6893a8df753ddfcc27f28dfd2bd828e53f3f32b3
2024-10-25 08:36:03 +00:00
Jason Macnak ec0ea4de67 Avoid sharing ownership of ANativeBufferInfo w/ SyncThread
... and instead track when SyncThread is done with the use of each
ANativeBufferInfo.

Prior to this topic, VK process cleanup could race with SyncThread
destruction. The process cleanup could destroy a VkInstance/VkDevice
while SyncThread still has a reference via the
std::shared_ptr<AndroidNativeBufferInfo> in
waitForQsriFenceTask. This could result in crashes or locks when
the final reference to the AndroidNativeBufferInfo happens during
SyncThread's desturction and
AndroidNativeBufferInfo::QueueState::teardown() happens after
the device was already destroyed.

Bug: b/360379616
Test: cvd start --gpu_mode=gfxstream_guest_angle_host_swiftshader
Test: atest com.android.cuttlefish.tests.FastbootRebootTest \
        --rerun-until-failure
Test: wait 30 minutes
Change-Id: I099bafbf4ecef26ca02a10afc97400732ed47935
2024-09-18 14:39:45 -07:00
Jason Macnak 9bc12d915e Add perfetto tracing to host renderer
... to aid debugging.

Bug: b/364967041
Test: cvd start --gpu_mode=gfxstream_guest_angle_host_swiftshader
Test: perfetto capture and open in ui.perfetto.dev
Change-Id: Ieda7f9ce8d0a0923a989cd201438819568cab140
2024-09-05 17:24:05 -07:00
Jason Macnak 58b1c700e5 Use callback in VkAndroidNativeBuffer
... to help break cicular dependency between FrameBuffer and the
backends.

Bug: b/360379616
Test: build
Change-Id: Ia20a59de8ea08faca92f20c15e4b3b2240ccb2c2
2024-08-23 14:43:51 -07:00
Aaron Ruby 52cef357e8 gfxstream: Replace GuestUsesAngle nomenclature with GuestVulkanOnly.
As this flag now applies with Linux+Zink as the GL translation as well.

Change-Id: I8f648ebe845a251f7c32479ad7bf87ee02a14ce3
2024-07-02 13:31:23 -04:00
Serdar Kocdemir 47eb1d243a Implement metal_objects for MoltenVK
Using metal_objects extension for MoltenVK
to avoid using the deprecated and unsafe old API
and fix AHB and external memory related issues.

Bug: 333460957
Test: build and run with -use-host-vulkan, with VVL disabled
Change-Id: If1269359a7b4a7f8a4746c8ca698eb8838aebb9a
2024-06-25 19:54:38 +01:00
Serdar Kocdemir 381a42396a Use VK_WHOLE_SIZE for mapping ANB staging memory
Avoid invalid usage when invalidating the mapped memory range
with whole size of the buffer, which might be different than
the requested allocation size.

Bug: 333460957
Test: build and run with VVL
Change-Id: I422f6b7c57d7b3210c8e982ca416b6f6451870ab
2024-06-17 13:21:57 +00:00
Serdar Kocdemir 89940c0671 Remove binding structure from ANB image creation chain
Similar to VkNativeBufferANDROID, we should also remove
VkBindImageMemorySwapchainInfoKHR structure from the
createinfo chain when preparing the ANB images based on
memory binding parameters.

Bug: 333460957
Test: dEQP-VK.wsi.android.swapchain.*
Change-Id: I051fdb1aa2b7d46cfa6c7f97e1dfab1dfe4b67df
2024-06-17 14:21:04 +01:00
Serdar Kocdemir 550f713d8d Allocate staging buffer based on its own memory requirements
Fixes invalid usage of image memory size directly for the
allocation of the staging buffer for Android native buffers.
Staging buffers might require bigger sizes.

Test: Run with -guest-angle and VVL
Change-Id: Ib2d95ad04b5180b2e4e41a619c55157a23e8526c
2024-06-05 12:51:23 +00:00
Erwin Jansen b45c014871 Enable GFXStream bazel build
This builds the "standalone" GFXStream library that can be consumed by
Qemu 8.2

The bazel build allows us to transition rutabaga to a bazel based
build, which will unify the Qemu 8.2 build as used by the emulator.

It also opens up the path to migrate this to g3 if we decide to do this.

This change forces a few header changes, as bazel is more strict about
the relationship between headers and packages, and doesn't easily give
you fine grained control over the include paths.

Change-Id: I3566d69f10c534f1176fa92eaa7f5f12ec0bcd4f
2024-03-20 18:21:20 -07:00
Aaron Ruby fb4e96b3df gfxstream: VkNativeBufferANDROID flow only requires ext-mem import, not export.
Title says it all.

BUG=328436383
TEST=compile

Change-Id: Id7d5cb7bb863ea1063f448031f54a8b3252aadfa
2024-03-08 11:56:06 -08:00
Jason Macnak 5c76bdb518 Adds vk debug annotations for more host objs and renderer ops
... to aid debugging.

Bug: b/165022040
Test: export VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_api_dump
Test: cvd start --gpu_mode=gfxstream_guest_angle
Test: cvd start --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: Ib96bdba9a380e2a703062dc91f3abdf975b57c77
2024-01-30 10:52:57 -08:00
Aaron Ruby 4fc86edae8 gfxstream: Add Vulkan external memory resource import implementation for host.
Developed for QNX use-case, but applies generally to any
platform that supports external memory for import but not for
export.

Some robustness around VK_QNX_external_memory_screen_buffer API
usage added with the updateExternalMemoryInfo() function.

BUG=319510663
TEST=compile && launch_cvd --gpu_mode=gfxstream_guest_angle

Change-Id: I7b10b70da024df60881c8b27ea29bd44101b95f6
2024-01-16 15:53:20 -08:00
Gurchetan Singh a2bb14fcba gfxstream: use absolute path for some code
Some code may be auto-generated, some may not be.

Eventually we want to move autogenerated code into specialized
directories, so it be generated but not necessarily checked
in [for certain cases].

Also, nuke codegen for CMakeLists.txt: we have multiple other
build systems now (Blueprint, meson), and it doesn't make
sense codegen one anymore.

BUG=296903491
TEST=compile

Change-Id: I63beff1726074268188694fbfeb803429ee96478
2024-01-04 17:23:05 -08:00
Yahan Zhou 4e831407f4 Initialize AHB queueState before using it
Bug: 300276632
Test: dEQP-VK.wsi.android.maintenance1.*
Change-Id: Ie2d46c36f59c4d7561ae5d93af130ae04323a496
2023-10-17 23:14:15 +00:00
Yahan Zhou 1c3da73640 Update vk.xml and code generator
This commit updates vk.xml and code generator to make them backward
compatible. The updates in code generator includes:

 1. Parse "protect" properly.
 2. Ignore "optional" if the "optional" was added in newer vk.xml.
    - This is done by having an extra table for related fields.
 3. Parse latexmath properly.
 4. Parse "supported" properly.
 5. Skip parameters and members if they are not for Vulkan API.
 6. VkNativeBufferANDROID diverged from upstream, keep the old one.

Bug: 293346694
Test: rebuild and run aemu with older system images
Change-Id: I72dad62bcbeb041bb49f1a6467ec5af2a1ef7960
2023-08-16 15:03:00 -07:00
Jason Macnak 648a9edc06 Rename stream-servers to host
Bug: b/271464937
Test: m
Change-Id: I89553dfe2e27170e1e968e234b364f13e76b2f88
2023-05-19 15:09:46 -07:00