Move to tracing with tracy support
Some checks failed
Build legacy Nix package on Ubuntu / build (push) Has been cancelled

This commit is contained in:
Florian RICHER 2025-05-30 23:27:03 +02:00
parent 8a57094478
commit d765e78da4
Signed by: florian.richer
GPG key ID: C73D37CBED7BFC77
8 changed files with 369 additions and 158 deletions

View file

@ -31,8 +31,10 @@ impl Texture {
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
path: &str,
) -> Result<Self, Error> {
let image = image::open(path)?;
Self::from_dynamic_image(device, memory_allocator, builder, image)
let _span = tracing::info_span!("texture_load_from_file", path = path);
let bytes = std::fs::read(path)?;
Self::from_bytes(device, memory_allocator, builder, &bytes)
}
pub fn from_bytes(
@ -51,8 +53,11 @@ impl Texture {
builder: &mut AutoCommandBufferBuilder<PrimaryAutoCommandBuffer>,
image: DynamicImage,
) -> Result<Self, Error> {
let _span = tracing::info_span!("texture_from_dynamic_image");
let image_data = image.to_rgba8();
let image_dimensions = image_data.dimensions();
let image_data = image_data.into_raw();
let upload_buffer = Buffer::new_slice(
memory_allocator.clone(),
@ -70,7 +75,7 @@ impl Texture {
{
let buffer_data = &mut *upload_buffer.write()?;
buffer_data.copy_from_slice(image_data.as_raw());
buffer_data.copy_from_slice(&image_data);
}
let image = Image::new(
@ -103,7 +108,7 @@ impl Texture {
let image_view = ImageView::new_default(image)?;
log::trace!("Texture loaded with dimensions {:?}", image_dimensions);
tracing::trace!("Texture loaded with dimensions {:?}", image_dimensions);
Ok(Self::new(image_view, sampler))
}