Commit graph

188 commits

Author SHA1 Message Date
Gurchetan Singh
4f9d7c3385 gfxstream: codegen: don't generate custom protocols in function table
vulkan_gfxstream.h contains custom protocols not found
in vk.xml (vk_gfxstream.xml).

gfxstream_vk_entrypoints.h is codegen by Mesa common code,
and it does not accept the custom XML.

So avoid generating implementations for them:

guest/vulkan_enc/gfxstream_guest_vk_autogen_impl/gen/func_table.cpp:5321:1:
note: declare 'static' if the function is not intended to be
      used outside of this translation unit
 5321 | void gfxstream_vk_CollectDescriptorPoolIdsGOOGLE(
      | ^
      | static
fatal error: too many errors emitted, stopping now [-ferror-limit=]

Reviewed-by: David Gilhooley <djgilhooley.gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38632>
2025-11-25 09:12:15 -08:00
Jason Macnak
deb48556dc gfxstream: codegen changes for new filenames and namespaces
Bug: n/a
Test: build + CI

Reviewed-by: David Gilhooley <djgilhooley.gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38153>
2025-10-30 15:27:26 +00:00
Gurchetan Singh
a85e9b8d8a gfxstream: fix build after VK 1.4.33.0 spec update
The root cause is "Add initial Vulkan Base support", which refactors
Vulkan versions into smaller features (base + graphics + compute).
Not sure if this is the cleanest solution, but someone needs to
refactor gfxstream codegen anyways.

There's also can issue with VkRenderingArea.

Fixes: 61c71733c8 ("vulkan: update spec to 1.4.330")
TEST=libgfxstream_vulkan.so + gfxstream_backend.so (host) commpiles
     with new changes

Reviewed-by: David Gilhooley <djgilhooley.gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38153>
2025-10-30 15:27:26 +00:00
Gurchetan Singh
cd06ec1dcb gfxstream: codegen: remove CheckOutOfMemory
Nobody uses it.

Reviewed-by: David Gilhooley <djgilhooley.gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37855>
2025-10-20 15:45:07 +00:00
Gurchetan Singh
af6ff36379 gfxstream: codegen: add vkTraceAsyncGOOGLE to GLOBAL_COMMANDS_WITHOUT_DISPATCH
Otherwise the codegen output fails to compile.

Reviewed-by: David Gilhooley <djgilhooley.gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37855>
2025-10-20 15:45:07 +00:00
Jason Macnak
03a4d7ff7e gfxstream: Address some Werror errors from ag/35389434
Fix things.

Test: github CI

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37410>
2025-09-16 23:26:27 +00:00
Serdar Kocdemir
f1c1dc66d4 gfxstream: Enable VK_MVK_macos_surface for host dispatch
To be used in Vulkan composition on macOS.

Test: -feature GuestAngle, VulkanNativeSwapchain

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37410>
2025-09-16 23:26:27 +00:00
Jason Macnak
46bfb31d7f gfxstream: 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.

Test: Capture guest and host trace and inspect in perfetto UI

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37410>
2025-09-16 23:26:27 +00:00
Aaron Ruby
c3533e49ab gfxstream: Prune all guest-side KHR entrypoints that are provided with VK_VERSION_1_1
vk dispatch in mesa provides the redirection for this. Also, other
recent changes have increment the minimium host requirement for
gfxstream-vk to VK_VERSION_1_1, anyways.

Reviewed-by: Gurchetan Singh <gurchetansingh@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36942>
2025-08-27 16:40:44 +00:00
Bo Hu
4ebda87b49 gfxstream: [vulkan snapshot]: update code gen for vkUpdateDescriptorSet change
Update codegen

Reviewed-by: David Gilhooley <djgilhooley.gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36826>
2025-08-19 10:46:16 +00:00
Jeongik Cha
3e39c09aa0 gfxstream: Generate goldfish dispatch code for AHB extension
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36510>
2025-08-01 18:34:15 +00:00
Aaron Ruby
89ccc8ba2b gfxstream: Pre-fetch the VkQueue objects from the host
.. and refactor vk_queue initialization entirely to store the queue
information at device-creation time.

Reviewed-by: Gurchetan Singh <gurchetansingh@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36330>
2025-07-24 15:58:30 +00:00
Aaron Ruby
b1f6b76f85 gfxstream: Remove on_vkGetDeviceQueue* impls entirely
The VkQueue_info::device field is not actually needed anywhere.

Reviewed-by: Gurchetan Singh <gurchetansingh@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36330>
2025-07-24 15:58:30 +00:00
Aaron Ruby
525513fd23 gfxstream: Modify deviceName, driverVersion, driverName, driverInfo ...
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
... to report that Vulkan is running through a gfxstream driver to the
host driver. This matches what Venus does.

TODOs added for driverID, need spec'd driverID for gfxstream in Mesa.

Example:

Device Properties and Extensions:
=================================
GPU0:
VkPhysicalDeviceProperties:
---------------------------
        apiVersion        = 1.3.0 (4206592)
        driverVersion     = 525.147.5.0 (2204418368)
        vendorID          = 0x10de
        deviceID          = 0x1fb9
        deviceType        = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
        deviceName        = Virtio-GPU GFXStream (Quadro T1000)
        pipelineCacheUUID = 5e84b6ed-4e70-35e3-a855-d75f23b64fd5

VkPhysicalDeviceDriverProperties:
---------------------------------
        driverID        = DRIVER_ID_NVIDIA_PROPRIETARY
        driverName      = gfxstream
        driverInfo      = Mesa 25.1.0
        conformanceVersion:
                major    = 1
                minor    = 3
                subminor = 3
                patch    = 1

Reviewed-by: Gurchetan Singh <gurchetansingh@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36290>
2025-07-23 17:26:25 +00:00
Aaron Ruby
ae904e11a8 gfxstream: init vk_queues in CreateDevice() based on queueCreateInfo
... and defer getDeviceQueue impl to vk_common and trim down impls in
gfxstream.

gfxstream advertises, and selects queues/queueFamilies from what the
real device on the host advertises. During createDevice(), it needs to
allocate the queue objects to support this.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36227>
2025-07-18 18:49:37 +00:00
Bo Hu
f146a3a13a gfxstream: update codegen for event save and load
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run
Event save and load codegen.

Reviewed-by: Aaron Ruby <aruby@qnx.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36047>
2025-07-16 17:03:43 +00:00
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