Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
slightly more improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
manglemix committed May 1, 2024
1 parent ee16034 commit 3fd2dec
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 138 deletions.
4 changes: 3 additions & 1 deletion compute-shader/src/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ pub trait CreateBuffer: ValidBufferType {
}

impl<T: BufferSized + ?Sized, H: HostReadableWritable, S: ShaderWritable, O: UniformOrStorage>
CreateBuffer for BufferType<T, H, S, O> where Self: ValidBufferType
CreateBuffer for BufferType<T, H, S, O>
where
Self: ValidBufferType,
{
const HOST_CAN_READ: bool = H::CAN_READ;
const HOST_CAN_WRITE: bool = H::CAN_WRITE;
Expand Down
112 changes: 31 additions & 81 deletions compute-shader/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::sync::RwLock;

use buffers::{
BufferDestination, BufferSource, CreateBuffer, ValidBufferType
};
use buffers::{BufferDestination, BufferSource, CreateBuffer, ValidBufferType};
use crossbeam::queue::SegQueue;
use futures::FutureExt;
use fxhash::FxHashMap;
Expand Down Expand Up @@ -177,11 +175,7 @@ impl<A> Compute<A> {
}
}


impl<B1,>
Compute<(
B1,
)>
impl<B1> Compute<(B1,)>
where
B1: CreateBuffer,
{
Expand All @@ -194,45 +188,27 @@ where
Ok(Self::new_inner(
shader_module_decsriptor,
device,
Box::new([
type1.into_buffer(0, device),
]),
Box::new([
type1.into_layout(0),
]),
[type1.size()]
.into_iter()
.max()
.unwrap(),
Box::new([type1.into_buffer(0, device)]),
Box::new([type1.into_layout(0)]),
[type1.size()].into_iter().max().unwrap(),
))
}

pub fn new_pass(
&self,
arg1: impl BufferSource<B1::WriteType>,
) -> ComputePass<(
B1,
)> {
pub fn new_pass(&self, arg1: impl BufferSource<B1::WriteType>) -> ComputePass<(B1,)> {
self.new_pass_inner(|command_encoder, arg_buffers, stager, device| {
arg1.into_buffer(command_encoder, &arg_buffers[0], stager, device);
})
}

pub async fn write_args(
&self,
arg1: impl BufferSource<B1::WriteType>,
) {
pub async fn write_args(&self, arg1: impl BufferSource<B1::WriteType>) {
self.write_args_inner(|command_encoder, arg_buffers, stager, device| {
arg1.into_buffer(command_encoder, &arg_buffers[0], stager, device);
})
.await;
}
}

impl<B1, B2>
Compute<(
B1, B2,
)>
impl<B1, B2> Compute<(B1, B2)>
where
B1: CreateBuffer,
B2: CreateBuffer,
Expand All @@ -247,28 +223,17 @@ where
Ok(Self::new_inner(
shader_module_decsriptor,
device,
Box::new([
type1.into_buffer(0, device),
type2.into_buffer(1, device),
]),
Box::new([
type1.into_layout(0),
type2.into_layout(1),
]),
[type1.size(), type2.size()]
.into_iter()
.max()
.unwrap(),
Box::new([type1.into_buffer(0, device), type2.into_buffer(1, device)]),
Box::new([type1.into_layout(0), type2.into_layout(1)]),
[type1.size(), type2.size()].into_iter().max().unwrap(),
))
}

pub fn new_pass(
&self,
arg1: impl BufferSource<B1::WriteType>,
arg2: impl BufferSource<B2::WriteType>,
) -> ComputePass<(
B1, B2,
)> {
) -> ComputePass<(B1, B2)> {
self.new_pass_inner(|command_encoder, arg_buffers, stager, device| {
arg1.into_buffer(command_encoder, &arg_buffers[0], stager, device);
arg2.into_buffer(command_encoder, &arg_buffers[1], stager, device);
Expand All @@ -288,10 +253,7 @@ where
}
}

impl<B1, B2, B3>
Compute<(
B1, B2, B3,
)>
impl<B1, B2, B3> Compute<(B1, B2, B3)>
where
B1: CreateBuffer,
B2: CreateBuffer,
Expand Down Expand Up @@ -330,9 +292,7 @@ where
arg1: impl BufferSource<B1::WriteType>,
arg2: impl BufferSource<B2::WriteType>,
arg3: impl BufferSource<B3::WriteType>,
) -> ComputePass<(
B1, B2, B3,
)> {
) -> ComputePass<(B1, B2, B3)> {
self.new_pass_inner(|command_encoder, arg_buffers, stager, device| {
arg1.into_buffer(command_encoder, &arg_buffers[0], stager, device);
arg2.into_buffer(command_encoder, &arg_buffers[1], stager, device);
Expand All @@ -354,10 +314,7 @@ where
.await;
}
}
impl<B1, B2, B3, B4>
Compute<(
B1, B2, B3, B4,
)>
impl<B1, B2, B3, B4> Compute<(B1, B2, B3, B4)>
where
B1: CreateBuffer,
B2: CreateBuffer,
Expand Down Expand Up @@ -401,9 +358,7 @@ where
arg2: impl BufferSource<B2::WriteType>,
arg3: impl BufferSource<B3::WriteType>,
arg4: impl BufferSource<B4::WriteType>,
) -> ComputePass<(
B1, B2, B3, B4,
)> {
) -> ComputePass<(B1, B2, B3, B4)> {
self.new_pass_inner(|command_encoder, arg_buffers, stager, device| {
arg1.into_buffer(command_encoder, &arg_buffers[0], stager, device);
arg2.into_buffer(command_encoder, &arg_buffers[1], stager, device);
Expand All @@ -428,10 +383,7 @@ where
.await;
}
}
impl<B1, B2, B3, B4, B5>
Compute<(
B1, B2, B3, B4, B5,
)>
impl<B1, B2, B3, B4, B5> Compute<(B1, B2, B3, B4, B5)>
where
B1: CreateBuffer,
B2: CreateBuffer,
Expand Down Expand Up @@ -466,10 +418,16 @@ where
type4.into_layout(3),
type5.into_layout(4),
]),
[type1.size(), type2.size(), type3.size(), type4.size(), type5.size()]
.into_iter()
.max()
.unwrap(),
[
type1.size(),
type2.size(),
type3.size(),
type4.size(),
type5.size(),
]
.into_iter()
.max()
.unwrap(),
))
}

Expand All @@ -480,9 +438,7 @@ where
arg3: impl BufferSource<B3::WriteType>,
arg4: impl BufferSource<B4::WriteType>,
arg5: impl BufferSource<B5::WriteType>,
) -> ComputePass<(
B1, B2, B3, B4, B5
)> {
) -> ComputePass<(B1, B2, B3, B4, B5)> {
self.new_pass_inner(|command_encoder, arg_buffers, stager, device| {
arg1.into_buffer(command_encoder, &arg_buffers[0], stager, device);
arg2.into_buffer(command_encoder, &arg_buffers[1], stager, device);
Expand Down Expand Up @@ -580,19 +536,14 @@ impl<'a, A> ComputePass<'a, A> {
}
}

impl<'a, B1,> ComputePass<'a, (B1,)>
impl<'a, B1> ComputePass<'a, (B1,)>
where
B1: ValidBufferType,
{
pub async fn call(
self,
mut arg1: impl BufferDestination<B1::ReadType>,
) {
pub async fn call(self, mut arg1: impl BufferDestination<B1::ReadType>) {
let (device, buffers, (state1,)) = self
.call_inner(|command_encoder, arg_buffers, buffers, device| {
(
arg1.enqueue(command_encoder, &arg_buffers[0], &buffers, device),
)
(arg1.enqueue(command_encoder, &arg_buffers[0], &buffers, device),)
})
.await;

Expand Down Expand Up @@ -683,7 +634,6 @@ where
}
}


impl<'a, B1, B2, B3, B4, B5> ComputePass<'a, (B1, B2, B3, B4, B5)>
where
B1: ValidBufferType,
Expand Down
2 changes: 1 addition & 1 deletion localization/src/engines/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ pub struct WindowConfig<N: Float, FI, FV, FA, FAV> {
impl<N: Float> Default for DefaultWindowConfig<N> {
fn default() -> Self {
Self {
bucket_duration: Duration::from_secs(1),
bucket_duration: Duration::from_secs(2),
max_no_observation_duration: Duration::from_millis(100),
isometry_func: |_| {},
linear_velocity_func: |_| {},
Expand Down
9 changes: 7 additions & 2 deletions lunasimbot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ async fn main(context: MainRuntimeContext) -> anyhow::Result<()> {
.flat_map(|y| {
(-100..100).into_iter().map(move |x| HeightQuery {
isometry: Isometry3::from_parts(
(isometry * Point3::from(origin + Vector3::new(x as f32 * 0.02, 0.0, y as f32 * 0.02))).into(),
(isometry
* Point3::from(
origin + Vector3::new(x as f32 * 0.02, 0.0, y as f32 * 0.02),
))
.into(),
UnitQuaternion::default(),
),
max_points: 32,
Expand Down Expand Up @@ -147,7 +151,8 @@ async fn main(context: MainRuntimeContext) -> anyhow::Result<()> {
.get_path_pub()
.accept_subscription(path_sub.create_subscription());

let driver = DifferentialDriver::new(robot_base.get_ref());
let mut driver = DifferentialDriver::new(robot_base.get_ref());
driver.skip_distance = 0.5;
let mut drive_mode_pub = driver.create_drive_mode_sub().into_mono_pub();
drive_mode_pub.set(DriveMode::ForwardOnly);
pathfinder
Expand Down
Loading

0 comments on commit 3fd2dec

Please sign in to comment.