1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Uploads data to the GPU which is needed for rendering.
use crate::{
    context::MapContext,
    render::{
        eventually::{Eventually, Eventually::Initialized},
        tile_view_pattern::WgpuTileViewPattern,
        Renderer,
    },
};

pub fn upload_system(
    MapContext {
        world,
        view_state,
        renderer: Renderer { queue, .. },
        ..
    }: &mut MapContext,
) {
    let Some(Initialized(tile_view_pattern)) = world
        .resources
        .query_mut::<&mut Eventually<WgpuTileViewPattern>>()
    else {
        return;
    };

    let view_proj = view_state.view_projection();
    tile_view_pattern.upload_pattern(queue, &view_proj);
}