Attempt to fix layer for mesa (intel)

This commit is contained in:
hodasemi 2023-04-15 07:54:01 +02:00
parent b971e0d2a6
commit a5a3702153
3 changed files with 44 additions and 28 deletions

View file

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

View file

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

View file

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