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, ...@@ -880,6 +880,19 @@ ErrorOrResult<GLuint> InternalFormat::computeRowPitch(GLenum formatType,
return aligned.ValueOrDie(); 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, ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLenum formatType,
GLsizei width, GLsizei width,
GLsizei height, GLsizei height,
...@@ -887,15 +900,9 @@ ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLenum formatType, ...@@ -887,15 +900,9 @@ ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLenum formatType,
GLint rowLength, GLint rowLength,
GLint imageHeight) const GLint imageHeight) const
{ {
GLuint rows =
(imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height));
GLuint rowPitch = 0; GLuint rowPitch = 0;
ANGLE_TRY_RESULT(computeRowPitch(formatType, width, alignment, rowLength), rowPitch); ANGLE_TRY_RESULT(computeRowPitch(formatType, width, alignment, rowLength), rowPitch);
return computeDepthPitch(height, imageHeight, rowPitch);
CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
auto depthPitch = checkedRowPitch * rows;
ANGLE_TRY_CHECKED_MATH(depthPitch);
return depthPitch.ValueOrDie();
} }
ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(GLenum formatType, ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(GLenum formatType,
...@@ -943,18 +950,16 @@ ErrorOrResult<GLuint> InternalFormat::computePackUnpackEndByte( ...@@ -943,18 +950,16 @@ ErrorOrResult<GLuint> InternalFormat::computePackUnpackEndByte(
const PixelStoreStateBase &state, const PixelStoreStateBase &state,
bool is3D) const bool is3D) const
{ {
GLuint rowPitch = 0;
ANGLE_TRY_RESULT(computeRowPitch(formatType, size.width, state.alignment, state.rowLength),
rowPitch);
GLuint depthPitch = 0; GLuint depthPitch = 0;
if (is3D) if (is3D)
{ {
ANGLE_TRY_RESULT(computeDepthPitch(formatType, size.width, size.height, state.alignment, ANGLE_TRY_RESULT(computeDepthPitch(size.height, state.imageHeight, rowPitch), depthPitch);
state.rowLength, state.imageHeight),
depthPitch);
} }
GLuint rowPitch = 0;
ANGLE_TRY_RESULT(computeRowPitch(formatType, size.width, state.alignment, state.rowLength),
rowPitch);
CheckedNumeric<GLuint> checkedCopyBytes = 0; CheckedNumeric<GLuint> checkedCopyBytes = 0;
if (compressed) if (compressed)
{ {
......
...@@ -53,6 +53,9 @@ struct InternalFormat ...@@ -53,6 +53,9 @@ struct InternalFormat
GLsizei width, GLsizei width,
GLint alignment, GLint alignment,
GLint rowLength) const; GLint rowLength) const;
ErrorOrResult<GLuint> computeDepthPitch(GLsizei height,
GLint imageHeight,
GLuint rowPitch) const;
ErrorOrResult<GLuint> computeDepthPitch(GLenum formatType, ErrorOrResult<GLuint> computeDepthPitch(GLenum formatType,
GLsizei width, GLsizei width,
GLsizei height, GLsizei height,
......
...@@ -257,8 +257,7 @@ gl::Error Image11::loadData(const gl::Box &area, ...@@ -257,8 +257,7 @@ gl::Error Image11::loadData(const gl::Box &area,
formatInfo.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength), formatInfo.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
inputRowPitch); inputRowPitch);
GLuint inputDepthPitch = 0; GLuint inputDepthPitch = 0;
ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(type, area.width, area.height, unpack.alignment, ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(area.height, unpack.imageHeight, inputRowPitch),
unpack.rowLength, unpack.imageHeight),
inputDepthPitch); inputDepthPitch);
GLuint inputSkipBytes = 0; GLuint inputSkipBytes = 0;
ANGLE_TRY_RESULT( ANGLE_TRY_RESULT(
...@@ -295,9 +294,7 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input) ...@@ -295,9 +294,7 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
GLsizei inputRowPitch = 0; GLsizei inputRowPitch = 0;
ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch); ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch);
GLsizei inputDepthPitch = 0; GLsizei inputDepthPitch = 0;
ANGLE_TRY_RESULT( ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(area.height, 0, inputRowPitch), inputDepthPitch);
formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1, 0, 0),
inputDepthPitch);
const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat); const d3d11::DXGIFormatSize &dxgiFormatInfo = d3d11::GetDXGIFormatSizeInfo(mDXGIFormat);
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes; GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
......
...@@ -625,8 +625,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ...@@ -625,8 +625,7 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index,
internalFormatInfo.computeRowPitch(type, width, unpack.alignment, unpack.rowLength), internalFormatInfo.computeRowPitch(type, width, unpack.alignment, unpack.rowLength),
srcRowPitch); srcRowPitch);
GLuint srcDepthPitch = 0; GLuint srcDepthPitch = 0;
ANGLE_TRY_RESULT(internalFormatInfo.computeDepthPitch(type, width, height, unpack.alignment, ANGLE_TRY_RESULT(internalFormatInfo.computeDepthPitch(height, unpack.imageHeight, srcRowPitch),
unpack.rowLength, unpack.imageHeight),
srcDepthPitch); srcDepthPitch);
GLuint srcSkipBytes = 0; GLuint srcSkipBytes = 0;
ANGLE_TRY_RESULT( ANGLE_TRY_RESULT(
......
...@@ -525,9 +525,8 @@ gl::Error Image9::loadCompressedData(const gl::Box &area, const void *input) ...@@ -525,9 +525,8 @@ gl::Error Image9::loadCompressedData(const gl::Box &area, const void *input)
GLsizei inputRowPitch = 0; GLsizei inputRowPitch = 0;
ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch); ANGLE_TRY_RESULT(formatInfo.computeRowPitch(GL_UNSIGNED_BYTE, area.width, 1, 0), inputRowPitch);
GLsizei inputDepthPitch = 0; GLsizei inputDepthPitch = 0;
ANGLE_TRY_RESULT( ANGLE_TRY_RESULT(formatInfo.computeDepthPitch(area.height, 0, inputDepthPitch),
formatInfo.computeDepthPitch(GL_UNSIGNED_BYTE, area.width, area.height, 1, 0, 0), inputDepthPitch);
inputDepthPitch);
const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat); const d3d9::TextureFormat &d3d9FormatInfo = d3d9::GetTextureFormatInfo(mInternalFormat);
......
...@@ -319,8 +319,7 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(GLenum target, ...@@ -319,8 +319,7 @@ gl::Error TextureGL::setSubImageRowByRowWorkaround(GLenum target,
ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength), ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
rowBytes); rowBytes);
GLuint imageBytes = 0; GLuint imageBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeDepthPitch(type, area.width, area.height, unpack.alignment, ANGLE_TRY_RESULT(glFormat.computeDepthPitch(area.height, unpack.imageHeight, rowBytes),
unpack.rowLength, unpack.imageHeight),
imageBytes); imageBytes);
bool useTexImage3D = UseTexImage3D(mState.mTarget); bool useTexImage3D = UseTexImage3D(mState.mTarget);
GLuint skipBytes = 0; GLuint skipBytes = 0;
...@@ -371,8 +370,7 @@ gl::Error TextureGL::setSubImagePaddingWorkaround(GLenum target, ...@@ -371,8 +370,7 @@ gl::Error TextureGL::setSubImagePaddingWorkaround(GLenum target,
ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength), ANGLE_TRY_RESULT(glFormat.computeRowPitch(type, area.width, unpack.alignment, unpack.rowLength),
rowBytes); rowBytes);
GLuint imageBytes = 0; GLuint imageBytes = 0;
ANGLE_TRY_RESULT(glFormat.computeDepthPitch(type, area.width, area.height, unpack.alignment, ANGLE_TRY_RESULT(glFormat.computeDepthPitch(area.height, unpack.imageHeight, rowBytes),
unpack.rowLength, unpack.imageHeight),
imageBytes); imageBytes);
bool useTexImage3D = UseTexImage3D(mState.mTarget); bool useTexImage3D = UseTexImage3D(mState.mTarget);
GLuint skipBytes = 0; 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