Refactored texture dirtiness.

TRAC #18714 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@824 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 01dae855
...@@ -2127,13 +2127,13 @@ void Context::applyTextures(SamplerType type) ...@@ -2127,13 +2127,13 @@ void Context::applyTextures(SamplerType type)
Texture *texture = getSamplerTexture(textureUnit, textureType); Texture *texture = getSamplerTexture(textureUnit, textureType);
if (appliedTextureSerial[samplerIndex] != texture->getSerial() || texture->isDirtyParameter() || texture->isDirtyImage()) if (appliedTextureSerial[samplerIndex] != texture->getSerial() || texture->hasDirtyParameters() || texture->hasDirtyImages())
{ {
IDirect3DBaseTexture9 *d3dTexture = texture->getTexture(); IDirect3DBaseTexture9 *d3dTexture = texture->getTexture();
if (d3dTexture) if (d3dTexture)
{ {
if (appliedTextureSerial[samplerIndex] != texture->getSerial() || texture->isDirtyParameter()) if (appliedTextureSerial[samplerIndex] != texture->getSerial() || texture->hasDirtyParameters())
{ {
GLenum wrapS = texture->getWrapS(); GLenum wrapS = texture->getWrapS();
GLenum wrapT = texture->getWrapT(); GLenum wrapT = texture->getWrapT();
...@@ -2150,7 +2150,7 @@ void Context::applyTextures(SamplerType type) ...@@ -2150,7 +2150,7 @@ void Context::applyTextures(SamplerType type)
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter); mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter);
} }
if (appliedTextureSerial[samplerIndex] != texture->getSerial() || texture->isDirtyImage()) if (appliedTextureSerial[samplerIndex] != texture->getSerial() || texture->hasDirtyImages())
{ {
mDevice->SetTexture(d3dSampler, d3dTexture); mDevice->SetTexture(d3dSampler, d3dTexture);
} }
......
...@@ -114,9 +114,9 @@ Texture::Texture(GLuint id) : RefCountObject(id), mSerial(issueSerial()) ...@@ -114,9 +114,9 @@ Texture::Texture(GLuint id) : RefCountObject(id), mSerial(issueSerial())
mMagFilter = GL_LINEAR; mMagFilter = GL_LINEAR;
mWrapS = GL_REPEAT; mWrapS = GL_REPEAT;
mWrapT = GL_REPEAT; mWrapT = GL_REPEAT;
mDirtyParameter = true; mDirtyParameters = true;
mDirtyImage = true; mDirtyImages = true;
mIsRenderable = false; mIsRenderable = false;
} }
...@@ -146,7 +146,7 @@ bool Texture::setMinFilter(GLenum filter) ...@@ -146,7 +146,7 @@ bool Texture::setMinFilter(GLenum filter)
if (mMinFilter != filter) if (mMinFilter != filter)
{ {
mMinFilter = filter; mMinFilter = filter;
mDirtyParameter = true; mDirtyParameters = true;
} }
return true; return true;
} }
...@@ -166,7 +166,7 @@ bool Texture::setMagFilter(GLenum filter) ...@@ -166,7 +166,7 @@ bool Texture::setMagFilter(GLenum filter)
if (mMagFilter != filter) if (mMagFilter != filter)
{ {
mMagFilter = filter; mMagFilter = filter;
mDirtyParameter = true; mDirtyParameters = true;
} }
return true; return true;
} }
...@@ -187,7 +187,7 @@ bool Texture::setWrapS(GLenum wrap) ...@@ -187,7 +187,7 @@ bool Texture::setWrapS(GLenum wrap)
if (mWrapS != wrap) if (mWrapS != wrap)
{ {
mWrapS = wrap; mWrapS = wrap;
mDirtyParameter = true; mDirtyParameters = true;
} }
return true; return true;
} }
...@@ -208,7 +208,7 @@ bool Texture::setWrapT(GLenum wrap) ...@@ -208,7 +208,7 @@ bool Texture::setWrapT(GLenum wrap)
if (mWrapT != wrap) if (mWrapT != wrap)
{ {
mWrapT = wrap; mWrapT = wrap;
mDirtyParameter = true; mDirtyParameters = true;
} }
return true; return true;
} }
...@@ -1119,7 +1119,7 @@ void Texture::setImage(GLint unpackAlignment, const void *pixels, Image *image) ...@@ -1119,7 +1119,7 @@ void Texture::setImage(GLint unpackAlignment, const void *pixels, Image *image)
} }
image->dirty = true; image->dirty = true;
mDirtyImage = true; mDirtyImages = true;
} }
} }
...@@ -1143,7 +1143,7 @@ void Texture::setCompressedImage(GLsizei imageSize, const void *pixels, Image *i ...@@ -1143,7 +1143,7 @@ void Texture::setCompressedImage(GLsizei imageSize, const void *pixels, Image *i
} }
image->dirty = true; image->dirty = true;
mDirtyImage = true; mDirtyImages = true;
} }
} }
...@@ -1186,7 +1186,7 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig ...@@ -1186,7 +1186,7 @@ bool Texture::subImage(GLint xoffset, GLint yoffset, GLsizei width, GLsizei heig
} }
image->dirty = true; image->dirty = true;
mDirtyImage = true; mDirtyImages = true;
} }
return true; return true;
...@@ -1230,7 +1230,7 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL ...@@ -1230,7 +1230,7 @@ bool Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLsizei width, GL
} }
image->dirty = true; image->dirty = true;
mDirtyImage = true; mDirtyImages = true;
} }
return true; return true;
...@@ -1413,7 +1413,7 @@ void Texture::copyToImage(Image *image, GLint xoffset, GLint yoffset, GLint x, G ...@@ -1413,7 +1413,7 @@ void Texture::copyToImage(Image *image, GLint xoffset, GLint yoffset, GLint x, G
renderTargetData->Release(); renderTargetData->Release();
image->dirty = true; image->dirty = true;
mDirtyImage = true; mDirtyImages = true;
} }
IDirect3DBaseTexture9 *Texture::getTexture() IDirect3DBaseTexture9 *Texture::getTexture()
...@@ -1433,20 +1433,20 @@ IDirect3DBaseTexture9 *Texture::getTexture() ...@@ -1433,20 +1433,20 @@ IDirect3DBaseTexture9 *Texture::getTexture()
return getBaseTexture(); return getBaseTexture();
} }
bool Texture::isDirtyParameter() const bool Texture::hasDirtyParameters() const
{ {
return mDirtyParameter; return mDirtyParameters;
} }
bool Texture::isDirtyImage() const bool Texture::hasDirtyImages() const
{ {
return mDirtyImage; return mDirtyImages;
} }
void Texture::resetDirty() void Texture::resetDirty()
{ {
mDirtyParameter = false; mDirtyParameters = false;
mDirtyImage = false; mDirtyImages = false;
} }
unsigned int Texture::getSerial() const unsigned int Texture::getSerial() const
...@@ -1577,13 +1577,10 @@ void Texture2D::redefineImage(GLint level, GLenum format, GLsizei width, GLsizei ...@@ -1577,13 +1577,10 @@ void Texture2D::redefineImage(GLint level, GLenum format, GLsizei width, GLsizei
mImageArray[i].dirty = true; mImageArray[i].dirty = true;
} }
if (mTexture != NULL) mTexture->Release();
{ mTexture = NULL;
mTexture->Release(); mDirtyImages = true;
mTexture = NULL; mIsRenderable = false;
mDirtyImage = true;
mIsRenderable = false;
}
if (mSurface) if (mSurface)
{ {
...@@ -1624,7 +1621,7 @@ void Texture2D::bindTexImage(egl::Surface *surface) ...@@ -1624,7 +1621,7 @@ void Texture2D::bindTexImage(egl::Surface *surface)
IDirect3DTexture9 *texture = surface->getOffscreenTexture(); IDirect3DTexture9 *texture = surface->getOffscreenTexture();
mTexture = texture; mTexture = texture;
mDirtyImage = true; mDirtyImages = true;
mIsRenderable = true; mIsRenderable = true;
mSurface = surface; mSurface = surface;
mSurface->setBoundTexture(this); mSurface->setBoundTexture(this);
...@@ -1896,7 +1893,7 @@ void Texture2D::createTexture() ...@@ -1896,7 +1893,7 @@ void Texture2D::createTexture()
} }
mTexture = texture; mTexture = texture;
mDirtyImage = true; mDirtyImages = true;
mIsRenderable = false; mIsRenderable = false;
} }
...@@ -1990,7 +1987,7 @@ void Texture2D::convertToRenderTarget() ...@@ -1990,7 +1987,7 @@ void Texture2D::convertToRenderTarget()
} }
mTexture = texture; mTexture = texture;
mDirtyImage = true; mDirtyImages = true;
mIsRenderable = true; mIsRenderable = true;
} }
...@@ -2358,7 +2355,7 @@ void TextureCubeMap::createTexture() ...@@ -2358,7 +2355,7 @@ void TextureCubeMap::createTexture()
} }
mTexture = texture; mTexture = texture;
mDirtyImage = true; mDirtyImages = true;
mIsRenderable = false; mIsRenderable = false;
} }
...@@ -2457,7 +2454,7 @@ void TextureCubeMap::convertToRenderTarget() ...@@ -2457,7 +2454,7 @@ void TextureCubeMap::convertToRenderTarget()
} }
mTexture = texture; mTexture = texture;
mDirtyImage = true; mDirtyImages = true;
mIsRenderable = true; mIsRenderable = true;
} }
...@@ -2506,13 +2503,10 @@ void TextureCubeMap::redefineImage(int face, GLint level, GLenum format, GLsizei ...@@ -2506,13 +2503,10 @@ void TextureCubeMap::redefineImage(int face, GLint level, GLenum format, GLsizei
} }
} }
if (mTexture != NULL) mTexture->Release();
{ mTexture = NULL;
mTexture->Release(); mDirtyImages = true;
mTexture = NULL; mIsRenderable = false;
mDirtyImage = true;
mIsRenderable = false;
}
} }
} }
......
...@@ -77,8 +77,8 @@ class Texture : public RefCountObject ...@@ -77,8 +77,8 @@ class Texture : public RefCountObject
virtual void generateMipmaps() = 0; virtual void generateMipmaps() = 0;
virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0; virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0;
bool isDirtyParameter() const; bool hasDirtyParameters() const;
bool isDirtyImage() const; bool hasDirtyImages() const;
void resetDirty(); void resetDirty();
unsigned int getSerial() const; unsigned int getSerial() const;
...@@ -132,9 +132,9 @@ class Texture : public RefCountObject ...@@ -132,9 +132,9 @@ class Texture : public RefCountObject
GLenum mMagFilter; GLenum mMagFilter;
GLenum mWrapS; GLenum mWrapS;
GLenum mWrapT; GLenum mWrapT;
bool mDirtyParameter; bool mDirtyParameters;
bool mDirtyImage; bool mDirtyImages;
bool mIsRenderable; bool mIsRenderable;
......
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