# resource_system.rs - source
Source of the Rust file `maplibre/src/debug/resource_system.rs`.

    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
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57

    //! Prepares GPU-owned resources by initializing them if they are uninitialized or out-of-date.
    use crate::{
        context::MapContext,
        debug::DebugPipeline,
        render::{
            eventually::Eventually,
            resource::{RenderPipeline, TilePipeline},
            shaders,
            shaders::Shader,
            RenderResources, Renderer,
        },
    };

    pub fn resource_system(
        MapContext {
            world,
            renderer:
                Renderer {
                    device,
                    resources: RenderResources { surface, .. },
                    settings,
                    ..
                },
            ..
        }: &mut MapContext,
    ) {
        let Some(debug_pipeline) = world
            .resources
            .query_mut::<&mut Eventually<DebugPipeline>>()
        else {
            return;
        };

        debug_pipeline.initialize(|| {
            let mask_shader = shaders::TileMaskShader {
                format: surface.surface_format(),
                draw_colors: true,
                debug_lines: true,
            };

            let pipeline = TilePipeline::new(
                "debug_pipeline".into(),
                *settings,
                mask_shader.describe_vertex(),
                mask_shader.describe_fragment(),
                false,
                false,
                true,
                false,
                false,
                false,
            )
            .describe_render_pipeline()
            .initialize(device);
            DebugPipeline(pipeline)
        });
    }