Skip to content

Commit a8bbd82

Browse files
committed
Re-adjust approach.
1 parent f610708 commit a8bbd82

3 files changed

Lines changed: 9 additions & 64 deletions

File tree

crates/processing_render/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ half = "2.7"
2222
crossbeam-channel = "0.5"
2323
processing_core = { workspace = true }
2424
processing_midi = { workspace = true }
25-
wgpu = { version = "29.0.1", default-features = false }
2625

2726
[build-dependencies]
2827
wesl = { workspace = true, features = ["package"] }

crates/processing_render/src/graphics.rs

Lines changed: 9 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ use bevy::{
1515
render::{
1616
RenderApp,
1717
render_resource::{
18-
CommandEncoderDescriptor, Extent3d, LoadOp, MapMode, Operations, Origin3d, PollType,
19-
RenderPassColorAttachment, RenderPassDescriptor, StoreOp, TexelCopyBufferInfo,
18+
CommandEncoderDescriptor, Extent3d, MapMode, Origin3d, PollType, TexelCopyBufferInfo,
2019
TexelCopyBufferLayout, TexelCopyTextureInfo, Texture, TextureFormat, TextureUsages,
2120
},
2221
renderer::{RenderDevice, RenderQueue},
@@ -448,16 +447,6 @@ pub fn begin_draw(In(entity): In<Entity>, mut state_query: Query<&mut RenderStat
448447
}
449448

450449
pub fn flush(app: &mut App, entity: Entity) -> Result<()> {
451-
// f there's nothing to render, skip the whole render pass. this avoids some issues on
452-
// macos with msaa resolve where nothing is rendered
453-
let is_empty = graphics_mut!(app, entity)
454-
.get::<CommandBuffer>()
455-
.map(|c| c.commands.is_empty())
456-
.unwrap_or(true);
457-
if is_empty {
458-
return Ok(());
459-
}
460-
461450
graphics_mut!(app, entity).insert(Flush);
462451
app.update();
463452
graphics_mut!(app, entity).remove::<Flush>();
@@ -494,49 +483,15 @@ pub fn end_draw(app: &mut App, entity: Entity) -> Result<()> {
494483
///
495484
// TODO: why is metal particularly affected by this? can we remove this?
496485
pub fn warmup(app: &mut App, entity: Entity) -> Result<()> {
497-
let main_texture = {
498-
let render_world = app.sub_app_mut(RenderApp).world_mut();
499-
let mut query = render_world.query::<(&MainEntity, &ViewTarget)>();
500-
let mut found = None;
501-
for (main_entity, vt) in query.iter(render_world) {
502-
if **main_entity == entity {
503-
found = Some(vt.main_texture().clone());
504-
break;
505-
}
506-
}
507-
found.ok_or(ProcessingError::GraphicsNotFound)?
508-
};
509-
510-
let render_app = app.sub_app(RenderApp);
511-
let render_device = render_app.world().resource::<RenderDevice>();
512-
let render_queue = render_app.world().resource::<RenderQueue>();
513-
514-
let view = main_texture.create_view(&bevy::render::render_resource::TextureViewDescriptor {
515-
label: Some("processing_warmup_view"),
516-
..Default::default()
517-
});
518-
let mut encoder = render_device.create_command_encoder(&CommandEncoderDescriptor {
519-
label: Some("processing_warmup_encoder"),
520-
});
521-
{
522-
let _pass = encoder.begin_render_pass(&RenderPassDescriptor {
523-
label: Some("processing_warmup_clear"),
524-
color_attachments: &[Some(RenderPassColorAttachment {
525-
view: &view,
526-
depth_slice: None,
527-
resolve_target: None,
528-
ops: Operations {
529-
load: LoadOp::Clear(wgpu::Color::TRANSPARENT),
530-
store: StoreOp::Store,
531-
},
532-
})],
533-
depth_stencil_attachment: None,
534-
timestamp_writes: None,
535-
occlusion_query_set: None,
536-
multiview_mask: None,
537-
});
486+
for _ in 0..3 {
487+
app.world_mut()
488+
.run_system_cached_with(
489+
record_command,
490+
(entity, DrawCommand::BackgroundColor(DEFAULT_CLEAR_COLOR)),
491+
)
492+
.unwrap()?;
493+
flush(app, entity)?;
538494
}
539-
render_queue.submit([encoder.finish()]);
540495
Ok(())
541496
}
542497

crates/processing_render/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,7 @@ pub fn graphics_create(
263263
)
264264
.unwrap()?;
265265

266-
app.update();
267-
#[cfg(target_os = "macos")]
268266
graphics::warmup(app, entity)?;
269-
270-
app.world_mut()
271-
.run_system_cached_with(
272-
graphics::record_command,
273-
(entity, DrawCommand::BackgroundColor(DEFAULT_CLEAR_COLOR)),
274-
)
275-
.unwrap()?;
276267
Ok(entity)
277268
})
278269
}

0 commit comments

Comments
 (0)