41 Commits
Author SHA1 Message Date
Serdar Kocdemir 32b99c2f08 Some logging cleanup
Remove printf usages. Also reduces the severity of error for unimplemented
displayvk::clear call.

Bug: 389637419
Test: CI
Change-Id: If3de85fc910d1c7e1e10a1292bf02d26be0b8801
2025-09-16 16:06:52 +00:00
Serdar Kocdemir 90d0347c16 Use uint8_t instead of unsigned char for screenMask data
.. to unify with other usages over the data and indicate the intent
better.

Bug: 389646068
Test: CI
Change-Id: I0d0c2f05020bbd86728abdbfebb5084b1112b657
2025-09-11 08:25:45 +00:00
Jason Macnak baa96a6945 Convert egl2egl to a feature
... to avoid having to pass around extra params.

Bug: n/a
Test: cvd create --gpu_mode=gfxstream
Change-Id: Id1bac44a576a8faf1ae8ecbaa17d6f98ca0919b4
2025-07-16 00:02:45 +00:00
Serdar Kocdemir f2f8994652 Remove duplicated error message
Bug: N/A
Test: build
Change-Id: I0125e2cb1eb6978ab47112a227129de334d827e5
2025-06-17 21:04:07 +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 d4ae528b16 Hide ASG internals from the consumer interface
Refactors Gfxstream's ASG to hide ASG internals (context init, ring
buffer, ring config, etc) from external use. The ASG consumer interface
is updated to only take the shared memory pointers as arguments and then
all of the internal ASG context / ring initialization should happen
inside of `RingStream`. This requires a little bit of refactoring
around `onUnavailableRead()` to move the unavailable read count and
to move the setting of the `asg_context::host_state` into `RingStream`.

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: I43cc8e55ec4ded3071c22e2cfce6fab930262a17
2025-05-07 12:35:25 -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 7e7eb0fd46 Move snapshot interface
... alongside the rest of the Gfxstream host 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: I5db79bd3f7f6e8d776a34696f0fde3b3ef66627e
2025-04-30 03:55:26 +00:00
Jason Macnak d0da7da0cf Migrate "misc" operations from h/g/aemu to h/h/gfxstream
Consolidates the second copy of opengl headers into common/opengl
and fixes some targets which were transitively relying on headers
via gl-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: Id6a651b746bb36da04650f62dc8c0ae7e01989cb
2025-04-28 01:18:46 +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 550ddd6600 Use reference type for FeatureSet arguments
FeautreSet is a large structure with lots of strings, better
to not copy around unnecessarily.

Bug: N/A
Test: build
Change-Id: I604b4ad7af01f222b54dcda4cd2299e350324f50
2025-03-27 14:47:51 +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
Jason Macnak 66ec155f8f Address some -Wshadow errors
Bug: b/399867568
Test: build
Change-Id: I3bf03c418add538b5d5a0f298d559753aa578fe5
2025-03-05 08:02:31 -08:00
Jason Macnak 0334ecf991 Ensure resume waits for the RenderThreads to resume
Without waiting for the `RenderThread`s to complete,
`RenderThread::resume()` might destroy `mStream` before
or during use `RenderThread::loadSnapshot()`.

Setting the `waitForSave` to false was a carry over from
aosp/2824962 where some allowances were made for the end2end that
did fake snapshoting. The snapshot end2end tests were removed
to do fundamental limitations with faking VM functionality
so this `waitForSave` is no longer needed and can be completely
removed.

Bug: b/397503985
Test: snapshot with Cuttlefish
Change-Id: If252466e677a985e9ee3bde2b35d53ac2ebda759
2025-02-18 15:16:36 -08:00
Bo Hu 0be3975608 Fix deadlock on RenderThread exit.
We expose the global egl lock to synchronize the followiing
scenarios where we have observed deadlocks:

- Nvidia seems to have registered some cleanup code
(pthread_key_create) that has a race condition against other
threads calling vkDestroyDevice. So this workaround synchronizes
the RenderThread exit with vkDestroyDevice calls.

- Nvidia also seems to have a deadlock between vkDestroyDevice
and eglMakeCurrent.

Also add addtional protection around eglSwapBuffers.

Bug: 377677250
Test: Run dEQP with Nvidia GPU. Observe no hang/crash.

Change-Id: I570c14671cb8cdc79f8a1b3b1077a1f7c13d28fe
2025-01-21 10:57:40 -08:00
Aaron Ruby e2bd78c55a Rename internal *BufferWithHandle functions to *BufferWithResourceHandle
nomenclature to be more specific

BUG=382442209

Change-Id: I922c71ddfd0232349b5dffb51ea15c36c9714a55
2024-12-18 11:33:29 -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
Jason Macnak 810c16aa7c Avoid double loading EmulatedEglFenceSync
... as this is already loaded at the end of FrameBuffer::onLoad().

Bug: b/369615058
Test: cvd start \
      --enable_virtiofs=false \
      --gpu_mode=gfxstream_guest_angle_host_swiftshader \
      --gpu_renderer_features=VulkanSnapshots:enabled
Test: cvd snapshot_take \
      --force \
      --auto_suspend \
      --snapshot_path=/tmp/snapshot1
Test: cvd create --snapshot_path=/tmp/snapshot1
Change-Id: I96fc4e004940b5a26ff3a42e65fca759e2ea8549
2024-10-28 14:39:25 -07:00
Aaron Ruby 00f66d1deb gfxstream: Remove shared_egl_context APIs from AndroidVirtioGpuOps
Keep accessible in stream-renderer interface

Change-Id: If17b3efd8df6275933c8d146be934612db15f2ad
2024-10-09 18:15:00 -04:00
Aaron Ruby 7cd7430ef3 gfxstream: Remove platformImportResource from AndroidVirtioGpuOps
Change-Id: Iab46ad0c4475d119cfce37c336bc60c631ef6b03
2024-10-09 17:58:38 -04:00
Aaron Ruby cc41b4d599 gfxstream: Remove wait_sync_color_buffer from AndroidVirtioGpuOps
It's only accessed through stream-renderer interface

Change-Id: I6706ebfe4f745856829a0b43f771acdc573456f5
2024-10-09 17:35:49 -04:00
Aaron Ruby d46c53ad05 gfxstream: Remove all platform_resource_info interfaces from unstable API
This interface provides duplicate functionality and is deprecated.

Change-Id: I2e1554c2994aeb9002905d6b8e8b77404d4c2ffa
2024-10-09 12:06:45 -04:00
Jason Macnak 09548c18e5 Remove some unused sync functions
... now that there are async equivalents.

Bug: b/360379616
Test: build
Change-Id: I30619388e58d25e277c7e1a98906ae4d9b58a217
2024-08-20 11:39:49 -07:00
Serdar Kocdemir d131318316 Enable log colors with ANDROID_EMUGL_LOG_COLORS
Test: build and run emulator
Change-Id: I4361b4235f987262d4b0667f15d6d05b19a7b692
2024-07-30 18:39:31 +01:00
Gurchetan Singh ae7c701d1c gfxstream: fix VERBOSE logging change
Breaks meson build.  Two issues:

1) It requires a new API from AEMU base, which for the
   meson build doesn't work since it likes to keep working
   with AEMU v0.1.2

2) The logging facade itself is too QEMU 2.12 centric.  Upstream
   QEMU and crosvm's logging handlers are hooked into
   stream_renderer_{error, warn, info}, example:

https://github.com/qemu/qemu/blob/master/hw/display/virtio-gpu-rutabaga.c#L933

So VERBOSE shouldn't be AEMU anyways if you want a generic
host-side logging facade.

BUG=317816825
TEST=meson build

Change-Id: I659e10d8b2920b6478043df0ba5fff80ada05b1d
2024-06-27 10:23:08 -07:00
Serdar Kocdemir 47d2bcc32d Fixes for verbose logging
Enable verbose logging on gfxstream with ANDROID_EMUGL_VERBOSE.
Use existing logging functions for common vulkan operations.

Bug: 349563520
Test: build and run with ANDROID_EMUGL_VERBOSE=1
Change-Id: I56270fc104a278af8a5c06c86394966cc38f99ab
2024-06-27 07:11:48 +00: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
Jason Macnak 2687212e49 Introduce Gfxstream Features to decouple Gfxstream from AEMU
... which will allow building Gfxstream from a fixed version of
AEMU for the purposes of packaging.

Bug: b/326648397
Test: cvd start --gpu_mode=gfxstream
Test: cvd start --gpu_mode=gfxstream_guest_angle
Change-Id: I8ac1622428f0194997597868bef49118bcc3ea90
2024-03-18 15:50:46 -07: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
Kaiyi Li 3a894ad36f Fix crash on exit
In RendererImpl::~RendererImpl, we have the following indirect call stack:

* teardownGlobalVkEmulation
* FrameBuffer::~FrameBuffer
* FrameBuffer::finalize
* RenderWindow::~RenderWindow
  Triggers FrameBuffer::finalize indirectly by sending the finalize
  command
* RendererImpl::~RendererImpl

However, teardownGlobalVkEmulation shouldn't be called until
mCleanupThread has exited, because we may have queued Vulkan objects
cleanups on that thread by calling
FrameBuffer::registerProcessCleanupCallback in on_vkCreateInstance, and
the clean up may depend on the global Vulkan emulation object.

Test: build
Change-Id: I667f2685dd9dc5749244844a3259e51a3250de7b
2024-01-02 11:14:38 -08:00
Jason Macnak 1220d96124 Ensure EmuglPipe RenderThread-s have a virtio gpu context id
... and avoid setting invalid PUIDs in rcSetPuid() to avoid lots of
"Failed to find process owned resources fpr puid" errors.

After aosp/2752873, the host GlProcessPipe stopped initializing a unique
id for the process pipe. However, it continued to communicate the value
of the `m_uniqueId` back to the guest. The guest still uses PUID for
rcSetPuid commands in the guest EGL/GL implementations. This would
result in garbage PUIDs being used by RenderThreads for
getProcessResources() calls. Further, if a guest process used both
EGL/GL and Vulkan, getProcessResources() would return nullptr and then
the host would crash when the VkDecoder tried to read the seqnoPtr in
the process resources.

Bug: b/312560224
Test: cvd start --gpu_mode=gfxstream
Change-Id: Ie3697a7588a8d2180ccc9e7f02f38ed6d9f1bd12
2023-11-22 10:52:54 -08:00
Yahan Zhou d1c7e1e700 Add basic vulkan snapshot test
The test creates an instance, saves and loads it, to make sure it does
not crash.

In end2end snapshot tests, we do not have a real guest system. Thus
snapshot can only test the host part. To make it work we will need to
skip render thread and stream snapshots, and reuse all render channels
created before snapshots.

We also added APIs to ask render thread not to wait for snapshots, and
sync up with FrameBuffer after snapshot loads.

It runs with cuttlefish.

Bug: 294277842
Test: GfxstreamEnd2EndVkSnapshotBasicTest
Change-Id: Ibea5d9830f0e927e7dbe3552ed31ad901b5397ab
2023-11-14 10:23:34 -08:00
Jason Macnak 08f5382c16 Wait for clean up worker thread to finish in stop()
... so that previous tests fully clean up before the next tests
start up.

Bug: b/292257025
Test: atest --host GfxstreamEnd2EndTests
Change-Id: I038512f85c6573d337fef5ce9292c1f27c4821ea
2023-09-11 12:15:13 -07: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