ong>rasterizer_impl.h namespace CudaRasterizer { //模版函数,获取内存,chunk:数据块首地址的引用(char*),函数结束后更新为获取内存后的块尾地址; template <typename T> static void obtain(char*& chunk, T*& ptr, std::size_t count, std::size_t alignment) { //ptr:T*类型指针的引用,T表示一种数据类型,函数结束后更新为指向T*型的地址指针; //count:T型数据的个数;alignment:对齐的长度,也即是最短的内存块长度 std::size_t offset = (reinterpret_cast<std::uintptr_t>(chunk) + alignment - 1) & ~(alignment - 1); ptr = reinterpret_cast<T*>(offset); chunk = reinterpret_cast<char*>(ptr + count); } //几何状态 struct GeometryState { size_t scan_size; //执行InclusiveSum所需的内存大小 float* depths; //深度 char* scanning_space; //执行InclusiveSum所需的临时内存位置 bool* clamped; //被钳制为正值的RGB颜色 int* internal_radii; //内部用的半径,每个高斯球对应一个半径 float2* means2D; //像素坐标系下的坐标 float* cov3D; //3d协方差,对称矩阵,6个值 float4* conic_opacity; //2d协方差矩阵的逆和不透明度 float* rgb; //颜色,3个值rgb uint32_t* point_offsets; //tiles_touched数组的前缀和 uint32_t* tiles_touched; //碰到的tiles数量 static GeometryState fromChunk(char*& chunk, size_t P); }; //图像状态 struct ImageState { uint2* ranges; // 每一个tile项在point_list_keys对应的范围 uint32_t* n_contrib; // 贡献的高斯球个数 float* accum_alpha; // 累积的alpha值 static ImageState fromChunk(char*& chunk, size_t N); }; //装箱状态 struct BinningState { size_t sorting_size; //辅助空间大小 uint64_t* point_list_keys_unsorted; //d_keys_in uint64_t* point_list_keys; //d_keys_out uint32_t* point_list_unsorted; //d_values_in uint32_t* point_list; //d_values_out char* list_sorting_space; //辅助空间 static BinningState fromChunk(char*& chunk, size_t P); }; //用于计算需要用到多大存储空间 template<typename T> size_t required(size_t P) { char* size = nullptr; // 起始地址为空,那么结束地址也即所需存储大小 T::fromChunk(size, P); return ((size_t)size) + 128; // 增加128个字节长度返回,也即是多预留128个字节 } };