From 2680bd0608b0c88225a89ce662f2292714a36136 Mon Sep 17 00:00:00 2001 From: Matthew Endsley Date: Tue, 6 Jan 2015 11:23:50 +0000 Subject: [PATCH] D3D11 constant buffer must align ByteWidth to 16 bytes See remarks of: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476092(v=vs.85).aspx Most PC drivers don't seem to enforce this, but it will crash the xb1 implementation if fed an unaligned value. --- src/renderer_d3d11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index c208773d..50f1a972 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -2647,7 +2647,7 @@ namespace bgfx { namespace d3d11 if (0 < size) { D3D11_BUFFER_DESC desc; - desc.ByteWidth = size; + desc.ByteWidth = (size + 0xf) & ~0xf; desc.Usage = D3D11_USAGE_DEFAULT; desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; desc.CPUAccessFlags = 0;