Commit 0e48719f by Corentin Wallez Committed by Commit Bot

formatutils: allow reusing rowPitch computation for depthPitch

This should fix a null D3D11 backend draw call performance regression. BUG=651101 Change-Id: I2eb10cddd15f0e7b25b886c89eccd2906e988c72 Reviewed-on: https://chromium-review.googlesource.com/392227Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 2549e74e
......@@ -880,6 +880,19 @@ ErrorOrResult<GLuint> InternalFormat::computeRowPitch(GLenum formatType,
return aligned.ValueOrDie();
}
ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLsizei height,
GLint imageHeight,
GLuint rowPitch) const
{
GLuint rows =
(imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height));
CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
auto depthPitch = checkedRowPitch * rows;
ANGLE_TRY_CHECKED_MATH(depthPitch);
return depthPitch.ValueOrDie();
}
ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLenum formatType,
GLsizei width,
GLsizei height,
......@@ -887,15 +900,9 @@ ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLenum formatType,
GLint rowLength,
GLint imageHeight) const
{
GLuint rows =
(imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height));
GLuint rowPitch = 0;
ANGLE_TRY_RESULT(computeRowPitch(formatType, width, alignment, rowLength), rowPitch);
CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
auto depthPitch = checkedRowPitch * rows;
ANGLE_TRY_CHECKED_MATH(depthPitch);
return depthPitch.ValueOrDie();
return computeDepthPitch(height, imageHeight, rowPitch);
}
ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(GLenum formatType,
......@@ -943,18 +950,16 @@ ErrorOrResult<GLuint> InternalFormat::computePackUnpackEndByte(
const PixelStoreStateBase &state,
bool is3D) const
{
GLuint rowPitch = 0;
ANGLE_TRY_RESULT(computeRowPitch(formatType, size.width, state.alignment, state.rowLength),
rowPitch);
GLuint depthPitch = 0;
if (is3D)
{
ANGLE_TRY_RESULT(computeDepthPitch(formatType, size.width, size.height, state.alignment,
state.rowLength, state.imageHeight),
depthPitch);
ANGLE_TRY_RESULT(computeDepthPitch(size.height, state.imageHeight, rowPitch), depthPitch);
}
GLuint rowPitch = 0;
ANGLE_TRY_RESULT(computeRowPitch(formatType, size.width, state.alignment, state.rowLength),
rowPitch);
CheckedNumeric<GLuint> checkedCopyBytes = 0;
if (compressed)
{
......
......@@ -53,6 +53,9 @@ struct InternalFormat
GLsizei width,
GLint alignment,
GLint rowLength) const;
ErrorOrResult<GLuint> computeDepthPitch(GLsizei height,
GLint imageHeight,
GLuint rowPitch) const;
ErrorOrResult<GLuint> computeDepthPitch(GLenum formatType,
GLsizei width,
GLsizei height,
......
......@@ -257,8 +257,7 @@ gl::Error Image11::loadData(const gl::Box &area,
formatInfo.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
inputRowPitch);
GLuint inputDepthPitch = 0;
ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, area.width, area.height, unpack.alignment,
unpack.rowLength, unpack.imageHeight),
ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(area.height, unpack.imageHeight, inputRowPitch),
inputDepthPitch);
GLuint inputSkipBytes = 0;
ANGLE_TRY_RESULT(
......@@ -295,9 +294,7 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
GLsizei inputRowPitch = 0;
ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch);
GLsizei inputDepthPitch = 0;
ANGLE_TRY_RESULT(
formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1, 0, 0),
inputDepthPitch);
ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(area.height, 0, inputRowPitch), inputDepthPitch);
const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat);
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
......
......@@ -625,8 +625,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index,
internalFormatInfo.computeRowPitch(type, width, unpack.alignment, unpack.rowLength),
srcRowPitch);
GLuint srcDepthPitch = 0;
ANGLE_TRY_RESULT(internalFormatInfo.computeDepthPitch(type, width, height, unpack.alignment,
unpack.rowLength, unpack.imageHeight),
ANGLE_TRY_RESULT(internalFormatInfo.computeDepthPitch(height, unpack.imageHeight, srcRowPitch),
srcDepthPitch);
GLuint srcSkipBytes = 0;
ANGLE_TRY_RESULT(
......
......@@ -525,9 +525,8 @@ gl::Error Image9::loadCompressedData(const gl::Box &area, const void *input)
GLsizei inputRowPitch = 0;
ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch);
GLsizei inputDepthPitch = 0;
ANGLE_TRY_RESULT(
formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1, 0, 0),
inputDepthPitch);
ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(area.height, 0, inputDepthPitch),
inputDepthPitch);
const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
......
......@@ -319,8 +319,7 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(GLenum target,
ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
rowBytes);
GLuint imageBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeDepthPitch(type, area.width, area.height, unpack.alignment,
unpack.rowLength, unpack.imageHeight),
ANGLE_TRY_RESULT(glFormat.computeDepthPitch(area.height, unpack.imageHeight, rowBytes),
imageBytes);
bool useTexImage3D = UseTexImage3D(mState.mTarget);
GLuint skipBytes = 0;
......@@ -371,8 +370,7 @@ gl::Error TextureGL::setSubImagePaddingWorkaround(GLenum target,
ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
rowBytes);
GLuint imageBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeDepthPitch(type, area.width, area.height, unpack.alignment,
unpack.rowLength, unpack.imageHeight),
ANGLE_TRY_RESULT(glFormat.computeDepthPitch(area.height, unpack.imageHeight, rowBytes),
imageBytes);
bool useTexImage3D = UseTexImage3D(mState.mTarget);
GLuint skipBytes = 0;
......
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