template <typename T> constexpr UINT CalcConstantBufferByteSize() { // Constant buffers must be a multiple of the minimum hardware // allocation size (usually 256 bytes). So round up to nearest // multiple of 256. We do this by adding 255 and then masking off // the lower 2 bytes which store all bits < 256. // Example: Suppose byteSize = 300. // (300 + 255) & ~255 // 555 & ~255 // 0x022B & ~0x00ff // 0x022B & 0xff00 // 0x0200 // 512 UINT byteSize = sizeof(T); return (byteSize + 255) & ~255; }
如何256字节对齐呢
原创
©著作权归作者所有:来自51CTO博客作者嘿克不黑的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
关于bmp 4字节对齐
Windows规定一个扫描行所占的字节数必须是4的倍数(即以long为单位),不足的以0填充,开
bmp 图像处理 字节对齐 图像显示 灰度变换