fix needless SmUniformData updates

This commit is contained in:
griffi-gh 2024-05-14 00:08:27 +02:00
parent 7220b4fae0
commit e73b336670
2 changed files with 6 additions and 3 deletions

View file

@ -24,7 +24,7 @@ pub fn render_submerged_view(
state: UniqueView<SmOverlayRenderState>,
buf: UniqueView<FstriPrimitive>,
) {
if state.uniform.stored_data.is_none() { return }
if !state.uniform.internal_do_render_flag { return }
let mut rpass = ctx.encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
label: Some("smoverlay_render_pass"),

View file

@ -11,7 +11,8 @@ pub struct SmUniformData {
}
pub struct SmUniform {
pub stored_data: Option<SmUniformData>,
pub internal_do_render_flag: bool,
stored_data: Option<SmUniformData>,
pub buffer: wgpu::Buffer,
pub bind_group_layout: wgpu::BindGroupLayout,
pub bind_group: wgpu::BindGroup,
@ -53,6 +54,7 @@ pub fn init_sm_uniform(
});
SmUniform {
internal_do_render_flag: false,
stored_data: None,
buffer,
bind_group_layout,
@ -67,7 +69,7 @@ pub fn update_sm_uniform(
trans: View<Transform>,
world: UniqueView<ChunkStorage>,
) {
state.uniform.stored_data = None;
state.uniform.internal_do_render_flag = false;
let (_, plr_trans) = (&plr, &trans).iter().next().expect("Main player MIA");
let plr_pos = plr_trans.0.to_scale_rotation_translation().2;
@ -79,6 +81,7 @@ pub fn update_sm_uniform(
color: color.to_array()
};
state.uniform.internal_do_render_flag = true;
if state.uniform.stored_data == Some(new_data) {
return
}