小编Har*_*ish的帖子

如何优化VBO/IBO以最大化GPU缓存使用率

我正在使用在CUDA上运行的Marching Cubes算法从体积数据生成网格.

我试过保存网格并以3种方式渲染它.

  1. 将一组原始三角形保存为连续的顶点数据数组.我估计第一遍的大小,创建一个OpenGL VBO,将其映射到CUDA并以下面的格式将顶点数据写入它

V0x, V0y, V0z, N0x, N0y, N0z, V1x, V1y, V1z, N1x, N1y, N1z, ...

并使用它绘制glDrawArrays().

VBO中的冗余顶点,每个多维数据集的冗余顶点,无索引.

  1. 从第1步获取网格,使用thrust::sort()thrust::unique()删除冗余顶点,使用计算索引thrust::lower_bound().将结果保存到映射到CUDA的OpenGL VBO/IBO.使用绘制模型glDrawElements().

VBO中没有冗余顶点,生成指数.

  1. 生成每个立方体的唯一顶点列表,将它们存储在VBO中,以及它们在IBO中形成三角形的索引.渲染使用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?

c++ opengl cuda thrust

6
推荐指数
1
解决办法
562
查看次数

将CUDA设备交错数组转换为元组以进行向量运算

如何将包含交错浮点数的设备数组转换为推力矢量运算的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)

我如何实现副本,还是有其他更好的方法来做到这一点?

c++ cuda thrust

2
推荐指数
1
解决办法
1064
查看次数

标签 统计

c++ ×2

cuda ×2

thrust ×2

opengl ×1