mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-27 01:05:03 +00:00
Merge pull request #564 from tomaka/subpass-ctnt
Use an enum for subpass content
This commit is contained in:
commit
c5c2347556
@ -46,6 +46,7 @@ use device::Queue;
|
||||
use framebuffer::FramebufferAbstract;
|
||||
use framebuffer::RenderPassAbstract;
|
||||
use framebuffer::RenderPassDescClearValues;
|
||||
use framebuffer::SubpassContents;
|
||||
use image::ImageAccess;
|
||||
use image::ImageLayout;
|
||||
use instance::QueueFamily;
|
||||
@ -111,8 +112,10 @@ impl<P> AutoCommandBufferBuilder<P> {
|
||||
unsafe {
|
||||
let clear_values = framebuffer.convert_clear_values(clear_values);
|
||||
let clear_values = clear_values.collect::<Vec<_>>().into_iter(); // TODO: necessary for Send + Sync ; needs an API rework of convert_clear_values
|
||||
let contents = if secondary { SubpassContents::SecondaryCommandBuffers }
|
||||
else { SubpassContents::Inline };
|
||||
self.inner
|
||||
.begin_render_pass(framebuffer, secondary, clear_values);
|
||||
.begin_render_pass(framebuffer, contents, clear_values);
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
@ -348,7 +351,9 @@ impl<P> AutoCommandBufferBuilder<P> {
|
||||
-> Result<Self, AutoCommandBufferBuilderContextError> {
|
||||
unsafe {
|
||||
// TODO: check
|
||||
self.inner.next_subpass(secondary);
|
||||
let contents = if secondary { SubpassContents::SecondaryCommandBuffers }
|
||||
else { SubpassContents::Inline };
|
||||
self.inner.next_subpass(contents);
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ use device::Queue;
|
||||
use format::ClearValue;
|
||||
use framebuffer::FramebufferAbstract;
|
||||
use framebuffer::RenderPassAbstract;
|
||||
use framebuffer::SubpassContents;
|
||||
use image::ImageAccess;
|
||||
use image::ImageLayout;
|
||||
use image::ImageViewAccess;
|
||||
@ -585,15 +586,15 @@ impl<P> SyncCommandBufferBuilder<P> {
|
||||
// TODO: after begin_render_pass has been called, flushing should be forbidden and an error
|
||||
// returned if conflict
|
||||
#[inline]
|
||||
pub unsafe fn begin_render_pass<F, I>(&mut self, framebuffer: F, secondary: bool,
|
||||
clear_values: I)
|
||||
pub unsafe fn begin_render_pass<F, I>(&mut self, framebuffer: F,
|
||||
subpass_contents: SubpassContents, clear_values: I)
|
||||
-> Result<(), SyncCommandBufferBuilderError>
|
||||
where F: FramebufferAbstract + Send + Sync + 'static,
|
||||
I: Iterator<Item = ClearValue> + Send + Sync + 'static
|
||||
{
|
||||
struct Cmd<F, I> {
|
||||
framebuffer: F,
|
||||
secondary: bool,
|
||||
subpass_contents: SubpassContents,
|
||||
clear_values: Option<I>,
|
||||
}
|
||||
|
||||
@ -603,7 +604,7 @@ impl<P> SyncCommandBufferBuilder<P> {
|
||||
{
|
||||
unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) {
|
||||
out.begin_render_pass(&self.framebuffer,
|
||||
self.secondary,
|
||||
self.subpass_contents,
|
||||
self.clear_values.take().unwrap());
|
||||
}
|
||||
|
||||
@ -632,7 +633,7 @@ impl<P> SyncCommandBufferBuilder<P> {
|
||||
// attachments of the framebuffer, meaning that they will stay locked
|
||||
self.commands.lock().unwrap().commands.push(Box::new(Cmd {
|
||||
framebuffer,
|
||||
secondary,
|
||||
subpass_contents,
|
||||
clear_values: Some(clear_values),
|
||||
}));
|
||||
|
||||
@ -1336,14 +1337,14 @@ impl<P> SyncCommandBufferBuilder<P> {
|
||||
|
||||
/// Calls `vkCmdNextSubpass` on the builder.
|
||||
#[inline]
|
||||
pub unsafe fn next_subpass(&mut self, secondary: bool) {
|
||||
pub unsafe fn next_subpass(&mut self, subpass_contents: SubpassContents) {
|
||||
struct Cmd {
|
||||
secondary: bool,
|
||||
subpass_contents: SubpassContents,
|
||||
}
|
||||
|
||||
impl<P> Command<P> for Cmd {
|
||||
unsafe fn send(&mut self, out: &mut UnsafeCommandBufferBuilder<P>) {
|
||||
out.next_subpass(self.secondary);
|
||||
out.next_subpass(self.subpass_contents);
|
||||
}
|
||||
|
||||
fn into_final_command(self: Box<Self>) -> Box<FinalCommand + Send + Sync> {
|
||||
@ -1355,7 +1356,7 @@ impl<P> SyncCommandBufferBuilder<P> {
|
||||
.lock()
|
||||
.unwrap()
|
||||
.commands
|
||||
.push(Box::new(Cmd { secondary }));
|
||||
.push(Box::new(Cmd { subpass_contents }));
|
||||
}
|
||||
|
||||
/// Calls `vkCmdPushConstants` on the builder.
|
||||
|
@ -36,6 +36,7 @@ use framebuffer::FramebufferAbstract;
|
||||
use framebuffer::RenderPass;
|
||||
use framebuffer::RenderPassAbstract;
|
||||
use framebuffer::Subpass;
|
||||
use framebuffer::SubpassContents;
|
||||
use image::ImageAccess;
|
||||
use image::ImageLayout;
|
||||
use instance::QueueFamily;
|
||||
@ -293,10 +294,9 @@ impl<P> UnsafeCommandBufferBuilder<P> {
|
||||
}
|
||||
|
||||
/// Calls `vkCmdBeginRenderPass` on the builder.
|
||||
// TODO: use an enum as the parameter
|
||||
#[inline]
|
||||
pub unsafe fn begin_render_pass<F, I>(&mut self, framebuffer: &F, secondary: bool,
|
||||
clear_values: I)
|
||||
pub unsafe fn begin_render_pass<F, I>(&mut self, framebuffer: &F,
|
||||
subpass_contents: SubpassContents, clear_values: I)
|
||||
where F: ?Sized + FramebufferAbstract,
|
||||
I: Iterator<Item = ClearValue>
|
||||
{
|
||||
@ -367,13 +367,7 @@ impl<P> UnsafeCommandBufferBuilder<P> {
|
||||
pClearValues: raw_clear_values.as_ptr(),
|
||||
};
|
||||
|
||||
let contents = if secondary {
|
||||
vk::SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS
|
||||
} else {
|
||||
vk::SUBPASS_CONTENTS_INLINE
|
||||
};
|
||||
|
||||
vk.CmdBeginRenderPass(cmd, &begin, contents);
|
||||
vk.CmdBeginRenderPass(cmd, &begin, subpass_contents as u32);
|
||||
}
|
||||
|
||||
/// Calls `vkCmdBindDescriptorSets` on the builder.
|
||||
@ -771,18 +765,11 @@ impl<P> UnsafeCommandBufferBuilder<P> {
|
||||
}
|
||||
|
||||
/// Calls `vkCmdNextSubpass` on the builder.
|
||||
// TODO: use an enum as the parameter
|
||||
#[inline]
|
||||
pub unsafe fn next_subpass(&mut self, secondary: bool) {
|
||||
pub unsafe fn next_subpass(&mut self, subpass_contents: SubpassContents) {
|
||||
let vk = self.device().pointers();
|
||||
let cmd = self.internal_object();
|
||||
|
||||
let contents = if secondary {
|
||||
vk::SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS
|
||||
} else {
|
||||
vk::SUBPASS_CONTENTS_INLINE
|
||||
};
|
||||
vk.CmdNextSubpass(cmd, contents);
|
||||
vk.CmdNextSubpass(cmd, subpass_contents as u32);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -117,6 +117,8 @@ pub use self::traits::RenderPassDescClearValues;
|
||||
pub use self::traits::RenderPassSubpassInterface;
|
||||
pub use self::traits::Subpass;
|
||||
|
||||
use vk;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
mod attachments_list;
|
||||
@ -126,3 +128,13 @@ mod empty;
|
||||
mod framebuffer;
|
||||
mod sys;
|
||||
mod traits;
|
||||
|
||||
/// Describes what a subpass in a command buffer will contain.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
#[repr(u32)]
|
||||
pub enum SubpassContents {
|
||||
/// The subpass will only directly contain commands.
|
||||
Inline = vk::SUBPASS_CONTENTS_INLINE,
|
||||
/// The subpass will only contain secondary command buffers invocations.
|
||||
SecondaryCommandBuffers = vk::SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user