简体   繁体   English

在DirectX11中为动态和静态对象使用单独的顶点缓冲区

[英]Using separate vertex buffer for dynamic and static objects in DirectX11

Are there any benefits of having separate vertex buffers for static and dynamic objects in a DirectX 11 application? 在DirectX 11应用程序中为静态对象和动态对象使用单独的顶点缓冲区有什么好处? My approach is to have the vertices of all objects in a scene stored in the same vertex buffer. 我的方法是将场景中所有对象的顶点存储在同一顶点缓冲区中。

However, I will only have to re-map a small number of objects (1 to 5) of the whole collection (up to 200 objects). 但是,我只需要重新映射整个集合中的少量对象(1到5)(最多200个对象)。 The majority of objects are static and will not be transformed in any way. 大多数对象是静态的,不会以任何方式转换。 What is the best approach for doing this? 这样做的最佳方法是什么?

Mapping a big vertex buffer with discard forces the driver to allocate new memory every frame. 用丢弃映射大的顶点缓冲区会强制驱动程序在每个帧中分配新的内存。 Up to ~4 frames can be in flight, so there can be 4 copies of that buffer. 最多可以运行约4帧,因此该缓冲区可以有4个副本。 This can lead to memory overcommitment and stuttering. 这可能导致内存过量使用和卡顿。 For example, ATI advises to discard vertex buffers up to 4 mb max ( GCN Performance Tweets ). 例如,ATI建议丢弃最大不超过4 mb的顶点缓冲区( GCN Performance Tweets )。 Besides, every time you will have to needlessly copy static data to a new vertex buffer. 此外,每次您都将不必要地将静态数据复制到新的顶点缓冲区中。

Mapping with no overwrite should work better. 没有覆盖的映射应该更好地工作。 It would require to manually manage the memory, so you won't overwrite the data which is in flight. 这将需要手动管理内存,因此您不会覆盖正在传输的数据。 I'm not sure about the performance implications, but for sure this isn't a recommended path. 我不确定性能的影响,但是可以肯定,这不是推荐的方法。

Best approach would be to simplify driver's work by providing as many hints as possible. 最好的方法是通过提供尽可能多的提示来简化驾驶员的工作。 Create static vertex buffers with immutable flag, long lived with default flag and dynamic with dynamic flag. 使用不可变标志创建静态顶点缓冲区,使用默认标志创建长期顶点缓冲区,使用动态标志创建动态顶点缓冲区。 See vendor guides like GCN Performance Tweets or Don't Throw it all Away: Efficient Buffer Management for additional details. 有关其他详细信息,请参见供应商指南,如GCN性能推文或“ 不要一味扔掉:高效的缓冲区管理 ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM