mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-30 02:34:48 +00:00
optional OomErrors, fixed calls to changed functions
This commit is contained in:
parent
010a4a7174
commit
6593618feb
@ -1867,7 +1867,7 @@ pub fn submit(me: &InnerCommandBuffer, me_arc: Arc<KeepAlive>,
|
|||||||
let mut infos = SmallVec::<[_; 3]>::new();
|
let mut infos = SmallVec::<[_; 3]>::new();
|
||||||
|
|
||||||
if !before_command_buffers.is_empty() {
|
if !before_command_buffers.is_empty() {
|
||||||
// TODO: Use try!()?
|
// TODO: Use try!()? - Mixthos
|
||||||
let semaphore = Semaphore::new(queue.device());
|
let semaphore = Semaphore::new(queue.device());
|
||||||
let semaphore_id = semaphore.internal_object();
|
let semaphore_id = semaphore.internal_object();
|
||||||
pre_semaphores_stages.push(vk::PIPELINE_STAGE_TOP_OF_PIPE_BIT); // TODO:
|
pre_semaphores_stages.push(vk::PIPELINE_STAGE_TOP_OF_PIPE_BIT); // TODO:
|
||||||
@ -1888,7 +1888,7 @@ pub fn submit(me: &InnerCommandBuffer, me_arc: Arc<KeepAlive>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
let after_semaphore = if !after_command_buffers.is_empty() {
|
let after_semaphore = if !after_command_buffers.is_empty() {
|
||||||
// TODO: Use try!()?
|
// TODO: Use try!()? - Mixthos
|
||||||
let semaphore = Semaphore::new(queue.device());
|
let semaphore = Semaphore::new(queue.device());
|
||||||
let semaphore_id = semaphore.internal_object();
|
let semaphore_id = semaphore.internal_object();
|
||||||
post_semaphores_ids.push(semaphore.internal_object());
|
post_semaphores_ids.push(semaphore.internal_object());
|
||||||
|
@ -53,9 +53,9 @@ impl UnsafeDescriptorSet {
|
|||||||
/// - Panicks if the pool and the layout were not created from the same `Device`.
|
/// - Panicks if the pool and the layout were not created from the same `Device`.
|
||||||
///
|
///
|
||||||
// FIXME: this has to check whether there's still enough room in the pool
|
// FIXME: this has to check whether there's still enough room in the pool
|
||||||
pub unsafe fn uninitialized(pool: &Arc<DescriptorPool>,
|
pub unsafe fn uninitialized_raw(pool: &Arc<DescriptorPool>,
|
||||||
layout: &Arc<UnsafeDescriptorSetLayout>)
|
layout: &Arc<UnsafeDescriptorSetLayout>)
|
||||||
-> Result<UnsafeDescriptorSet, OomError>
|
-> Result<UnsafeDescriptorSet, OomError>
|
||||||
{
|
{
|
||||||
assert_eq!(&**pool.device() as *const Device, &**layout.device() as *const Device);
|
assert_eq!(&**pool.device() as *const Device, &**layout.device() as *const Device);
|
||||||
|
|
||||||
@ -89,6 +89,22 @@ impl UnsafeDescriptorSet {
|
|||||||
resources_buffers: Vec::new(),
|
resources_buffers: Vec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Builds a new descriptor set.
|
||||||
|
///
|
||||||
|
/// # Panic
|
||||||
|
///
|
||||||
|
/// - Panicks if the pool and the layout were not created from the same `Device`.
|
||||||
|
/// - Panicks if the device or host ran out of memory.
|
||||||
|
///
|
||||||
|
// FIXME: this has to check whether there's still enough room in the pool
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn uninitialized(pool: &Arc<DescriptorPool>,
|
||||||
|
layout: &Arc<UnsafeDescriptorSetLayout>)
|
||||||
|
-> UnsafeDescriptorSet
|
||||||
|
{
|
||||||
|
UnsafeDescriptorSet::uninitialized_raw(pool, layout).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
/// Modifies a descriptor set without checking that the writes are correct.
|
/// Modifies a descriptor set without checking that the writes are correct.
|
||||||
///
|
///
|
||||||
|
@ -32,8 +32,8 @@ pub struct UnsafeDescriptorSetLayout {
|
|||||||
|
|
||||||
impl UnsafeDescriptorSetLayout {
|
impl UnsafeDescriptorSetLayout {
|
||||||
/// Builds a new `UnsafeDescriptorSetLayout` with the given descriptors.
|
/// Builds a new `UnsafeDescriptorSetLayout` with the given descriptors.
|
||||||
pub fn new<I>(device: &Arc<Device>, descriptors: I)
|
pub fn raw<I>(device: &Arc<Device>, descriptors: I)
|
||||||
-> Result<Arc<UnsafeDescriptorSetLayout>, OomError>
|
-> Result<UnsafeDescriptorSetLayout, OomError>
|
||||||
where I: IntoIterator<Item = DescriptorDesc>
|
where I: IntoIterator<Item = DescriptorDesc>
|
||||||
{
|
{
|
||||||
let vk = device.pointers();
|
let vk = device.pointers();
|
||||||
@ -63,10 +63,23 @@ impl UnsafeDescriptorSetLayout {
|
|||||||
output
|
output
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Arc::new(UnsafeDescriptorSetLayout {
|
Ok(UnsafeDescriptorSetLayout {
|
||||||
layout: layout,
|
layout: layout,
|
||||||
device: device.clone(),
|
device: device.clone(),
|
||||||
}))
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Builds a new `UnsafeDescriptorSetLayout` with the given descriptors.
|
||||||
|
///
|
||||||
|
/// # Panic
|
||||||
|
///
|
||||||
|
/// - Panicks if the device or host ran out of memory.
|
||||||
|
///
|
||||||
|
#[inline]
|
||||||
|
pub fn new<I>(device: &Arc<Device>, descriptors: I) -> Arc<UnsafeDescriptorSetLayout>
|
||||||
|
where I: IntoIterator<Item = DescriptorDesc>
|
||||||
|
{
|
||||||
|
Arc::new(UnsafeDescriptorSetLayout::raw(device, descriptors).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the device used to create this layout.
|
/// Returns the device used to create this layout.
|
||||||
|
@ -49,7 +49,7 @@ impl EmptySinglePassRenderPass {
|
|||||||
preserve_attachments: vec![],
|
preserve_attachments: vec![],
|
||||||
};
|
};
|
||||||
|
|
||||||
UnsafeRenderPass::new(device, iter::empty(), Some(pass).into_iter(), iter::empty())
|
UnsafeRenderPass::raw(device, iter::empty(), Some(pass).into_iter(), iter::empty())
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(EmptySinglePassRenderPass {
|
Ok(EmptySinglePassRenderPass {
|
||||||
|
@ -84,8 +84,8 @@ macro_rules! ordered_passes_renderpass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CustomRenderPass {
|
impl CustomRenderPass {
|
||||||
pub fn new(device: &Arc<Device>, formats: &Formats)
|
pub fn raw(device: &Arc<Device>, formats: &Formats)
|
||||||
-> Result<Arc<CustomRenderPass>, OomError>
|
-> Result<CustomRenderPass, OomError>
|
||||||
{
|
{
|
||||||
#![allow(unsafe_code)]
|
#![allow(unsafe_code)]
|
||||||
|
|
||||||
@ -93,10 +93,17 @@ macro_rules! ordered_passes_renderpass {
|
|||||||
UnsafeRenderPass::new(device, attachments(formats), passes(), dependencies())
|
UnsafeRenderPass::new(device, attachments(formats), passes(), dependencies())
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(Arc::new(CustomRenderPass {
|
Ok(CustomRenderPass {
|
||||||
render_pass: rp,
|
render_pass: rp,
|
||||||
formats: formats.clone(),
|
formats: formats.clone(),
|
||||||
}))
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn new(device: &Arc<Device>, formats: &Formats)
|
||||||
|
-> Arc<CustomRenderPass>
|
||||||
|
{
|
||||||
|
CustomRenderPass::raw(device, formats)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ impl UnsafeRenderPass {
|
|||||||
/// performed. `debug_assert!` is used, so some restrictions are only checked in debug
|
/// performed. `debug_assert!` is used, so some restrictions are only checked in debug
|
||||||
/// mode.
|
/// mode.
|
||||||
///
|
///
|
||||||
pub unsafe fn new<Ia, Ip, Id>(device: &Arc<Device>, attachments: Ia, passes: Ip,
|
pub unsafe fn raw<Ia, Ip, Id>(device: &Arc<Device>, attachments: Ia, passes: Ip,
|
||||||
pass_dependencies: Id)
|
pass_dependencies: Id)
|
||||||
-> Result<UnsafeRenderPass, OomError>
|
-> Result<UnsafeRenderPass, OomError>
|
||||||
where Ia: ExactSizeIterator<Item = LayoutAttachmentDescription> + Clone, // with specialization we can handle the "Clone" restriction internally
|
where Ia: ExactSizeIterator<Item = LayoutAttachmentDescription> + Clone, // with specialization we can handle the "Clone" restriction internally
|
||||||
@ -243,6 +243,36 @@ impl UnsafeRenderPass {
|
|||||||
renderpass: renderpass,
|
renderpass: renderpass,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Builds a new renderpass.
|
||||||
|
///
|
||||||
|
/// This function calls the methods of the `Layout` implementation and builds the
|
||||||
|
/// corresponding Vulkan object.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// This function doesn't check whether all the restrictions in the attachments, passes and
|
||||||
|
/// passes dependencies were enforced.
|
||||||
|
///
|
||||||
|
/// See the documentation of the structs of this module for more info about these restrictions.
|
||||||
|
///
|
||||||
|
/// # Panic
|
||||||
|
///
|
||||||
|
/// - Can panick if it detects some violations in the restrictions. Only unexpensive checks are
|
||||||
|
/// performed. `debug_assert!` is used, so some restrictions are only checked in debug
|
||||||
|
/// mode.
|
||||||
|
///
|
||||||
|
/// - Panicks if the device or host ran out of memory.
|
||||||
|
///
|
||||||
|
pub unsafe fn new<Ia, Ip, Id>(device: &Arc<Device>, attachments: Ia, passes: Ip,
|
||||||
|
pass_dependencies: Id)
|
||||||
|
-> UnsafeRenderPass
|
||||||
|
where Ia: ExactSizeIterator<Item = LayoutAttachmentDescription> + Clone, // with specialization we can handle the "Clone" restriction internally
|
||||||
|
Ip: ExactSizeIterator<Item = LayoutPassDescription> + Clone, // with specialization we can handle the "Clone" restriction internally
|
||||||
|
Id: ExactSizeIterator<Item = LayoutPassDependencyDescription>
|
||||||
|
{
|
||||||
|
UnsafeRenderPass::raw(device, attachments, passes, pass_dependencies).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the device that was used to create this render pass.
|
/// Returns the device that was used to create this render pass.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -166,10 +166,10 @@ impl<F> AttachmentImage<F> {
|
|||||||
let mem = try!(MemoryPool::alloc(&device.standard_pool(), mem_ty,
|
let mem = try!(MemoryPool::alloc(&device.standard_pool(), mem_ty,
|
||||||
mem_reqs.size, mem_reqs.alignment));
|
mem_reqs.size, mem_reqs.alignment));
|
||||||
debug_assert!((mem.offset() % mem_reqs.alignment) == 0);
|
debug_assert!((mem.offset() % mem_reqs.alignment) == 0);
|
||||||
unsafe { try!(image.bind_memory(mem.memory(), mem.offset())); }
|
unsafe { try!(image.bind_memory_raw(mem.memory(), mem.offset())); }
|
||||||
|
|
||||||
let view = unsafe {
|
let view = unsafe {
|
||||||
try!(UnsafeImageView::new(&image, 0 .. 1, 0 .. 1))
|
try!(UnsafeImageView::raw(&image, 0 .. 1, 0 .. 1))
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Arc::new(AttachmentImage {
|
Ok(Arc::new(AttachmentImage {
|
||||||
|
@ -81,10 +81,10 @@ impl<F> ImmutableImage<F> {
|
|||||||
let mem = try!(MemoryPool::alloc(&device.standard_pool(), mem_ty,
|
let mem = try!(MemoryPool::alloc(&device.standard_pool(), mem_ty,
|
||||||
mem_reqs.size, mem_reqs.alignment));
|
mem_reqs.size, mem_reqs.alignment));
|
||||||
debug_assert!((mem.offset() % mem_reqs.alignment) == 0);
|
debug_assert!((mem.offset() % mem_reqs.alignment) == 0);
|
||||||
unsafe { try!(image.bind_memory(mem.memory(), mem.offset())); }
|
unsafe { try!(image.bind_memory_raw(mem.memory(), mem.offset())); }
|
||||||
|
|
||||||
let view = unsafe {
|
let view = unsafe {
|
||||||
try!(UnsafeImageView::new(&image, 0 .. image.mipmap_levels(),
|
try!(UnsafeImageView::raw(&image, 0 .. image.mipmap_levels(),
|
||||||
0 .. image.dimensions().array_layers()))
|
0 .. image.dimensions().array_layers()))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ impl SwapchainImage {
|
|||||||
pub unsafe fn from_raw(image: UnsafeImage, format: Format, swapchain: &Arc<Swapchain>, id: u32)
|
pub unsafe fn from_raw(image: UnsafeImage, format: Format, swapchain: &Arc<Swapchain>, id: u32)
|
||||||
-> Result<Arc<SwapchainImage>, OomError>
|
-> Result<Arc<SwapchainImage>, OomError>
|
||||||
{
|
{
|
||||||
let view = try!(UnsafeImageView::new(&image, 0 .. 1, 0 .. 1));
|
let view = try!(UnsafeImageView::raw(&image, 0 .. 1, 0 .. 1));
|
||||||
|
|
||||||
Ok(Arc::new(SwapchainImage {
|
Ok(Arc::new(SwapchainImage {
|
||||||
image: image,
|
image: image,
|
||||||
@ -124,7 +124,7 @@ unsafe impl Image for SwapchainImage {
|
|||||||
let dependency = mem::replace(&mut guarded.latest_submission, Some(Arc::downgrade(submission)));
|
let dependency = mem::replace(&mut guarded.latest_submission, Some(Arc::downgrade(submission)));
|
||||||
let dependency = dependency.and_then(|d| d.upgrade());
|
let dependency = dependency.and_then(|d| d.upgrade());
|
||||||
|
|
||||||
// TODO: use try!()?
|
// TODO: use try!()? - Mixthos
|
||||||
let signal = Semaphore::new(submission.queue().device());
|
let signal = Semaphore::new(submission.queue().device());
|
||||||
let wait = self.swapchain.image_semaphore(self.id, signal.clone()).expect("Try to render to a swapchain image that was not acquired first");
|
let wait = self.swapchain.image_semaphore(self.id, signal.clone()).expect("Try to render to a swapchain image that was not acquired first");
|
||||||
|
|
||||||
|
@ -458,8 +458,8 @@ impl UnsafeImage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn bind_memory(&self, memory: &DeviceMemory, offset: usize)
|
pub unsafe fn bind_memory_raw(&self, memory: &DeviceMemory, offset: usize)
|
||||||
-> Result<(), OomError>
|
-> Result<(), OomError>
|
||||||
{
|
{
|
||||||
let vk = self.device.pointers();
|
let vk = self.device.pointers();
|
||||||
|
|
||||||
@ -478,6 +478,12 @@ impl UnsafeImage {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn bind_memory(&self, memory: &DeviceMemory, offset: usize)
|
||||||
|
{
|
||||||
|
self.bind_memory_raw(memory, offset);
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn format(&self) -> Format {
|
pub fn format(&self) -> Format {
|
||||||
self.format
|
self.format
|
||||||
@ -623,7 +629,7 @@ impl UnsafeImageView {
|
|||||||
///
|
///
|
||||||
/// Note that you must create the view with identity swizzling if you want to use this view
|
/// Note that you must create the view with identity swizzling if you want to use this view
|
||||||
/// as a framebuffer attachment.
|
/// as a framebuffer attachment.
|
||||||
pub unsafe fn new(image: &UnsafeImage, mipmap_levels: Range<u32>, array_layers: Range<u32>)
|
pub unsafe fn raw(image: &UnsafeImage, mipmap_levels: Range<u32>, array_layers: Range<u32>)
|
||||||
-> Result<UnsafeImageView, OomError>
|
-> Result<UnsafeImageView, OomError>
|
||||||
{
|
{
|
||||||
let vk = image.device.pointers();
|
let vk = image.device.pointers();
|
||||||
@ -674,6 +680,21 @@ impl UnsafeImageView {
|
|||||||
format: image.format,
|
format: image.format,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates a new view from an image.
|
||||||
|
///
|
||||||
|
/// Note that you must create the view with identity swizzling if you want to use this view
|
||||||
|
/// as a framebuffer attachment.
|
||||||
|
///
|
||||||
|
/// # Panic
|
||||||
|
///
|
||||||
|
/// - Panicks if the device or host ran out of memory.
|
||||||
|
#[inline]
|
||||||
|
pub unsafe fn new(image: &UnsafeImage, mipmap_levels: Range<u32>, array_layers: Range<u32>)
|
||||||
|
-> UnsafeImageView
|
||||||
|
{
|
||||||
|
UnsafeImageView::raw(image, mipmap_levels, array_layers).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn format(&self) -> Format {
|
pub fn format(&self) -> Format {
|
||||||
|
Loading…
Reference in New Issue
Block a user