晚上好,如何創建有效的維度
我想一個XMFLOAT3X3發送到常量緩衝區常量緩衝區(見下面的代碼)。
ZeroMemory(&constDesc, sizeof(constDesc));
constDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
constDesc.ByteWidth = sizeof(XMFLOAT3X3);
constDesc.Usage = D3D11_USAGE_DEFAULT;
result = m_pDevice->CreateBuffer(&constDesc,0,&m_pTexTransformCB);
if (FAILED(result)) {
MessageBoxA(NULL,"Error creating constant buffer m_pTexTransformCB", "Error", MB_OK);
return false;
}
但是,編譯器告訴我,XMFLOAT3X3是恆定的緩衝bytewidth無效尺寸:
D3D11: ERROR: ID3D11Device::CreateBuffer: The Dimensions are invalid. For ConstantBuffers, marked with the D3D11_BIND_CONSTANT_BUFFER BindFlag, the ByteWidth (value = 36) must be a multiple of 16 and be less than or equal to 65536. [ STATE_CREATION ERROR #66: CREATEBUFFER_INVALIDDIMENSIONS ]
不過,我有點新HLSL,所以我不知道如果我將字節寬度設置爲48,着色器cbuffer中的float3x3將正確註冊。我應該如何處理這個最好的?
如果您需要更多信息,請發表評論,我將編輯該問題。我希望這很清楚。