Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Cleanup dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
darthdeus committed Dec 22, 2023
1 parent 92f5a73 commit 791d46b
Showing 1 changed file with 0 additions and 90 deletions.
90 changes: 0 additions & 90 deletions comfy-wgpu/src/egui_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,94 +133,4 @@ impl EguiRenderRoutine {
// .execute_with_renderpass(rpass, input.paint_jobs, &this.screen_descriptor);
// });
// }

/// Creates an egui texture from the given image data, format, and dimensions.
#[allow(dead_code)]
pub fn create_egui_texture(
internal: &mut egui_wgpu::Renderer,
device: &wgpu::Device,
queue: &wgpu::Queue,
format: wgpu::TextureFormat,
image_rgba: &[u8],
dimensions: (u32, u32),
label: Option<&str>,
) -> egui::TextureId {
let texture_size = wgpu::Extent3d {
width: dimensions.0,
height: dimensions.1,
depth_or_array_layers: 1,
};

let image_texture = device.create_texture(&wgpu::TextureDescriptor {
size: texture_size,
mip_level_count: 1,
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format,
usage: wgpu::TextureUsages::TEXTURE_BINDING |
wgpu::TextureUsages::COPY_DST,
label,
view_formats: &[],
});

Self::wgpu_texture_to_egui(
internal,
device,
queue,
image_texture,
image_rgba,
dimensions,
format,
)
}

/// Creates egui::TextureId with wgpu backend with existing wgpu::Texture
#[allow(dead_code)]
pub fn wgpu_texture_to_egui(
internal: &mut egui_wgpu::Renderer,
device: &wgpu::Device,
queue: &wgpu::Queue,
image_texture: wgpu::Texture,
image_rgba: &[u8],
dimensions: (u32, u32),
format: wgpu_types::TextureFormat,
) -> egui::TextureId {
let texture_size = wgpu::Extent3d {
width: dimensions.0,
height: dimensions.1,
depth_or_array_layers: 1,
};

queue.write_texture(
wgpu::ImageCopyTexture {
texture: &image_texture,
mip_level: 0,
origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All,
},
image_rgba,
wgpu::ImageDataLayout {
offset: 0,
bytes_per_row: Some(
(dimensions.0 / format.block_dimensions().0) *
format.block_size(None).expect(
"combined depth-stencil format requires \
specifying a TextureAspect",
),
),
rows_per_image: None,
},
texture_size,
);

egui_wgpu::Renderer::register_native_texture(
internal,
device,
&image_texture.create_view(&wgpu::TextureViewDescriptor {
dimension: Some(wgpu::TextureViewDimension::D2),
..Default::default()
}),
wgpu::FilterMode::Linear,
)
}
}

0 comments on commit 791d46b

Please sign in to comment.