Commit graph

81 commits

Author SHA1 Message Date
Aaron Ruby
20803a3957 rutabaga_gfx: Add rutabaga_resource_wait_sync interface
Add to FFI as well

Change-Id: Ie859d72f5817be949baabb211d483066271d49eb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5913186
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-10-08 00:40:53 +00:00
Aaron Ruby
f9cd754c55 rutabaga_gfx/ffi: fix case when num_iovecs is zero in create_blob
Panicked on rutabaga_reosurce_create_blob, std::slice::from_raw_parts
requires non-null pointer

Add check to prevent hitting this case

Change-Id: I51ca19249322126f7fccdd334c766f2bc30b5650
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5812885
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-08-26 21:35:13 +00:00
Gurchetan Singh
6c219468aa rutabaga_gfx/ffi: fix case when num_in_fences or cmd_size is zero
Following observed:

thread '<unnamed>' panicked at library/core/src/panicking.rs:156:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`
stack backtrace:
  20:     0x7fbc13444397 - rutabaga_ffi::rutabaga_submit_command::{{closure}}::h396fa3925e07701c
  21:     0x7fbc1342af28 - core::ops::function::FnOnce::call_once::h83bf6f55aff2e840
  22:     0x7fbc13423a36 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h988a1c0089589129
  23:     0x7fbc134292a8 - std::panicking::try::do_call::h83aa5cffd0c7a46a
  24:     0x7fbc13444eeb - __rust_try
  25:     0x7fbc13428c13 - std::panicking::try::hc36d232483e714b8
  26:     0x7fbc13427c7d - std::panic::catch_unwind::h2433ece368f25877
  27:     0x7fbc134442f0 - rutabaga_submit_command

Reason, according to the docs:

"data must be non-null and aligned even for
 zero-length slices."

Add check to prevent hitting this case.

BUG=none
TEST=compile

Change-Id: Ic0d36055a13cd1cc9c65e7e12c0aef7aa95a58ce
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5718431
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-07-17 22:58:42 +00:00
Gurchetan Singh
075c7bf647 rutabaga_gfx/ffi: fix meson build
The library installed by Meson actually contains no symbols right now.
We have to:

1) Have Cargo place the libraries in the Meson build dir
2) Move the libraries from ${MESON_BUILD_DIR}/debug (where Cargo
   places them) to ${MESON_BUILD_DIR} sp Meson custom target script
   can reference them
3) Have meson install the libraries and generate pkg-config

BUG=b:344998548
TEST=link against FFI via gfxstream guest

Change-Id: I6536674fdb6ee3493433bf48ed233d6ca947e9aa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5631146
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-06-18 19:17:20 +00:00
Gurchetan Singh
7cd8cb25e4 rutabaga_gfx: explicit imports in FFI
Stylistic change.

BUG=b:344998548
TEST=compile

Change-Id: Id2ab7793207fe14c14650d3bebaf7279b534299f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5631145
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-06-18 19:02:22 +00:00
Gurchetan Singh
d66e99ecfb rutabaga_gfx/ffi: fix warning
Fixes

warning: unused return value of `Box::<T>::from_raw` that must be used
   --> src/lib.rs:285:18
    |
285 |         unsafe { Box::from_raw(*ptr) };

BUG=344998548
TEST=compilet

Change-Id: Ibb75410519f447c9ef19e1eff3ec79d01ab03c34
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5599140
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-06-05 00:35:59 +00:00
Gurchetan Singh
704bec9aea rutabaga_gfx/ffi: add meson build
This is somewhat more modern than the Makefile.  Both just invoke
cargo under the hood.  The proper solution may come when Meson
starts supporting external crates:

https://github.com/mesonbuild/meson/issues/2173

Right now, this is a just a minimal version for developers.  A known
issue is modifying dependent crates (rutabaga_gfx) doesn't cause
a rebuild.  A solution is just `touch src/lib.rs` in ffi.

Also, `ninja -C build/ clean` isn't recommended.  Just do cargo
clean.

BUG=344998548
TEST=meson setup build
     ninja -C build/ install

Change-Id: Id5a142cc5cb5a8001198afc4d1cdbe800ec2ec23
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5599139
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-06-05 00:35:53 +00:00
Jason Macnak
520875b8c1 gpu: Add a parameter for passing args to the renderer
... which is useful for enabling/disabling features in Gfxstream
but which does not affect Crosvm/Rutabaga directly.

Bug: b/277618864
Test: cvd start --gpu_mode=gfxstream
Change-Id: If0aa51f410c1f53c72f4e71f531ce6d797a37052
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5318696
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2024-03-04 21:16:26 +00:00
Gurchetan Singh
02110bc6fc rutabaga_gfx: fixes for crrev.com/c/5279413
- Functions should be marked as unsafe, as the caller needs to
  guarantee that the directory is a valid string.
- Comment fixes

BUG=324440526
TEST=cargo test

Change-Id: I43405fd2d63a8de3c9b73f349f7e8928373cf9ab
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5313625
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-02-21 22:19:29 +00:00
Kaiyi Li
c28067d1d9 Reformat comments
Test: presubmit
Change-Id: I39c261d9985989873b698213c5d8b653fc13757b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5299850
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-02-15 23:30:13 +00:00
Gurchetan Singh
24cda1ef68 rutabaga_gfx: hook up FFI snapshot to gfxstream
This adds the plumbing to hook up the FFI snapshot API
to gfxstream.

Some 2D only checks were deleted as well.

BUG=324440526
TEST=cargo test

Change-Id: I052bdde1ce508684910c64463470e95f8b67b35f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5279413
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-02-13 19:06:13 +00:00
Gurchetan Singh
8f5cb2e7a4 rutabaga_gfx/ffi: fix compile on Windows
- Internally define iovec since libc::iovec doesn't
  exist on Windows
- Add some Unix only paths

BUG=b:324640237
TEST=cargo build --target x86_64-pc-windows-gnu

Change-Id: I174f55bf84f9b94c7642650e3708ebf09a6ac05a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5286457
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
2024-02-12 20:43:22 +00:00
Gurchetan Singh
ae733ceb2b rutabaga_gfx: release commit 0.1.3
This revbumps rutabaga_gfx and rutabaga_gfx_ffi to
version 0.1.3

BUG=b:322802940
TEST=compile

Change-Id: Ib8026be6a7e64969fd502c4b3dde75b9af5485c4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5270777
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-02-09 20:41:50 +00:00
Pierre Labatut
9ffd450153 [rutabaga_gfx:ffi] Locate target build directory.
Get the directomy from the environement if available.

Test:
  mkdir /tmp/out
  cd rutabaga_gfx/ffi
  CARGO_TARGET_DIR=/tmp/out cargo build

  # Also try.
  cargo build

Bug: b/317884283
Change-Id: I43fc7d17e4bef50e4afcd45144a2dc9bef273a6b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5237622
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Pierre Labatut <plabatut@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2024-01-26 16:11:00 +00:00
Frederick Mayle
c81256f2f1 rutabaga_gfx: add FFI API for snapshot-restore
BUG=b:266514608

Change-Id: I091ca52b5864359b0bb03f7cb3ecbfabe47f8203
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4853266
Commit-Queue: Frederick Mayle <fmayle@google.com>
Auto-Submit: Frederick Mayle <fmayle@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-01-25 03:16:30 +00:00
Frederick Mayle
c16b2bf620 rutabaga_gfx: use thread_local for debug handler callback
If OnceCell is used, then rutabaga_init can only be called once per
process.

This commit fixes the ffi tests for me.

Change-Id: If31792d7679292e4bb63d7442a28effafb181b02
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5232199
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-01-25 02:49:30 +00:00
Alex Bennée
86e0bdd7e6 rutabaga_gfx: allow .pc {prefix} to be relocated
While /usr is the usual place to put headers we should follow the lead
of the PREFIX set at install time, especially before this is widely
packaged. Therefor replace the static .pc file with one generated by
build.rs.

TEST=make prefix=$PREFIX install

Change-Id: I905422df37f89e31f3942af38a91ebc51f39e479
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5159307
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2024-01-04 01:45:39 +00:00
Dmitry Osipenko
dbda320eb8 rutabaga_gfx: Remove virgl_renderer_next feature flag
Crosvm enables unstable virglrenderer features based on the pkgconfig
flags. The virgl_renderer_next build flag isn't used anymore, remove it.

BUG=none
TEST=none
Suggested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Change-Id: I96ba36a9a8c1af9a252e8dcbe664cbf1597543a6
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5077248
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2023-12-15 00:59:44 +00:00
Gurchetan Singh
fc415bccc4 rutabaga_gfx/ffi: fixes for Makefile
Special thanks to marcandre.lureau@ for suggestions:

- Add build.rs for SONAME
- Fix softlinks (librutabaga_gfx_ffi.so.0 -> librutabaga_gfx_ffi.so.0.1.2)

BUG=273561059
TEST=sudo make install

Change-Id: I19420a89bb0b7bd3e90c161c876ae8c1d2f52af9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4863380
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-09-13 20:27:11 +00:00
Gurchetan Singh
c3ad0e43eb rutabaga_gfx: Make gfxstream optional
The fact gfxstream exists on the system is implementation detail
of rutabaga_gfx.  This will allow testing/packaging of rutabaga_gfx
without packaging gfxstream + AEMU base (for now).

BUG=296070975
TEST=compile

Change-Id: I65adfbc5e8c90aa5654c91392915833b1133133f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4860836
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-09-13 00:11:12 +00:00
Dmitry Osipenko
222ca69401 gpu: Support passing guest fences to host
Support passing guest fences to host for waiting by using extended
VIRTIO_GPU_CMD_SUBMIT_3D command that replaces previously unused
padding field with a new 'num_in_fences' field. The in-fence IDs
are prepended to the cmdbuf data. There is new corresponding
VIRTIO_GPU_F_FENCE_PASSING feature flag, it must be supported by
guest in order to activate fence passing on host. There is new
VIRTIO_GPU_FLAG_FENCE_SHAREABLE flag for VIRTIO_GPU_CMD_SUBMIT_3D
command that is set if job's fence is shareable.

Fence passing allows guest to offload dma-fence waiting to host,
removing unnecessary stalls in the GPU pipeline. Guest kernel doesn't
have to stall job submission anymore until all in-fences are signalled
on guest side.

This new feature improves GL/VL interop performance up to 2-3x times
for native contexts. It will also allow to share host GPU fences with
host display subsystem easily for explicit fencing of framebuffer flips
within the host kernel display driver, which is useful for virtio-wl.

TEST=none
BUG=b:253779836
Link: https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1138
Change-Id: Ie547614c26ff5f3f75ccf203096e9087827be542
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679609
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
2023-08-28 16:05:30 +00:00
Gurchetan Singh
803cbb2ca8 docs: add gfxstream release links, also FFI description
To make potential Debian packaging easier, include links
to latest release.

BUG=b:296070975
TEST=compile

Change-Id: I13a49acb8ec2f677e3095c31e24ad9a6e2a9a1cc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4808252
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-08-23 23:31:37 +00:00
Gurchetan Singh
fd0a3fbd6b rutabaga_gfx: release commit 0.1.2
This revbumps rutabaga_gfx and rutabaga_gfx_ffi to
version 0.1.2

BUG=b:296070975
TEST=compile

Change-Id: I45d2930b0bee39a569def85354418d0b391e1d23
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4778941
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-08-23 01:02:33 +00:00
Daniel Verkamp
695d254bcd rutabaga_gfx: replace VolatileSlice with IoSliceMut
This removes the rutabaga_gfx dependency on data_model.

BUG=b:273555494
TEST=tools/dev_container tools/presubmit

Change-Id: I03be8c8f9f722d368d90e6d9b0d7aeac475f2b06
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4785448
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-08-22 23:54:17 +00:00
Gurchetan Singh
a5f42c4282 rutabaga_gfx/ffi: u64 --> *c_void
Removes the need of casts for API user.

BUG=b:273555494
TEST= compile

Change-Id: I32c545394e67546ea0bd118452bdbd430dd8735d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4763869
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-08-09 17:24:14 +00:00
Frederick Mayle
6919b3ed01 rutabaga_gfx: remove layer of boxing from RutabagaHandler
Just random cleanup while browsing.

Change-Id: Idbbddab072abc0de36e03b7fac8fde263e1bcfec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4753011
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-08-08 19:33:24 +00:00
Alyssa Ross
998597a1bd devices: gpu: map with the right PROT_* flags
This will allow differentiating between the keymap, which must be
mapped read-only (this is enforced by at least Weston and Sway), with
all the other handles, which are writeable.

Add them the map_info field.  Maybe in the future, they can be apart
of the virtio-spec (if we can't rely on the hypervisor only to enfore
the read-only attribute).

TEST=run a Wayland application in a VM with a wlroots host compositor
     run gfxstream

Change-Id: Ie381806a5b7c5edf725caece9a4b02a7f5775ea1
Co-authored-by: Idan Raiter <idanr@google.com>
Tested-by: Ryan Neph <ryanneph@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4584252
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-08-08 17:35:20 +00:00
Alyssa Ross
708fb72f3b rutabaga_gfx/ffi: fix installing on Linux
* If $(DESTDIR)$(libdir) wasn't already a directory, the library
   would be installed to that path, rather than inside that directory.

 * The unversioned library links would be installed directly into
   prefix rather than into libdir, where nothing would find them.

TEST=make install with prefix pointing to an empty/non-existent path.

Change-Id: If6e2844e0d854a53dd61a88b02f91334f3311eeb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4754156
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2023-08-07 17:36:04 +00:00
Gurchetan Singh
548c98f4fc rutabaga_gfx: clean up header
- Group definitions in ways that make more logical sense
- rutabaga_fence -> *rutabaga_fence
- const correctness

BUG=b:273555494
TEST=compile

Change-Id: I2c3c715ee1b03b0441868a517545d34ff774c2de
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4712928
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-26 17:51:36 +00:00
Gurchetan Singh
f21b1f6799 rutabaga_gfx: support debug callback
This adds a debug callback to rutabaga_gfx + gfxstream.  This is
because VMMs often redirect logging to custom handlers, or even
abort on error.  For gfxstream alone, for the unstable API
we have:

- METRICS_CALLBACK_ADD_INSTANT_EVENT
- METRICS_CALLBACK_ADD_INSTANT_EVENT_WITH_DESCRIPTOR
- METRICS_CALLBACK_ADD_VULKAN_OUT_OF_MEMORY_EVENT
- METRICS_CALLBACK_SET_ANNOTATION
- METRICS_CALLBACK_ABORT

Many of these can be converted to use this more generic debug
handler (just by extending the struct).

BUG=b:292548160
TEST=see debug output when booting a VMM with FFI bindings.

Change-Id: Id69bfc9e5fb4c5610f5108278aed37c31150c95a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4712927
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-26 17:51:27 +00:00
Gurchetan Singh
5f8fcd5278 rutabaga_gfx: add generic callback function
Sometimes, it's desirable for rutabaga to tell the VMM something.
Currently, it's just fences, but in the future it may be messages
from gfxstream.

BUG=b:292548160
TEST=run VM

Change-Id: Ica13a83a4bb8ebab88e929b469143a4a7f35f43e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4712926
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-07-25 01:04:54 +00:00
Gurchetan Singh
c7fa3ee7fe rutabaga_gfx: extensible submit cmd
Fence passing API.

BUG=b:291675505
TEST=compile

Change-Id: Ied4a05d1036a0d2ee30c2ba914f266db042df9a3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4697702
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-22 00:03:18 +00:00
Gurchetan Singh
c5c1f01826 rutabaga_gfx/ffi: expose WSI option
For a stable rutabaga API, we should do this.

BUG=b:273555494
TEST=./rutabaga_test

Change-Id: I4cbb35324cff6dd5c1fafc06d91a3826d659cff8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4673245
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-07-11 03:20:32 +00:00
Gurchetan Singh
70e260527b rutabaga_gfx/ffi: win32 fix
A forward declaration should be enough and not clash with other
self-defintions.  Similiar to what gfxstream does.

BUG=b:273555494
TEST=compile

Change-Id: Ib5dae74f0590337977466f8e5921111db713517f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4673244
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-07-07 18:56:07 +00:00
Gurchetan Singh
46827e1984 rutabaga_gfx/ffi: fix gfxstream capset names
Recent capset name changes have caused test to
fail.  Fix this.

BUG=b:273555494
TEST=./rutabaga_test

Change-Id: I875f8a6350970f90ae127eaeb527f3264db54236
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4673243
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-07 18:56:01 +00:00
Gurchetan Singh
4d712914d2 rutabaga_gfx/ffi: fix cross domain test
Recent protocol changes have caused test to fail.
Fix this.

BUG=b:273555494
TES=./rutabaga_test

Change-Id: I5f344a16d3bc7a6edcb4bb217e842477b6bdd637
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4673242
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-07-07 18:55:37 +00:00
Gurchetan Singh
b52492660a rutabaga_gfx/ffi: clang-format virtgpu cross domain protocol
We should do this.

BUG=b:273555494
TEST=./rutabaga_test

Change-Id: I8fc3a7d0bd3802df8c57e3b15eb0bb3fd1371366
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4673241
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-07-07 18:55:31 +00:00
Gurchetan Singh
77217157df rutabaga_gfx: separate namespace for Wayland read pipes
talex5@ reports:

"When sending a pipe, the guest has to know what ID the host will
assign to it. The guest guesses, by adding 2 to the last ID it
knows about, and the host checks its guess. If it was wrong
(e.g. because the host created a new ID at the same time) then you
get a protocol error."

A solution is a separate namespace for Wayland read pipes.

BUG=b:259268477
TEST= - copy+paste still works
      - didn't repro exact case, but should just work (TM)

Change-Id: I76938b8b8105289bbfa4c5891eb95f7035d5196a
2023-06-30 10:16:57 -07:00
Gurchetan Singh
e4c1878733 rutabaga_gfx: capset changes needed by QEMU integration
For QEMU, rather than specifying the ambiguous arguments like
"use_gles" (which GLES? virgl or gfxstream) or "use_vulkan"
(which vulkan?), let's use the more clear capset names.  For
example, one can just specify:

-device virtio-vga-rutabaga,capset_names=gfxstream-gles:cross-domain

For guest ANGLE:

-device virtio-vga-rutabaga,capset_names=gfxstream-vulkan

The problem is gfxstream labels everything it does has "gfxstream".
Further differentiation is needed for the proposed launcher flow
to work into all the things gfxstream does: cerealized vulkan,
gfxstream gles, host composer and Magma host drivers in the guest.

BUG=b:280681128
TEST=guest ANGLE + QEMU works

Change-Id: Ia7dba6e91585e1f9adaa1b26fb3bb523a8fa0957
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4517952
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-05-11 22:14:21 +00:00
Gurchetan Singh
83453921d4 rutabaga_gfx: more cross-platform support
For AEMU, we'll want MacOS support for sure.

BUG=b:281527670
TEST=cargo build --target=x86_64-apple-darwin --release

Change-Id: Ia7ce0e33df52b8b94426aafd70a0129670c1539e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4513917
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-05-08 20:35:37 +00:00
Gurchetan Singh
f90779dae8 rutabaga_gfx: finish removing set_use_guest_angle
Missed a spot last time.

BUG=278138335
TEST=compile

Change-Id: I74edbdded7614250ef55a51370a5faa6a2ee0cbf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4505110
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-05-04 00:19:00 +00:00
Pierre Labatut
67b36de49a Also build rutabaga as a ststic library.
This is useful to create monolithic portable binaries.

Change-Id: I7de6b20fbc5ab85f588cd2711d7e99d0183d9f15
Bug: b/276425028
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4450988
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2023-04-20 17:22:38 +00:00
Gurchetan Singh
18472b0b0a rutabaga_gfx: match gfxstream declarations
This matches the latest gfxstream declarations.  Having
everything as a single enum without separation between
fence/mem isn't too bad since adding a new type essentially
means creating a new OS (which happens rarely).

BUG=b:273555494
TEST=compile

Change-Id: I6c6dd957e443cb51c3c8109d514d15985636a2b3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4425451
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-14 20:27:49 +00:00
Gurchetan Singh
e712a6cfc4 rutabaga_gfx/ffi: version dependencies
BUG=b:273555494
TEST=compile

Change-Id: I5a696de1e346ad99fa5734676b02b5ecfa47a426
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4418826
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-04-12 18:02:07 +00:00
Christian Blichmann
c53b40e455 Fix typos found by common-typos checker
Change-Id: Ie539304c85d0dc54bc1e17892db8bbbfb15b69ef
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4417934
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-04-12 16:58:51 +00:00
Gurchetan Singh
2003b20c5c rutabaga_gfx/ffi: add rutabaga_calculate_capset_mask
Useful for falling back to older methods of rendering when
needed.

BUG=b:273555494
TEST=rutabaga_test

Change-Id: Ic5b99e68f09f59c08bf29a2d42848c5451e4bbd8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4409070
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-04-10 19:17:08 +00:00
Gurchetan Singh
35e268ae2a rutabaga_gfx/ffi: modify makefile to create includedir
It's more traditional to install headers this way.

BUG=b:273555494
TEST=compile

Change-Id: I9cbcee18adf488fe54a0630ab9229ae231b16692
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4409071
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-08 00:02:22 +00:00
Gurchetan Singh
069e979a68 rutabaga_gfx/ffi: clang-format modifications
- Use spaces instead of tabs
- Use Clang format in Chromium build tools (also same one used
  by gfxstream), i.e:

   ~/buildtools/linux64/clang-format -i rutabaga_gfx_ffi.h

BUG=b:273555494
TEST=rutabaga_test

Change-Id: I1aa4d87f1d694fe3200281dada33dcc915a0afd7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4409068
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-04-07 21:37:23 +00:00
Gurchetan Singh
61ee6744f2 rutabaga_gfx: nuke base dependency
The base crate has some nifty abstractions but also
pulls in things like minijail, audio_streams and
various random items.

This prevents true cross-platform interoperatibility,
which requires the ability to upload to crates.io
with relative ease.

This change removes the base crate.  The replacement
strategy is two fold:

- For things like SafeDescriptor which don't have
  adequate solutions on crates.io, just copy it
  internally.  I think SafeDescriptor in particular --
  since it works on bot Windows/Linux should probably
  be made into a separate crate long-term since it is
  generically valuable.  Similarly for the Event and
  WaitContext APIs.  For now, live with the duplication.

- Otherwise, the nix crate does most of the Linux
  specific items.

The cross-domain context type has a lot of dependencies
on Linux sockets / epoll.  This is refactored to look more
like the Fuchsia solution, which uses std::sync::mspc
channels to connect to an utility Wayland FIDL library.

The rest of Rutabaga mostly relies just on SafeDescriptor
and the ability to clone it.  rutabaga_gralloc allows
provides shared memory used via virtwl.

Another thing to call out is zerocopy is now strongly
versioned to the latest stable release on crates.io

I also got rid of #[cfg(feature = "virgl_renderer_next")]
on the renderer server fd, since it was complicating the
refactoring.  SafeDescriptor works everywhere and adding
the #ifdef should be reserved for the lowest-levels of
platform specific code when possible.

Overall, this makes compiling on Fuchsia hosts much
simpler.

BUG=b:273555494
TEST= - run cross_domain context type, see Wayland apps
      - note there is a previous bug in cross domain
        when resizing windows, it occurs before this CL.
        The reason seems to be raciness and can likely be fixed
        gfxstream-like seqno.
      - run gfxstream + virgl on Linux, verify everything works.

Change-Id: I7519f2b8ed0cd57c47980d4e76403057498cf064
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4353700
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-03-27 18:46:22 +00:00
Gurchetan Singh
ce5ff3e75e rutabaga_gfx: add log package
This tracks librust-log-dev, which is at version 0.4.17-3 in the
Debian package tracker.

It may be possible to use another version too.

BUG=b:273555494
TEST=rutabaga_test

Change-Id: Ib0aaca5800f22960dad89b4e138a0dd5fefcb9c2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4353699
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-03-27 18:46:07 +00:00