diff --git a/vulkano/src/command_buffer/auto.rs b/vulkano/src/command_buffer/auto.rs index 31e8aa6a..e7f480c9 100644 --- a/vulkano/src/command_buffer/auto.rs +++ b/vulkano/src/command_buffer/auto.rs @@ -69,6 +69,12 @@ use sync::PipelineStages; pub struct AutoCommandBufferBuilder
{ inner: SyncCommandBufferBuilder
,
state_cacher: StateCacher,
+ // Contains the number of subpasses remaining in the current render pass, or `None` if we're
+ // outside a render pass. If this is `Some(0)`, the user must call `end_render_pass`. If this
+ // is `Some(1)` or more, the user must call `next_subpass`.
+ subpasses_remaining: Option AutoCommandBufferBuilder {
pub fn build(self) -> Result AutoCommandBufferBuilder {
where F: FramebufferAbstract + RenderPassDescClearValues AutoCommandBufferBuilder {
T: ?Sized,
{
unsafe {
- // TODO: check that we're not in a render pass
+ // TODO: error instead
+ assert!(self.subpasses_remaining.is_none());
let infos = validity::check_copy_buffer(self.device(), &src, &dest)?;
self.inner.copy_buffer(src, dest, iter::once((0, 0, infos.copy_size)));
@@ -146,6 +163,9 @@ impl AutoCommandBufferBuilder {
where S: BufferAccess + Send + Sync + 'static,
D: ImageAccess + Send + Sync + 'static
{
+ // TODO: error instead
+ assert!(self.subpasses_remaining.is_none());
+
let dims = dest.dimensions().width_height_depth();
self.copy_buffer_to_image_dimensions(src, dest, [0, 0, 0], dims, 0, 1, 0)
}
@@ -159,7 +179,9 @@ impl AutoCommandBufferBuilder {
D: ImageAccess + Send + Sync + 'static
{
unsafe {
- // TODO: check that we're not in a render pass
+ // TODO: error instead
+ assert!(self.subpasses_remaining.is_none());
+
// TODO: check validity
// TODO: hastily implemented
@@ -199,6 +221,9 @@ impl AutoCommandBufferBuilder {
unsafe {
// TODO: missing checks
+ // TODO: error instead
+ assert!(self.subpasses_remaining.is_none());
+
if let StateCacherOutcome::NeedChange =
self.state_cacher.bind_compute_pipeline(&pipeline)
{
@@ -223,6 +248,9 @@ impl AutoCommandBufferBuilder {
unsafe {
// TODO: missing checks
+ // TODO: error instead
+ assert!(self.subpasses_remaining.is_some());
+
if let StateCacherOutcome::NeedChange =
self.state_cacher.bind_graphics_pipeline(&pipeline)
{
@@ -252,6 +280,9 @@ impl AutoCommandBufferBuilder {
I: Index + 'static
{
unsafe {
+ // TODO: error instead
+ assert!(self.subpasses_remaining.is_some());
+
// TODO: missing checks
let index_count = index_buffer.len();
@@ -287,6 +318,9 @@ impl AutoCommandBufferBuilder {
+ 'static
{
unsafe {
+ // TODO: error instead
+ assert!(self.subpasses_remaining.is_some());
+
// TODO: missing checks
let draw_count = indirect_buffer.len() as u32;
@@ -316,7 +350,9 @@ impl AutoCommandBufferBuilder {
#[inline]
pub fn end_render_pass(mut self) -> Result AutoCommandBufferBuilder {
where B: BufferAccess + Send + Sync + 'static
{
unsafe {
- // TODO: check that we're not in a render pass
+ // TODO: error instead
+ assert!(self.subpasses_remaining.is_none());
validity::check_fill_buffer(self.device(), &buffer)?;
self.inner.fill_buffer(buffer, data);
Ok(self)
@@ -350,7 +387,17 @@ impl AutoCommandBufferBuilder {
pub fn next_subpass(mut self, secondary: bool)
-> Result AutoCommandBufferBuilder {
D: Send + Sync + 'static
{
unsafe {
- // TODO: check that we're not in a render pass
+ // TODO: error instead
+ assert!(self.subpasses_remaining.is_none());
+
validity::check_update_buffer(self.device(), &buffer, &data)?;
let size_of_data = mem::size_of_val(&data);