Commit 16b7ae6e by Nicolas Capens Committed by Shannon Woods

Only discard the storage texture when there is a mismatch with its mipmap chain

TRAC #23341 Signed-off-by: Shannon Woods Author: Nicolas Capens
parent 63d5e35f
......@@ -1311,6 +1311,11 @@ int TextureStorage::getLodOffset() const
return mLodOffset;
}
int TextureStorage::levelCount()
{
return getBaseTexture() ? getBaseTexture()->GetLevelCount() - getLodOffset() : 0;
}
Texture::Texture(GLuint id) : RefCountObject(id)
{
mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
......@@ -1798,9 +1803,21 @@ void Texture2D::redefineImage(GLint level, GLint internalformat, GLsizei width,
{
releaseTexImage();
bool redefined = mImageArray[level].redefine(internalformat, width, height, false);
// If there currently is a corresponding storage texture image, it has these parameters
const int storageWidth = std::max(1, mImageArray[0].getWidth() >> level);
const int storageHeight = std::max(1, mImageArray[0].getHeight() >> level);
const int storageFormat = mImageArray[0].getInternalFormat();
mImageArray[level].redefine(internalformat, width, height, false);
if (mTexStorage)
{
const int storageLevels = mTexStorage->levelCount();
if (mTexStorage && redefined)
if ((level >= storageLevels && storageLevels != 0) ||
width != storageWidth ||
height != storageHeight ||
internalformat != storageFormat) // Discard mismatched storage
{
for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
{
......@@ -1811,6 +1828,7 @@ void Texture2D::redefineImage(GLint level, GLint internalformat, GLsizei width,
mTexStorage = NULL;
mDirtyImages = true;
}
}
}
void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
......@@ -2821,9 +2839,21 @@ unsigned int TextureCubeMap::faceIndex(GLenum face)
void TextureCubeMap::redefineImage(int face, GLint level, GLint internalformat, GLsizei width, GLsizei height)
{
bool redefined = mImageArray[face][level].redefine(internalformat, width, height, false);
// If there currently is a corresponding storage texture image, it has these parameters
const int storageWidth = std::max(1, mImageArray[0][0].getWidth() >> level);
const int storageHeight = std::max(1, mImageArray[0][0].getHeight() >> level);
const int storageFormat = mImageArray[0][0].getInternalFormat();
if (mTexStorage && redefined)
mImageArray[face][level].redefine(internalformat, width, height, false);
if (mTexStorage)
{
const int storageLevels = mTexStorage->levelCount();
if ((level >= storageLevels && storageLevels != 0) ||
width != storageWidth ||
height != storageHeight ||
internalformat != storageFormat) // Discard mismatched storage
{
for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
{
......@@ -2838,6 +2868,7 @@ void TextureCubeMap::redefineImage(int face, GLint level, GLint internalformat,
mDirtyImages = true;
}
}
}
void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
......
//
// Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved.
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
......@@ -147,8 +147,10 @@ class TextureStorage
D3DPOOL getPool() const;
DWORD getUsage() const;
unsigned int getTextureSerial() const;
virtual IDirect3DBaseTexture9 *getBaseTexture() const = 0;
virtual unsigned int getRenderTargetSerial(GLenum target) const = 0;
int getLodOffset() const;
int levelCount();
protected:
int mLodOffset;
......@@ -258,7 +260,7 @@ class TextureStorage2D : public TextureStorage
virtual ~TextureStorage2D();
IDirect3DSurface9 *getSurfaceLevel(int level, bool dirty);
IDirect3DBaseTexture9 *getBaseTexture() const;
virtual IDirect3DBaseTexture9 *getBaseTexture() const;
virtual unsigned int getRenderTargetSerial(GLenum target) const;
......@@ -345,7 +347,7 @@ class TextureStorageCubeMap : public TextureStorage
virtual ~TextureStorageCubeMap();
IDirect3DSurface9 *getCubeMapSurface(GLenum faceTarget, int level, bool dirty);
IDirect3DBaseTexture9 *getBaseTexture() const;
virtual IDirect3DBaseTexture9 *getBaseTexture() const;
virtual unsigned int getRenderTargetSerial(GLenum target) 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