Update from dev #53

Merged
hodasemi merged 10 commits from dev into master 2023-08-16 07:05:12 +00:00
3 changed files with 44 additions and 28 deletions
Showing only changes of commit a5a3702153 - Show all commits

View file

@ -94,7 +94,6 @@ impl Pedals {
let descriptor_pool = DescriptorPool::builder()
.set_layout(pipeline.descriptor_layout().clone())
.set_descriptor_set_count(2)
.build(device.clone())?;
let brake_color_buffer = Buffer::builder()
@ -116,7 +115,16 @@ impl Pedals {
write_log!("allocate throttle descriptor");
let throttle_descriptor = descriptor_pool.prepare_set().allocate()?;
let throttle_descriptor = match descriptor_pool.prepare_set().allocate() {
Ok(d) => d,
Err(err) => {
write_log!(format!("desc alloc {:?}, {}", err, err.backtrace()));
return Err(err);
}
};
write_log!("update throttle descriptor");
throttle_descriptor.update(&[DescriptorWrite::uniform_buffers(
0,
&[&throttle_color_buffer],
@ -130,6 +138,8 @@ impl Pedals {
brake_samples.push_overwrite(0.0);
}
write_log!(format!("create vertex buffers ({icon_width})"));
let brake_vertex_buffer = Self::create_vertex_buffer(&device, icon_width as VkDeviceSize)?;
let throttle_vertex_buffer =
Self::create_vertex_buffer(&device, icon_width as VkDeviceSize)?;
@ -160,6 +170,8 @@ impl Pedals {
throttle_vertex_buffer,
};
write_log!("update vertex buffers");
me.update_vertex_buffers()?;
Ok(me)
@ -207,26 +219,27 @@ impl Pedals {
let command_buffer =
CommandBuffer::new_primary().build(self.device.clone(), self.queue.clone())?;
if self.enable {
{
let mut recorder = command_buffer.begin(VkCommandBufferBeginInfo::new(
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
| VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT,
))?;
if self.enable {
self.render_target
.begin(&mut recorder, VK_SUBPASS_CONTENTS_INLINE, 0);
self.render_target
.begin(&mut recorder, VK_SUBPASS_CONTENTS_INLINE, 0);
recorder.bind_pipeline(self.pipeline.pipeline())?;
recorder.bind_pipeline(self.pipeline.pipeline())?;
recorder.bind_descriptor_sets_minimal(&[&self.throttle_descriptor]);
recorder.bind_vertex_buffer(&self.throttle_vertex_buffer);
recorder.draw_complete_single_instance(self.throttle_vertex_buffer.size() as u32);
recorder.bind_descriptor_sets_minimal(&[&self.throttle_descriptor]);
recorder.bind_vertex_buffer(&self.throttle_vertex_buffer);
recorder.draw_complete_single_instance(self.throttle_vertex_buffer.size() as u32);
recorder.bind_descriptor_sets_minimal(&[&self.brake_descriptor]);
recorder.bind_vertex_buffer(&self.brake_vertex_buffer);
recorder.draw_complete_single_instance(self.brake_vertex_buffer.size() as u32);
recorder.bind_descriptor_sets_minimal(&[&self.brake_descriptor]);
recorder.bind_vertex_buffer(&self.brake_vertex_buffer);
recorder.draw_complete_single_instance(self.brake_vertex_buffer.size() as u32);
self.render_target.end(&mut recorder);
self.render_target.end(&mut recorder);
}
}
Ok(command_buffer)

View file

@ -29,6 +29,7 @@ impl HistoryPipeline {
VK_SHADER_STAGE_FRAGMENT_BIT,
0,
)
.change_descriptor_count(2)
.build(device.clone())?;
let pipeline_layout = PipelineLayout::builder()

View file

@ -222,29 +222,31 @@ impl Radar {
let command_buffer =
CommandBuffer::new_primary().build(self.device.clone(), self.queue.clone())?;
if self.enable {
{
let mut recorder = command_buffer.begin(VkCommandBufferBeginInfo::new(
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
| VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT,
))?;
self.render_target.begin(
&mut recorder,
VK_SUBPASS_CONTENTS_INLINE,
image_index as usize,
);
if self.enable {
self.render_target.begin(
&mut recorder,
VK_SUBPASS_CONTENTS_INLINE,
image_index as usize,
);
recorder.bind_pipeline(self.pipeline.pipeline())?;
recorder.bind_pipeline(self.pipeline.pipeline())?;
for object in self.objects() {
let buffer = &object.position_buffer;
for object in self.objects() {
let buffer = &object.position_buffer;
recorder.bind_descriptor_sets_minimal(&[&object.descriptor_set]);
recorder.bind_vertex_buffer(buffer);
recorder.draw_complete_single_instance(buffer.size() as u32);
recorder.bind_descriptor_sets_minimal(&[&object.descriptor_set]);
recorder.bind_vertex_buffer(buffer);
recorder.draw_complete_single_instance(buffer.size() as u32);
}
self.render_target.end(&mut recorder);
}
self.render_target.end(&mut recorder);
}
Ok(command_buffer)