mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-25 05:08:21 -06:00
separate clear_bg pass
This commit is contained in:
parent
d34fda3cd3
commit
c4f60e2634
|
@ -1,4 +1,4 @@
|
||||||
use shipyard::{AllStoragesViewMut, IntoIter, IntoWorkload, SystemModificator, Unique, UniqueView, UniqueViewMut, View, Workload, WorkloadModificator};
|
use shipyard::{AllStoragesViewMut, IntoIter, IntoWorkload, Unique, UniqueView, UniqueViewMut, View, Workload, WorkloadModificator};
|
||||||
use winit::dpi::PhysicalSize;
|
use winit::dpi::PhysicalSize;
|
||||||
use glam::Vec3;
|
use glam::Vec3;
|
||||||
use crate::{events::WindowResizedEvent, state::is_ingame};
|
use crate::{events::WindowResizedEvent, state::is_ingame};
|
||||||
|
@ -6,8 +6,7 @@ use crate::{events::WindowResizedEvent, state::is_ingame};
|
||||||
mod renderer;
|
mod renderer;
|
||||||
pub use renderer::Renderer;
|
pub use renderer::Renderer;
|
||||||
|
|
||||||
use self::{camera::CameraUniformBuffer, world::WorldRenderState};
|
pub mod background;
|
||||||
|
|
||||||
pub mod world;
|
pub mod world;
|
||||||
pub mod camera;
|
pub mod camera;
|
||||||
pub mod depth;
|
pub mod depth;
|
||||||
|
@ -58,39 +57,18 @@ pub fn render_master(storages: AllStoragesViewMut) {
|
||||||
let surface_texture = renderer.surface().get_current_texture().unwrap();
|
let surface_texture = renderer.surface().get_current_texture().unwrap();
|
||||||
let surface_view = surface_texture.texture.create_view(&wgpu::TextureViewDescriptor::default());
|
let surface_view = surface_texture.texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||||
|
|
||||||
{
|
|
||||||
let bg = storages.borrow::<UniqueView<BackgroundColor>>().unwrap().0;
|
|
||||||
let _render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
|
||||||
label: Some("rpass_background"),
|
|
||||||
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
|
||||||
view: &surface_view,
|
|
||||||
resolve_target: None,
|
|
||||||
ops: wgpu::Operations {
|
|
||||||
load: wgpu::LoadOp::Clear(wgpu::Color {
|
|
||||||
r: bg.x as f64,
|
|
||||||
g: bg.y as f64,
|
|
||||||
b: bg.z as f64,
|
|
||||||
a: 1.0,
|
|
||||||
}),
|
|
||||||
store: wgpu::StoreOp::Store,
|
|
||||||
},
|
|
||||||
})],
|
|
||||||
depth_stencil_attachment: None,
|
|
||||||
..Default::default()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut data = RenderCtx {
|
let mut data = RenderCtx {
|
||||||
renderer: &renderer,
|
renderer: &renderer,
|
||||||
encoder: &mut encoder,
|
encoder: &mut encoder,
|
||||||
surface_view: &surface_view,
|
surface_view: &surface_view,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
storages.run_with_data(background::clear_bg, &mut data);
|
||||||
if storages.run(is_ingame) {
|
if storages.run(is_ingame) {
|
||||||
storages.run_with_data(world::draw_world, &mut data);
|
storages.run_with_data(world::draw_world, &mut data);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.queue().submit(std::iter::once(encoder.finish()));
|
renderer.queue().submit([encoder.finish()]);
|
||||||
surface_texture.present();
|
surface_texture.present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
kubi/src/rendering/background.rs
Normal file
25
kubi/src/rendering/background.rs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
use shipyard::UniqueView;
|
||||||
|
use super::{BackgroundColor, RenderCtx};
|
||||||
|
|
||||||
|
pub fn clear_bg(
|
||||||
|
ctx: &mut RenderCtx,
|
||||||
|
bg: UniqueView<BackgroundColor>,
|
||||||
|
) {
|
||||||
|
let _rpass = ctx.encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||||
|
label: Some("clear_bg"),
|
||||||
|
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
|
||||||
|
view: ctx.surface_view,
|
||||||
|
resolve_target: None,
|
||||||
|
ops: wgpu::Operations {
|
||||||
|
load: wgpu::LoadOp::Clear(wgpu::Color {
|
||||||
|
r: bg.0.x as f64,
|
||||||
|
g: bg.0.y as f64,
|
||||||
|
b: bg.0.z as f64,
|
||||||
|
a: 1.0,
|
||||||
|
}),
|
||||||
|
store: wgpu::StoreOp::Store,
|
||||||
|
},
|
||||||
|
})],
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in a new issue