我正在使用在CUDA上运行的Marching Cubes算法从体积数据生成网格.
我试过保存网格并以3种方式渲染它.
V0x, V0y, V0z, N0x, N0y, N0z, V1x, V1y, V1z, N1x, N1y, N1z, ...
并使用它绘制glDrawArrays().
VBO中的冗余顶点,每个多维数据集的冗余顶点,无索引.
thrust::sort()和thrust::unique()删除冗余顶点,使用计算索引thrust::lower_bound().将结果保存到映射到CUDA的OpenGL VBO/IBO.使用绘制模型glDrawElements().VBO中没有冗余顶点,生成指数.
glDrawElements().VBO中的冗余顶点,每个多维数据集的唯一顶点,每个多维数据集的生成索引
现在我得到的相同数据集的FPS是相同的ISO-Value`
Method 1 : 92 FPS, 30,647,016 Verts, 0 Indices
Method 2 : 122 FPS, 6,578,066 Verts, 30,647,016 Indices
Method 3 : 140 FPS, 20,349,880 Verts, 30,647,016 Indices
Run Code Online (Sandbox Code Playgroud)
即使方法2产生最少数量的顶点,FPS也很低.我相信这是因为索引的顺序可以最大限度地减少GPU缓存的使用.方法3的索引顺序获得更高的GPU缓存使用率,因此FPS更高.
如何修改/修改方法2以获得更高的FPS?
如何将包含交错浮点数的设备数组转换为推力矢量运算的CUDA推力元组.
目的:我使用CUDA上的Marching Cubes生成一个粗略的顶点列表.输出是顶点列表,具有冗余且无连接.我希望得到一个唯一顶点的列表,然后得到这些独特顶点的索引缓冲区,所以我可以执行一些操作,如网格简化等...
float *devPtr; //this is device pointer that holds an array of floats
//6 floats represent a vertex, array size is vertsCount*6*sizeof(float).
//format is [v0x, v0y, v0z, n0x, n0y, n0z, v1x, v1y, v1z, n1x, ...]
typedef thrust::tuple<float, float, float, float, float, float> MCVertex;
thrust::device_vector<MCVertex> inputVertices(vertsCount);
//copy from *devPtr to inputVertices.
//use something like unique to get rid of redundancies.
thrust::unique(inputVertices.begin(), inputVertices.end());
Run Code Online (Sandbox Code Playgroud)
我如何实现副本,还是有其他更好的方法来做到这一点?