Commit 0acb268c by Jamie Madill Committed by Commit Bot

TextureD3D: Only update storage if images dirty.

This uses the existing dirty bit mDirtyImages to early return in the TextureD3D::updateStorage methods. Also fixes a couple missing cases for setting dirty images. The code could be improved in the future by using a bitset of dirty images per mip level instead of a single bit. BUG=angleproject:1392 Change-Id: I58df2be455b6ee51c3e3f76a6fa44ad585d1480d Reviewed-on: https://chromium-review.googlesource.com/761243Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 192199a7
...@@ -107,12 +107,13 @@ gl::Error TextureD3D::getNativeTexture(const gl::Context *context, TextureStorag ...@@ -107,12 +107,13 @@ gl::Error TextureD3D::getNativeTexture(const gl::Context *context, TextureStorag
gl::Error TextureD3D::getImageAndSyncFromStorage(const gl::Context *context, gl::Error TextureD3D::getImageAndSyncFromStorage(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
ImageD3D **outImage) const ImageD3D **outImage)
{ {
ImageD3D *image = getImage(index); ImageD3D *image = getImage(index);
if (mTexStorage && mTexStorage->isRenderTarget()) if (mTexStorage && mTexStorage->isRenderTarget())
{ {
ANGLE_TRY(image->copyFromTexStorage(context, index, mTexStorage)); ANGLE_TRY(image->copyFromTexStorage(context, index, mTexStorage));
mDirtyImages = true;
} }
*outImage = image; *outImage = image;
return gl::NoError(); return gl::NoError();
...@@ -513,6 +514,8 @@ gl::Error TextureD3D::generateMipmapUsingImages(const gl::Context *context, cons ...@@ -513,6 +514,8 @@ gl::Error TextureD3D::generateMipmapUsingImages(const gl::Context *context, cons
} }
} }
mDirtyImages = true;
if (mTexStorage) if (mTexStorage)
{ {
ANGLE_TRY(updateStorage(context)); ANGLE_TRY(updateStorage(context));
...@@ -1108,6 +1111,8 @@ gl::Error TextureD3D_2D::copyTexture(const gl::Context *context, ...@@ -1108,6 +1111,8 @@ gl::Error TextureD3D_2D::copyTexture(const gl::Context *context,
ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceRect, destOffset, ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceRect, destOffset,
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
mDirtyImages = true;
gl::Box destRegion(destOffset, size); gl::Box destRegion(destOffset, size);
ANGLE_TRY(commitRegion(context, destImageIndex, destRegion)); ANGLE_TRY(commitRegion(context, destImageIndex, destRegion));
} }
...@@ -1155,6 +1160,8 @@ gl::Error TextureD3D_2D::copySubTexture(const gl::Context *context, ...@@ -1155,6 +1160,8 @@ gl::Error TextureD3D_2D::copySubTexture(const gl::Context *context,
ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceArea, destOffset, ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceArea, destOffset,
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
mDirtyImages = true;
gl::Box destRegion(destOffset.x, destOffset.y, 0, sourceArea.width, sourceArea.height, 1); gl::Box destRegion(destOffset.x, destOffset.y, 0, sourceArea.width, sourceArea.height, 1);
ANGLE_TRY(commitRegion(context, destImageIndex, destRegion)); ANGLE_TRY(commitRegion(context, destImageIndex, destRegion));
} }
...@@ -1454,6 +1461,11 @@ gl::Error TextureD3D_2D::setCompleteTexStorage(const gl::Context *context, ...@@ -1454,6 +1461,11 @@ gl::Error TextureD3D_2D::setCompleteTexStorage(const gl::Context *context,
gl::Error TextureD3D_2D::updateStorage(const gl::Context *context) gl::Error TextureD3D_2D::updateStorage(const gl::Context *context)
{ {
if (!mDirtyImages)
{
return gl::NoError();
}
ASSERT(mTexStorage != nullptr); ASSERT(mTexStorage != nullptr);
GLint storageLevels = mTexStorage->getLevelCount(); GLint storageLevels = mTexStorage->getLevelCount();
for (int level = 0; level < storageLevels; level++) for (int level = 0; level < storageLevels; level++)
...@@ -1464,6 +1476,7 @@ gl::Error TextureD3D_2D::updateStorage(const gl::Context *context) ...@@ -1464,6 +1476,7 @@ gl::Error TextureD3D_2D::updateStorage(const gl::Context *context)
} }
} }
mDirtyImages = false;
return gl::NoError(); return gl::NoError();
} }
...@@ -1879,6 +1892,8 @@ gl::Error TextureD3D_Cube::copyTexture(const gl::Context *context, ...@@ -1879,6 +1892,8 @@ gl::Error TextureD3D_Cube::copyTexture(const gl::Context *context,
ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceRect, destOffset, ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceRect, destOffset,
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
mDirtyImages = true;
gl::Box destRegion(destOffset, size); gl::Box destRegion(destOffset, size);
ANGLE_TRY(commitRegion(context, destImageIndex, destRegion)); ANGLE_TRY(commitRegion(context, destImageIndex, destRegion));
} }
...@@ -1929,6 +1944,8 @@ gl::Error TextureD3D_Cube::copySubTexture(const gl::Context *context, ...@@ -1929,6 +1944,8 @@ gl::Error TextureD3D_Cube::copySubTexture(const gl::Context *context,
ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceArea, destOffset, ANGLE_TRY(mRenderer->copyImage(context, destImage, sourceImage, sourceArea, destOffset,
unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha)); unpackFlipY, unpackPremultiplyAlpha, unpackUnmultiplyAlpha));
mDirtyImages = true;
gl::Box destRegion(destOffset.x, destOffset.y, 0, sourceArea.width, sourceArea.height, 1); gl::Box destRegion(destOffset.x, destOffset.y, 0, sourceArea.width, sourceArea.height, 1);
ANGLE_TRY(commitRegion(context, destImageIndex, destRegion)); ANGLE_TRY(commitRegion(context, destImageIndex, destRegion));
} }
...@@ -2137,6 +2154,11 @@ gl::Error TextureD3D_Cube::setCompleteTexStorage(const gl::Context *context, ...@@ -2137,6 +2154,11 @@ gl::Error TextureD3D_Cube::setCompleteTexStorage(const gl::Context *context,
gl::Error TextureD3D_Cube::updateStorage(const gl::Context *context) gl::Error TextureD3D_Cube::updateStorage(const gl::Context *context)
{ {
if (!mDirtyImages)
{
return gl::NoError();
}
ASSERT(mTexStorage != nullptr); ASSERT(mTexStorage != nullptr);
GLint storageLevels = mTexStorage->getLevelCount(); GLint storageLevels = mTexStorage->getLevelCount();
for (int face = 0; face < 6; face++) for (int face = 0; face < 6; face++)
...@@ -2150,6 +2172,7 @@ gl::Error TextureD3D_Cube::updateStorage(const gl::Context *context) ...@@ -2150,6 +2172,7 @@ gl::Error TextureD3D_Cube::updateStorage(const gl::Context *context)
} }
} }
mDirtyImages = false;
return gl::NoError(); return gl::NoError();
} }
...@@ -2541,6 +2564,8 @@ gl::Error TextureD3D_3D::copySubImage(const gl::Context *context, ...@@ -2541,6 +2564,8 @@ gl::Error TextureD3D_3D::copySubImage(const gl::Context *context,
} }
ANGLE_TRY(mImageArray[level]->copyFromFramebuffer(context, clippedDestOffset, clippedSourceArea, ANGLE_TRY(mImageArray[level]->copyFromFramebuffer(context, clippedDestOffset, clippedSourceArea,
source)); source));
mDirtyImages = true;
if (syncTexStorage) if (syncTexStorage)
{ {
ANGLE_TRY(updateStorageLevel(context, level)); ANGLE_TRY(updateStorageLevel(context, level));
...@@ -2700,6 +2725,11 @@ gl::Error TextureD3D_3D::setCompleteTexStorage(const gl::Context *context, ...@@ -2700,6 +2725,11 @@ gl::Error TextureD3D_3D::setCompleteTexStorage(const gl::Context *context,
gl::Error TextureD3D_3D::updateStorage(const gl::Context *context) gl::Error TextureD3D_3D::updateStorage(const gl::Context *context)
{ {
if (!mDirtyImages)
{
return gl::NoError();
}
ASSERT(mTexStorage != nullptr); ASSERT(mTexStorage != nullptr);
GLint storageLevels = mTexStorage->getLevelCount(); GLint storageLevels = mTexStorage->getLevelCount();
for (int level = 0; level < storageLevels; level++) for (int level = 0; level < storageLevels; level++)
...@@ -2710,6 +2740,7 @@ gl::Error TextureD3D_3D::updateStorage(const gl::Context *context) ...@@ -2710,6 +2740,7 @@ gl::Error TextureD3D_3D::updateStorage(const gl::Context *context)
} }
} }
mDirtyImages = false;
return gl::NoError(); return gl::NoError();
} }
...@@ -3272,6 +3303,11 @@ gl::Error TextureD3D_2DArray::setCompleteTexStorage(const gl::Context *context, ...@@ -3272,6 +3303,11 @@ gl::Error TextureD3D_2DArray::setCompleteTexStorage(const gl::Context *context,
gl::Error TextureD3D_2DArray::updateStorage(const gl::Context *context) gl::Error TextureD3D_2DArray::updateStorage(const gl::Context *context)
{ {
if (!mDirtyImages)
{
return gl::NoError();
}
ASSERT(mTexStorage != nullptr); ASSERT(mTexStorage != nullptr);
GLint storageLevels = mTexStorage->getLevelCount(); GLint storageLevels = mTexStorage->getLevelCount();
for (int level = 0; level < storageLevels; level++) for (int level = 0; level < storageLevels; level++)
...@@ -3282,6 +3318,7 @@ gl::Error TextureD3D_2DArray::updateStorage(const gl::Context *context) ...@@ -3282,6 +3318,7 @@ gl::Error TextureD3D_2DArray::updateStorage(const gl::Context *context)
} }
} }
mDirtyImages = false;
return gl::NoError(); return gl::NoError();
} }
......
...@@ -50,7 +50,7 @@ class TextureD3D : public TextureImpl ...@@ -50,7 +50,7 @@ class TextureD3D : public TextureImpl
gl::Error getImageAndSyncFromStorage(const gl::Context *context, gl::Error getImageAndSyncFromStorage(const gl::Context *context,
const gl::ImageIndex &index, const gl::ImageIndex &index,
ImageD3D **outImage) const; ImageD3D **outImage);
GLint getBaseLevelWidth() const; GLint getBaseLevelWidth() const;
GLint getBaseLevelHeight() const; GLint getBaseLevelHeight() const;
......
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