Compare commits

...

4 Commits

Author SHA1 Message Date
Matthew Gordon 4372d0c214 Upgrade a bunch of packages 2024-01-18 19:52:27 -04:00
Matthew Gordon f693faed12 Switch to semver for dependencies 2024-01-18 19:41:16 -04:00
Matthew Gordon 7b50b884f4 Remove Vukan 2024-01-18 19:37:40 -04:00
Matthew Gordon 5e34c37848 Vulkan WIP 2024-01-18 19:37:03 -04:00
5 changed files with 727 additions and 640 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/target
*~
\#*#
.#*

1225
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -6,15 +6,14 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde_json = "~1.0"
tokio = {version="~1.17", features=["rt-multi-thread", "macros"]}
tokio-util = {version="~0.7", features=["io"]}
reqwest = {version="~0.11", features=["json", "stream"]}
proj = "~0.25"
geo-types = "~0.7"
clap = {version="~3.1", features=["derive"]}
anyhow = "~1.0"
futures = "~0.3"
bytes = "~1.1"
las = {version="~0.7", features=["laz"]}
ash = {version="~0.36", features=["linked"]}
serde_json = "1.0"
tokio = {version="1.35", features=["rt-multi-thread", "macros"]}
tokio-util = {version="0.7", features=["io"]}
reqwest = {version="0.11", features=["json", "stream"]}
proj = "0.27"
geo-types = "0.7"
clap = {version="3.1", features=["derive"]}
anyhow = "1.0"
futures = "0.3"
bytes = "1.5"
las = {version="0.8", features=["laz"]}

View File

@ -19,7 +19,7 @@ impl std::fmt::Display for Error {
}
impl std::error::Error for Error {}
fn convert_err(err: reqwest::Error) -> std::io::Error {
fn convert_err(_err: reqwest::Error) -> std::io::Error {
todo!()
}
pub async fn get_lidar_tile_around_point(
@ -86,26 +86,3 @@ pub async fn get_lidar_tile_around_point(
.map_err(convert_err),
))
}
pub async fn test() -> Result<(), reqwest::Error> {
let client = reqwest::Client::new();
print!(
"{}",
serde_json::to_string_pretty(&client
.get("https://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_LidarIndex/MapServer/1/query")
.query(&[("f", "json"),("geometryType","esriGeometryPoint"),("geometry","2470000,7443000"),("returnIdsOnly","true")])
.send()
.await?
.json::<serde_json::Value>().await?).expect("JSON")
);
print!(
"{}",
serde_json::to_string_pretty(&client
.get("https://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_LidarIndex/MapServer/1/14601")
.query(&[("f", "json")])
.send()
.await?
.json::<serde_json::Value>().await?).expect("JSON")
);
Ok(())
}

View File

@ -1,11 +1,4 @@
use {
ash::{vk, Entry},
clap::Parser,
geo_types::Point,
las::Read as LasRead,
proj::Proj,
tokio::io::AsyncReadExt,
};
use {clap::Parser, geo_types::Point, las::Read as LasRead, proj::Proj, tokio::io::AsyncReadExt};
mod geonb;
@ -19,92 +12,16 @@ struct Args {
// Longitude to fetch LIDAR tile at
#[clap(long)]
longitude: Option<f64>,
}
fn pretty_print_memory_size(x: u64) -> String {
if x > 1_000_000_000 {
format!("{:.1}G", x / 1_000_000_000)
} else if x > 1_000_000 {
format!("{:.0}M", x / 1_000_000)
} else if x > 1000 {
format!("{:.0}K", x / 1000)
} else {
format!("{}", x)
}
}
fn init_vulkan() {
let instance = {
let entry = Entry::linked();
let app_info = vk::ApplicationInfo {
api_version: vk::make_api_version(0, 1, 0, 0),
..Default::default()
};
let create_info = vk::InstanceCreateInfo {
p_application_info: &app_info,
..Default::default()
};
unsafe {
entry
.create_instance(&create_info, None)
.expect("vulkan instance")
}
};
unsafe {
instance
.enumerate_physical_devices()
.expect("vulkan physical devices")
.iter()
.for_each(|&device| {
let device_properties = instance.get_physical_device_properties(device);
let api_version = device_properties.api_version;
let api_major_version = (api_version >> 22) & 0x7f;
let api_minor_version = (api_version >> 12) & 0x3ff;
println!(
"{}:\n\tAPI Version{}.{}\n\t{:?}",
std::ffi::CStr::from_ptr(&device_properties.device_name[0])
.to_str()
.expect("device name string"),
api_major_version,
api_minor_version,
device_properties.device_type
);
println!("\tMemory:");
let memory_properties = instance.get_physical_device_memory_properties(device);
for i in 0..memory_properties.memory_type_count as usize {
let memory_type = memory_properties.memory_types[i];
println!("\t\t{:?}", memory_type.property_flags);
let heap_index = memory_type.heap_index as usize;
let heap = memory_properties.memory_heaps[heap_index];
println!(
"\t\t\t{}: {}\t{:?}",
heap_index,
pretty_print_memory_size(heap.size),
heap.flags
);
}
println!("\tQueues:");
instance
.get_physical_device_queue_family_properties(device)
.iter()
.enumerate()
.for_each(|(i, queue_info)| {
println!(
"\t\t{}: {:?} ({})",
i, queue_info.queue_flags, queue_info.queue_count
);
});
});
}
// Print extra debug info when initializing Vulkan
#[clap(long)]
debug_init: bool,
}
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let args = Args::parse();
init_vulkan();
if let (Some(latitude), Some(longitude)) = (args.latitude, args.longitude) {
let location = Proj::new_known_crs("+proj=longlat +datum=WGS84", "EPSG:2953", None)
.unwrap()