45 Commits
Author SHA1 Message Date
osy ae26042d4b Fix macOS compile
- Untangle GL dependenices
- Add dummy files to prevent linker errors on empty archives
- Add missing macOS framework dependencies
2025-10-05 17:06:10 -07:00
Serdar Kocdemir 74647db33f Add mipLevels argument to vulkan color buffer creation
Android Hardware Buffers can be created with mip levels and
the mismatch is causing errors when importing vulkan images.

Bug: 406456167
Test: CtsNativeHardwareTestCases
Change-Id: I3634bd400574453bf4ff123c149cb5f95409a42f
2025-09-11 08:25:45 +00:00
Serdar Kocdemir 7f5dfcf1dc Implement colorbuffervk readback for screenshots
When using vulkan composition with guestangle, color buffers will
only be stored in vk targets and this will enable taking screenshots.
Current version only support the most common formats with no snipping.

Bug: 389646068
Test: take screenshot in vulkan-only mode
Change-Id: I4f5a4e05ceb9230915c33d2033ec17425a0baaee
2025-09-04 19:31:59 +00:00
Serdar Kocdemir 6308f87a93 Add support for display color transform matrix
Add new display operation callback to be able to set and get color
transform matrix, which can be used to change appearance of the
display for accessibility features.

Bug: 420586022
Test: Set color accessibility options in emulator
Test: adb shell settings put secure accessibility_display_inversion_enabled 1
Test: FrameBufferTest.SetMultiDisplayColorTransform
Change-Id: If972487785b0635bfc6ec126d950dec0cf1cd6fb
2025-07-10 23:58:52 +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
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 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 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 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 4f0bcb55cc Refactor ExternalHandleInfo
.. to increase readability and reduce duplicated
functionality around the code base.

Bug: 389637419
Test: CI
Change-Id: Ib838b166a7629f00375cad6beb0a1630d2041986
2025-03-28 16:29:15 +00:00
Aaron Ruby 2c41de3be7 Remove GFXSTREAM_ENABLE_GUEST_VIRTIO_RESOURCE_TILING_CONTROL entirely
... and all the 'linear' flag propogation throughout

Test: Zink+gfxstream-vulkan on QNX host

Change-Id: Ib9ec2c950ca862f163c3446a2eb4dd2ee75facda
2025-03-24 11:41:23 -04:00
Serdar Kocdemir 6c0ccd1fb5 Disable gl-vk interop on unsupported GPUs
Fixes issues with certain AMD card on windows for vulkan
hwui modes.

Bug: b/391127381
Test: run XR emulator on AMD windows
Change-Id: Ia6a86cd5bc882821bd1c6c398eff1b0d5be3d5aa
2025-03-11 16:56:46 +00:00
Jason Macnak 4e379d810e Remove the global VkEmulation variable
... and move into FrameBuffer.

Bug: b/383139165
Test: cvd create --gpu_mode=gfxstream_guest_angle_host_swiftshader
Change-Id: Iab139a0793564b21126a66946031caab8a8a6456
2025-03-04 13:03:38 -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
Aaron Ruby 1ade01f177 Revert "Revert "Revert "gfxstream: stream-renderer: add waitSyncResource...""
This reverts commit 1cc4e5cfc8.

This is now a "revert^3". So finally removing this API/feature,
and all the associated code that was tracking this in queueSubmit.
As mentioned on chromium review, this was initially added by QNX for
zink+gfxstream-vulkan bring-up on Linux, but sync issues fixed in
Vulkan. This was never a robust API, and doesn't make sense in the
context of the virtio-gpu spec (i.e. for scanout resources).

Test:Linux + Android guests using gfxstream-vulkan-only configs

Change-Id: I9e25f797b27388f78c19b2fb6d979fd803bce60e
2025-03-03 18:51:02 -05:00
Aaron Ruby a051293dbd Remove all interfaces for explicitly importing a native resource
This will be covered explicitly with a new stream-renderer interface

BUG=382442209

Change-Id: Ife83b2be0d5d3b821d060cc52dd751701d4220a8
2024-12-18 11:33:29 -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
Aaron Ruby 9ef51649a5 Revert^2 "Use a common GenericDescriptorInfo struct"
1bfb4638b4

NO_IFTTT=doesn't affect snapshot

Change-Id: I754c649c6e1f842108674ea405c6dcaab90e9c07
2024-12-18 10:46:01 -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 1bfb4638b4 Revert "Use a common GenericDescriptorInfo struct"
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

NO_IFTTT=Revert, doesn't affect snapshot

Change-Id: I6b3184618a4beb16a25ddd1dbbd55d551aa85190
2024-12-13 19:03:45 -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
Aaron Ruby aa85881311 Remove all references/usage of importEglImage
QNX only uses importEglNativePixmap

Change-Id: I2fc9c7c526bf8b2c2a0d60ea57a518925da6ccec
2024-12-10 12:44:08 -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
Aaron Ruby 4dd24d4409 Use a common GenericDescriptorInfo struct
Also clean up references to headers/namespace for ManagedDescriptor type

BUG=382442209
TEST=compile
NO_IFTTT=doesn't affect snapshot

Change-Id: I7dc660f239e47974588b574b3ce676c482658bd7
2024-12-09 13:35:59 -05:00
Serdar Kocdemir 3c57698c11 Add buffer size checks for color copy operations
Make readColorBufferToBytes calls safer by providing the size of
the destination buffer. Old unsafe version is kept with maximum
size value to allow backwards compatibility.

Bug: 378779335
Test: presubmit, run on Mac
Change-Id: Idcadecda7642bdb45be65c7f0908fd7925c152fa
2024-11-14 14:45:24 +00:00
Aaron Ruby 7cd7430ef3 gfxstream: Remove platformImportResource from AndroidVirtioGpuOps
Change-Id: Iab46ad0c4475d119cfce37c336bc60c631ef6b03
2024-10-09 17:58:38 -04:00
Yahan Zhou a4194ec41d Introduce dirty bit for color buffer gl
We need to copy from gl to vk frequently. Let's skip the copying if
nothing changed since the last copy.

We did so by introducing a dirty bit for color buffer gl. We mark it as
dirty whenever gl contents are updated. Then Vulkan will only copy from
gl if the dirty bit is set.

Bug: 348710938
Test: GfxstreamEnd2EndVkTest.ImportAndBlitFrom*
Change-Id: I19aa7ed34f9ccb4a08187a8b53297b55ad5ccd67
2024-08-02 17:47:05 +00:00
Yahan Zhou 08a349a1a0 Revert "Copy to both gl and vk buffers on video decoding"
This reverts commit 41d23f1c80.

Reason for revert: working on a better fix

Change-Id: Id982386f79a5778bb1d21e521b8de5ac10aaa68f
2024-07-31 14:51:44 -07:00
Yahan Zhou 41d23f1c80 Copy to both gl and vk buffers on video decoding
It looks like we missed a copy between gl and vk in video decoding. We
do not know exactly where, but adding updateFromBytes to both gl and vk
seems to fix the issue.

Bug: 348710938
Test: manual
Change-Id: Ib4d9460a7da7d5b6fcb56fb66e34bb6651320aa7
2024-07-29 15:10:09 -07:00
Gurchetan Singh 619646f3a4 gfxstream: host: BlobManager --> ExternalObjectManager
We should try to support external sync, along with
external memory so:

find ./ -type f -exec sed -i -e 's/BlobManager/ExternalObjectManager/g' {} \;
find ./ -type f -exec sed -i -e 's/removeDescriptorInfo/removeBlobDescriptorInfo/g' {} \;
find ./ -type f -exec sed -i -e 's/addDescriptorInfo/addBlobDescriptorInfo/g' {} \;
find ./ -type f -exec sed -i -e 's/mDescriptorInfo/mBlobDescriptorInfo/g' {} \;
find ./ -type f -exec sed -i -e 's/ManagedDescriptorInfo/BlobDescriptorInfo/g' {} \;

BUG=350965057
TEST=compile

Change-Id: Id9fe5319ed617638ae8c67f9377f5426fe15cf44
2024-07-03 16:21:42 +00:00
Gurchetan Singh b86aa8b160 gfxstream: host: add exportColorBuffer + exportBuffer functions
We want to share the color buffer or buffer with a Wayland,

BUG=349122558
TEST=see dmabufs being exported

Change-Id: I5d3a94aec2b7a58b8281ba081d8041e21d12e8bf
2024-07-02 11:47:45 -07:00
Gurchetan Singh 1cc4e5cfc8 Revert "Revert "gfxstream: stream-renderer: add waitSyncResource..."
Revert submission 3125001

BUG=346348303
TEST=atbd

Change-Id: Iff294455e95093e80cbcb66f36d0a280c48299b3
2024-06-14 07:48:33 -07:00
Gurchetan Singh 68437f938a Revert "gfxstream: stream-renderer: add waitSyncResource interface"
BUG=346348303
TEST=todo

This reverts commit 7609a83699.

Change-Id: I15432fe856bc1e5b3f1b71731c5bdf290da54ac1
2024-06-13 18:31:34 +00:00
Aaron Ruby 7609a83699 gfxstream: stream-renderer: add waitSyncResource interface
Useful for syncing against a specific resource. This will only be
applicable to colorBuffer resources.

Add waitSync implementation for ColorBufferVk

BUG=343234676
TEST=gfxstream guest ANGLE + gfxstream guest Zink + end2endtests

Change-Id: I8268f3b3637984f3d4d1cd6127fdd542978790c0
2024-06-06 16:21:07 -07:00
Aaron Ruby 550b6bdb7a gfxstream: For vulkanOnly, propogate the linear bind attribute to the ColorBuffer image creation
From virtio-gpu resource creation.

BUG=343234676
TEST=gfxstream guest Linux

Change-Id: I60da16cf47f80c63a43aab51c2f1c522773472e6
2024-05-29 12:33:16 -07:00
Yahan Zhou 430ed7099c Patch up ColorBuffer for vk snapshot
Set the flags and properties properly when vk snapshot is enabled.

Bug: 340286132
Test: manual
Change-Id: Ib911bddd0c68c0248349ed3165c7d5a12fbbbfad
2024-05-22 15:11:53 -07:00
Yahan Zhou b1514065bc Snapshot image layout
Should be able to snapshot Chrome home page without crashing. (Website
browsing still needs more work.)

Bug: 332775761
Test: CanSubmitQueue
Change-Id: If1dbd4fc2af17d022cdcdfca98528d7183e32ab6
2024-04-08 11:30:57 -07:00
Yahan Zhou 505f0290f9 Make it not crash during vk snapshot load
We are trying to make vk snapshot load the google Chrome home page
without crashing. With this CL it does not crash during load but would
crash with a device lost after submitting a queue (which is
unsurprising because everything is missing to snapshot vk queue).

Content of this commit includes:

 - Add dependencies for VkImageView, VkGraphicsPipelines, VkFramebuffer.
   They are necessary to tell the snapshot module the order of vk object
   creation.
 - Add vkBindImageMemory into the loading sequencey of VkImage, so that
   it would be executed before vkCreateImageView.
 - Delay the destruction of VkShaderModule. This is because other
   objects can still refer to it after it is destroyed.
 - Initialize VK backend for color buffer properly on snapshot load.
 - Save and load vk images in the same order by sorting them according
   to their boxed handle.
 - Record all the placeholder handles for vkCreateDescriptorPool. For
   performance purpose this function creates a lot of extra handles
   without real contents. We need to snapshot those handles as well.

Bug: 329506242
Test: GfxstreamEnd2EndVkSnapshotImageTest, GfxstreamEnd2EndVkSnapshotPipelineTest

Change-Id: I999c3477f861cec51ae743f11c3031be438b3ddf
2024-03-21 13:52:57 -07:00
Yahan Zhou d7f0dc6881 Try not to crash when gl interop fails
We don't know the root cause yet but sometimes VK -> GL interop can
fail. Let's try harder not to crash.

More details: glImportMemoryWin32HandleEXT can fail sometimes, let's
make it not to crash when it happens.

Bug: 322858149
Change-Id: I044643d15febdc36f90f69bbc4529eef50049323
2024-02-29 10:26:11 -08:00
Gurchetan Singh 95b30dc862 Reland "gfxstream: introduce GFXSTREAM_ENABLE_HOST_GLES compiler flag"
Same as before, but added extra GFXSTREAM_ENABLE_HOST_GLES
to keep MacOS builders happy.

Change-Id: I333503ecb6e67840326ce248428fa097eb152e92
2024-01-18 18:34:08 -08:00
Gurchetan Singh 6ed12e9d66 Revert "gfxstream: introduce GFXSTREAM_ENABLE_HOST_GLES compiler flag"
This reverts commit 4675a9d4ef.

Reason for revert: I suppose it breaks MacOS

Change-Id: I91bef5c2fa0e8726b6e77e6678540b808ad26316
2024-01-19 02:19:50 +00:00
Gurchetan Singh 4675a9d4ef gfxstream: introduce GFXSTREAM_ENABLE_HOST_GLES compiler flag
This allows:

meson -Ddecoders=vulkan

to build without errors.  This is useful for enviroments where
GLES does not exist (Fuchsia) or where importing the entire
gfxstream GLES decoder is undesirable.

BUG=31148679
TEST=compile

Change-Id: I59e385c205588a4dbbe472fac1681ebe261127dc
2024-01-17 18:13:22 -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
Bo Hu e1a53fad22 gfx-codecs: handle different color spaces
Bug: 289049378
Test:
CtsMediaV2TestCases android.mediav2.cts.DecodeGlAccuracyTest
CtsMediaV2TestCases android.mediav2.cts.EncodeDecodeAccuracyTest

Change-Id: Ifd016324f444be5ed7d1c38c9f85dcdd994fd82b
2023-06-27 14:50:10 -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