181 Commits
Author SHA1 Message Date
Serdar Kocdemir d369c80352 Fix some log messages
Fix print format for matrix types in rc encoder.
Make sure decoder and dispatch logging can be enabled.

Bug: 420586022
Test: Enable extra logging manually
Change-Id: Ic75fb9393ea08dfa4f485611225eb5680cf6e44e
2025-07-25 22:20:02 +00:00
Serdar Kocdemir 0a0ba2b54b Add new render control functions for display color transform
New rc functions will be used from the host compositor to set a display
color transform matrix is given. This feature is used when the matrix is
set explicitly on surface flinger, or when using accessibility color
features, such as color blind modes. New functionality is added into
generate-apigen-sources code generator code to handle matrix data type.

New functions
* rcGetDisplayColorTransform: Get the matrix for the display
* rcSetDisplayColorTransform: Set the matrix for the display

Bug: 420586022
Test: Set color accessibility options in emulator
Test: ./scripts/generate-apigen-sources.sh
Change-Id: I21fa4bb4b5bbc6038f464f68c4c63eb50e46411c
2025-07-25 22:20:02 +00:00
Jason Macnak 0220d94cc9 Remove codegen cmake after https://github.com/google/gfxstream/pull/28 2025-06-12 16:44:27 +00:00
Jason Macnak 14bffb8712 Use std::memcpy for opcode and packet len
... to avoid strict aliasing violations.
2025-06-11 23:10:29 +00:00
Jason Macnak 31adc8a3e6 Minor codegen changes
* Pragma macros are typcially not indented

 * Use GFXSTREAM_ERROR instead of fprintf

 * Update the run command in the header comments
2025-06-11 23:10:29 +00:00
Jason Macnak b595177715 Update apigen to avoid strict aliasing violations
The `tmpBuf` pointer may not necessarily meeting the alignment
requirements of the return value type.
2025-06-11 23:10:29 +00:00
Jason Macnak 900317596d Cleanup apigen
* Switched to snake case for filenames since there was a mix

 * Clang-format

 * Bazel support for binary and tests
2025-06-11 23:10:29 +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
Jason Macnak 233de0f143 Move vulkan xml into thirdparty
Bug: b/416342919
Test: n/a
Change-Id: I7662ee031c2e8ecd894c8714dd00c2d74673a53c
2025-05-12 22:45:56 +00:00
Jason Macnak d905d112f6 More release tool findings
* Delete getopt and replace with simple string arg parsing.

* Remove unused windows files.

Bug: b/416342919
Test: n/a
Change-Id: Ic30a6321308b5d062df7eb906ad0e646cd2a7d69
2025-05-12 22:45:46 +00:00
Jason Macnak f96a59449c Add license headers to our cmake files
... as this is flagged by the release checker.

Bug: b/403363880
Test: n/a
Change-Id: I3743a2e710ddf7dfd196cb7d53f25eeaeab921f0
2025-05-08 13:50:49 -07:00
Jason Macnak d2de457391 Add apache header to apigen sources
Bug: b/403363880
Test: n/a
Change-Id: I88968b9231ed387dfe752760d9321a29997a7b0e
2025-05-08 12:21:45 -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 4b4e852b36 Cleanup references to host-common
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: I6765726663c333cd8dbbf3223e8960bec5d224d9
2025-04-28 13:06:02 +00: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
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 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 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
Gurchetan Singh 08f5c21ebc gfxstream: fix scripts/generate-gfxstream-vulkan.sh
Mostly just change the locations of directories.

One exception is aosp/3271678, which needs to land in the
Mesa codegen directory.

For workflows without an AOSP tree, one can just pass in
the path to Mesa tree.

Mesa uses a newer version of vk.xml than the host does,
so some changes are observed.

BUG=369200554
TEST=generate-gfxstream-vulkan.sh in AOSP

or

cd ~/
git clone https://gitlab.freedesktop.org/mesa/mesa.git
cd ${gfxstream_dir}
./scripts/generate-gfxstream-vulkan.sh ~/mesa

Change-Id: I5a023ed4d8788a31f352d017f321656c7b7a7410
2024-09-25 08:56:30 -07:00
Gurchetan Singh ff5d0a45ab gfxstream: move guest vulkan to Mesa
This moves gfxstream to Mesa.

BUG=329882826
TEST=CI

Change-Id: Ib8c7f251574c7d4ab54fe09fbb351bd0b08ab837
2024-09-23 08:08:14 -07:00
Serdar Kocdemir 9d85314d53 Add VkPrivateDataSlot handle type for codegen
Private data slot types are required to support VK_EXT_private_data
extension. dEQP tests require some additional changes for handle
remapping over uint64_t types, which will be submitted later.

Bug: 368009403
Test: codegen & build & presubmit
Change-Id: If97478293fd8009a4279861fcbd780069708ab0f
2024-09-23 10:26:26 +00:00
Treehugger Robot 3c69e0cc07 Merge "[Vulkan Snapshot] Add dependency graphics pipeline -> render pass" into main 2024-09-19 11:11:12 +00:00
Yahan Zhou f4551c0011 [Vulkan Snapshot] Add dependency graphics pipeline -> render pass
Bug: 333460261
Test: manual
Change-Id: Ia2b891a001743a836f21d9fb683cd3ab12073cbc
2024-09-18 15:09:15 -07:00
Gurchetan Singh fb45d77edd gfxstream: moar relicense
Moar relicense.

BUG=367357743
TEST=CI

Change-Id: I5e1e74ffbb1a5b837fa686902c62594a6eed0ea6
2024-09-18 07:59:57 -07:00
Treehugger Robot 9200414d9f Merge "Add VK_EXT_external_memory_metal definitions" into main 2024-09-18 11:05:36 +00:00
Gurchetan Singh 4f8febda59 gfxstream: simplify codegen
This simplifies the amount of code imported from Vulkan
docs.  It vendors the code to just a subset needed by
the cerealgenerator.  The files that are kept are:

    - generator.py
    - cgenerator.py
    - reg.py
    - genvk.py

Since these files originate with Khronos, they are
Apache licensed.

Long-term, there are various ideas on how to proceed
with codegen.  Probably the above files can be nuked
in the event some of those ideas come to pass.

BUG=296903491
TEST=./generate-gfxstream-vulkan.sh

Change-Id: I55842e778af9b71ceab2dcaf1c2d7aafebe86b14
2024-09-17 09:31:46 -07:00
Serdar Kocdemir a3b628b880 Add VK_EXT_external_memory_metal definitions
Partial update to vulkan headers and auto generated code to
include the new extension. It will be used to fix issues on
external memory implementation with MoltenVK later on.
References:
Khronos MR 6800
MoltenVK PR 2314

Bug: b/349066492
Test: build & presubmit
Change-Id: I91f0e6c73bfa3c8c13b8008b7913d72fda371403
2024-09-17 11:26:08 +01:00
Gurchetan Singh 85bf811687 gfxstream: re-license cereal
While cereal implements an API provided by Khronos Apache 2.0
files, the files were started in AOSP, and can be relicensed to
MIT.

BUG=367357743
TEST=CI

Change-Id: Ic621270619df68384edbd06f4537b3c4f22a40fa
2024-09-16 21:07:45 +00:00
Gurchetan Singh 627cc7bc28 gfxstream: delete unneccessary code
genvk.py itself includes different types of generators:
spirvgenerator.py, rubygenerator.py, etc.  cerealgenerator.py
is an additional one.  A strategy to pare down the size of
the code would be modify genvk.py to remove unneeded generators,
and just import the cerealgenerator: i.e, importing the subset
of scripts useful to gfxstream.

The removes the notion of upstreaming to vulkan-docs, but does
imply more dedicated codegen strategy long-term.  

About 300kLoC can be removed, since previously we just a blanket
copy.

BUG=296903491
TEST=CI

Change-Id: Iabaadb948220ec1ab1283fa58f1b151492103388
2024-09-13 11:59:22 -07:00
Gurchetan Singh 37ba9ba374 gfxstream: codegen: don't require clang-format
When auto-generating at build time, this causes
problems for AOSP:

https://android.googlesource.com/platform/build/+/main/Changes.md#PATH_Tools

Don't require via environment variable.

BUG=296903491
TEST=CI

Change-Id: If84107bbf87e9c98cbd3ada8a6d5338fd7e989b2
2024-09-13 11:59:07 -07:00
Gurchetan Singh 74b2d3bcef gfxstream: don't assert without host
When invoking the build in the guest, we don't need
to define this.

BUG=296903491
TEST=run autogen

Change-Id: I76142ff973ea2243bf9052c1dfbc3868bb0e58b0
2024-09-13 11:58:19 -07:00
Treehugger Robot 27e3c2240f Merge "Revert "Signal the fence after color buffer copying"" into main 2024-09-12 20:11:19 +00:00
Yahan Zhou a9f55412d7 Revert "Signal the fence after color buffer copying"
This reverts commit dd5c7b6aeb.

Reason for revert: b/366153044

Change-Id: Ica249648af206a8d75fcc81703a8283689ab7e95
2024-09-12 18:52:08 +00:00
Yahan Zhou 9477dc845e Merge "Signal the fence after color buffer copying" into main 2024-09-11 16:27:37 +00:00
Yahan Zhou dd5c7b6aeb Signal the fence after color buffer copying
We move the fence signaling to after color buffer copying. This is done
by reusing the existing CPU CV object and wait on it before triggering
the GPU vkWaitForFences.

Also rewrite fenceInfo.status with std::future to simplify the code.

Design: go/emu-async-cb-copy
Bug: 3250107
Test: GfxstreamEnd2EndTests#MultiThreadedResetCommandBuffer
Change-Id: Id956eb75f4b99e904f0ab82f2edaa1e134e07f2c
2024-09-10 14:06:07 -07:00
Jason Macnak 5408a830e0 Merge "Add perfetto tracing to host renderer" into main 2024-09-09 15:50:14 +00: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 16ff26e7ba Handle external fences in vkGetFenceStatus()
The vkGetFenceStatus() call can not be sent to the host for fences
that have imported an external payload (sync fd) because the sync
fd does not exist on the host. A fence used as part of a swapchain
present may be created in the unsignaled state. Then, during
vkQueuePresentKHR() on Android, vkQueueSignalReleaseImage() is used
to import a sync fd payload into the present fence. Prior to this
change, if the user (ANGLE) does vkGetFenceStatus() on this fence,
it would never appear as signaled because the sync fd fence is not
actuallly connected to the fence on the host and the host would just
always return the VK_NOT_READY from the fence's initial unsignaled
state.

This change also updates VkFence_Info to use a std::optional<int>
to make it possible to distinguish if a fence has an imported
already-signaled payload vs not having an imported payload.

Bug: b/362313516
Test: cts -m CtsGraphicsTestCases
Test: GfxstreamEnd2EndTests
Change-Id: I41f3c452937bb11c93c491b716e6f1947c2b7cdf
2024-09-05 21:42:15 +00:00
Gurchetan Singh 4aa337a877 gfxstream: guest: vulkan: use hardware/google/aemu
Removes use of android-emu/aemu/base from
libgfxsteam_vulkan.so.  Also removes duplicated code
entries that are known to VK-specific.  More code
can likely be deleted than currently is.

BUG=353368163
TEST=complile

Change-Id: I7fb0248351bd3e04ebafe008e39f83bb7f048b29
2024-09-03 09:34:33 -07:00
Gurchetan Singh 03a43e6430 gfxstream: guest: remove unnecessary includes in VkEncoder
We probably want to recreate encoder logging, but
just delete it for now.

BUG=311486792
TEST=CI

Change-Id: I036108d644a249c52162ffd50fc7386a3e1fecf7
2024-09-03 09:34:33 -07:00
Gurchetan Singh f26bd83a98 gfxstream: guest: vulkan: use connection manager
This adds the GfxStreamVulkanConnection, and makes
libgfxstream_vulkan.so use it.  All dependencies
to HostConnection are removed.

For Android builds, dependencies to renderControl
and libOpenGlCodecCommon remain.  In the future,
these will be isolated to Goldfish-based system
images.

BUG=311486792
TEST=CI

Change-Id: I880a7ef4e54fe0f8b929b020687b350e057daa96
2024-09-03 09:34:33 -07:00
Treehugger Robot b672c0000c Merge changes from topic "gfxstream-drm-modifier" into main
* changes:
  vkCreateInfo: support VkImageDrmFormatModifierListCreateInfoEXT
  vkGetPhysicalDeviceImageFormatProperties2: support drm modifiers
  vkAllocateMemory: support DRM format modifiers for dmabuf memory
  Force request VK_EXT_image_drm_format_modifier in vkCreateDevice
  Enable VK_EXT_image_drm_format_modifier on Linux guests
  Enable VK_EXT_image_drm_format_modifier in cerealgenerator.py
  Revert "HACK: gfxstream: guest: mesa: force non-modifier path"
  Add missing includes
2024-08-08 15:06:26 +00:00
Marcin Radomski 245f455a56 Enable VK_EXT_image_drm_format_modifier in cerealgenerator.py
Add the extension to list in cerealgenerator.py, rerun
scripts/generate-gfxstream-vulkan.sh

Bug: 328011003
Test: vkvcube-wayland + kumquat on the entire CL chain
Change-Id: If5cf2b04e9fb03e2f484fee12bbe13572c945b8b
2024-08-08 10:22:21 +02:00
Treehugger Robot 8f6ce72077 Merge "[Vulkan Snapshot] tryLock when an API might create extra handles" into main 2024-08-07 23:21:30 +00:00
Yahan Zhou 5fa84090ee [Vulkan Snapshot] tryLock when an API might create extra handles
We acquire the lock when createExtraHandlecsForNextApi is called. But
depending on config, vkCreateDescriptorPool may or may not call
createExtraHandlesForNextApi, which results in inconsistency of the lock
state when calling snapshot()->vkCreateDescriptorPool.

We add a tryLock so that it always acquires the lock before modifying
mReconstruction.

Bug: 349648408
Test: VulkanBatchedDescriptorSetUpdate
Change-Id: I8f582580e01916edce042db192c497c8dd7a32d2
2024-08-07 14:59:12 -07:00
Gurchetan Singh 7ecccf04b4 gfxstream: guest: nuke Android HealthMonitor
The HealthMonitor is hang detection at the API Vulkan
encoder level.

It's actually not used in CF/AAOS/Emualtor.  The
plan for AOSP is actually to increase the amount
of Android CTS that are run against gfxstream to
increase health/stability, for example (b/347288539).

So if we consistently pass CTS on main with gfxstream
(as is the plan), HealthMonitoring would be somewhat
redundant.

Also, AndroidHealthMonitor is somewhat duplicated with
libaemu's HealthMonitor as well.

Also, nuke EncoderAutoLock while we're at it.  It also
is unused code.

BUG=353368163
TEST=compile

Change-Id: If7da3db0f83e7e2dd9f0b448f51a55dcf23aed39
2024-08-05 18:31:01 -07:00
Serdar Kocdemir ac9736bef4 Add error messages for unhandled extensions
Print missing structure information before calling abort.

Bug: 351729579
Bug: 353390628
Test: run vulkan caps viewer
Change-Id: Ifd53ec6fbac3830067f680bc197317abc94134fb
2024-08-01 10:30:16 +00:00
Treehugger Robot 5e14673d1f Merge changes from topic "MEMORY_IMPORT_VVL_ERROR" into main
* changes:
  Fixing a VVL error relating to mismatched host memory index upon memory import.
  Adding support for VK_EXT_external_memory_host extension
2024-07-26 04:30:11 +00:00
Jason Macnak 400f21cfd1 Disable device groups
... by silo'ing each physical device in its own device group.
This unblocks dEQP VK testing until the mesa layer has codegen
to fully translate structs in pNext chains.

Bug: b/333133323
Test: GfxstreamEnd2EndTests
Test: dEQP-VK.api.object_management.single.device_group
Change-Id: I115901009a0de647717414f10bc3cf94551cd09d
2024-07-24 10:12:04 -07:00
sergiuferentz 4023855ed3 Adding support for VK_EXT_external_memory_host extension
Supports querying supported memory indexes for host allocations.

Bug: 354139765
Test: N/A
Change-Id: I92bddd3a21c509c1dbcd04aa92591460f553f841
2024-07-23 16:16:32 +00:00