Skip to main content

dear_imgui_wgpu/texture/
manager.rs

1use super::*;
2
3/// Texture manager for WGPU renderer
4///
5/// This manages the mapping between Dear ImGui texture IDs and WGPU textures,
6/// similar to the ImageBindGroups storage in the C++ implementation.
7#[derive(Debug)]
8pub struct WgpuTextureManager {
9    /// Map from texture ID to WGPU texture
10    pub(super) textures: HashMap<TextureId, WgpuTexture>,
11    /// Next available texture ID
12    pub(super) next_id: u64,
13    /// Custom samplers registered for external textures (sampler_id -> sampler)
14    pub(super) custom_samplers: HashMap<u64, Sampler>,
15    /// Mapping from texture_id -> sampler_id for per-texture custom sampling
16    pub(super) custom_sampler_by_texture: HashMap<TextureId, u64>,
17    /// Cached common bind groups (uniform buffer + sampler) per sampler_id
18    pub(super) common_bind_groups: HashMap<u64, BindGroup>,
19    /// Next available sampler ID
20    pub(super) next_sampler_id: u64,
21}
22
23impl Default for WgpuTextureManager {
24    fn default() -> Self {
25        Self::new()
26    }
27}