Commit da066657 by Jamie Madill

Fix invalid storage recovery on FL 9_3.

This problem was uncovered when I inadvertently changed TextureD3D to delete its storage before its images. Small mips of compressed textures must use a nullptr argument to CopySubResource, otherwise the runtime complains about un-aligned sizes. Also change the class to delete the Images before the Storage again so we don't wastefully recover the images before deleting them. Also change the Image pointers to use std::array and std::unique_ptr. BUG=angleproject:1156 BUG=angleproject:2077 Change-Id: Idb2e53835b7a9b973285ff0781f70b25f05c77aa Reviewed-on: https://chromium-review.googlesource.com/543438Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 6be3d4cd
......@@ -28,6 +28,9 @@ class RendererD3D;
class RenderTargetD3D;
class TextureStorage;
template <typename T>
using TexLevelsArray = std::array<T, gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS>;
class TextureD3D : public TextureImpl
{
public:
......@@ -181,6 +184,8 @@ class TextureD3D_2D : public TextureD3D
TextureD3D_2D(const gl::TextureState &data, RendererD3D *renderer);
virtual ~TextureD3D_2D();
gl::Error onDestroy(const gl::Context *context) override;
ImageD3D *getImage(int level, int layer) const;
ImageD3D *getImage(const gl::ImageIndex &index) const override;
GLsizei getLayerCount(int level) const override;
......@@ -314,7 +319,7 @@ class TextureD3D_2D : public TextureD3D
bool forceRelease);
bool mEGLImageTarget;
ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
TexLevelsArray<std::unique_ptr<ImageD3D>> mImageArray;
};
class TextureD3D_Cube : public TextureD3D
......@@ -323,6 +328,8 @@ class TextureD3D_Cube : public TextureD3D
TextureD3D_Cube(const gl::TextureState &data, RendererD3D *renderer);
virtual ~TextureD3D_Cube();
gl::Error onDestroy(const gl::Context *context) override;
ImageD3D *getImage(int level, int layer) const;
ImageD3D *getImage(const gl::ImageIndex &index) const override;
GLsizei getLayerCount(int level) const override;
......@@ -446,7 +453,7 @@ class TextureD3D_Cube : public TextureD3D
const gl::Extents &size,
bool forceRelease);
ImageD3D *mImageArray[6][gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
std::array<TexLevelsArray<std::unique_ptr<ImageD3D>>, 6> mImageArray;
};
class TextureD3D_3D : public TextureD3D
......@@ -455,6 +462,8 @@ class TextureD3D_3D : public TextureD3D
TextureD3D_3D(const gl::TextureState &data, RendererD3D *renderer);
virtual ~TextureD3D_3D();
gl::Error onDestroy(const gl::Context *context) override;
ImageD3D *getImage(int level, int layer) const;
ImageD3D *getImage(const gl::ImageIndex &index) const override;
GLsizei getLayerCount(int level) const override;
......@@ -559,7 +568,7 @@ class TextureD3D_3D : public TextureD3D
const gl::Extents &size,
bool forceRelease);
ImageD3D *mImageArray[gl::IMPLEMENTATION_MAX_TEXTURE_LEVELS];
TexLevelsArray<std::unique_ptr<ImageD3D>> mImageArray;
};
class TextureD3D_2DArray : public TextureD3D
......@@ -568,6 +577,8 @@ class TextureD3D_2DArray : public TextureD3D
TextureD3D_2DArray(const gl::TextureState &data, RendererD3D *renderer);
virtual ~TextureD3D_2DArray();
gl::Error onDestroy(const gl::Context *context) override;
virtual ImageD3D *getImage(int level, int layer) const;
virtual ImageD3D *getImage(const gl::ImageIndex &index) const;
virtual GLsizei getLayerCount(int level) const;
......
......@@ -488,17 +488,25 @@ gl::Error TextureStorage11::copySubresourceLevel(const gl::Context *context,
D3D11_BOX *pSrcBox = nullptr;
if (mRenderer->getRenderer11DeviceCaps().featureLevel <= D3D_FEATURE_LEVEL_9_3)
{
// However, D3D10Level9 doesn't always perform CopySubresourceRegion correctly unless the
// source box is specified. This is okay, since we don't perform CopySubresourceRegion on
// depth/stencil textures on 9_3.
ASSERT(mFormatInfo.dsvFormat == DXGI_FORMAT_UNKNOWN);
srcBox.left = region.x;
srcBox.right = region.x + region.width;
srcBox.top = region.y;
srcBox.bottom = region.y + region.height;
srcBox.front = region.z;
srcBox.back = region.z + region.depth;
pSrcBox = &srcBox;
GLsizei width = region.width;
GLsizei height = region.height;
d3d11::MakeValidSize(false, mFormatInfo.texFormat, &width, &height, nullptr);
// Keep srcbox as nullptr if we're dealing with tiny mips of compressed textures.
if (width == region.width && height == region.height)
{
// However, D3D10Level9 doesn't always perform CopySubresourceRegion correctly unless
// the source box is specified. This is okay, since we don't perform
// CopySubresourceRegion on depth/stencil textures on 9_3.
ASSERT(mFormatInfo.dsvFormat == DXGI_FORMAT_UNKNOWN);
srcBox.left = region.x;
srcBox.right = region.x + region.width;
srcBox.top = region.y;
srcBox.bottom = region.y + region.height;
srcBox.front = region.z;
srcBox.back = region.z + region.depth;
pSrcBox = &srcBox;
}
}
deviceContext->CopySubresourceRegion(dstTexture.get(), dstSubresource, region.x, region.y,
......
......@@ -1793,7 +1793,10 @@ void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsi
upsampleCount++;
}
}
*levelOffset = upsampleCount;
if (levelOffset)
{
*levelOffset = upsampleCount;
}
}
void GenerateInitialTextureData(GLint internalFormat,
......
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