Issue render target serials per texture storage.
TRAC #18730
Signed-off-by: Daniel Koch
Author: Nicolas Capens
git-svn-id: http://angleproject.googlecode.com/svn/trunk@855 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index cef8bad..fc58024 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -2151,13 +2151,13 @@
Texture *texture = getSamplerTexture(textureUnit, textureType);
- if (appliedTextureSerial[samplerIndex] != texture->getSerial() || texture->hasDirtyParameters() || texture->hasDirtyImages())
+ if (appliedTextureSerial[samplerIndex] != texture->getTextureSerial() || texture->hasDirtyParameters() || texture->hasDirtyImages())
{
IDirect3DBaseTexture9 *d3dTexture = texture->getTexture();
if (d3dTexture)
{
- if (appliedTextureSerial[samplerIndex] != texture->getSerial() || texture->hasDirtyParameters())
+ if (appliedTextureSerial[samplerIndex] != texture->getTextureSerial() || texture->hasDirtyParameters())
{
GLenum wrapS = texture->getWrapS();
GLenum wrapT = texture->getWrapT();
@@ -2174,7 +2174,7 @@
mDevice->SetSamplerState(d3dSampler, D3DSAMP_MIPFILTER, d3dMipFilter);
}
- if (appliedTextureSerial[samplerIndex] != texture->getSerial() || texture->hasDirtyImages())
+ if (appliedTextureSerial[samplerIndex] != texture->getTextureSerial() || texture->hasDirtyImages())
{
mDevice->SetTexture(d3dSampler, d3dTexture);
}
@@ -2184,7 +2184,7 @@
mDevice->SetTexture(d3dSampler, getIncompleteTexture(textureType)->getTexture());
}
- appliedTextureSerial[samplerIndex] = texture->getSerial();
+ appliedTextureSerial[samplerIndex] = texture->getTextureSerial();
texture->resetDirty();
}
}
diff --git a/src/libGLESv2/Renderbuffer.cpp b/src/libGLESv2/Renderbuffer.cpp
index fc56db1..a39c4ad 100644
--- a/src/libGLESv2/Renderbuffer.cpp
+++ b/src/libGLESv2/Renderbuffer.cpp
@@ -16,9 +16,9 @@
namespace gl
{
-unsigned int RenderbufferInterface::mCurrentSerial = 1;
+unsigned int RenderbufferStorage::mCurrentSerial = 1;
-RenderbufferInterface::RenderbufferInterface() : mSerial(issueSerial())
+RenderbufferInterface::RenderbufferInterface()
{
}
@@ -52,16 +52,6 @@
return dx2es::GetStencilSize(getD3DFormat());
}
-unsigned int RenderbufferInterface::getSerial() const
-{
- return mSerial;
-}
-
-unsigned int RenderbufferInterface::issueSerial()
-{
- return mCurrentSerial++;
-}
-
RenderbufferTexture::RenderbufferTexture(Texture *texture, GLenum target) : mTexture(texture), mTarget(target)
{
}
@@ -94,15 +84,20 @@
{
return mTexture->getInternalFormat();
}
-
+
+D3DFORMAT RenderbufferTexture::getD3DFormat() const
+{
+ return mTexture->getD3DFormat();
+}
+
GLsizei RenderbufferTexture::getSamples() const
{
return 0;
}
-D3DFORMAT RenderbufferTexture::getD3DFormat() const
+unsigned int RenderbufferTexture::getSerial() const
{
- return mTexture->getD3DFormat();
+ return mTexture->getRenderTargetSerial(mTarget);
}
Renderbuffer::Renderbuffer(GLuint id, RenderbufferInterface *instance) : RefCountObject(id)
@@ -194,7 +189,7 @@
mInstance = newStorage;
}
-RenderbufferStorage::RenderbufferStorage()
+RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerial())
{
mWidth = 0;
mHeight = 0;
@@ -232,14 +227,31 @@
return mInternalFormat;
}
+D3DFORMAT RenderbufferStorage::getD3DFormat() const
+{
+ return mD3DFormat;
+}
+
GLsizei RenderbufferStorage::getSamples() const
{
return mSamples;
}
-D3DFORMAT RenderbufferStorage::getD3DFormat() const
+unsigned int RenderbufferStorage::getSerial() const
{
- return mD3DFormat;
+ return mSerial;
+}
+
+unsigned int RenderbufferStorage::issueSerial()
+{
+ return mCurrentSerial++;
+}
+
+unsigned int RenderbufferStorage::issueCubeSerials()
+{
+ unsigned int firstSerial = mCurrentSerial;
+ mCurrentSerial += 6;
+ return firstSerial;
}
Colorbuffer::Colorbuffer(IDirect3DSurface9 *renderTarget) : mRenderTarget(renderTarget)
diff --git a/src/libGLESv2/Renderbuffer.h b/src/libGLESv2/Renderbuffer.h
index 1348758..e854775 100644
--- a/src/libGLESv2/Renderbuffer.h
+++ b/src/libGLESv2/Renderbuffer.h
@@ -48,16 +48,10 @@
GLuint getDepthSize() const;
GLuint getStencilSize() const;
- unsigned int getSerial() const;
+ virtual unsigned int getSerial() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(RenderbufferInterface);
-
- static unsigned int issueSerial();
-
- const unsigned int mSerial;
-
- static unsigned int mCurrentSerial;
};
class RenderbufferTexture : public RenderbufferInterface
@@ -70,11 +64,13 @@
IDirect3DSurface9 *getRenderTarget();
IDirect3DSurface9 *getDepthStencil();
- GLsizei getWidth() const;
- GLsizei getHeight() const;
- GLenum getInternalFormat() const;
- D3DFORMAT getD3DFormat() const;
- GLsizei getSamples() const;
+ virtual GLsizei getWidth() const;
+ virtual GLsizei getHeight() const;
+ virtual GLenum getInternalFormat() const;
+ virtual D3DFORMAT getD3DFormat() const;
+ virtual GLsizei getSamples() const;
+
+ virtual unsigned int getSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(RenderbufferTexture);
@@ -102,6 +98,11 @@
virtual D3DFORMAT getD3DFormat() const;
virtual GLsizei getSamples() const;
+ virtual unsigned int getSerial() const;
+
+ static unsigned int issueSerial();
+ static unsigned int issueCubeSerials();
+
protected:
GLsizei mWidth;
GLsizei mHeight;
@@ -111,6 +112,10 @@
private:
DISALLOW_COPY_AND_ASSIGN(RenderbufferStorage);
+
+ const unsigned int mSerial;
+
+ static unsigned int mCurrentSerial;
};
// Renderbuffer implements the GL renderbuffer object.
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index 316b9e3..1fb80aa 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -27,7 +27,7 @@
namespace gl
{
-unsigned int TextureStorage::mCurrentSerial = 1;
+unsigned int TextureStorage::mCurrentTextureSerial = 1;
Image::Image()
: mWidth(0), mHeight(0), mDirty(false), mSurface(NULL), mFormat(GL_NONE), mType(GL_UNSIGNED_BYTE)
@@ -1199,7 +1199,7 @@
mDirty = true;
}
-TextureStorage::TextureStorage(bool renderable) : mIsRenderable(renderable), mSerial(issueSerial())
+TextureStorage::TextureStorage(bool renderable) : mIsRenderable(renderable), mTextureSerial(issueTextureSerial())
{
}
@@ -1212,14 +1212,14 @@
return mIsRenderable;
}
-unsigned int TextureStorage::getSerial() const
+unsigned int TextureStorage::getTextureSerial() const
{
- return mSerial;
+ return mTextureSerial;
}
-unsigned int TextureStorage::issueSerial()
+unsigned int TextureStorage::issueTextureSerial()
{
- return mCurrentSerial++;
+ return mCurrentTextureSerial++;
}
Texture::Texture(GLuint id) : RefCountObject(id)
@@ -1494,10 +1494,16 @@
mDirtyImages = false;
}
-unsigned int Texture::getSerial() const
+unsigned int Texture::getTextureSerial() const
{
TextureStorage *texture = getStorage();
- return texture ? texture->getSerial() : 0;
+ return texture ? texture->getTextureSerial() : 0;
+}
+
+unsigned int Texture::getRenderTargetSerial(GLenum target) const
+{
+ TextureStorage *texture = getStorage();
+ return texture ? texture->getRenderTargetSerial(target) : 0;
}
GLint Texture::creationLevels(GLsizei width, GLsizei height) const
@@ -1523,12 +1529,12 @@
return getBaseTexture() ? getBaseTexture()->GetLevelCount() : 0;
}
-TextureStorage2D::TextureStorage2D(IDirect3DTexture9 *surfaceTexture) : TextureStorage(true)
+TextureStorage2D::TextureStorage2D(IDirect3DTexture9 *surfaceTexture) : TextureStorage(true), mRenderTargetSerial(RenderbufferStorage::issueSerial())
{
mTexture = surfaceTexture;
}
-TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, int width, int height, bool renderable) : TextureStorage(renderable)
+TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, int width, int height, bool renderable) : TextureStorage(renderable), mRenderTargetSerial(RenderbufferStorage::issueSerial())
{
IDirect3DDevice9 *device = getDevice();
@@ -1565,6 +1571,11 @@
return mTexture;
}
+unsigned int TextureStorage2D::getRenderTargetSerial(GLenum target) const
+{
+ return mRenderTargetSerial;
+}
+
Texture2D::Texture2D(GLuint id) : Texture(id)
{
mTexture = NULL;
@@ -1631,7 +1642,6 @@
delete mTexture;
mTexture = NULL;
mDirtyImages = true;
- mColorbufferProxy.set(NULL);
}
}
@@ -1665,7 +1675,7 @@
delete mTexture;
mTexture = new TextureStorage2D(surface->getOffscreenTexture());
- mColorbufferProxy.set(NULL);
+
mDirtyImages = true;
mSurface = surface;
mSurface->setBoundTexture(this);
@@ -1682,7 +1692,6 @@
{
delete mTexture;
mTexture = NULL;
- mColorbufferProxy.set(NULL);
}
for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
@@ -1949,7 +1958,6 @@
delete mTexture;
mTexture = new TextureStorage2D(levels, format, width, height, false);
- mColorbufferProxy.set(NULL);
mDirtyImages = true;
}
@@ -2017,7 +2025,7 @@
delete mTexture;
mTexture = newTexture;
- mColorbufferProxy.set(NULL);
+
mDirtyImages = true;
}
@@ -2117,7 +2125,7 @@
return mTexture;
}
-TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, int size, bool renderable) : TextureStorage(renderable)
+TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, int size, bool renderable) : TextureStorage(renderable), mFirstRenderTargetSerial(RenderbufferStorage::issueCubeSerials())
{
IDirect3DDevice9 *device = getDevice();
@@ -2154,6 +2162,11 @@
return mTexture;
}
+unsigned int TextureStorageCubeMap::getRenderTargetSerial(GLenum target) const
+{
+ return mFirstRenderTargetSerial + TextureCubeMap::faceIndex(target);
+}
+
TextureCubeMap::TextureCubeMap(GLuint id) : Texture(id)
{
mTexture = NULL;
@@ -2167,6 +2180,7 @@
}
delete mTexture;
+ mTexture = NULL;
}
GLenum TextureCubeMap::getTarget() const
@@ -2391,7 +2405,6 @@
delete mTexture;
mTexture = new TextureStorageCubeMap(levels, format, size, false);
- for(int face = 0; face < 6; face++) mFaceProxies[face].set(NULL);
mDirtyImages = true;
}
@@ -2464,7 +2477,6 @@
delete mTexture;
mTexture = newTexture;
- for(int face = 0; face < 6; face++) mFaceProxies[face].set(NULL);
mDirtyImages = true;
}
@@ -2503,7 +2515,6 @@
delete mTexture;
mTexture = NULL;
- for(int face = 0; face < 6; face++) mFaceProxies[face].set(NULL);
mDirtyImages = true;
}
}
diff --git a/src/libGLESv2/Texture.h b/src/libGLESv2/Texture.h
index d90d825..741691b 100644
--- a/src/libGLESv2/Texture.h
+++ b/src/libGLESv2/Texture.h
@@ -143,17 +143,18 @@
virtual ~TextureStorage();
bool isRenderable() const;
- unsigned int getSerial() const;
+ unsigned int getTextureSerial() const;
+ virtual unsigned int getRenderTargetSerial(GLenum target) const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorage);
const bool mIsRenderable;
- const unsigned int mSerial;
- static unsigned int issueSerial();
+ const unsigned int mTextureSerial;
+ static unsigned int issueTextureSerial();
- static unsigned int mCurrentSerial;
+ static unsigned int mCurrentTextureSerial;
};
class Texture : public RefCountObject
@@ -193,7 +194,8 @@
bool hasDirtyParameters() const;
bool hasDirtyImages() const;
void resetDirty();
- unsigned int getSerial() const;
+ unsigned int getTextureSerial() const;
+ unsigned int getRenderTargetSerial(GLenum target) const;
static const GLuint INCOMPLETE_TEXTURE_ID = static_cast<GLuint>(-1); // Every texture takes an id at creation time. The value is arbitrary because it is never registered with the resource manager.
@@ -243,10 +245,13 @@
IDirect3DSurface9 *getSurfaceLevel(int level);
IDirect3DBaseTexture9 *getBaseTexture() const;
+ virtual unsigned int getRenderTargetSerial(GLenum target) const;
+
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorage2D);
IDirect3DTexture9 *mTexture;
+ const unsigned int mRenderTargetSerial;
};
class Texture2D : public Texture
@@ -311,10 +316,13 @@
IDirect3DSurface9 *getCubeMapSurface(GLenum faceTarget, int level);
IDirect3DBaseTexture9 *getBaseTexture() const;
+ virtual unsigned int getRenderTargetSerial(GLenum target) const;
+
private:
DISALLOW_COPY_AND_ASSIGN(TextureStorageCubeMap);
IDirect3DCubeTexture9 *mTexture;
+ const unsigned int mFirstRenderTargetSerial;
};
class TextureCubeMap : public Texture
@@ -353,6 +361,8 @@
virtual Renderbuffer *getRenderbuffer(GLenum target);
+ static unsigned int faceIndex(GLenum face);
+
private:
DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
@@ -363,8 +373,6 @@
virtual IDirect3DSurface9 *getRenderTarget(GLenum target);
virtual TextureStorage *getStorage() const;
- static unsigned int faceIndex(GLenum face);
-
bool isCubeComplete() const;
void setImage(int faceIndex, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);