Ensure texture storage exists before retrieving serial

Trac #19330 Signed-off-by: Nicolas Capens In some cases we were trying to retrieve a serial from a rendertarget texture which didn't have the storage allocated yet. This was resulting in a 0 serial which was indistinguishable from the case where context was just marked dirty and we assumed the target was up-to-date. This resulted in failing to apply the correct rendertarget and as a result some d3d clear calls were failing (picked up by debug runtime). git-svn-id: https://angleproject.googlecode.com/svn/trunk@929 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 4d6c6d75
#define MAJOR_VERSION 1
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 928
#define BUILD_REVISION 929
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -1565,9 +1565,10 @@ IDirect3DBaseTexture9 *Texture::getTexture()
return NULL;
}
if (!getBaseTexture())
// ensure the underlying texture is created
if (getStorage(false) == NULL)
{
createTexture();
return NULL;
}
updateTexture();
......@@ -1591,15 +1592,15 @@ void Texture::resetDirty()
mDirtyImages = false;
}
unsigned int Texture::getTextureSerial() const
unsigned int Texture::getTextureSerial()
{
TextureStorage *texture = getStorage();
TextureStorage *texture = getStorage(false);
return texture ? texture->getTextureSerial() : 0;
}
unsigned int Texture::getRenderTargetSerial(GLenum target) const
unsigned int Texture::getRenderTargetSerial(GLenum target)
{
TextureStorage *texture = getStorage();
TextureStorage *texture = getStorage(true);
return texture ? texture->getRenderTargetSerial(target) : 0;
}
......@@ -2305,12 +2306,8 @@ IDirect3DSurface9 *Texture2D::getRenderTarget(GLenum target)
{
ASSERT(target == GL_TEXTURE_2D);
if (!mTexStorage || !mTexStorage->isRenderTarget())
{
convertToRenderTarget();
}
if (mTexStorage == NULL)
// ensure the underlying texture is created
if (getStorage(true) == NULL)
{
return NULL;
}
......@@ -2320,8 +2317,20 @@ IDirect3DSurface9 *Texture2D::getRenderTarget(GLenum target)
return mTexStorage->getSurfaceLevel(0);
}
TextureStorage *Texture2D::getStorage() const
TextureStorage *Texture2D::getStorage(bool renderTarget)
{
if (!mTexStorage || (renderTarget && !mTexStorage->isRenderTarget()))
{
if (renderTarget)
{
convertToRenderTarget();
}
else
{
createTexture();
}
}
return mTexStorage;
}
......@@ -2998,12 +3007,8 @@ IDirect3DSurface9 *TextureCubeMap::getRenderTarget(GLenum target)
{
ASSERT(IsCubemapTextureTarget(target));
if (!mTexStorage || !mTexStorage->isRenderTarget())
{
convertToRenderTarget();
}
if (mTexStorage == NULL)
// ensure the underlying texture is created
if (getStorage(true) == NULL)
{
return NULL;
}
......@@ -3013,8 +3018,20 @@ IDirect3DSurface9 *TextureCubeMap::getRenderTarget(GLenum target)
return mTexStorage->getCubeMapSurface(target, 0);
}
TextureStorage *TextureCubeMap::getStorage() const
TextureStorage *TextureCubeMap::getStorage(bool renderTarget)
{
if (!mTexStorage || (renderTarget && !mTexStorage->isRenderTarget()))
{
if (renderTarget)
{
convertToRenderTarget();
}
else
{
createTexture();
}
}
return mTexStorage;
}
......
......@@ -205,8 +205,8 @@ class Texture : public RefCountObject
bool hasDirtyParameters() const;
bool hasDirtyImages() const;
void resetDirty();
unsigned int getTextureSerial() const;
unsigned int getRenderTargetSerial(GLenum target) const;
unsigned int getTextureSerial();
unsigned int getRenderTargetSerial(GLenum target);
bool isImmutable() const;
......@@ -248,7 +248,7 @@ class Texture : public RefCountObject
private:
DISALLOW_COPY_AND_ASSIGN(Texture);
virtual TextureStorage *getStorage() const = 0;
virtual TextureStorage *getStorage(bool renderTarget) = 0;
};
class TextureStorage2D : public TextureStorage
......@@ -311,7 +311,7 @@ class Texture2D : public Texture
virtual void updateTexture();
virtual void convertToRenderTarget();
virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
virtual TextureStorage *getStorage() const;
virtual TextureStorage *getStorage(bool renderTarget);
bool isMipmapComplete() const;
......@@ -392,7 +392,7 @@ class TextureCubeMap : public Texture
virtual void updateTexture();
virtual void convertToRenderTarget();
virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
virtual TextureStorage *getStorage() const;
virtual TextureStorage *getStorage(bool renderTarget);
bool isCubeComplete() const;
bool isMipmapCubeComplete() 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