mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-09 20:04:20 +00:00
rutabaga_gfx: add stream_renderer_vulkan_info
The exact internals of the API may change though. For example, using a device UUID is a less error-prone than using physical device index. However, this is sufficient to get gfxstream external memory on atleast some platforms. BUG=b:235485545 TEST=compile and run ./deqp-vk with kFeature_ExternalBlob enabled Change-Id: I10d2aaecfbcd61f383dd326184e60942755db196 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864029 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Idan Raiter <idanr@google.com> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
This commit is contained in:
parent
583e650455
commit
710b3c9082
1 changed files with 25 additions and 1 deletions
|
@ -76,6 +76,13 @@ pub struct stream_renderer_handle {
|
|||
pub handle_type: u32,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Default)]
|
||||
pub struct stream_renderer_vulkan_info {
|
||||
pub memory_index: u32,
|
||||
pub physical_device_index: u32,
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
type stream_renderer_create_blob = ResourceCreateBlob;
|
||||
|
||||
|
@ -167,6 +174,10 @@ extern "C" {
|
|||
) -> c_int;
|
||||
fn stream_renderer_resource_unmap(res_handle: u32) -> c_int;
|
||||
fn stream_renderer_resource_map_info(res_handle: u32, map_info: *mut u32) -> c_int;
|
||||
fn stream_renderer_vulkan_info(
|
||||
res_handle: u32,
|
||||
vulkan_info: *mut stream_renderer_vulkan_info,
|
||||
) -> c_int;
|
||||
fn stream_renderer_context_create(
|
||||
handle: u32,
|
||||
nlen: u32,
|
||||
|
@ -317,12 +328,25 @@ impl Gfxstream {
|
|||
|
||||
fn map_info(&self, resource_id: u32) -> RutabagaResult<u32> {
|
||||
let mut map_info = 0;
|
||||
// Safe because `map_info` is a local stack variable owned by us.
|
||||
let ret = unsafe { stream_renderer_resource_map_info(resource_id, &mut map_info) };
|
||||
ret_to_res(ret)?;
|
||||
|
||||
Ok(map_info)
|
||||
}
|
||||
|
||||
fn vulkan_info(&self, resource_id: u32) -> RutabagaResult<VulkanInfo> {
|
||||
let mut vulkan_info: stream_renderer_vulkan_info = Default::default();
|
||||
// Safe because `vulkan_info` is a local stack variable owned by us.
|
||||
let ret = unsafe { stream_renderer_vulkan_info(resource_id, &mut vulkan_info) };
|
||||
ret_to_res(ret)?;
|
||||
|
||||
Ok(VulkanInfo {
|
||||
memory_idx: vulkan_info.memory_index,
|
||||
physical_device_idx: vulkan_info.physical_device_index,
|
||||
})
|
||||
}
|
||||
|
||||
fn export_blob(&self, resource_id: u32) -> RutabagaResult<Arc<RutabagaHandle>> {
|
||||
let mut stream_handle: stream_renderer_handle = Default::default();
|
||||
let ret = unsafe { stream_renderer_export_blob(resource_id as u32, &mut stream_handle) };
|
||||
|
@ -571,7 +595,7 @@ impl RutabagaComponent for Gfxstream {
|
|||
map_info: self.map_info(resource_id).ok(),
|
||||
info_2d: None,
|
||||
info_3d: None,
|
||||
vulkan_info: None,
|
||||
vulkan_info: self.vulkan_info(resource_id).ok(),
|
||||
backing_iovecs: iovec_opt,
|
||||
import_mask: 0,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue