185: Fixes for gfx HEAD, update Cargo.lock, and add gl backend option r=kvark a=aloucks

Updated Cargo.lock and some minor changes to get portability compiling again using the latest gfx master. 

With these changes I was able to get `vulkaninfo` to run on a GPU-less VM using Mesa. 

```
$ RUST_BACKTRACE=1 VK_ICD_FILENAMES=portability-linux-debug.json vulkaninfo > ~/vulkaninfo.txt

==========
VULKANINFO
==========

Vulkan Instance Version: 1.1.106



Instance Extensions:
====================
Instance Extensions	count = 4
	VK_EXT_debug_report                 : extension revision  9
	VK_EXT_debug_utils                  : extension revision  1
	VK_KHR_get_physical_device_properties2: extension revision  1
	VK_KHR_surface                      : extension revision 25
Layers: count = 15
=======

...

Device Properties and Extensions :
==================================
GPU0
VkPhysicalDeviceProperties:
===========================
	apiVersion     = 0x400042  (1.0.66)
	driverVersion  = 1 (0x1)
	vendorID       = 0x0000
	deviceID       = 0x0000
	deviceType     = CPU
	deviceName     = Mesa OffScreen

...
```

Full output:

https://gist.github.com/aloucks/1a9acfb51adba4bb598ee6de0a213d82

It's probably a long way from being usable, but it would be nice to use portability for unit testing in CI jobs. 

See also: https://github.com/gfx-rs/gfx/pull/2791 for updates to the gl backend. 

Co-authored-by: Aaron Loucks <aloucks@cofront.net>
This commit is contained in:
bors[bot] 2019-06-01 01:04:26 +00:00
commit 5796b6b158
7 changed files with 450 additions and 265 deletions

651
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -53,3 +53,8 @@ optional = true
git = "https://github.com/gfx-rs/gfx"
#path = "../../gfx/src/backend/metal"
optional = true
[dependencies.gfx-backend-gl]
git = "https://github.com/gfx-rs/gfx"
#path = "../../gfx/src/backend/gl"
optional = true

View file

@ -9,6 +9,7 @@ use hal::device::WaitFor;
use hal::pool::RawCommandPool;
use hal::queue::RawCommandQueue;
use std::borrow::Cow;
#[cfg(feature = "gfx-backend-metal")]
use std::env;
use std::ffi::{CStr, CString};
@ -387,13 +388,22 @@ pub extern "C" fn gfxGetPhysicalDeviceProperties(
unsafe { mem::transmute(name) }
};
use hal::adapter::DeviceType;
let device_type = match adapter.info.device_type {
DeviceType::IntegratedGpu => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
DeviceType::DiscreteGpu => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU,
DeviceType::VirtualGpu => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU,
DeviceType::Other => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_OTHER,
DeviceType::Cpu => VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU,
};
unsafe {
*pProperties = VkPhysicalDeviceProperties {
apiVersion: (major << 22) | (minor << 12) | patch,
driverVersion: DRIVER_VERSION,
vendorID: adapter_info.vendor as _,
deviceID: adapter_info.device as _,
deviceType: VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU, // TODO
deviceType: device_type,
deviceName: device_name,
pipelineCacheUUID: [0; 16usize],
limits,
@ -1958,8 +1968,8 @@ pub extern "C" fn gfxCreateGraphicsPipelines(
entry: name.to_str().unwrap(),
module: &*stage.module,
specialization: pso::Specialization {
constants: &spec_constants[cur_specialization .. cur_specialization + spec_count],
data: &spec_data,
constants: Cow::from(&spec_constants[cur_specialization .. cur_specialization + spec_count]),
data: Cow::from(&spec_data),
},
};
cur_specialization += spec_count;
@ -2349,8 +2359,8 @@ pub extern "C" fn gfxCreateComputePipelines(
entry: name.to_str().unwrap(),
module: &*info.stage.module,
specialization: pso::Specialization {
constants: &spec_constants[cur_specialization .. cur_specialization + spec_count],
data: &spec_data,
constants: Cow::from(&spec_constants[cur_specialization .. cur_specialization + spec_count]),
data: Cow::from(&spec_data),
},
};
cur_specialization += spec_count;
@ -4290,19 +4300,14 @@ pub extern "C" fn gfxCreateSwapchainKHR(
}
}
let images = match backbuffers {
hal::Backbuffer::Images(images) => images
.into_iter()
.map(|raw| Handle::new(Image {
raw,
mip_levels: 1,
array_layers: 1,
}))
.collect(),
hal::Backbuffer::Framebuffer(_) => panic!(
"Expected backbuffer images. Backends returning only framebuffers are not supported!"
),
};
let images = backbuffers
.into_iter()
.map(|raw| Handle::new(Image {
raw,
mip_levels: 1,
array_layers: 1,
}))
.collect();
let swapchain = Swapchain {
raw: Some(swapchain),
@ -4579,16 +4584,21 @@ pub extern "C" fn gfxAcquireNextImageKHR(
None => return VkResult::VK_ERROR_OUT_OF_DATE_KHR,
};
use hal::device::OutOfMemory::{OutOfDeviceMemory, OutOfHostMemory};
match unsafe {
raw.acquire_image(timeout, semaphore.as_ref(), fence.as_ref())
} {
Ok(frame) => {
unsafe { *pImageIndex = frame; }
unsafe { *pImageIndex = frame.0; }
VkResult::VK_SUCCESS
}
Err(hal::AcquireError::NotReady) => VkResult::VK_NOT_READY,
Err(hal::AcquireError::OutOfDate) => VkResult::VK_ERROR_OUT_OF_DATE_KHR,
Err(hal::AcquireError::SurfaceLost(_)) => VkResult::VK_ERROR_SURFACE_LOST_KHR,
Err(hal::AcquireError::DeviceLost(_)) => VkResult::VK_ERROR_DEVICE_LOST,
Err(hal::AcquireError::OutOfMemory(OutOfDeviceMemory)) => VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY,
Err(hal::AcquireError::OutOfMemory(OutOfHostMemory)) => VkResult::VK_ERROR_OUT_OF_HOST_MEMORY,
}
}
#[inline]

View file

@ -13,6 +13,8 @@ extern crate gfx_backend_dx11 as back;
extern crate gfx_backend_metal as back;
#[cfg(feature = "gfx-backend-vulkan")]
extern crate gfx_backend_vulkan as back;
#[cfg(feature = "gfx-backend-gl")]
extern crate gfx_backend_gl as back;
extern crate copyless;
#[macro_use]

View file

@ -17,6 +17,7 @@ dx12 = ["portability-gfx/gfx-backend-dx12"]
dx11 = ["portability-gfx/gfx-backend-dx11"]
metal = ["portability-gfx/gfx-backend-metal"]
vulkan = ["portability-gfx/gfx-backend-vulkan"]
gl = ["portability-gfx/gfx-backend-gl"]
[dependencies]
portability-gfx = { path = "../libportability-gfx", features = ["dispatch"] }

View file

@ -0,0 +1,7 @@
{
"file_format_version": "1.0.0",
"ICD": {
"library_path": "../target/debug/libportability_icd.so",
"api_version": "1.0.0"
}
}

View file

@ -18,6 +18,7 @@ dx12 = ["portability-gfx/gfx-backend-dx12"]
dx11 = ["portability-gfx/gfx-backend-dx11"]
metal = ["portability-gfx/gfx-backend-metal"]
vulkan = ["portability-gfx/gfx-backend-vulkan"]
gl = ["portability-gfx/gfx-backend-gl"]
[dependencies]
portability-gfx = { path = "../libportability-gfx" }