Skip to content
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

Merged
merged 2 commits into from
Sep 17, 2023
Merged

Generic batching #34

merged 2 commits into from
Sep 17, 2023

Conversation

robtfm
Copy link

@robtfm robtfm commented Sep 16, 2023

No description provided.

type CompareData: PartialEq;
type BufferData: GpuArrayBufferable + Sync + Send + 'static;
fn get_batch_data(
batch_data: <Self::Query as WorldQuery>::Item<'_>,
Copy link
Owner

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?

Copy link
Owner

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?

Comment on lines +127 to +135
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();
}
Copy link
Owner

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),
Copy link
Owner

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<'_>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import WorldQuery.

@superdump superdump merged commit e359322 into superdump:batching Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants