35 Commits
Author SHA1 Message Date
Serdar Kocdemir 2c8c616a2a Avoid calls to getMaxGlesVersion in vulkan mode
Bug: 389646068
Test: -feature GuestAngle,VulkanNativeSwapchain
Change-Id: Icc9496b7f727b89521a912a439454f0ffbd89a6f
2025-09-11 08:25:45 +00:00
Serdar Kocdemir d8bd31204e Adjustments to some log messages
Reduce usages of stderr printing and use gfxstream logging
functions instead.

Bug: 389637419
Bug: 433496880
Test: CI
Change-Id: I52ad2fe9953cffa1b028b9a388e7f90c7141a9c0
2025-09-04 19:31:59 +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
Serdar Kocdemir 6a6ce6457e Add extension control for color transform support
In order to provide backwards compatibility for new system images
running on old host emulators, use a new extension to query color
transform operations support. Guest side should check the support
before making RC calls for color transform.

Bug: 431625531
Test: avd_boot_test with old host emulator
Change-Id: I361344ea9af925673d976d91e03826bd10421f78
2025-07-25 22:20:02 +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 d4ffa9a5bc Normalize some directory names and includes
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: I0d4aa852da43ed3b2a411181689876c8b78f5367
2025-05-07 12:35:39 -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
Bo Hu 665f46d920 [vulkan snapshot]: save and restore context id for VkInstance
When a guest process died, e.g., during adb reboot,
it's vk instance will be cleaned up automatically on
the host. However, this does not happen after loading
vulkan snapshot, as there is no context id information saved
for each vk instance.

This cl fixes that problem by remembering the context id
associated with each VkInstance, save them during
snapshot save and restore them during load.

Test: save snapshot, load, adb reboot, save and load again
it should not crash during loading.

Bug: 413670220

Change-Id: I0cc7db41efc61d596ba64903cada27d9cb6348f3
2025-04-28 15:45:27 -07: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 ff0ca91754 Move sync devce from h/g/aemu to h/g/gfxstream
and split type declarations off into render-utils as this is a
part of the RenderLib 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: I14f0e04b67d3a10556dc4be1b5e4404598b94f14
2025-04-20 04:56:38 +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 8876f3a739 Add extra logs for egl config selection
To help debugging the issues from the logs.

Bug: 394610018
Test: CI
Change-Id: I59062994289afe9f3987ddbae3df5ec9be0b9b09
2025-03-28 14:45:11 +00:00
Serdar Kocdemir 35db18236b Enable warnings as errors on cmake builds
And fix various compilation warnings.

Bug: N/A
Test: rebuild
Change-Id: Ife3489b29b1f2822f69d77ce4305b6b31b19d1cf
2025-03-14 14:01:26 +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
Serdar Kocdemir 2b90740d10 Avoid flush color buffer calls on unknown surfaces
Bug: 392777654
Test: run foldable AVD, check error logs
Change-Id: I4f52220b504c5fce32c77bf2d946da1e4b421869
2025-02-06 15:28:44 +00: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
Jason Macnak 338d461a8d Enable "-Wall" for Gfxstream
Bug: b/383139165
Test: m
Change-Id: I5962c1b5df3c79d6e95a3c9f2e0278717e1a39a7
2024-12-09 14:53:30 -08: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
Serdar Kocdemir 3d6cf83caa Replace stderr logging with appropriate logger routines
Usages of fprintf(stderr,..) causes various issues when dealing with
bugs. Replacing them with appropriate versions to ensure they are
collected with any extra information needed and to avoid AS thinking
there were a crash.

Bug: 374311144
Test: build and presubmit
Change-Id: I6893a8df753ddfcc27f28dfd2bd828e53f3f32b3
2024-10-25 08:36:03 +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
Erwin Jansen b45c014871 Enable GFXStream bazel build
This builds the "standalone" GFXStream library that can be consumed by
Qemu 8.2

The bazel build allows us to transition rutabaga to a bazel based
build, which will unify the Qemu 8.2 build as used by the emulator.

It also opens up the path to migrate this to g3 if we decide to do this.

This change forces a few header changes, as bazel is more strict about
the relationship between headers and packages, and doesn't easily give
you fine grained control over the include paths.

Change-Id: I3566d69f10c534f1176fa92eaa7f5f12ec0bcd4f
2024-03-20 18:21:20 -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
Mehdi Alizadeh 813c75c93b Merge "Revert "gfxstream: introduce GFXSTREAM_ENABLE_HOST_GLES compiler flag"" into main 2024-01-19 02:21:20 +00: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
Treehugger Robot 0f1ed1fb78 Merge changes from topic "use_gles" into main
* changes:
  gfxstream: introduce GFXSTREAM_ENABLE_HOST_GLES compiler flag
  gfxstream: USE_MAGMA --> GFXSTREAM_ENABLE_HOST_MAGMA
  gfxstream: unified Meson build between guest & host
2024-01-18 21:40:15 +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
Yahan Zhou c2ec5a6be8 Use safer getter for fenceSync
rcClientWaitSyncKHR casts raw pointers from the guest which is unsafe.
Use EmulatedEglFenceSync::getFromHandle which checks if the fenceSync
has been registered and is still alive.

Bug: 320559580
Change-Id: Iaa26cd71409802d597145b62dd0eff099a0b2541
2024-01-17 15:26:30 -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
Joshua Duong 4d138b1127 Merge "Check if a fence sync is stale" into main 2023-08-04 16:40:29 +00:00
Andrew Woloszyn f4355a98ef Add timeline triggering triggerWaitVkQsri.
Bug: b/277980467
Test: running Chrome with instructions from the bug
Change-Id: Ie4bc8942b41ea37d8432859ad0a73ef2a65e50a7
2023-07-24 15:34:00 -04:00
Yahan Zhou 01c8f4ef99 Check if a fence sync is stale
Bug: 195481616
Bug: 290953613
Change-Id: Iaf14478dc5cfb7d385e0245a57341f7ceba9e59b
2023-07-12 11:32:33 -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