spatialrust_gpu/aoso_staging/
upload.rs1use super::*;
2
3pub fn upload_spatial_tensor_xyz_chunks(
5 runtime: &WgpuRuntime,
6 tensor: &SpatialTensor<'_>,
7) -> SpatialResult<Vec<GpuAoSoXyzChunk>> {
8 let cloud = tensor.cloud();
9 tensor
10 .chunks()
11 .map(|chunk| GpuAoSoXyzChunk::pack_and_upload(runtime, "aoso-xyz-chunk", &chunk, cloud))
12 .collect()
13}
14
15pub fn upload_spatial_tensor_attribute_chunks(
17 runtime: &WgpuRuntime,
18 tensor: &SpatialTensor<'_>,
19 layout: AoSoAAttributeLayout,
20) -> SpatialResult<Vec<GpuAoSoAttributeChunk>> {
21 let cloud = tensor.cloud();
22 tensor
23 .chunks()
24 .map(|chunk| {
25 let packed = if layout == AoSoAAttributeLayout::XYZ_INTENSITY {
26 chunk.pack_xyz_intensity(cloud)?
27 } else if layout == AoSoAAttributeLayout::XYZ_NORMALS {
28 chunk.pack_xyz_normals(cloud)?
29 } else if layout == AoSoAAttributeLayout::XYZ_INTENSITY_NORMALS {
30 chunk.pack_xyz_intensity_normals(cloud)?
31 } else {
32 return Err(SpatialError::InvalidArgument(
33 "unsupported AoSoA attribute layout".to_owned(),
34 ));
35 };
36 GpuAoSoAttributeChunk::upload(runtime, "aoso-attribute-chunk", &packed)
37 })
38 .collect()
39}