Commit edbeae5f by Geoff Lang

Update the TextureStorage calls to associate textures to use Errors objects.

BUG=angle:520 Change-Id: Ied81c25a04d7239985cc83bb20493ce0bfd372d3 Reviewed-on: https://chromium-review.googlesource.com/217336Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 993d08d9
......@@ -136,7 +136,11 @@ gl::Error Image11::copyToStorageImpl(TextureStorage11 *storage11, const gl::Imag
if (attemptToReleaseStagingTexture)
{
// If another image is relying on this Storage for its data, then we must let it recover its data before we overwrite it.
storage11->releaseAssociatedImage(index, this);
gl::Error error = storage11->releaseAssociatedImage(index, this);
if (error.isError())
{
return error;
}
}
gl::Error error = storage11->updateSubresourceLevel(getStagingTexture(), getStagingSubresource(),
......@@ -164,7 +168,7 @@ bool Image11::isAssociatedStorageValid(TextureStorage11* textureStorage) const
return (mAssociatedStorage == textureStorage);
}
bool Image11::recoverFromAssociatedStorage()
gl::Error Image11::recoverFromAssociatedStorage()
{
if (mRecoverFromStorage)
{
......@@ -180,17 +184,20 @@ bool Image11::recoverFromAssociatedStorage()
{
// CopySubResource from the Storage to the Staging texture
gl::Box region(0, 0, 0, mWidth, mHeight, mDepth);
mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource, mAssociatedImageIndex, region);
gl::Error error = mAssociatedStorage->copySubresourceLevel(mStagingTexture, mStagingSubresource, mAssociatedImageIndex, region);
if (error.isError())
{
return error;
}
mRecoveredFromStorageCount += 1;
}
// Reset all the recovery parameters, even if the texture storage association is broken.
disassociateStorage();
return textureStorageCorrect;
}
return false;
return gl::Error(GL_NO_ERROR);
}
void Image11::disassociateStorage()
......
......@@ -56,7 +56,7 @@ class Image11 : public ImageD3D
virtual gl::Error copy(GLint xoffset, GLint yoffset, GLint zoffset, const gl::Rectangle &sourceArea,
const gl::ImageIndex &sourceIndex, TextureStorage *source);
bool recoverFromAssociatedStorage();
gl::Error recoverFromAssociatedStorage();
bool isAssociatedStorageValid(TextureStorage11* textureStorage) const;
void disassociateStorage();
......
......@@ -321,24 +321,21 @@ gl::Error TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, u
}
}
bool TextureStorage11::copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource,
const gl::ImageIndex &index, const gl::Box &region)
gl::Error TextureStorage11::copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource,
const gl::ImageIndex &index, const gl::Box &region)
{
if (dstTexture)
{
ID3D11Resource *srcTexture = getResource();
unsigned int srcSubresource = getSubresourceIndex(index);
ASSERT(dstTexture);
ASSERT(srcTexture);
ID3D11Resource *srcTexture = getResource();
ASSERT(srcTexture);
ID3D11DeviceContext *context = mRenderer->getDeviceContext();
unsigned int srcSubresource = getSubresourceIndex(index);
context->CopySubresourceRegion(dstTexture, dstSubresource, region.x, region.y, region.z,
srcTexture, srcSubresource, NULL);
return true;
}
ID3D11DeviceContext *context = mRenderer->getDeviceContext();
context->CopySubresourceRegion(dstTexture, dstSubresource, region.x, region.y, region.z,
srcTexture, srcSubresource, NULL);
return false;
return gl::Error(GL_NO_ERROR);
}
void TextureStorage11::generateMipmap(const gl::ImageIndex &sourceIndex, const gl::ImageIndex &destIndex)
......@@ -574,7 +571,12 @@ TextureStorage11_2D::~TextureStorage11_2D()
if (imageAssociationCorrect)
{
// We must let the Images recover their data before we delete it from the TextureStorage.
mAssociatedImages[i]->recoverFromAssociatedStorage();
gl::Error error = mAssociatedImages[i]->recoverFromAssociatedStorage();
if (error.isError())
{
// TODO: Find a way to report this back to the context
ERR(error.getMessage().c_str());
}
}
}
}
......@@ -641,7 +643,7 @@ void TextureStorage11_2D::disassociateImage(const gl::ImageIndex &index, Image11
}
// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
void TextureStorage11_2D::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
gl::Error TextureStorage11_2D::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
{
GLint level = index.mipIndex;
......@@ -660,10 +662,16 @@ void TextureStorage11_2D::releaseAssociatedImage(const gl::ImageIndex &index, Im
{
// Force the image to recover from storage before its data is overwritten.
// This will reset mAssociatedImages[level] to NULL too.
mAssociatedImages[level]->recoverFromAssociatedStorage();
gl::Error error = mAssociatedImages[level]->recoverFromAssociatedStorage();
if (error.isError())
{
return error;
}
}
}
}
return gl::Error(GL_NO_ERROR);
}
ID3D11Resource *TextureStorage11_2D::getResource() const
......@@ -1006,7 +1014,7 @@ void TextureStorage11_Cube::disassociateImage(const gl::ImageIndex &index, Image
}
// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
void TextureStorage11_Cube::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
gl::Error TextureStorage11_Cube::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
{
GLint level = index.mipIndex;
GLint layerTarget = index.layerIndex;
......@@ -1029,11 +1037,17 @@ void TextureStorage11_Cube::releaseAssociatedImage(const gl::ImageIndex &index,
{
// Force the image to recover from storage before its data is overwritten.
// This will reset mAssociatedImages[level] to NULL too.
mAssociatedImages[layerTarget][level]->recoverFromAssociatedStorage();
gl::Error error = mAssociatedImages[layerTarget][level]->recoverFromAssociatedStorage();
if (error.isError())
{
return error;
}
}
}
}
}
return gl::Error(GL_NO_ERROR);
}
ID3D11Resource *TextureStorage11_Cube::getResource() const
......@@ -1395,7 +1409,7 @@ void TextureStorage11_3D::disassociateImage(const gl::ImageIndex &index, Image11
}
// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
void TextureStorage11_3D::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
gl::Error TextureStorage11_3D::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
{
GLint level = index.mipIndex;
......@@ -1414,10 +1428,16 @@ void TextureStorage11_3D::releaseAssociatedImage(const gl::ImageIndex &index, Im
{
// Force the image to recover from storage before its data is overwritten.
// This will reset mAssociatedImages[level] to NULL too.
mAssociatedImages[level]->recoverFromAssociatedStorage();
gl::Error error = mAssociatedImages[level]->recoverFromAssociatedStorage();
if (error.isError())
{
return error;
}
}
}
}
return gl::Error(GL_NO_ERROR);
}
ID3D11Resource *TextureStorage11_3D::getResource() const
......@@ -1754,7 +1774,7 @@ void TextureStorage11_2DArray::disassociateImage(const gl::ImageIndex &index, Im
}
// releaseAssociatedImage prepares the Storage for a new Image association. It lets the old Image recover its data before ending the association.
void TextureStorage11_2DArray::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
gl::Error TextureStorage11_2DArray::releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage)
{
GLint level = index.mipIndex;
GLint layerTarget = index.layerIndex;
......@@ -1775,10 +1795,16 @@ void TextureStorage11_2DArray::releaseAssociatedImage(const gl::ImageIndex &inde
{
// Force the image to recover from storage before its data is overwritten.
// This will reset mAssociatedImages[level] to NULL too.
mAssociatedImages[key]->recoverFromAssociatedStorage();
gl::Error error = mAssociatedImages[key]->recoverFromAssociatedStorage();
if (error.isError())
{
return error;
}
}
}
}
return gl::Error(GL_NO_ERROR);
}
ID3D11Resource *TextureStorage11_2DArray::getResource() const
......
......@@ -60,13 +60,13 @@ class TextureStorage11 : public TextureStorage
gl::Error updateSubresourceLevel(ID3D11Resource *texture, unsigned int sourceSubresource,
const gl::ImageIndex &index, const gl::Box &copyArea);
bool copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource,
const gl::ImageIndex &index, const gl::Box &region);
gl::Error copySubresourceLevel(ID3D11Resource* dstTexture, unsigned int dstSubresource,
const gl::ImageIndex &index, const gl::Box &region);
virtual void associateImage(Image11* image, const gl::ImageIndex &index) = 0;
virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage) = 0;
virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage) = 0;
virtual void releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage) = 0;
virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage) = 0;
virtual gl::Error copyToStorage(TextureStorage *destStorage);
virtual gl::Error setData(const gl::ImageIndex &index, const gl::Box &sourceBox, GLenum internalFormat, GLenum type,
......@@ -152,7 +152,7 @@ class TextureStorage11_2D : public TextureStorage11
virtual void associateImage(Image11* image, const gl::ImageIndex &index);
virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
virtual void releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
protected:
virtual ID3D11Resource *getSwizzleTexture();
......@@ -186,7 +186,7 @@ class TextureStorage11_Cube : public TextureStorage11
virtual void associateImage(Image11* image, const gl::ImageIndex &index);
virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
virtual void releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
protected:
virtual ID3D11Resource *getSwizzleTexture();
......@@ -223,7 +223,7 @@ class TextureStorage11_3D : public TextureStorage11
virtual void associateImage(Image11* image, const gl::ImageIndex &index);
virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
virtual void releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
protected:
virtual ID3D11Resource *getSwizzleTexture();
......@@ -262,7 +262,7 @@ class TextureStorage11_2DArray : public TextureStorage11
virtual void associateImage(Image11* image, const gl::ImageIndex &index);
virtual void disassociateImage(const gl::ImageIndex &index, Image11* expectedImage);
virtual bool isAssociatedImageValid(const gl::ImageIndex &index, Image11* expectedImage);
virtual void releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
virtual gl::Error releaseAssociatedImage(const gl::ImageIndex &index, Image11* incomingImage);
protected:
virtual ID3D11Resource *getSwizzleTexture();
......
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