Commit graph

172 commits

Author SHA1 Message Date
Albert Liu
dce282e7d9 gfxstream: Add VK_EXT_memory_budget to allowlists. (mesa3d side)
Codegen change.

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35768>
2025-06-26 17:11:41 +00:00
Serdar Kocdemir
7a723331a1 gfxstream: Remove unnecessary parentheses in codegen
Improve readability of the code by removing some of the
unnecessary parentheses in the generated code.

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35580>
2025-06-17 16:13:03 +00:00
Serdar Kocdemir
c77ccd0904 gfxstream: Check size for memcpy operations
Avoid nullptr from zero-size allocations being passed
into the copy functions, which is causing UB errors.

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35580>
2025-06-17 16:13:03 +00:00
Jason Macnak
191fe7e4c4 gfxstream: Update snapshot decoder to handle imageless framebuffer
When `VkFramebufferCreateInfo::flags` has
`VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT`,
`VkFramebufferCreateInfo::pAttachments` should be ignored.

Test: cvd create \
    --gpu_mode=gfxstream_guest_angle_host_swiftshader \
    --gpu_renderer_features="VulkanSnapshots:enabled"

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35580>
2025-06-17 16:13:03 +00:00
Bo Hu
0c1390acfb gfxstream: [vulkan snapshot]: update codegen for vkCmdCopyImageToBuffer
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35580>
2025-06-17 16:13:03 +00:00
Jason Macnak
3bf5347436 gfxstream: Fix strict aliasing violations in VkDecoder
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35494>
2025-06-12 08:48:23 -07:00
Bo Hu
f3e9f0e9a6 gfxstream: update codegen for vkQueueFlushCommandsGOOGLE
This method requires removal of obsolete recording

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35494>
2025-06-12 08:48:23 -07:00
Jason Macnak
7fb8d85c26 gfxstream: 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.

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

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35416>
2025-06-10 16:11:47 +00:00
sergiuferentz
de3361d050 gfxstream: intercept vkCmdClearColor(...) and do linear->SRGB conversion
Reviewed-by: Marcin Radomski <dextero@google.com>
Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:23 +00:00
Serdar Kocdemir
3ade950b6f gfxstream: Fix codegen for the moved logging.h file
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:22 +00:00
Serdar Kocdemir
68e42404b7 gfxstream: Implement private data extension
The logic is implemented on the guest side as we need special handling
for swapchain and device memory handle types.

Memory handles for coherent memory allocations on the guest can map into
a single handle on the host side, which makes it infeasible to pass
through the extension functions with handle remapping. Swapchain handles
are not passed to the host driver, so we need to keep a separate table
for them as well. Instead of separating the logic based on the handle
type, we manage all the private data set/get calls on the guest side
without encoding the commands to the host.

Test: dEQP-VK.api.object_management.private_data.*
Test: dEQP-VK.wsi.android.swapchain.private_data.*

Reviewed-by: Marcin Radomski <dextero@google.com>
Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:22 +00:00
Bo Hu
b6c5a548ad gfxstream: [vulkan snapshot]: update codegen for vkUpdateDescriptorSetWithTemplateSized
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:22 +00:00
Bo Hu
b951324606 gfxstream: [vulkan snapshot]: update codegen to handle failed api calls
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:22 +00:00
Bo Hu
786bd1c6f2 gfxstream: [vulkan snapshot]: update to support vkCmdCopyBuffer
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:21 +00:00
Jason Macnak
eea41d1f86 gfxstream: Update codegen license
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:20 +00:00
Serdar Kocdemir
33ba95cb0c gfxstream: Track vkGetDeviceImageMemoryRequirements on host
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.

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:20 +00:00
Bo Hu
4340dfb400 gfxstream: [vulkan snapshot]: update codegen for vkCmdBindPipeline
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:20 +00:00
Jason Macnak
e7826d89a7 gfxstream: Update GfxApiLogger namespace and header file
... to parallel the changes in ag/33517750.

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:20 +00:00
Bo Hu
464c2e35b8 gfxstream:: update code gen for vkResetCommandPool
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:19 +00:00
Jason Macnak
afab126947 gfxstream: Update gfxstreaml vk xml location
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:19 +00:00
Serdar Kocdemir
ad5f1ed77e gfxstream: Mark VK_KHR_ray_tracing_pipeline dispatch only
VkStridedDeviceAddressRegionKHR structure cannot be correctly
serialized. Update codegen to not use marshalling.

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:19 +00:00
Jason Macnak
3331752323 gfxstream: Remove old include
... no longer needed after the aemu -> gfxstream changes.

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:18 +00:00
Jason Macnak
c0c10744fd gfxstream: Update codegen for aemu -> gfxstream stream 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//...

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:18 +00:00
Bo Hu
3df2a0c061 gfxstream: update sudbdecode snapshot code
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:17 +00:00
Jason Macnak
524d9b0647 gfxstream: Update codegen after many aemu -> gfxstream changes
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:17 +00:00
Jason Macnak
711606dff4 gfxstream: Update codegen to use gfxstream_common_base
... after ag/32953937.

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:17 +00:00
Serdar Kocdemir
5a5810d2f0 gfxstream: Use logging functions for call tracing
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:16 +00:00
Joshua Duong
9bc395fca4 gfxstream: VkDecoder: break from seqno logic when puid dies.
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:16 +00:00
Jason Macnak
30fd362ca7 gfxstream: Update iostream header
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:15 +00:00
Serdar Kocdemir
9ba070a398 gfxstream: Track sparse image related functions
Sparse resources are not commonly available on Android devices
and overriding the functions enables the host to disable the
feature support when needed.

Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:15 +00:00
Jason Macnak
1d4b4fe8b7 gfxstream: Update to new logging
Reviewed-by: Marcin Radomski <dextero@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35323>
2025-06-04 17:24:14 +00:00
Bo Hu
0d3355e41b gfxstream: update code generator for simplified dep graph
Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34418>
2025-04-09 18:29:57 +00:00
Serdar Kocdemir
6cd7b4953c gfxstream: Wrap vkEnumerateInstanceExtensionProperties for host
Due to AMD driver issues on linux, we need to serialize
multithreaded calls.

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34418>
2025-04-09 18:29:57 +00:00
Serdar Kocdemir
c46e8ca4e6 gfxstream: Add dispatcher validity checks
Add conditioning before making driver calls to be
able to workaround some of the fatal errors, such
as unboxing issues during or after snapshot load.
This enables invalidating a host dispatcher based
on the application state. A default error will be
returned for vulkan calls.

Builtin expectation function is used to reduce
performance cost of the checks.

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34418>
2025-04-09 18:29:57 +00:00
Jason Macnak
11bec23bba gfxstream: Remove extra dispatch variable
... to addresss variable shadowing warnings and handle the 2 global
commands that do not require a dispatch.

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34418>
2025-04-09 18:29:57 +00:00
Jason Macnak
e458641516 gfxstream: Update variable names to avoid -Wshadow error
... as vkCmdUpdateBuffer() uses these param names.

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34418>
2025-04-09 18:29:57 +00:00
Serdar Kocdemir
425fe5edf8 gfxstream: wrap semaphore functions on the host
Codegen changes to be able to alter the behavior of vkSignalSemaphores
and vkWaitSemaphores calls on the host side.

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34418>
2025-04-09 18:29:57 +00:00
Serdar Kocdemir
af8b08281b gfxstream: 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.

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34418>
2025-04-09 18:29:57 +00:00
Aaron Ruby
2e15763686 gfxstream: Full emulation support for VK_EXT_image_drm_format_modifier
- Fix the checks for emulation (based on presence of the extension
on the host)
- Add flag in gfxstream_vk_physical_device, otherwise the real device
extensions are not properly filtered when communicating with the host.
- The "function" version of the check in ResourceTracker can eventually
just check the flag once mesa and gfxstream objects are combined
- Remove the duplicate getPhysicalDeviceFormatProperties2 impl, this is
covered by the ResourceTracker impl
- Add ResourceTracker impl for getImageDrmFormatModifierPropertiesEXT
- Remove isDmaBufImage flag from VkImage_info, and clean up all the code
associated with this flag. In on_vkCreateImage, all required info is
avaialble from the extMemImageCi::handleType. In on_vkAllocateMemory,
this is all associated with the tiling of the dedicatedImage for the
allocation

Reviewed-By: Gurchetan Singh <gurchetansingh@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33944>
2025-03-11 20:04:34 +00:00
Aaron Ruby
4197081329 gfxstream: Remove vkGetImageSubresourceLayout ResourceTracker entry
... and the linearPeerImage that was backing emulated drmFmtMod images.

With proper drmFmtMod emulation, the VkImage itself will be
linear-tiled.

Reviewed-By: Gurchetan Singh <gurchetansingh@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33944>
2025-03-11 20:04:34 +00:00
Jason Macnak
14bc2e2d39 gfxstream: Remove duplicated boxed handle func declarations
... and fix up include paths.

Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33740>
2025-02-27 17:37:55 +00:00
Jason Macnak
039e64264a gfxstream: 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`.

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

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33740>
2025-02-27 17:37:55 +00:00
Jason Macnak
4ddd8bd96e gfxstream: Remove unused handling mappers
Not used.

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33740>
2025-02-27 17:37:55 +00:00
Serdar Kocdemir
6bf253b8e8 gfxstream: Add VK_KHR_multiview support
Enable the extension to be advertised for the guest.

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33740>
2025-02-27 17:37:55 +00:00
Serdar Kocdemir
35dd4b4fc2 gfxstream: Track more fence functions on host
Add vkGetFenceStatus and vkWaitForFences functions to the
global state tracking list for the host.
This will allow adding more functionality to the fences
and perform additional operations before waiting for and
signaling them.

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33740>
2025-02-27 17:37:55 +00:00
Sergii Ushakov
3449c3c98a gfxstream: Emulate DMABUF with OPAQUE_FD
Enables software rendering via swiftshader on host side and angle
on guest when using DMABUF based framebuffers.

TEST=Run internal application successfully

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33740>
2025-02-27 17:37:55 +00:00
Jason Macnak
18afdaa168 gfxstream: Move snapshot decoder replay into VkDecoderGlobalState
... to break the recursive behavior of the replay calling into
VkDecoderSnapshot so that locking and thread safety annotations can be
preserved in VkDecoderSnapshot.

Follow up to aosp/3412302.

Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Test: cvd snapshot_take --snapshot_path=<>
Test: cvd create --snapshot_path=<>

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33740>
2025-02-27 17:37:55 +00:00
Bo Hu
0a0a350499 gfxstream: Adding support for VK_KHR_global_priority extension
According to
https://registry.khronos.org/vulkan/specs/latest/man/html/VK_KHR_global_priority.html

This device extension allows applications to query
the global queue priorities supported by a queue
family, and then set a priority when creating queues

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33740>
2025-02-27 17:37:55 +00:00
Eric Engestrom
93a720f81a gfxstream: mark unused variables as such
It's unclear to me whether this is dead code that should be removed or
dead code that should be used, so I just marked it as unused to remove
a few thousand warnings when compiling.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33384>
2025-02-05 19:28:42 +00:00
Eric Engestrom
b2b37cb1de gfxstream: use range variable for its intended purpose
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33384>
2025-02-05 19:28:42 +00:00