c++ - 避免使用 DirectXMath XMStore/load

标签 c++ directx directx-11 directxmath

我以前做过 OpenGL,现在正在学习一些 DirectX11。新数学库中的一件事是存在用于 vector 和矩阵的加载/存储方法(例如 http://msdn.microsoft.com/en-us/library/ee415635(v=vs.85).aspx )。

对我来说,这让我很奇怪,当我想使用它们时必须存储/加载每个 vector 和矩阵 - 很多笨重的代码 - 我想知道是否有任何好的、干净的替代加载/存储过程?

最佳答案

你可以看看simplemath如果有帮助的话。它现在是 DirectXTK 的一部分.

来自链接站点:

Why wrap DirectXMath?
DirectXMath provides highly optimized vector and matrix math functions, which take advantage of SSE SIMD intrinsics when compiled for x86/x64, or the ARM NEON instruction set when compiled for an ARM platform such as Windows RT or Windows Phone. The downside of being designed for efficient SIMD usage is that DirectXMath can be somewhat complicated to work with. Developers must be aware of correct type usage (understanding the difference between SIMD register types such as XMVECTOR vs. memory storage types such as XMFLOAT4), must take care to maintain correct alignment for SIMD heap allocations, and must carefully structure their code to avoid accessing individual components from a SIMD register. This complexity is necessary for optimal SIMD performance, but sometimes you just want to get stuff working without so much hassle!

You should use SimpleMath if you are:

  • Looking for a C++ math library with similar API to the C# XNA types
  • Porting existing XNA code from C# to C++
  • Wanting to optimize for programmer efficiency (simplicity, readability, development speed) at the expense of runtime efficiency

You should go straight to the underlying DirectXMath API if you:

  • Want to create the fastest possible code
  • Enjoy the lateral thinking needed to express algorithms in raw SIMD

关于c++ - 避免使用 DirectXMath XMStore/load,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24435848/

相关文章:

c++ (double)0.700 * int(1000) => 699(不是 double 问题)

opengl - 透视除法后的 Z 值始终小于 -1

c++ - 在 Directx 中围绕特定半径的固定点旋转点?

multithreading - 检测窗口恢复操作即将开始

DirectX SDK 的 C++ 链接器错误

c++ - 具有 DirectX 桌面框架的消费者-生产者线程

c++ - DirectX:渲染到 Texture2DArray,并在计算着色器中从中加载

c++ - 在构造函数中声明 2D vector

c++ - 应用程序完成时未处理的异常

c++ - 从 C++ Visual 2006 迁移到 V2010 CFile 到 ifstream