rutabaga_gfx: update Vulkano to match ToT

- Instance creation requires VulkanLibrary type
- UnsafeImage --> Arc<UnsafeImage>

BUG=b:173630595
TEST=cargo test --features=vulkano

Change-Id: Ie64d06fe0f20d63a19c94ae9fe6c904e83508178
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3858687
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Gurchetan Singh 2022-08-26 08:51:31 -07:00 committed by crosvm LUCI
parent 7a6049d0d7
commit 7f5c54392a
2 changed files with 27 additions and 8 deletions

View file

@ -44,6 +44,8 @@ use vulkano::memory::MemoryAllocateInfo;
use vulkano::memory::MemoryMapError;
use vulkano::memory::MemoryRequirements;
use vulkano::sync::Sharing;
use vulkano::LoadingError;
use vulkano::VulkanLibrary;
use crate::rutabaga_gralloc::gralloc::Gralloc;
use crate::rutabaga_gralloc::gralloc::ImageAllocationInfo;
@ -93,16 +95,21 @@ impl VulkanoGralloc {
pub fn init() -> RutabagaResult<Box<dyn Gralloc>> {
// Initialization copied from triangle.rs in Vulkano. Look there for a more detailed
// explanation of VK initialization.
let library = VulkanLibrary::new()?;
let instance_extensions = InstanceExtensions {
khr_external_memory_capabilities: true,
khr_get_physical_device_properties2: true,
..InstanceExtensions::none()
};
let instance = Instance::new(InstanceCreateInfo {
enabled_extensions: instance_extensions,
max_api_version: Some(Version::V1_1),
..Default::default()
})?;
let instance = Instance::new(
library,
InstanceCreateInfo {
enabled_extensions: instance_extensions,
max_api_version: Some(Version::V1_1),
..Default::default()
},
)?;
let mut devices: Map<PhysicalDeviceType, Arc<Device>> = Default::default();
let mut has_integrated_gpu = false;
@ -175,7 +182,7 @@ impl VulkanoGralloc {
unsafe fn create_image(
&mut self,
info: ImageAllocationInfo,
) -> RutabagaResult<(sys::UnsafeImage, MemoryRequirements)> {
) -> RutabagaResult<(Arc<sys::UnsafeImage>, MemoryRequirements)> {
let device = if self.has_integrated_gpu {
self.devices
.get(&PhysicalDeviceType::IntegratedGpu)
@ -500,3 +507,9 @@ impl From<MemoryMapError> for RutabagaError {
RutabagaError::VkMemoryMapError(e)
}
}
impl From<LoadingError> for RutabagaError {
fn from(e: LoadingError) -> RutabagaError {
RutabagaError::VkLoadingError(e)
}
}

View file

@ -30,6 +30,8 @@ use vulkano::memory::DeviceMemoryAllocationError;
use vulkano::memory::DeviceMemoryExportError;
#[cfg(feature = "vulkano")]
use vulkano::memory::MemoryMapError;
#[cfg(feature = "vulkano")]
use vulkano::LoadingError;
/// Represents a buffer. `base` contains the address of a buffer, while `len` contains the length
/// of the buffer.
@ -253,9 +255,13 @@ pub enum RutabagaError {
#[cfg(feature = "vulkano")]
#[error("vulkano instance creation failure {0}")]
VkInstanceCreationError(InstanceCreationError),
/// Memory map error
/// Loading error
#[cfg(feature = "vulkano")]
#[error("vullano memory map failure {0}")]
#[error("vulkano loading failure {0}")]
VkLoadingError(LoadingError),
/// Memory map error
#[cfg(feature = "vulkano")]
#[error("vulkano memory map failure {0}")]
VkMemoryMapError(MemoryMapError),
/// Volatile memory error
#[error("noticed a volatile memory error {0}")]