Add a roundUp math utility function that rounds an integral value up to a nearest multiple.

TRAC #22852 Signed-off-by: Geoff Lang Signed-off-by: Nicolas Capens Author: Jamie Madill git-svn-id: https://angleproject.googlecode.com/svn/branches/es3proto@2286 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 97c3d501
...@@ -154,6 +154,12 @@ struct Range ...@@ -154,6 +154,12 @@ struct Range
int end; int end;
}; };
template <typename T>
T roundUp(const T value, const T alignment)
{
return value + alignment - 1 - (value - 1) % alignment;
}
} }
#endif // LIBGLESV2_MATHUTIL_H_ #endif // LIBGLESV2_MATHUTIL_H_
...@@ -134,8 +134,8 @@ bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsign ...@@ -134,8 +134,8 @@ bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsign
{ {
// Round up the width and height to the nearest multiple of dimension alignment // Round up the width and height to the nearest multiple of dimension alignment
unsigned int dimensionAlignment = d3d11::GetTextureFormatDimensionAlignment(mTextureFormat); unsigned int dimensionAlignment = d3d11::GetTextureFormatDimensionAlignment(mTextureFormat);
width = width + dimensionAlignment - 1 - (width - 1) % dimensionAlignment; width = roundUp(width, (GLsizei)dimensionAlignment);
height = height + dimensionAlignment - 1 - (height - 1) % dimensionAlignment; height = roundUp(height, (GLsizei)dimensionAlignment);
D3D11_BOX srcBox; D3D11_BOX srcBox;
srcBox.left = xoffset; srcBox.left = xoffset;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment