mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-26 08:51:31 +11:00
Revert changes if got an error during descriptor set allocation
This commit is contained in:
parent
2db11c607e
commit
f8b35fba0f
11
Cargo.lock
generated
11
Cargo.lock
generated
|
@ -265,7 +265,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "gfx-backend-dx11"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#ee7ae15b09363580fd81b8538e53890231e46bf3"
|
||||
source = "git+https://github.com/gfx-rs/gfx#da53237ac20aa6ca823ca743f555f859808c6486"
|
||||
dependencies = [
|
||||
"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)",
|
||||
|
@ -281,7 +281,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "gfx-backend-dx12"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#ee7ae15b09363580fd81b8538e53890231e46bf3"
|
||||
source = "git+https://github.com/gfx-rs/gfx#da53237ac20aa6ca823ca743f555f859808c6486"
|
||||
dependencies = [
|
||||
"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)",
|
||||
|
@ -297,14 +297,13 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "gfx-backend-metal"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#ee7ae15b09363580fd81b8538e53890231e46bf3"
|
||||
source = "git+https://github.com/gfx-rs/gfx#da53237ac20aa6ca823ca743f555f859808c6486"
|
||||
dependencies = [
|
||||
"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)",
|
||||
"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-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)",
|
||||
"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)",
|
||||
|
@ -318,7 +317,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "gfx-backend-vulkan"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#ee7ae15b09363580fd81b8538e53890231e46bf3"
|
||||
source = "git+https://github.com/gfx-rs/gfx#da53237ac20aa6ca823ca743f555f859808c6486"
|
||||
dependencies = [
|
||||
"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)",
|
||||
|
@ -336,7 +335,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "gfx-hal"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/gfx-rs/gfx#ee7ae15b09363580fd81b8538e53890231e46bf3"
|
||||
source = "git+https://github.com/gfx-rs/gfx#da53237ac20aa6ca823ca743f555f859808c6486"
|
||||
dependencies = [
|
||||
"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)",
|
||||
|
|
|
@ -956,7 +956,7 @@ pub extern "C" fn gfxQueueSubmit(
|
|||
let stages = slice::from_raw_parts(submission.pWaitDstStageMask, submission.waitSemaphoreCount as _);
|
||||
|
||||
stages.into_iter()
|
||||
.zip(semaphores.into_iter())
|
||||
.zip(semaphores)
|
||||
.map(|(stage, semaphore)| (&**semaphore, conv::map_pipeline_stage_flags(*stage)))
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
@ -2415,23 +2415,41 @@ pub extern "C" fn gfxAllocateDescriptorSets(
|
|||
let sets = unsafe {
|
||||
slice::from_raw_parts_mut(pDescriptorSets, info.descriptorSetCount as _)
|
||||
};
|
||||
for (set, raw_set) in sets.iter_mut().zip(descriptor_sets.into_iter()) {
|
||||
*set = match raw_set {
|
||||
Ok(set) => Handle::new(set),
|
||||
Err(e) => return match e {
|
||||
pso::AllocationError::OutOfHostMemory => VkResult::VK_ERROR_OUT_OF_HOST_MEMORY,
|
||||
pso::AllocationError::OutOfDeviceMemory => VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY,
|
||||
pso::AllocationError::OutOfPoolMemory => VkResult::VK_ERROR_OUT_OF_POOL_MEMORY_KHR,
|
||||
pso::AllocationError::IncompatibleLayout => VkResult::VK_ERROR_DEVICE_LOST,
|
||||
pso::AllocationError::FragmentedPool => VkResult::VK_ERROR_FRAGMENTED_POOL,
|
||||
},
|
||||
let mut result = VkResult::VK_SUCCESS;
|
||||
assert_eq!(descriptor_sets.len(), info.descriptorSetCount as usize);
|
||||
|
||||
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::OutOfDeviceMemory => VkResult::VK_ERROR_OUT_OF_DEVICE_MEMORY,
|
||||
pso::AllocationError::OutOfPoolMemory => VkResult::VK_ERROR_OUT_OF_POOL_MEMORY_KHR,
|
||||
pso::AllocationError::IncompatibleLayout => VkResult::VK_ERROR_DEVICE_LOST,
|
||||
pso::AllocationError::FragmentedPool => VkResult::VK_ERROR_FRAGMENTED_POOL,
|
||||
};
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if result == VkResult::VK_SUCCESS {
|
||||
if let Some(ref mut local_sets) = pool.sets {
|
||||
local_sets.push(*set);
|
||||
local_sets.extend_from_slice(sets);
|
||||
}
|
||||
}
|
||||
|
||||
VkResult::VK_SUCCESS
|
||||
result
|
||||
}
|
||||
#[inline]
|
||||
pub extern "C" fn gfxFreeDescriptorSets(
|
||||
|
|
Loading…
Reference in a new issue