Skip to content

Commit

Permalink
Allow SyncCommandBufferBuilder commands to specify the access range (
Browse files Browse the repository at this point in the history
…#1869)

* Allow `SyncCommandBufferBuilder` commands to specify the access range

* Allow `SyncCommandBufferBuilder` commands to specify the access range

* Better handling of image initialization

* Small fix
  • Loading branch information
Rua authored Apr 16, 2022
1 parent 741a506 commit a42a3d1
Show file tree
Hide file tree
Showing 17 changed files with 1,293 additions and 1,149 deletions.
2 changes: 2 additions & 0 deletions vulkano/src/command_buffer/auto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ err_gen!(CopyQueryPoolResultsError {
err_gen!(FillBufferError {
AutoCommandBufferBuilderContextError,
CheckFillBufferError,
SyncCommandBufferBuilderError,
});

err_gen!(DebugMarkerError {
Expand Down Expand Up @@ -931,6 +932,7 @@ err_gen!(ResetQueryPoolError {
err_gen!(UpdateBufferError {
AutoCommandBufferBuilderContextError,
CheckUpdateBufferError,
SyncCommandBufferBuilderError,
});

/// Errors that can happen when calling [`clear_attachments`](AutoCommandBufferBuilder::clear_attachments)
Expand Down
86 changes: 34 additions & 52 deletions vulkano/src/command_buffer/commands/bind_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ impl SyncCommandBufferBuilder {

impl Command for Cmd {
fn name(&self) -> &'static str {
"vkCmdBindIndexBuffer"
"bind_index_buffer"
}

unsafe fn send(&self, out: &mut UnsafeCommandBufferBuilder) {
Expand All @@ -484,7 +484,7 @@ impl SyncCommandBufferBuilder {
}

self.current_state.index_buffer = Some((buffer.clone(), index_ty));
self.append_command(Cmd { buffer, index_ty }, []).unwrap();
self.commands.push(Box::new(Cmd { buffer, index_ty }));
}

/// Calls `vkCmdBindPipeline` on the builder with a compute pipeline.
Expand All @@ -496,7 +496,7 @@ impl SyncCommandBufferBuilder {

impl Command for Cmd {
fn name(&self) -> &'static str {
"vkCmdBindPipeline"
"bind_pipeline_compute"
}

unsafe fn send(&self, out: &mut UnsafeCommandBufferBuilder) {
Expand All @@ -505,7 +505,7 @@ impl SyncCommandBufferBuilder {
}

self.current_state.pipeline_compute = Some(pipeline.clone());
self.append_command(Cmd { pipeline }, []).unwrap();
self.commands.push(Box::new(Cmd { pipeline }));
}

/// Calls `vkCmdBindPipeline` on the builder with a graphics pipeline.
Expand All @@ -517,7 +517,7 @@ impl SyncCommandBufferBuilder {

impl Command for Cmd {
fn name(&self) -> &'static str {
"vkCmdBindPipeline"
"bind_pipeline_graphics"
}

unsafe fn send(&self, out: &mut UnsafeCommandBufferBuilder) {
Expand All @@ -534,7 +534,7 @@ impl SyncCommandBufferBuilder {
.map(|(s, _)| s),
);
self.current_state.pipeline_graphics = Some(pipeline.clone());
self.append_command(Cmd { pipeline }, []).unwrap();
self.commands.push(Box::new(Cmd { pipeline }));
}

/// Starts the process of binding vertex buffers. Returns an intermediate struct which can be
Expand Down Expand Up @@ -570,7 +570,7 @@ impl SyncCommandBufferBuilder {

impl Command for Cmd {
fn name(&self) -> &'static str {
"vkCmdPushConstants"
"push_constants"
}

unsafe fn send(&self, out: &mut UnsafeCommandBufferBuilder) {
Expand All @@ -594,17 +594,13 @@ impl SyncCommandBufferBuilder {
);
out.set_len(size as usize);

self.append_command(
Cmd {
pipeline_layout: pipeline_layout.clone(),
stages,
offset,
size,
data: out.into(),
},
[],
)
.unwrap();
self.commands.push(Box::new(Cmd {
pipeline_layout: pipeline_layout.clone(),
stages,
offset,
size,
data: out.into(),
}));

// TODO: Push constant invalidations.
// The Vulkan spec currently is unclear about this, so Vulkano currently just marks
Expand Down Expand Up @@ -634,7 +630,7 @@ impl SyncCommandBufferBuilder {

impl Command for Cmd {
fn name(&self) -> &'static str {
"vkCmdPushDescriptorSetKHR"
"push_descriptor_set"
}

unsafe fn send(&self, out: &mut UnsafeCommandBufferBuilder) {
Expand Down Expand Up @@ -672,16 +668,12 @@ impl SyncCommandBufferBuilder {
set_resources.update(write);
}

self.append_command(
Cmd {
pipeline_bind_point,
pipeline_layout,
set_num,
descriptor_writes,
},
[],
)
.unwrap();
self.commands.push(Box::new(Cmd {
pipeline_bind_point,
pipeline_layout,
set_num,
descriptor_writes,
}));
}
}

Expand Down Expand Up @@ -720,7 +712,7 @@ impl<'b> SyncCommandBufferBuilderBindDescriptorSets<'b> {

impl Command for Cmd {
fn name(&self) -> &'static str {
"vkCmdBindDescriptorSets"
"bind_descriptor_sets"
}

unsafe fn send(&self, out: &mut UnsafeCommandBufferBuilder) {
Expand Down Expand Up @@ -754,17 +746,12 @@ impl<'b> SyncCommandBufferBuilderBindDescriptorSets<'b> {
.insert(first_set + set_num as u32, SetOrPush::Set(set.clone()));
}

self.builder
.append_command(
Cmd {
descriptor_sets: self.descriptor_sets,
pipeline_bind_point,
pipeline_layout,
first_set,
},
[],
)
.unwrap();
self.builder.commands.push(Box::new(Cmd {
descriptor_sets: self.descriptor_sets,
pipeline_bind_point,
pipeline_layout,
first_set,
}));
}
}

Expand Down Expand Up @@ -793,7 +780,7 @@ impl<'a> SyncCommandBufferBuilderBindVertexBuffer<'a> {

impl Command for Cmd {
fn name(&self) -> &'static str {
"vkCmdBindVertexBuffers"
"bind_vertex_buffers"
}

unsafe fn send(&self, out: &mut UnsafeCommandBufferBuilder) {
Expand All @@ -808,16 +795,11 @@ impl<'a> SyncCommandBufferBuilderBindVertexBuffer<'a> {
.insert(first_set + i as u32, buffer.clone());
}

self.builder
.append_command(
Cmd {
first_set,
inner: Mutex::new(Some(self.inner)),
buffers: self.buffers,
},
[],
)
.unwrap();
self.builder.commands.push(Box::new(Cmd {
first_set,
inner: Mutex::new(Some(self.inner)),
buffers: self.buffers,
}));
}
}

Expand Down
12 changes: 6 additions & 6 deletions vulkano/src/command_buffer/commands/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ impl SyncCommandBufferBuilder {

impl Command for Cmd {
fn name(&self) -> &'static str {
"vkCmdBeginDebugUtilsLabelEXT"
"debug_marker_begin"
}

unsafe fn send(&self, out: &mut UnsafeCommandBufferBuilder) {
out.debug_marker_begin(self.name, self.color);
}
}

self.append_command(Cmd { name, color }, []).unwrap();
self.commands.push(Box::new(Cmd { name, color }));
}

/// Calls `vkCmdEndDebugUtilsLabelEXT` on the builder.
Expand All @@ -150,15 +150,15 @@ impl SyncCommandBufferBuilder {

impl Command for Cmd {
fn name(&self) -> &'static str {
"vkCmdEndDebugUtilsLabelEXT"
"debug_marker_end"
}

unsafe fn send(&self, out: &mut UnsafeCommandBufferBuilder) {
out.debug_marker_end();
}
}

self.append_command(Cmd {}, []).unwrap();
self.commands.push(Box::new(Cmd {}));
}

/// Calls `vkCmdInsertDebugUtilsLabelEXT` on the builder.
Expand All @@ -175,15 +175,15 @@ impl SyncCommandBufferBuilder {

impl Command for Cmd {
fn name(&self) -> &'static str {
"vkCmdInsertDebugUtilsLabelEXT"
"debug_marker_insert"
}

unsafe fn send(&self, out: &mut UnsafeCommandBufferBuilder) {
out.debug_marker_insert(self.name, self.color);
}
}

self.append_command(Cmd { name, color }, []).unwrap();
self.commands.push(Box::new(Cmd { name, color }));
}
}

Expand Down
Loading

0 comments on commit a42a3d1

Please sign in to comment.