Trait rutabaga_gfx::rutabaga_core::RutabagaComponent
source · pub trait RutabagaComponent {
Show 23 methods
// Provided methods
fn get_capset_info(&self, _capset_id: u32) -> (u32, u32) { ... }
fn get_capset(&self, _capset_id: u32, _version: u32) -> Vec<u8> { ... }
fn force_ctx_0(&self) { ... }
fn create_fence(&mut self, _fence: RutabagaFence) -> RutabagaResult<()> { ... }
fn event_poll(&self) { ... }
fn poll_descriptor(&self) -> Option<OwnedDescriptor> { ... }
fn create_3d(
&self,
resource_id: u32,
_resource_create_3d: ResourceCreate3D
) -> RutabagaResult<RutabagaResource> { ... }
fn attach_backing(
&self,
_resource_id: u32,
_vecs: &mut Vec<RutabagaIovec>
) -> RutabagaResult<()> { ... }
fn detach_backing(&self, _resource_id: u32) { ... }
fn unref_resource(&self, _resource_id: u32) { ... }
fn transfer_write(
&self,
_ctx_id: u32,
_resource: &mut RutabagaResource,
_transfer: Transfer3D
) -> RutabagaResult<()> { ... }
fn transfer_read(
&self,
_ctx_id: u32,
_resource: &mut RutabagaResource,
_transfer: Transfer3D,
_buf: Option<IoSliceMut<'_>>
) -> RutabagaResult<()> { ... }
fn resource_flush(
&self,
_resource_id: &mut RutabagaResource
) -> RutabagaResult<()> { ... }
fn create_blob(
&mut self,
_ctx_id: u32,
_resource_id: u32,
_resource_create_blob: ResourceCreateBlob,
_iovec_opt: Option<Vec<RutabagaIovec>>,
_handle_opt: Option<RutabagaHandle>
) -> RutabagaResult<RutabagaResource> { ... }
fn map(&self, _resource_id: u32) -> RutabagaResult<RutabagaMapping> { ... }
fn unmap(&self, _resource_id: u32) -> RutabagaResult<()> { ... }
fn export_fence(&self, _fence_id: u64) -> RutabagaResult<RutabagaHandle> { ... }
fn create_context(
&self,
_ctx_id: u32,
_context_init: u32,
_context_name: Option<&str>,
_fence_handler: RutabagaFenceHandler
) -> RutabagaResult<Box<dyn RutabagaContext>> { ... }
fn suspend(&self) -> RutabagaResult<()> { ... }
fn snapshot(&self, _directory: &str) -> RutabagaResult<()> { ... }
fn restore(&self, _directory: &str) -> RutabagaResult<()> { ... }
fn resume(&self) -> RutabagaResult<()> { ... }
fn wait_sync(&self, _resource: &RutabagaResource) -> RutabagaResult<()> { ... }
}
Expand description
A RutabagaComponent is a building block of the Virtual Graphics Interface (VGI). Each component on it’s own is sufficient to virtualize graphics on many Google products. These components wrap libraries like gfxstream or virglrenderer, and Rutabaga’s own 2D and cross-domain prototype functionality.
Most methods return a RutabagaResult
that indicate the success, failure, or requested data for
the given command.
Provided Methods§
sourcefn get_capset_info(&self, _capset_id: u32) -> (u32, u32)
fn get_capset_info(&self, _capset_id: u32) -> (u32, u32)
Implementations should return the version and size of the given capset_id. (0, 0) is returned by default.
sourcefn get_capset(&self, _capset_id: u32, _version: u32) -> Vec<u8>
fn get_capset(&self, _capset_id: u32, _version: u32) -> Vec<u8>
Implementations should return the capabilites of given a capset_id
and version
. A
zero-sized array is returned by default.
sourcefn force_ctx_0(&self)
fn force_ctx_0(&self)
Implementations should set their internal context to be the reserved context 0.
sourcefn create_fence(&mut self, _fence: RutabagaFence) -> RutabagaResult<()>
fn create_fence(&mut self, _fence: RutabagaFence) -> RutabagaResult<()>
Implementations must create a fence that represents the completion of prior work. This is required for synchronization with the guest kernel.
sourcefn event_poll(&self)
fn event_poll(&self)
Used only by VirglRenderer to poll when its poll_descriptor is signaled.
sourcefn poll_descriptor(&self) -> Option<OwnedDescriptor>
fn poll_descriptor(&self) -> Option<OwnedDescriptor>
Used only by VirglRenderer to return a poll_descriptor that is signaled when a poll() is necessary.
sourcefn create_3d(
&self,
resource_id: u32,
_resource_create_3d: ResourceCreate3D
) -> RutabagaResult<RutabagaResource>
fn create_3d( &self, resource_id: u32, _resource_create_3d: ResourceCreate3D ) -> RutabagaResult<RutabagaResource>
Implementations must create a resource with the given metadata. For 2D rutabaga components, this a system memory allocation. For 3D components, this is typically a GL texture or buffer. Vulkan components should use blob resources instead.
sourcefn attach_backing(
&self,
_resource_id: u32,
_vecs: &mut Vec<RutabagaIovec>
) -> RutabagaResult<()>
fn attach_backing( &self, _resource_id: u32, _vecs: &mut Vec<RutabagaIovec> ) -> RutabagaResult<()>
Implementations must attach vecs
to the resource.
sourcefn detach_backing(&self, _resource_id: u32)
fn detach_backing(&self, _resource_id: u32)
Implementations must detach vecs
from the resource.
sourcefn unref_resource(&self, _resource_id: u32)
fn unref_resource(&self, _resource_id: u32)
Implementations must release the guest kernel reference on the resource.
sourcefn transfer_write(
&self,
_ctx_id: u32,
_resource: &mut RutabagaResource,
_transfer: Transfer3D
) -> RutabagaResult<()>
fn transfer_write( &self, _ctx_id: u32, _resource: &mut RutabagaResource, _transfer: Transfer3D ) -> RutabagaResult<()>
Implementations must perform the transfer write operation. For 2D rutabaga components, this done via memcpy(). For 3D components, this is typically done via glTexSubImage(..).
sourcefn transfer_read(
&self,
_ctx_id: u32,
_resource: &mut RutabagaResource,
_transfer: Transfer3D,
_buf: Option<IoSliceMut<'_>>
) -> RutabagaResult<()>
fn transfer_read( &self, _ctx_id: u32, _resource: &mut RutabagaResource, _transfer: Transfer3D, _buf: Option<IoSliceMut<'_>> ) -> RutabagaResult<()>
Implementations must perform the transfer read operation. For 2D rutabaga components, this done via memcpy(). For 3D components, this is typically done via glReadPixels(..).
sourcefn resource_flush(
&self,
_resource_id: &mut RutabagaResource
) -> RutabagaResult<()>
fn resource_flush( &self, _resource_id: &mut RutabagaResource ) -> RutabagaResult<()>
Implementations must flush the given resource to the display.
sourcefn create_blob(
&mut self,
_ctx_id: u32,
_resource_id: u32,
_resource_create_blob: ResourceCreateBlob,
_iovec_opt: Option<Vec<RutabagaIovec>>,
_handle_opt: Option<RutabagaHandle>
) -> RutabagaResult<RutabagaResource>
fn create_blob( &mut self, _ctx_id: u32, _resource_id: u32, _resource_create_blob: ResourceCreateBlob, _iovec_opt: Option<Vec<RutabagaIovec>>, _handle_opt: Option<RutabagaHandle> ) -> RutabagaResult<RutabagaResource>
Implementations must create a blob resource on success. The memory parameters, size, and
usage of the blob resource is given by resource_create_blob
.
sourcefn map(&self, _resource_id: u32) -> RutabagaResult<RutabagaMapping>
fn map(&self, _resource_id: u32) -> RutabagaResult<RutabagaMapping>
Implementations must map the blob resource on success. This is typically done by glMapBufferRange(…) or vkMapMemory.
sourcefn unmap(&self, _resource_id: u32) -> RutabagaResult<()>
fn unmap(&self, _resource_id: u32) -> RutabagaResult<()>
Implementations must unmap the blob resource on success. This is typically done by glUnmapBuffer(…) or vkUnmapMemory.
sourcefn export_fence(&self, _fence_id: u64) -> RutabagaResult<RutabagaHandle>
fn export_fence(&self, _fence_id: u64) -> RutabagaResult<RutabagaHandle>
Implementations must return a RutabagaHandle of the fence on success.
sourcefn create_context(
&self,
_ctx_id: u32,
_context_init: u32,
_context_name: Option<&str>,
_fence_handler: RutabagaFenceHandler
) -> RutabagaResult<Box<dyn RutabagaContext>>
fn create_context( &self, _ctx_id: u32, _context_init: u32, _context_name: Option<&str>, _fence_handler: RutabagaFenceHandler ) -> RutabagaResult<Box<dyn RutabagaContext>>
Implementations must create a context for submitting commands. The command stream of the
context is determined by context_init
. For virgl contexts, it is a Gallium/TGSI command
stream. For gfxstream contexts, it’s an autogenerated Vulkan or GLES streams.
sourcefn suspend(&self) -> RutabagaResult<()>
fn suspend(&self) -> RutabagaResult<()>
Implementations should stop workers.
sourcefn snapshot(&self, _directory: &str) -> RutabagaResult<()>
fn snapshot(&self, _directory: &str) -> RutabagaResult<()>
Implementations must snapshot to the specified directory
sourcefn restore(&self, _directory: &str) -> RutabagaResult<()>
fn restore(&self, _directory: &str) -> RutabagaResult<()>
Implementations must restore from the specified directory
sourcefn resume(&self) -> RutabagaResult<()>
fn resume(&self) -> RutabagaResult<()>
Implementations should resume workers.
sourcefn wait_sync(&self, _resource: &RutabagaResource) -> RutabagaResult<()>
fn wait_sync(&self, _resource: &RutabagaResource) -> RutabagaResult<()>
Implementations must perform a blocking wait-sync on the resource identified by resource_id