we're chilling

This commit is contained in:
Quaternions 2023-10-01 15:05:39 -07:00
parent 1f9bdd9a34
commit 17b0d12d4d

View File

@ -98,15 +98,17 @@ impl GraphicsData {
//idk how to do this gooder lol //idk how to do this gooder lol
let mut double_map=std::collections::HashMap::<u32,u32>::new(); let mut double_map=std::collections::HashMap::<u32,u32>::new();
let mut texture_loading_threads=Vec::new(); let mut texture_loading_threads=Vec::new();
let the_device=std::sync::Arc::new(device);
let the_queue=std::sync::Arc::new(queue);
for (i,t) in indexed_models.textures.iter().enumerate(){ for (i,t) in indexed_models.textures.iter().enumerate(){
if let Ok(mut file) = std::fs::File::open(std::path::Path::new(&format!("textures/{}.dds",t))){ if let Ok(mut file) = std::fs::File::open(std::path::Path::new(&format!("textures/{}.dds",t))){
double_map.insert(i as u32, texture_loading_threads.len() as u32); double_map.insert(i as u32, texture_loading_threads.len() as u32);
let thread_device=the_device.clone();
let thread_queue=the_queue.clone();
texture_loading_threads.push(std::thread::spawn(move ||{ texture_loading_threads.push(std::thread::spawn(move ||{
let image = ddsfile::Dds::read(&mut file).unwrap(); (i,ddsfile::Dds::read(&mut file).unwrap())
}));
}
}
let texture_views:Vec<wgpu::TextureView>=texture_loading_threads.into_iter().map(|t|{
let (i,image)=t.join().unwrap();
let (mut width,mut height)=(image.get_width(),image.get_height()); let (mut width,mut height)=(image.get_width(),image.get_height());
@ -133,8 +135,8 @@ impl GraphicsData {
}; };
let max_mips = layer_size.max_mips(wgpu::TextureDimension::D2); let max_mips = layer_size.max_mips(wgpu::TextureDimension::D2);
let texture = thread_device.create_texture_with_data( let texture = device.create_texture_with_data(
&thread_queue, queue,
&wgpu::TextureDescriptor { &wgpu::TextureDescriptor {
size, size,
mip_level_count: max_mips, mip_level_count: max_mips,
@ -152,11 +154,8 @@ impl GraphicsData {
dimension: Some(wgpu::TextureViewDimension::D2), dimension: Some(wgpu::TextureViewDimension::D2),
..wgpu::TextureViewDescriptor::default() ..wgpu::TextureViewDescriptor::default()
}) })
})); }).collect();
}
}
let texture_views:Vec<wgpu::TextureView>=texture_loading_threads.iter().map(|t|{t.join().unwrap()}).collect();
let indexed_models_len=indexed_models.models.len(); let indexed_models_len=indexed_models.models.len();
//split groups with different textures into separate models //split groups with different textures into separate models
//the models received here are supposed to be tightly packed, i.e. no code needs to check if two models are using the same groups. //the models received here are supposed to be tightly packed, i.e. no code needs to check if two models are using the same groups.