Issue render target serials per texture storage.

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