DirectX :: XMMATRIX __declspec(align('16'))将不会对齐 [英] DirectX::XMMATRIX __declspec(align('16')) won't be aligned

查看:265
本文介绍了DirectX :: XMMATRIX __declspec(align('16'))将不会对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用DirectXMath建立我的3D模拟工程

I am using DirectXMath in building my 3D simulation project

   void SetConstantBuffer(ID3D11DeviceContext*_device_context, DirectX::XMMATRIX _world, DirectX::XMMATRIX _view, DirectX::XMMATRIX _projection)
   {
       ConstantBuffer const_buffer;
       const_buffer.View = DirectX::XMMatrixTranspose(_world);
       const_buffer.World = DirectX::XMMatrixTranspose(_view);
         const_buffer.Projection = DirectX::XMMatrixTranspose(_projection);
       _device_context->UpdateSubresource(m_const_buffer, 0, NULL, &const_buffer, 0, 0);
   }



我可能在DirectXMath中的SIMD标记上遇到这种编译器错误: p>

I get these kind of compiler errors probably on SIMD flag inside DirectXMath:


错误C2719:'_world':带有__declspec(align('16'))的形参不会对齐

错误C2719:'_view':带有__declspec(align('16'))的形式参数不会对齐

错误C2719:'_projection':带__declspec(align )不会对齐

error C2719: '_world': formal parameter with __declspec(align('16')) won't be aligned
error C2719: '_view': formal parameter with __declspec(align('16')) won't be aligned
error C2719: '_projection': formal parameter with __declspec(align('16')) won't be aligned

有没有其他方法不转换为DirectX :: XMFLOAT4X4?

我使用x86机器并在Visual Studio 2012 Express上编译。

Is there any other way without converting it to DirectX::XMFLOAT4X4?
By the way I'm using an x86 machine and compiling on Visual Studio 2012 Express.

推荐答案

const引用而不是值。

Pass the values by const reference instead of by value.

void SetConstantBuffer(
    ID3D11DeviceContext*_device_context,
    const DirectX::XMMATRIX &_world,
    const DirectX::XMMATRIX &_view,
    const DirectX::XMMATRIX &_projection)

这篇关于DirectX :: XMMATRIX __declspec(align('16'))将不会对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆