-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic batching #34
Generic batching #34
Conversation
type CompareData: PartialEq; | ||
type BufferData: GpuArrayBufferable + Sync + Send + 'static; | ||
fn get_batch_data( | ||
batch_data: <Self::Query as WorldQuery>::Item<'_>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, what should this anonymous lifetime be? Seems a bit sus in an API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it doesn't matter as it's only borrowed for the duration of get_batch_data, for now?
pub fn flush_buffer<F: GetBatchData>( | ||
render_device: Res<RenderDevice>, | ||
render_queue: Res<RenderQueue>, | ||
gpu_array_buffer: ResMut<GpuArrayBuffer<F::BufferData>>, | ||
) { | ||
let gpu_array_buffer = gpu_array_buffer.into_inner(); | ||
gpu_array_buffer.write_buffer(&render_device, &render_queue); | ||
gpu_array_buffer.clear(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! I wanted to separate this out so we could allow others to append stuff to the buffer for their own purposes.
@@ -97,7 +94,9 @@ impl Plugin for Mesh2dRenderPlugin { | |||
.add_systems( | |||
Render, | |||
( | |||
prepare_and_batch_meshes2d.in_set(RenderSet::PrepareResources), | |||
batch_render_phase::<Transparent2d, Mesh2dPipeline> | |||
.in_set(RenderSet::PrepareResources), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice that this just becomes a system.
type BufferData = Mesh2dUniform; | ||
|
||
fn get_batch_data( | ||
(material_bind_group_id, mesh_handle, mesh_transforms): <Self::Query as bevy_ecs::query::WorldQuery>::Item<'_>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import WorldQuery.
No description provided.