Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update gfx-hal to 0.7 #305

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ members = [
"shader",
"wsi",
"chain",
"graph",
# "graph",
"core",
"texture",
]
120 changes: 60 additions & 60 deletions command/src/buffer/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,9 @@ where
self.capability.assert();
rendy_core::hal::command::CommandBuffer::bind_index_buffer(
self.raw,
rendy_core::hal::buffer::IndexBufferView {
buffer,
range: rendy_core::hal::buffer::SubRange { offset, size: None },
index_type,
},
buffer,
rendy_core::hal::buffer::SubRange { offset, size: None },
index_type,
)
}

Expand All @@ -126,11 +124,10 @@ where
/// device limit.
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBindVertexBuffers.html
pub unsafe fn bind_vertex_buffers<'b>(
&mut self,
first_binding: u32,
buffers: impl IntoIterator<Item = (&'b B::Buffer, u64)>,
) where
pub unsafe fn bind_vertex_buffers<'b, I>(&mut self, first_binding: u32, buffers: I)
where
I: IntoIterator<Item = (&'b B::Buffer, u64)>,
I::IntoIter: ExactSizeIterator,
C: Supports<Graphics>,
{
self.capability.assert();
Expand Down Expand Up @@ -168,13 +165,15 @@ where
/// # Safety
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBindDescriptorSets.html
pub unsafe fn bind_graphics_descriptor_sets<'b>(
pub unsafe fn bind_graphics_descriptor_sets<'b, I, J>(
&mut self,
layout: &B::PipelineLayout,
first_set: u32,
sets: impl IntoIterator<Item = &'b B::DescriptorSet>,
offsets: impl IntoIterator<Item = u32>,
sets: I,
offsets: J,
) where
I: Iterator<Item = &'b B::DescriptorSet>,
J: Iterator<Item = u32>,
C: Supports<Graphics>,
{
self.capability.assert();
Expand Down Expand Up @@ -205,13 +204,15 @@ where
/// # Safety
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBindDescriptorSets.html
pub unsafe fn bind_compute_descriptor_sets<'b>(
pub unsafe fn bind_compute_descriptor_sets<'b, I, J>(
&mut self,
layout: &B::PipelineLayout,
first_set: u32,
sets: impl IntoIterator<Item = &'b B::DescriptorSet>,
offsets: impl IntoIterator<Item = u32>,
sets: I,
offsets: J,
) where
I: Iterator<Item = &'b B::DescriptorSet>,
J: Iterator<Item = u32>,
C: Supports<Compute>,
{
self.capability.assert();
Expand All @@ -234,7 +235,7 @@ where
&mut self,
stages: std::ops::Range<rendy_core::hal::pso::PipelineStage>,
dependencies: rendy_core::hal::memory::Dependencies,
barriers: impl IntoIterator<Item = rendy_core::hal::memory::Barrier<'b, B>>,
barriers: impl Iterator<Item = rendy_core::hal::memory::Barrier<'b, B>>,
) {
rendy_core::hal::command::CommandBuffer::pipeline_barrier(
self.raw,
Expand Down Expand Up @@ -268,11 +269,9 @@ where
/// Set viewports
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetViewport.html
pub unsafe fn set_viewports<'b>(
&mut self,
first_viewport: u32,
viewports: impl IntoIterator<Item = &'b rendy_core::hal::pso::Viewport>,
) where
pub unsafe fn set_viewports<I>(&mut self, first_viewport: u32, viewports: I)
where
I: Iterator<Item = rendy_core::hal::pso::Viewport>,
C: Supports<Graphics>,
{
self.capability.assert();
Expand All @@ -287,11 +286,9 @@ where
/// `maxViewports` device limit.
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdSetScissor.html
pub unsafe fn set_scissors<'b>(
&mut self,
first_scissor: u32,
rects: impl IntoIterator<Item = &'b rendy_core::hal::pso::Rect>,
) where
pub unsafe fn set_scissors<'b, I>(&mut self, first_scissor: u32, rects: I)
where
I: Iterator<Item = rendy_core::hal::pso::Rect>,
C: Supports<Graphics>,
{
self.capability.assert();
Expand Down Expand Up @@ -430,13 +427,11 @@ where
/// Clear regions within bound framebuffer attachments
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdClearAttachments.html#vkCmdBeginRenderPass
pub unsafe fn clear_attachments(
&mut self,
clears: impl IntoIterator<
Item = impl std::borrow::Borrow<rendy_core::hal::command::AttachmentClear>,
>,
rects: impl IntoIterator<Item = impl std::borrow::Borrow<rendy_core::hal::pso::ClearRect>>,
) {
pub unsafe fn clear_attachments<I, J>(&mut self, clears: I, rects: J)
where
I: Iterator<Item = rendy_core::hal::command::AttachmentClear>,
J: Iterator<Item = rendy_core::hal::pso::ClearRect>,
{
rendy_core::hal::command::CommandBuffer::clear_attachments(self.inner.raw, clears, rects);
}

Expand Down Expand Up @@ -631,10 +626,12 @@ where
B: rendy_core::hal::Backend,
{
/// Execute commands from secondary buffers.
pub fn execute_commands(
&mut self,
submittables: impl IntoIterator<Item = impl Submittable<B, SecondaryLevel, RenderPassContinue>>,
) {
pub fn execute_commands<I>(&mut self, submittables: I)
where
I: IntoIterator,
I::Item: Submittable<B, SecondaryLevel, RenderPassContinue>,
I::IntoIter: ExactSizeIterator,
{
let family = self.inner.family;
unsafe {
rendy_core::hal::command::CommandBuffer::execute_commands(
Expand Down Expand Up @@ -711,12 +708,12 @@ where
B: rendy_core::hal::Backend,
{
/// Beging recording render pass inline.
pub fn begin_render_pass_inline(
pub fn begin_render_pass_inline<'b>(
&mut self,
render_pass: &B::RenderPass,
framebuffer: &B::Framebuffer,
render_area: rendy_core::hal::pso::Rect,
clear_values: &[rendy_core::hal::command::ClearValue],
clear_values: impl Iterator<Item = rendy_core::hal::command::RenderAttachmentInfo<'b, B>>,
) -> RenderPassInlineEncoder<'_, B>
where
C: Supports<Graphics>,
Expand All @@ -742,12 +739,12 @@ where
}

/// Beging recording render pass secondary.
pub fn begin_render_pass_secondary(
pub fn begin_render_pass_secondary<'b>(
&mut self,
render_pass: &B::RenderPass,
framebuffer: &B::Framebuffer,
render_area: rendy_core::hal::pso::Rect,
clear_values: &[rendy_core::hal::command::ClearValue],
clear_values: impl Iterator<Item = rendy_core::hal::command::RenderAttachmentInfo<'b, B>>,
) -> RenderPassSecondaryEncoder<'_, B>
where
C: Supports<Graphics>,
Expand All @@ -771,10 +768,12 @@ where
}

/// Execute commands from secondary buffers.
pub fn execute_commands(
&mut self,
submittables: impl IntoIterator<Item = impl Submittable<B, SecondaryLevel>>,
) {
pub fn execute_commands<I>(&mut self, submittables: I)
where
I: IntoIterator,
I::Item: Submittable<B, SecondaryLevel>,
I::IntoIter: ExactSizeIterator,
{
let family = self.inner.family;
unsafe {
rendy_core::hal::command::CommandBuffer::execute_commands(
Expand Down Expand Up @@ -811,12 +810,9 @@ where
/// length of the corresponding buffer.
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyBuffer.html
pub unsafe fn copy_buffer(
&mut self,
src: &B::Buffer,
dst: &B::Buffer,
regions: impl IntoIterator<Item = rendy_core::hal::command::BufferCopy>,
) where
pub unsafe fn copy_buffer<I>(&mut self, src: &B::Buffer, dst: &B::Buffer, regions: I)
where
I: Iterator<Item = rendy_core::hal::command::BufferCopy>,
C: Supports<Transfer>,
{
self.capability.assert();
Expand All @@ -831,13 +827,14 @@ where
/// Same as `copy_buffer()`
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyBufferToImage.html
pub unsafe fn copy_buffer_to_image(
pub unsafe fn copy_buffer_to_image<I>(
&mut self,
src: &B::Buffer,
dst: &B::Image,
dst_layout: rendy_core::hal::image::Layout,
regions: impl IntoIterator<Item = rendy_core::hal::command::BufferImageCopy>,
regions: I,
) where
I: Iterator<Item = rendy_core::hal::command::BufferImageCopy>,
C: Supports<Transfer>,
{
self.capability.assert();
Expand All @@ -858,14 +855,15 @@ where
/// Same as `copy_buffer()`
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyImage.html
pub unsafe fn copy_image(
pub unsafe fn copy_image<I>(
&mut self,
src: &B::Image,
src_layout: rendy_core::hal::image::Layout,
dst: &B::Image,
dst_layout: rendy_core::hal::image::Layout,
regions: impl IntoIterator<Item = rendy_core::hal::command::ImageCopy>,
regions: I,
) where
I: Iterator<Item = rendy_core::hal::command::ImageCopy>,
C: Supports<Transfer>,
{
self.capability.assert();
Expand All @@ -887,13 +885,14 @@ where
/// Same as `copy_buffer()`
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdCopyImageToBuffer.html
pub unsafe fn copy_image_to_buffer(
pub unsafe fn copy_image_to_buffer<I>(
&mut self,
src: &B::Image,
src_layout: rendy_core::hal::image::Layout,
dst: &B::Buffer,
regions: impl IntoIterator<Item = rendy_core::hal::command::BufferImageCopy>,
regions: I,
) where
I: Iterator<Item = rendy_core::hal::command::BufferImageCopy>,
C: Supports<Transfer>,
{
self.capability.assert();
Expand All @@ -914,15 +913,16 @@ where
/// Same as `copy_buffer()`
///
/// See: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkCmdBlitImage.html
pub unsafe fn blit_image(
pub unsafe fn blit_image<I>(
&mut self,
src: &B::Image,
src_layout: rendy_core::hal::image::Layout,
dst: &B::Image,
dst_layout: rendy_core::hal::image::Layout,
filter: rendy_core::hal::image::Filter,
regions: impl IntoIterator<Item = rendy_core::hal::command::ImageBlit>,
regions: I,
) where
I: Iterator<Item = rendy_core::hal::command::ImageBlit>,
C: Supports<Graphics>,
{
self.capability.assert();
Expand Down
55 changes: 24 additions & 31 deletions command/src/family/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,31 @@ where
impl IntoIterator<Item = &'a (impl std::borrow::Borrow<B::Semaphore> + 'a)>,
>,
>,
fence: Option<&mut Fence<B>>,
mut fence: Option<&mut Fence<B>>,
) {
assert!(fence.as_ref().map_or(true, |f| f.is_unsignaled()));

let mut submissions = submissions.into_iter().peekable();
if submissions.peek().is_none() && fence.is_some() {
self.raw.submit(
rendy_core::hal::queue::Submission {
command_buffers: std::iter::empty::<&'a B::CommandBuffer>(),
wait_semaphores: std::iter::empty::<(&'a B::Semaphore, _)>(),
signal_semaphores: std::iter::empty::<&'a B::Semaphore>(),
},
fence.as_ref().map(|f| f.raw()),
std::iter::empty::<&'a B::CommandBuffer>(),
std::iter::empty::<(&'a B::Semaphore, _)>(),
std::iter::empty::<&'a B::Semaphore>(),
fence.as_mut().map(|f| f.raw_mut()),
);
} else {
let family = self.id.family;
while let Some(submission) = submissions.next() {
self.raw.submit(
rendy_core::hal::queue::Submission {
command_buffers: submission.submits.into_iter().map(|submit| {
assert_eq!(submit.family(), family);
submit.raw()
}),
wait_semaphores: submission.waits.into_iter().map(|w| (w.0.borrow(), w.1)),
signal_semaphores: submission.signals.into_iter().map(|s| s.borrow()),
},
submission.submits.into_iter().map(|submit| {
assert_eq!(submit.family(), family);
submit.raw()
}),
submission.waits.into_iter().map(|w| (w.0.borrow(), w.1)),
submission.signals.into_iter().map(|s| s.borrow()),
submissions
.peek()
.map_or(fence.as_ref().map(|f| f.raw()), |_| None),
.map_or(fence.as_mut().map(|f| f.raw_mut()), |_| None),
);
}
}
Expand Down Expand Up @@ -118,38 +114,35 @@ where
impl IntoIterator<Item = &'a (impl std::borrow::Borrow<B::Semaphore> + 'a)>,
>,
>,
fence: Option<&B::Fence>,
mut fence: Option<&mut B::Fence>,
) {
let mut submissions = submissions.into_iter().peekable();
if submissions.peek().is_none() && fence.is_some() {
self.raw.submit(
rendy_core::hal::queue::Submission {
command_buffers: std::iter::empty::<&'a B::CommandBuffer>(),
wait_semaphores: std::iter::empty::<(&'a B::Semaphore, _)>(),
signal_semaphores: std::iter::empty::<&'a B::Semaphore>(),
},
std::iter::empty::<&'a B::CommandBuffer>(),
std::iter::empty::<(&'a B::Semaphore, _)>(),
std::iter::empty::<&'a B::Semaphore>(),
fence,
);
} else {
let family = self.id.family;
while let Some(submission) = submissions.next() {
let fence = fence.as_mut().map(|f| &mut **f);
self.raw.submit(
rendy_core::hal::queue::Submission {
command_buffers: submission.submits.into_iter().map(|submit| {
assert_eq!(submit.family(), family);
submit.raw()
}),
wait_semaphores: submission.waits.into_iter().map(|w| (w.0.borrow(), w.1)),
signal_semaphores: submission.signals.into_iter().map(|s| s.borrow()),
},
submission.submits.into_iter().map(|submit| {
assert_eq!(submit.family(), family);
submit.raw()
}),
submission.waits.into_iter().map(|w| (w.0.borrow(), w.1)),
submission.signals.into_iter().map(|s| s.borrow()),
submissions.peek().map_or(fence, |_| None),
);
}
}
}

/// Wait for queue to finish all pending commands.
pub fn wait_idle(&self) -> Result<(), rendy_core::hal::device::OutOfMemory> {
pub fn wait_idle(&mut self) -> Result<(), rendy_core::hal::device::OutOfMemory> {
self.raw.wait_idle()
}
}
Loading