120 Commits
Author SHA1 Message Date
Jason Macnak 2ac5077203 Address some Werror errors from ag/35389434 2025-09-04 19:31:59 +00:00
Serdar Kocdemir 736d96cf48 Enable VK_MVK_macos_surface for host dispatch
To be used in Vulkan composition on macOS.

Bug: 389646068
Test: -feature GuestAngle, VulkanNativeSwapchain
Change-Id: I17bf1392c838d14f1eab5b307c5d0e77dea99b0d
2025-09-04 19:31:59 +00:00
Jason Macnak 81e9cb0616 Add a vkTraceAsyncGOOGLE
... to allow sharing perfetto global flow ids between guest and host
so that combined traces can have an arrow between the guest and host
render threads to aid debugging.

Bug: b/440065361
Test: Capture guest and host trace and inspect in perfetto UI
Change-Id: Id1c34dbee40c8febc9730479d1daed37722fcd09
2025-09-04 19:31:59 +00:00
Bo Hu 6b340cf804 [vulkan snapshot]: handle event save and load
There is currently a problem of missed setevent
and that leads to wait event hangs, or queue becomes
not able to idle, no matter how long it is waited upon.

To solve this problem, this cl follows each event's set,
reset, and save the set status into snapshot.
Later one, during loading, it recovers their set status,
so that subsequent cmd event wait can continue.

specifically, the following steps are taken:
1, set and reset operations from host or
in the queue are tracked.
2, if an event is set, that status will be saved
into snapshot; later during loadiing, the set operation
will be set again from the host or in the same queue
before snapshot.

This is not complete, but it is a first step
to resolve some of the timeout issue.

TODO:
event2

Test: xr should not hang during save due to
queue gets blocked (vkQueueSubmit does not return,
or wait for fence times out)

Bug: 417788798

Change-Id: I991cccfb2f34c6189f6c0759b8abbb365b695719
2025-07-10 23:58:52 +00:00
Serdar Kocdemir 515f98416c Remove unnecessary parentheses in codegen
Improve readability of the code by removing some of the
unnecessary parentheses in the generated code.
(regen auto generated code)

Bug: 329094533
Test: CI
Change-Id: I8c29b49cb58310c70820421e1fd3abea8bd00a92
2025-06-30 20:27:46 +00:00
Serdar Kocdemir 160ecf72d3 Check size for memcpy operations
Avoid nullptr from zero-size allocations being passed
into the copy functions, which is causing UB errors.
(regen auto generated code)

Bug: 329094533
Test: CI
Change-Id: I9d5a76f58585449d333ce56539e877ecb47c63e6
2025-06-17 21:04:07 +00:00
Jason Macnak acda9f92fb Fix strict aliasing violation in VkDecoder
Bug: b/424262482
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: I7443472fdeb4166f7918d00ab3a457ed82407edb
2025-06-12 02:20:48 +00:00
Jason Macnak 39330aa245 Use VkSnapshotApiCallHandle outside of VkReconstruction
... as VkSnapshotApiCallInfo* is a pointer into a
std::vector<VkSnapshotApiCallInfo> which can be invalidated during
multi threaded VK usage when the std::vector<> is resized.

Bug: b/422483825
Test: bazel test common/end2end:gfxstream_end2end_tests \
      --graphics_drivers=gles_angle_vulkan_swiftshader \
      --test_arg="--gtest_filter=*MultiThreadedResetCommandBuffer*VulkanSnapshots*" \
      --test_arg="--gtest_repeat=100" \
      --test_output=streamed
Change-Id: I8ea16eea8792b11056d6d7f17e370f9aa045406c
2025-06-05 17:26:09 +00:00
Serdar Kocdemir 0f6de998fd Autogenerate decoder code for the moved logging header
Bug: N/A
Test: CI
Change-Id: I56086defdc926393df77e4c35bd5794986fc6e80
2025-05-28 08:10:15 +00:00
Jason Macnak f98a2688b9 Merge "Move logging to common" into main 2025-05-15 07:56:40 -07:00
Serdar Kocdemir dfc661e725 Passthrough implementations for vkGetDeviceImageMemoryRequirements
vkGetDeviceImageMemoryRequirements can be used to get memory
requirements without creating an actual image and we should apply the
same image modifications based on the create info when returning the
memory requirements.

Bug: 406456167
Test: dEQP-VK.memory.requirements.create_info.image#regular_tiling_linear
Change-Id: I9176dcc13e467653533cf9434bd2673de05efd63
2025-05-15 08:47:36 +00: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
Serdar Kocdemir f29650f7f5 Regerenate autogenerated code
.. after recent changes on the build script due to xml file
location change.

Bug: 417150515
Test: CI
Change-Id: I04b2e40778fc8f2c832a4c9204a411fe9895dd08
2025-05-14 14:58:34 +01:00
Serdar Kocdemir 60beb01f14 Update vulkan headers to v313
Includes a small change to keep using MTLResource_id
which actually didn't make it into the spec.
A typo fix in vulkansc_raii.hpp
Fixes on end2end tests for vulkanhpp changes.
Change to enable comparison operators on handles even when
the spaceship operator is available, to avoid errors on
old compilers where they are not generated.

Bug: 417150515
Test: CI
Test: dEQP-VK.api.info.vulkan1p2
Test: atest GfxstreamEnd2EndTests
Change-Id: Ic9b9256541dde50b77c4d6d63d277bc222a64157
2025-05-14 12:36:42 +01:00
Serdar Kocdemir 1f77d6a2b8 Mark VK_KHR_ray_tracing_pipeline dispatch only
Bug: 417150515
Test: build
Change-Id: I543e9a24e719700a706a45f3174b8a9b74516beb
2025-05-12 23:55:50 +01:00
Jason Macnak 453d39675a Use Gfxstream's Stream for save/load interface
Moves several of the "common/base" classes to host/backend as these
classes all used `Stream` which is a host only interface.

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: Ia664776c2322b310614f632e4926bb3b031f3bc1
2025-05-07 12:35:25 -07:00
Jason Macnak e107241c14 Update codegen after many aemu -> gfxstream changes
Mostly just formatting changes.

Bug: b/403363880
Test: m
Change-Id: I2c114274ce81a3affda72bd732742679f2a25892
2025-05-02 14:52:58 +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
Serdar Kocdemir f23ba845ff Use logging functions for decoder call tracing
Bug: 389637419
Test: CI
Change-Id: I40fc0594646518b9f73d9e173cabfcc5a1a325f4
2025-04-25 17:08:49 +01:00
Joshua Duong f53f263e18 Notify RenderThreads when guest puid dies.
VkDecoder's seqno logic may get stuck if a guest process dies and
some vk commands don't make it over to the host.

Bug: 410069267
Test: CtsGraphicsTestCases
Change-Id: Ibcf3996ca6a681e1f734c943281b112506bab7ad
2025-04-21 13:36:09 -07:00
Treehugger Robot 64c9cf2424 Merge "Move iostream out of the "server" headers directory" into main 2025-04-15 09:25:25 -07:00
Serdar Kocdemir e401c33ff3 Override sparse image related functions
Disabling sparse binding feature support requires extra changes
on functions like vkGetPhysicalDeviceSparseImageFormatProperties
behavior.

Bug: 407982047
Test: CI
Test: dEQP-VK.draw.*
Change-Id: I45256ba3adae65a0ffd3eb930150d50312d4dd73
2025-04-15 09:32:33 +01:00
Jason Macnak 498ce2c768 Move iostream out of the "server" headers directory
... as this is a host-only impl header and not part of the public
Gfxstream interface.

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: I23d12d7ab4106ae5aa6c6a9fdf164bb644356580
2025-04-14 16:01:12 -07: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 849854f7ec Serialize vkEnumerateInstanceExtensionProperties on linux
This function crashes randomly on XR emulator on linux with
AMD GPUs and avoiding multithreaded operations seems to be a
good workaround until the underlying issue, or the driver bug
is fixed. Since the call is expected to be called rarely, we
don't limit this to aemu or amd.

Bug: 401005629
Bug: 373601997
Test: run XR emulator 20 times, play videos on chrome
Change-Id: Id11eff65b8a2ef33618d903e4499b4856a05209f
2025-03-07 13:24:14 +00:00
Serdar Kocdemir 2870798741 Update generated code for dispatcher checks
Adds validity conditioning before making driver calls
to be able to handle some fatal errors later on.

Bug: 383272733
Test: CI
Change-Id: Ie9898aeb9f15ad5388ee9db21559233eb43b5053
2025-03-06 12:04:08 +00:00
Jason Macnak 25b57c687f Remove extra dispatch variable
... to addresss variable shadowing warnings and handle the 2 global
commands that do not require a dispatch.

Bug: b/399867568
Test: build
Change-Id: Ie8b02e99de934e22a3549bc6ad103c6ac7edb276
2025-03-05 08:02:31 -08:00
Serdar Kocdemir 74fe27f5a5 Wrap semaphore signal and wait calls on the host
vkSignalSemaphores and vkWaitSemaphores calls will require special
handling for virtual queue mode to avoid hangs on singal-after-wait
cases. This CL implements a pass through version of the calls without
making any extra intervention or state tracking.

Bug: 398986781
Test: CI
Change-Id: I85d4a70c222b48b0aea727786152ab492de6b600
2025-03-02 10:54:45 +00:00
Jason Macnak 5c415a358b Remove duplicated boxed handle func declarations
... and fix up include paths.

Bug: b/369615058
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: Ia407b250ae10ff1d9dc99fff32099aca61219d09
2025-02-25 08:08:39 -08:00
Jason Macnak 263fcb6348 Move the handle replay buffer into BoxedHandleManager
... since `BoxedHandleManager` should, well, manager the handles.

This simplifies `VkDecoderGlobalState` a little bit and should also
allow us to remove a bunch of functions that no longer need to
depend on `VkDecoderGlobalState`.

Bug: b/369615058
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Test: cvd snapshot_take --force \
                        --auto_suspend \
                        --snapshot_path=/tmp/snapshot1
Test: cvd reset -y
Test: cvd create --snapshot_path=/tmp/snapshot1
Change-Id: I9d52a12a2fe1e7394259fff0c25075fd50c7cfca
2025-02-25 08:08:38 -08:00
Jason Macnak 53b16ae9b8 Remove unused handling mappers
Bug: n/a
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: I91f0da075372e2f54838f0d96e8b297e400e7750
2025-02-21 12:58:09 -08:00
Serdar Kocdemir 605d570e4c Passthrough tracking for fence status and wait functions
Add vkGetFenceStatus and vkWaitForFences functions to the
global state tracking list for the host.
This CL only implements the entry points for the functions
and should work the same as the non-intercepted versions.

Bug: 388691356
Test: run vulkan apps, presubmit
Change-Id: Ifdc919e77ae2fd9d46fdb0ff4a806f9dbfe2c28b
2025-02-10 10:59:04 -08:00
Serdar Kocdemir 547bb35b4f Track pipeline layouts on decoder
Track pipeline layout creation and destroy calls
to cleanup them correctly on device teardown.

Pipeline layouts require delayed delete operations for
VulkanQueueSubmitWithCommands feature which modifies order
of commands and they need to stay valid during recording.

Bug: 342343008
Test: run and shutdown gltfviewer with VVL
Change-Id: I465a8e3f6ed7e621470f32cdb7cda91ec3dcbba6
2025-01-21 03:17:49 -08:00
Bo Hu 6d8de0cd21 [vulkan snapshot]: clean up un-used ApiCallInfo
Previously, we missed the case where there is no vulkan
call, and ended up with some un-cleaned ApiCallInfo
clogging the entity manager

Bug: 370344466

Change-Id: I56f0261e12b6750036686962179fd5862261a249
2025-01-06 15:20:08 -08:00
Jason Macnak 5d86d48212 Pass VkSnapshotApiCallInfo-s through VkDecoderGlobalState
... so that `VkDecoderGlobalState` can append additional information
needed for snapshotting. Specifically, `VkDecoderGlobalState` may create
additional boxed handles that are not visible directly in the API surface.
For example, `vkCreateDevice()` creates boxed handles for the `VkQueue`-s
and `vkCreateDescriptorPool()` creates boxed handles for pre-allocated
`VkDescriptorSets`. These boxed handles are not recoverable from the API
for `vkCreateDevice()` nor `vkCreateDescriptorPool()` directly. This was
previously worked around by just sticking the extra boxed handles in
`VkReconstruction::mExtraHandlesForNextApi` but this is not thread safe.
Instead, let's give `VkDecoderGlobalState` and `VkDecoderSnapshot` exclusive
access to individual `VkSnapshotApiCallInfo` objects.

Bug: b/383139165
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: I158b12d38584ca964af841e77d1d58a9f6901613
2024-12-12 08:49:24 -08:00
Jason Macnak 201e206613 Simplify ApiInfo
Removes the additional saving of opcode and packet len as this is
all available from within the packet itself.

Removes the "trace" position from `VulkanMemReadingStream` as these
seemed to only be used for getting the packet start and packet size
but these are already available.

Bug: b/383139165
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: I2842c866a0bf10d117a8908fa6a0a94c4b83ac53
2024-12-11 15:30:36 -08:00
Serdar Kocdemir ee3e877d79 The BumpPool of VkStream is not freeAll'ed
Original change from: [email protected] at aosp/3310239
Moving the change into gfxstream and codegen.

The issue was found by [email protected].

Note that vkReadStream's BumpPool is effectively `freeAll`'ed by
`clearPool` calls. The same call for vkStream is not being called
while alloc is called here and there.

Bug: N/A
Test: manual
Change-Id: I478d0ea51c3a73211a3a3a78d3d02a035acab994
2024-12-02 12:03:11 +00:00
Serdar Kocdemir 4e18acff64 Implement queue related wrapper functions
Rerun code generator and implement passthrough versions
of the wrapper functions that'll be used later for multiple
queue emulation support.

Bug: b/327230380
Test: presubmit
Change-Id: I8e2c5042d5205fd942ed3f4a18670355debdc9ad
2024-11-20 10:22:51 +00:00
Joshua Duong 3e073ad037 Update auto-generated comments.
codegen was moved from gfxstream-protocols to mesa3d.

Bug: 377677250
Test: N/A
Change-Id: I56674e2fb312a9faf6f6e42391b08f514f638ec0
2024-11-11 08:15:29 -08:00
Bo Hu d4e8b72113 update VkDecoder to special handle vkCreateComputePipelines
Bug: 342343008

Change-Id: I5854f7dad881ec54d43fedc8773d23635a18cfcb
2024-10-30 05:25:20 +00:00
Serdar Kocdemir 4d94b08137 Fix vkCmdSetLineStippleKHR decoding
Add missing alias for the vkCmd function to the vk.xml to be
able to use it correctly at the host side decoder and subdecoder.

Bug: 357829977
Test: dEQP-VK.dynamic_state.monolithic.line_width.
Change-Id: If81e932ae9527eab8d0b09e2c3446f2f4c526bc6
2024-10-28 19:50:35 +00:00
Serdar Kocdemir 8751452348 Keep VK_EXT_line_rasterization in codegen
Adding the generated code back for the EXT version of the extension.

Bug: 357829977
Test: deqp
Change-Id: Ibe853ace8234fac725c2653805fce48a21d93784
2024-10-28 18:18:27 +00:00
Gurchetan Singh 838dd1d614 gfxstream: rerun codegen from external/mesa3d
With Mesa in the Emulator manifest, all Google projects
can just run codegen from that directory.

It has a deeper Git history, but the biggest win of the
dual upstream strategy is it only implies two levels
of synchronization:

1) mesa -> AOSP mesa (doable via Skia autorollers, other teams do
		      it)
2) AOSP main -> mesa (doable by a rotation of even long-term Gitlab
                      CI bot)

(2) depends on the volume of commits, which data indicates is
5/per month maybe.

BUG=374306378
TEST=CI

Change-Id: I667e2b4518837326c13cbac4af6d6d2ea7402112
2024-10-21 14:22:42 -07:00
Serdar Kocdemir d41a3b97b5 Update autogen for VK_KHR_line_rasterization
With recent mesa related changes, we started using a recent version of
vk.xml and this promoted extension was being used as EXT in our codegen
scripts. This resulted in some code loss, skips on pNext chain of
commands sent from the guest side and eventually CTS/dEQP failures.

Updating vulkan headers partially with this change to accomodate KHR
version of the extension correctly.

Bug: b/357832421
Test: dEQP-VK.api.info.vulkan1p2_limits_validation*
Change-Id: I53fbb2742a846dbce55080deb46f5e4fd46e6c11
2024-10-10 10:57:01 +01:00
Serdar Kocdemir 6d1465b619 Merge changes from topic "fence_opt_revert" into main
* changes:
  Revert^3 "Signal the fence after color buffer copying"
  Revert "Use the right wait object on queue submit"
  Revert "Fix sync issue with fence in queue submit"
2024-10-08 15:33:46 +00:00
Serdar Kocdemir f2e71aa813 Revert^3 "Signal the fence after color buffer copying"
This reverts commit 808604b08d.

Reason for revert: b/357832421#comment7

Change-Id: I2b78f578c242ef2d62191eab01c64bc33f793233
2024-10-08 11:15:20 +00:00
Serdar Kocdemir d1f0966b7c Merge "Add custom decode on fence status and wait functions" into main 2024-10-08 09:41:07 +00:00
Serdar Kocdemir 40e2910e1e Add custom decode on fence status and wait functions
Recent tornado over the codegen and mesa code removals resulted in
some incorrect revert operations and we lost some code. This CL
brings back custom decoding of some fence operations.
Although we actually start using the new codepath, it's still failing
on some deqp tests, and a partial/full revert might be necessary.

Bug: 357832421
Test: presubmit
Change-Id: Ia21674c0c6ab8b7e945cc9b801c301241912ca16
2024-10-07 21:24:15 +01:00
Serdar Kocdemir ba751f1b8e Update decoder.py to use try_unbox on destroy calls
Missing code generator changes for aosp/3272729.

Bug: 333460261
Test: -feature VulkanSnapshots
Change-Id: I0bb6dc04e5f300a2d9f8fb45056d8e24ddf5c95b
2024-10-04 12:24:56 +00:00