sync
This commit is contained in:
parent
6f1891f492
commit
7758a50ed5
@ -55,10 +55,10 @@ impl App {
|
|||||||
|
|
||||||
// Create a new texture. This texture will be used as the output texture for the render pass.
|
// Create a new texture. This texture will be used as the output texture for the render pass.
|
||||||
let texture_size = wgpu::Extent3d {
|
let texture_size = wgpu::Extent3d {
|
||||||
width: 256,
|
width: 256,
|
||||||
height: 256,
|
height: 256,
|
||||||
depth_or_array_layers: 1,
|
depth_or_array_layers: 1,
|
||||||
};
|
};
|
||||||
let texture = device.create_texture(&wgpu::TextureDescriptor {
|
let texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||||
label: Some("output texture"),
|
label: Some("output texture"),
|
||||||
size: texture_size,
|
size: texture_size,
|
||||||
@ -157,11 +157,10 @@ impl App {
|
|||||||
// Draw the element.
|
// Draw the element.
|
||||||
element.draw(attach, &mut render_pass);
|
element.draw(attach, &mut render_pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// output
|
// output
|
||||||
self.output.output(&mut encoder, &self._texture, self._texture_size, &self.ctx);
|
self.output
|
||||||
|
.output(&mut encoder, &self._texture, self._texture_size, &self.ctx);
|
||||||
self.ctx.queue.submit(Some(encoder.finish()));
|
self.ctx.queue.submit(Some(encoder.finish()));
|
||||||
|
|
||||||
self.output.get_data(&self.ctx).await;
|
self.output.get_data(&self.ctx).await;
|
||||||
@ -369,7 +368,7 @@ impl Output {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_data(&self,ctx: &Ctx) {
|
pub async fn get_data(&self, ctx: &Ctx) {
|
||||||
let device = &ctx.device;
|
let device = &ctx.device;
|
||||||
// 需要对映射变量设置范围,以便我们能够解除缓冲区的映射
|
// 需要对映射变量设置范围,以便我们能够解除缓冲区的映射
|
||||||
let buffer_slice = self.output_buffer.slice(..);
|
let buffer_slice = self.output_buffer.slice(..);
|
||||||
@ -385,8 +384,7 @@ impl Output {
|
|||||||
let data = buffer_slice.get_mapped_range();
|
let data = buffer_slice.get_mapped_range();
|
||||||
|
|
||||||
use image::{ImageBuffer, Rgba};
|
use image::{ImageBuffer, Rgba};
|
||||||
let buffer =
|
let buffer = ImageBuffer::<Rgba<u8>, _>::from_raw(256, 256, data).unwrap();
|
||||||
ImageBuffer::<Rgba<u8>, _>::from_raw(256,256, data).unwrap();
|
|
||||||
buffer.save("image.png").unwrap();
|
buffer.save("image.png").unwrap();
|
||||||
println!("保存图片成功!");
|
println!("保存图片成功!");
|
||||||
|
|
||||||
@ -406,12 +404,11 @@ mod test {
|
|||||||
use super::*;
|
use super::*;
|
||||||
#[test]
|
#[test]
|
||||||
fn test_app() {
|
fn test_app() {
|
||||||
let plugin_manager =
|
let plugin_manager = PluginManager::new(r#"/Users/tsuki/projects/mp/loaders"#).unwrap();
|
||||||
PluginManager::new(r#"C:\Users\qwin7\projects\radarmp\loaders"#).unwrap();
|
|
||||||
|
|
||||||
let data = plugin_manager.try_load_data(
|
let data = plugin_manager.try_load_data(
|
||||||
// "/Users/tsuki/Desktop/Z_RADR_I_X5775_20230726180000_O_DOR-XPD-CAP-FMT.BIN.zip",
|
"/Users/tsuki/Desktop/Z_RADR_I_X5775_20230726180000_O_DOR-XPD-CAP-FMT.BIN.zip",
|
||||||
r#"C:\Users\qwin7\Downloads\ZJSXAA_20230113070200_R.dat.gz"#,
|
// r#"C:\Users\qwin7\Downloads\ZJSXAA_20230113070200_R.dat.gz"#,
|
||||||
);
|
);
|
||||||
|
|
||||||
pollster::block_on(async {
|
pollster::block_on(async {
|
||||||
|
|||||||
@ -257,8 +257,7 @@ impl Element for PPI {
|
|||||||
|
|
||||||
impl PPI {
|
impl PPI {
|
||||||
fn init_shader(device: &wgpu::Device) -> wgpu::ShaderModule {
|
fn init_shader(device: &wgpu::Device) -> wgpu::ShaderModule {
|
||||||
let shader_str =
|
let shader_str = merge_shader(r#"/Users/tsuki/projects/mp/mp_elements/shaders/ppi.wgsl"#);
|
||||||
merge_shader(r#"C:\Users\qwin7\projects\radarmp\mp_elements\shaders\ppi.wgsl"#);
|
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
||||||
label: Some("PPI Shader Module"),
|
label: Some("PPI Shader Module"),
|
||||||
source: wgpu::ShaderSource::Wgsl(shader_str.into()),
|
source: wgpu::ShaderSource::Wgsl(shader_str.into()),
|
||||||
@ -266,17 +265,6 @@ impl PPI {
|
|||||||
shader
|
shader
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_uniform_buffer(device: &wgpu::Device) -> wgpu::Buffer {
|
|
||||||
let buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
|
||||||
label: Some("PPI Uniform Buffer"),
|
|
||||||
usage: wgpu::BufferUsages::COPY_DST | wgpu::BufferUsages::UNIFORM,
|
|
||||||
size: 0,
|
|
||||||
mapped_at_creation: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
fn generate_key(&self, data: &RadarGridData) -> BufferKey {
|
fn generate_key(&self, data: &RadarGridData) -> BufferKey {
|
||||||
let key_name = format!(
|
let key_name = format!(
|
||||||
"ppi_{}_{}",
|
"ppi_{}_{}",
|
||||||
@ -335,22 +323,17 @@ impl PPI {
|
|||||||
|
|
||||||
// index buffer
|
// index buffer
|
||||||
let mut indice_buffer = Vec::with_capacity(a.len() * r.len() * 6);
|
let mut indice_buffer = Vec::with_capacity(a.len() * r.len() * 6);
|
||||||
for a_idx in 0..a.len() - 1 {
|
|
||||||
for r_idx in 0..r.len() - 1 {
|
|
||||||
let lt = (a_idx * r.len() + r_idx) as u32;
|
|
||||||
let lb = (a_idx * r.len() + r_idx + 1) as u32;
|
|
||||||
let rt = ((a_idx + 1) * r.len() + r_idx) as u32;
|
|
||||||
let rb = ((a_idx + 1) * r.len() + r_idx + 1) as u32;
|
|
||||||
|
|
||||||
indice_buffer.push(lt);
|
for i in 0..a.len() * r.len() {
|
||||||
indice_buffer.push(lb);
|
indice_buffer.push(i as u32 * 4);
|
||||||
indice_buffer.push(rt);
|
indice_buffer.push(i as u32 * 4 + 1);
|
||||||
|
indice_buffer.push(i as u32 * 4 + 2);
|
||||||
|
|
||||||
indice_buffer.push(lb);
|
indice_buffer.push(i as u32 * 4 + 1);
|
||||||
indice_buffer.push(rb);
|
indice_buffer.push(i as u32 * 4 + 3);
|
||||||
indice_buffer.push(rt);
|
indice_buffer.push(i as u32 * 4 + 2);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (vertexs, indice_buffer);
|
return (vertexs, indice_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ struct UniformCommonTools {
|
|||||||
Ok(path) => path.parent().unwrap().to_owned(),
|
Ok(path) => path.parent().unwrap().to_owned(),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// panic!("Failed to canonicalize path: {}", e);
|
// panic!("Failed to canonicalize path: {}", e);
|
||||||
PathBuf::from(r#"C:\Users\qwin7\projects\radarmp\mp_elements\shaders"#)
|
PathBuf::from(r#"/Users/tsuki/projects/mp/mp_elements/shaders"#)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user