Remove RendetTarget from recorder due to lifetimes
This commit is contained in:
parent
419c044413
commit
dca9ab20be
2 changed files with 15 additions and 28 deletions
|
@ -75,7 +75,7 @@ pub struct CommandBuffer {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CommandBufferRecorder<'a> {
|
pub struct CommandBufferRecorder<'a> {
|
||||||
device: Arc<Device>,
|
device: Arc<Device>,
|
||||||
render_target: Option<&'a RenderTarget>,
|
sub_pass: u32,
|
||||||
pipeline: Option<Arc<Pipeline>>,
|
pipeline: Option<Arc<Pipeline>>,
|
||||||
|
|
||||||
calls: Arc<AtomicUsize>,
|
calls: Arc<AtomicUsize>,
|
||||||
|
@ -118,7 +118,7 @@ impl CommandBuffer {
|
||||||
|
|
||||||
Ok(CommandBufferRecorder {
|
Ok(CommandBufferRecorder {
|
||||||
device: self.device.clone(),
|
device: self.device.clone(),
|
||||||
render_target: None,
|
sub_pass: 0,
|
||||||
pipeline: None,
|
pipeline: None,
|
||||||
|
|
||||||
calls: self.calls.clone(),
|
calls: self.calls.clone(),
|
||||||
|
@ -321,22 +321,16 @@ impl<'a> CommandBufferRecorder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn begin_render_pass(
|
pub fn begin_render_pass(
|
||||||
&self,
|
&mut self,
|
||||||
renderpass_begin_info: VkRenderPassBeginInfo,
|
renderpass_begin_info: VkRenderPassBeginInfo,
|
||||||
subpass_contents: VkSubpassContents,
|
subpass_contents: VkSubpassContents,
|
||||||
) {
|
) {
|
||||||
|
self.sub_pass = 0;
|
||||||
|
|
||||||
self.device
|
self.device
|
||||||
.cmd_begin_render_pass(self.buffer, &renderpass_begin_info, subpass_contents);
|
.cmd_begin_render_pass(self.buffer, &renderpass_begin_info, subpass_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_render_target(&'a mut self, render_target: &'a RenderTarget) {
|
|
||||||
self.render_target = Some(render_target);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn clear_render_target(&'a mut self) {
|
|
||||||
self.render_target = None;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn begin_render_pass_full(
|
pub fn begin_render_pass_full(
|
||||||
&mut self,
|
&mut self,
|
||||||
render_pass: &Arc<RenderPass>,
|
render_pass: &Arc<RenderPass>,
|
||||||
|
@ -347,6 +341,8 @@ impl<'a> CommandBufferRecorder<'a> {
|
||||||
self.handles_lock.push(render_pass.clone());
|
self.handles_lock.push(render_pass.clone());
|
||||||
self.handles_lock.push(framebuffer.clone());
|
self.handles_lock.push(framebuffer.clone());
|
||||||
|
|
||||||
|
self.sub_pass = 0;
|
||||||
|
|
||||||
let render_pass_begin_info = VkRenderPassBeginInfo::new(
|
let render_pass_begin_info = VkRenderPassBeginInfo::new(
|
||||||
render_pass.vk_handle(),
|
render_pass.vk_handle(),
|
||||||
framebuffer.vk_handle(),
|
framebuffer.vk_handle(),
|
||||||
|
@ -364,7 +360,8 @@ impl<'a> CommandBufferRecorder<'a> {
|
||||||
.cmd_begin_render_pass(self.buffer, &render_pass_begin_info, subpass_contents);
|
.cmd_begin_render_pass(self.buffer, &render_pass_begin_info, subpass_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_subpass(&self, subpass_contents: VkSubpassContents) {
|
pub fn next_subpass(&mut self, subpass_contents: VkSubpassContents) {
|
||||||
|
self.sub_pass += 1;
|
||||||
self.device.cmd_next_subpass(self.buffer, subpass_contents);
|
self.device.cmd_next_subpass(self.buffer, subpass_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,11 +374,7 @@ impl<'a> CommandBufferRecorder<'a> {
|
||||||
|
|
||||||
match pipeline.pipeline_type() {
|
match pipeline.pipeline_type() {
|
||||||
PipelineType::Graphics => {
|
PipelineType::Graphics => {
|
||||||
if cfg!(debug_assertions) {
|
debug_assert_eq!(self.sub_pass, pipeline.sub_pass());
|
||||||
if let Some(render_target) = &self.render_target {
|
|
||||||
assert_eq!(render_target.subpass_index(), pipeline.sub_pass());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.device.cmd_bind_pipeline(
|
self.device.cmd_bind_pipeline(
|
||||||
self.buffer,
|
self.buffer,
|
||||||
|
|
|
@ -271,10 +271,6 @@ impl RenderTarget {
|
||||||
self.extent.height
|
self.extent.height
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn subpass_index(&self) -> u32 {
|
|
||||||
self.current_subpass.load(SeqCst)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn inheritance_info(&self) -> VkCommandBufferInheritanceInfo {
|
pub fn inheritance_info(&self) -> VkCommandBufferInheritanceInfo {
|
||||||
CommandBuffer::inheritance_info(
|
CommandBuffer::inheritance_info(
|
||||||
Some(&self.render_pass),
|
Some(&self.render_pass),
|
||||||
|
@ -284,9 +280,9 @@ impl RenderTarget {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn begin<'a>(
|
pub fn begin(
|
||||||
&'a self,
|
&self,
|
||||||
buffer_recorder: &'a mut CommandBufferRecorder<'a>,
|
buffer_recorder: &mut CommandBufferRecorder<'_>,
|
||||||
subpass_content: VkSubpassContents,
|
subpass_content: VkSubpassContents,
|
||||||
framebuffer_index: usize,
|
framebuffer_index: usize,
|
||||||
) {
|
) {
|
||||||
|
@ -301,7 +297,6 @@ impl RenderTarget {
|
||||||
);
|
);
|
||||||
|
|
||||||
buffer_recorder.begin_render_pass(renderpass_begin, subpass_content);
|
buffer_recorder.begin_render_pass(renderpass_begin, subpass_content);
|
||||||
buffer_recorder.set_render_target(self);
|
|
||||||
|
|
||||||
self.framebuffer_index.store(framebuffer_index, SeqCst);
|
self.framebuffer_index.store(framebuffer_index, SeqCst);
|
||||||
self.current_subpass.store(0, SeqCst);
|
self.current_subpass.store(0, SeqCst);
|
||||||
|
@ -309,16 +304,15 @@ impl RenderTarget {
|
||||||
|
|
||||||
pub fn next_subpass(
|
pub fn next_subpass(
|
||||||
&self,
|
&self,
|
||||||
buffer_recorder: &CommandBufferRecorder<'_>,
|
buffer_recorder: &mut CommandBufferRecorder<'_>,
|
||||||
subpass_content: VkSubpassContents,
|
subpass_content: VkSubpassContents,
|
||||||
) {
|
) {
|
||||||
buffer_recorder.next_subpass(subpass_content);
|
buffer_recorder.next_subpass(subpass_content);
|
||||||
self.current_subpass.fetch_add(1, SeqCst);
|
self.current_subpass.fetch_add(1, SeqCst);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn end<'a>(&self, buffer_recorder: &'a mut CommandBufferRecorder<'a>) {
|
pub fn end(&self, buffer_recorder: &mut CommandBufferRecorder<'_>) {
|
||||||
buffer_recorder.end_render_pass();
|
buffer_recorder.end_render_pass();
|
||||||
buffer_recorder.clear_render_target();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue