mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-26 08:51:31 +11:00
Merge #110
110: Expose VK_KHR_maintenance1 and fix the descriptor allocation fall back r=msiglreith a=kvark Depends on https://github.com/gfx-rs/gfx/pull/2202 cc @fkaa Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
commit
0b910b7632
11
Cargo.lock
generated
11
Cargo.lock
generated
|
@ -265,7 +265,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gfx-backend-dx11"
|
name = "gfx-backend-dx11"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/gfx-rs/gfx#ee7ae15b09363580fd81b8538e53890231e46bf3"
|
source = "git+https://github.com/gfx-rs/gfx#da53237ac20aa6ca823ca743f555f859808c6486"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -281,7 +281,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gfx-backend-dx12"
|
name = "gfx-backend-dx12"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/gfx-rs/gfx#ee7ae15b09363580fd81b8538e53890231e46bf3"
|
source = "git+https://github.com/gfx-rs/gfx#da53237ac20aa6ca823ca743f555f859808c6486"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -297,14 +297,13 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gfx-backend-metal"
|
name = "gfx-backend-metal"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/gfx-rs/gfx#ee7ae15b09363580fd81b8538e53890231e46bf3"
|
source = "git+https://github.com/gfx-rs/gfx#da53237ac20aa6ca823ca743f555f859808c6486"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"block 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cocoa 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cocoa 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-graphics 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-graphics 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"derivative 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
"gfx-hal 0.1.0 (git+https://github.com/gfx-rs/gfx)",
|
||||||
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -318,7 +317,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gfx-backend-vulkan"
|
name = "gfx-backend-vulkan"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/gfx-rs/gfx#ee7ae15b09363580fd81b8538e53890231e46bf3"
|
source = "git+https://github.com/gfx-rs/gfx#da53237ac20aa6ca823ca743f555f859808c6486"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ash 0.24.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ash 0.24.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"byteorder 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -336,7 +335,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gfx-hal"
|
name = "gfx-hal"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/gfx-rs/gfx#ee7ae15b09363580fd81b8538e53890231e46bf3"
|
source = "git+https://github.com/gfx-rs/gfx#da53237ac20aa6ca823ca743f555f859808c6486"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -771,6 +771,7 @@ static INSTANCE_EXTENSION_NAME_VK_KHR_WIN32_SURFACE: &str = "VK_KHR_win32_surfac
|
||||||
#[cfg(target_os="macos")]
|
#[cfg(target_os="macos")]
|
||||||
static INSTANCE_EXTENSION_NAME_VK_MACOS_SURFACE: &str = "VK_MVK_macos_surface";
|
static INSTANCE_EXTENSION_NAME_VK_MACOS_SURFACE: &str = "VK_MVK_macos_surface";
|
||||||
static DEVICE_EXTENSION_NAME_VK_KHR_SWAPCHAIN: &str = "VK_KHR_swapchain";
|
static DEVICE_EXTENSION_NAME_VK_KHR_SWAPCHAIN: &str = "VK_KHR_swapchain";
|
||||||
|
static DEVICE_EXTENSION_NAME_VK_KHR_MAINTENANCE1: &str = "VK_KHR_maintenance1";
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
// TODO: Request from backend
|
// TODO: Request from backend
|
||||||
|
@ -802,23 +803,13 @@ lazy_static! {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
extensions[0]
|
for (&name, extension) in INSTANCE_EXTENSION_NAMES.iter().zip(&mut extensions) {
|
||||||
.extensionName[..VK_KHR_SURFACE_EXTENSION_NAME.len()]
|
extension
|
||||||
|
.extensionName[.. name.len()]
|
||||||
.copy_from_slice(unsafe {
|
.copy_from_slice(unsafe {
|
||||||
mem::transmute(VK_KHR_SURFACE_EXTENSION_NAME as &[u8])
|
mem::transmute(name.as_bytes())
|
||||||
});
|
|
||||||
#[cfg(target_os="windows")]
|
|
||||||
extensions[1]
|
|
||||||
.extensionName[..VK_KHR_WIN32_SURFACE_EXTENSION_NAME.len()]
|
|
||||||
.copy_from_slice(unsafe {
|
|
||||||
mem::transmute(VK_KHR_WIN32_SURFACE_EXTENSION_NAME as &[u8])
|
|
||||||
});
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
extensions[1]
|
|
||||||
.extensionName[..VK_MVK_MACOS_SURFACE_EXTENSION_NAME.len()]
|
|
||||||
.copy_from_slice(unsafe {
|
|
||||||
mem::transmute(VK_MVK_MACOS_SURFACE_EXTENSION_NAME as &[u8])
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
extensions.to_vec()
|
extensions.to_vec()
|
||||||
};
|
};
|
||||||
|
@ -826,6 +817,7 @@ lazy_static! {
|
||||||
static ref DEVICE_EXTENSION_NAMES: Vec<&'static str> = {
|
static ref DEVICE_EXTENSION_NAMES: Vec<&'static str> = {
|
||||||
vec![
|
vec![
|
||||||
DEVICE_EXTENSION_NAME_VK_KHR_SWAPCHAIN,
|
DEVICE_EXTENSION_NAME_VK_KHR_SWAPCHAIN,
|
||||||
|
DEVICE_EXTENSION_NAME_VK_KHR_MAINTENANCE1,
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -835,13 +827,19 @@ lazy_static! {
|
||||||
extensionName: [0; 256], // VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
extensionName: [0; 256], // VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
||||||
specVersion: VK_KHR_SWAPCHAIN_SPEC_VERSION,
|
specVersion: VK_KHR_SWAPCHAIN_SPEC_VERSION,
|
||||||
},
|
},
|
||||||
|
VkExtensionProperties {
|
||||||
|
extensionName: [0; 256], // VK_KHR_MAINTENANCE1_EXTENSION_NAME
|
||||||
|
specVersion: VK_KHR_MAINTENANCE1_SPEC_VERSION,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
extensions[0]
|
for (&name, extension) in DEVICE_EXTENSION_NAMES.iter().zip(&mut extensions) {
|
||||||
.extensionName[..VK_KHR_SWAPCHAIN_EXTENSION_NAME.len()]
|
extension
|
||||||
|
.extensionName[.. name.len()]
|
||||||
.copy_from_slice(unsafe {
|
.copy_from_slice(unsafe {
|
||||||
mem::transmute(VK_KHR_SWAPCHAIN_EXTENSION_NAME as &[u8])
|
mem::transmute(name.as_bytes())
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
extensions.to_vec()
|
extensions.to_vec()
|
||||||
};
|
};
|
||||||
|
@ -958,7 +956,7 @@ pub extern "C" fn gfxQueueSubmit(
|
||||||
let stages = slice::from_raw_parts(submission.pWaitDstStageMask, submission.waitSemaphoreCount as _);
|
let stages = slice::from_raw_parts(submission.pWaitDstStageMask, submission.waitSemaphoreCount as _);
|
||||||
|
|
||||||
stages.into_iter()
|
stages.into_iter()
|
||||||
.zip(semaphores.into_iter())
|
.zip(semaphores)
|
||||||
.map(|(stage, semaphore)| (&**semaphore, conv::map_pipeline_stage_flags(*stage)))
|
.map(|(stage, semaphore)| (&**semaphore, conv::map_pipeline_stage_flags(*stage)))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
};
|
};
|
||||||
|
@ -2417,23 +2415,41 @@ pub extern "C" fn gfxAllocateDescriptorSets(
|
||||||
let sets = unsafe {
|
let sets = unsafe {
|
||||||
slice::from_raw_parts_mut(pDescriptorSets, info.descriptorSetCount as _)
|
slice::from_raw_parts_mut(pDescriptorSets, info.descriptorSetCount as _)
|
||||||
};
|
};
|
||||||
for (set, raw_set) in sets.iter_mut().zip(descriptor_sets.into_iter()) {
|
let mut result = VkResult::VK_SUCCESS;
|
||||||
*set = match raw_set {
|
assert_eq!(descriptor_sets.len(), info.descriptorSetCount as usize);
|
||||||
Ok(set) => Handle::new(set),
|
|
||||||
Err(e) => return match e {
|
for (i, raw_set) in descriptor_sets.into_iter().enumerate() {
|
||||||
|
match raw_set {
|
||||||
|
Ok(set) => {
|
||||||
|
sets[i] = Handle::new(set);
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
// revert all the changes!
|
||||||
|
for set in sets[..i].iter_mut() {
|
||||||
|
let _ = set.unbox();
|
||||||
|
}
|
||||||
|
for set in sets.iter_mut() {
|
||||||
|
*set = Handle::null();
|
||||||
|
}
|
||||||
|
result = match e {
|
||||||
pso::AllocationError::OutOfHostMemory => VkResult::VK_ERROR_OUT_OF_HOST_MEMORY,
|
pso::AllocationError::OutOfHostMemory => VkResult::VK_ERROR_OUT_OF_HOST_MEMORY,
|
||||||
pso::AllocationError::OutOfDeviceMemory => VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY,
|
pso::AllocationError::OutOfDeviceMemory => VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY,
|
||||||
pso::AllocationError::OutOfPoolMemory => VkResult::VK_ERROR_OUT_OF_POOL_MEMORY_KHR,
|
pso::AllocationError::OutOfPoolMemory => VkResult::VK_ERROR_OUT_OF_POOL_MEMORY_KHR,
|
||||||
pso::AllocationError::IncompatibleLayout => VkResult::VK_ERROR_DEVICE_LOST,
|
pso::AllocationError::IncompatibleLayout => VkResult::VK_ERROR_DEVICE_LOST,
|
||||||
pso::AllocationError::FragmentedPool => VkResult::VK_ERROR_FRAGMENTED_POOL,
|
pso::AllocationError::FragmentedPool => VkResult::VK_ERROR_FRAGMENTED_POOL,
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if result == VkResult::VK_SUCCESS {
|
||||||
if let Some(ref mut local_sets) = pool.sets {
|
if let Some(ref mut local_sets) = pool.sets {
|
||||||
local_sets.push(*set);
|
local_sets.extend_from_slice(sets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkResult::VK_SUCCESS
|
result
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxFreeDescriptorSets(
|
pub extern "C" fn gfxFreeDescriptorSets(
|
||||||
|
|
Loading…
Reference in a new issue