MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / register_texture_no_mips

Method register_texture_no_mips

native/shared/src/renderer/mod.rs:11526–11553  ·  view source on GitHub ↗

Single-mip texture for dynamically updated atlases.

(&mut self, width: u32, height: u32, data: &[u8])

Source from the content-addressed store, hash-verified

11524
11525 /// Single-mip texture for dynamically updated atlases.
11526 pub fn register_texture_no_mips(&mut self, width: u32, height: u32, data: &[u8]) -> u32 {
11527 let texture = self.device.create_texture_with_data(
11528 &self.queue,
11529 &wgpu::TextureDescriptor {
11530 label: Some("atlas_no_mips"),
11531 size: wgpu::Extent3d { width, height, depth_or_array_layers: 1 },
11532 mip_level_count: 1, sample_count: 1,
11533 dimension: wgpu::TextureDimension::D2,
11534 format: wgpu::TextureFormat::Rgba8Unorm,
11535 usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
11536 view_formats: &[],
11537 },
11538 wgpu::util::TextureDataOrder::LayerMajor, data,
11539 );
11540 let view = texture.create_view(&wgpu::TextureViewDescriptor::default());
11541 let bind_group = self.device.create_bind_group(&wgpu::BindGroupDescriptor {
11542 label: Some("atlas_bg"), layout: &self.texture_bind_group_layout,
11543 entries: &[
11544 wgpu::BindGroupEntry { binding: 0, resource: wgpu::BindingResource::TextureView(&view) },
11545 wgpu::BindGroupEntry { binding: 1, resource: wgpu::BindingResource::Sampler(&self.sampler) },
11546 ],
11547 });
11548 let idx = self.texture_bind_groups.len() as u32;
11549 self.texture_bind_groups.push(bind_group);
11550 self.textures.push(texture);
11551 self.texture_sizes.push((width, height));
11552 idx
11553 }
11554
11555 /// Replace an existing no-mips texture in-place.
11556 pub fn replace_texture_no_mips(&mut self, idx: u32, width: u32, height: u32, data: &[u8]) {

Callers 1

ensure_atlas_uploadedMethod · 0.80

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected