RHI: Fix compilation with MinGW developer builds

Make aligned a template, fixing:
rhi\qrhid3d11.cpp: In member function 'void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings*)':
rhi\qrhid3d11.cpp:1627:53: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
             Q_ASSERT(aligned(b->u.ubuf.offset, 256) == b->u.ubuf.offset);

Change-Id: I6b747ebaf78e5accb9b7ed145df71a80d0a15762
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
Friedemann Kleint 2019-06-26 10:37:57 +02:00
parent c2b00f8d57
commit fb244259ae

View File

@ -150,7 +150,8 @@ static QString comErrorMessage(HRESULT hr)
return result;
}
static inline uint aligned(uint v, uint byteAlign)
template <class Int>
static inline Int aligned(Int v, Int byteAlign)
{
return (v + byteAlign - 1) & ~(byteAlign - 1);
}
@ -595,7 +596,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind
for (int i = 0; i < dynamicOffsetCount; ++i) {
const QRhiCommandBuffer::DynamicOffset &dynOfs(dynamicOffsets[i]);
const uint binding = dynOfs.first;
Q_ASSERT(aligned(dynOfs.second, 256) == dynOfs.second);
Q_ASSERT(aligned(dynOfs.second, quint32(256)) == dynOfs.second);
const uint offsetInConstants = dynOfs.second / 16;
*p++ = binding;
*p++ = offsetInConstants;