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)
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 @@ void Context::applyTextures(SamplerType type)
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 @@ void Context::applyTextures(SamplerType type)
mDevice->SetTexture(d3dSampler, getIncompleteTexture(textureType)->getTexture());
}
appliedTextureSerial[samplerIndex] = texture->getSerial();
appliedTextureSerial[samplerIndex] = texture->getTextureSerial();
texture->resetDirty();
}
}
......
......@@ -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 @@ GLuint RenderbufferInterface::getStencilSize() const
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 @@ GLenum RenderbufferTexture::getInternalFormat() const
{
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 @@ void Renderbuffer::setStorage(RenderbufferStorage *newStorage)
mInstance = newStorage;
}
RenderbufferStorage::RenderbufferStorage()
RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerial())
{
mWidth = 0;
mHeight = 0;
......@@ -232,14 +227,31 @@ GLenum RenderbufferStorage::getInternalFormat() const
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)
......
......@@ -48,16 +48,10 @@ class RenderbufferInterface
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 @@ class RenderbufferTexture : public RenderbufferInterface
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 @@ class RenderbufferStorage : public RenderbufferInterface
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 @@ class RenderbufferStorage : public RenderbufferInterface
private:
DISALLOW_COPY_AND_ASSIGN(RenderbufferStorage);
const unsigned int mSerial;
static unsigned int mCurrentSerial;
};
// Renderbuffer implements the GL renderbuffer object.
......
......@@ -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 @@ void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
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
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 @@ void Texture::resetDirty()
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 @@ int Texture::levelCount() const
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 @@ IDirect3DBaseTexture9 *TextureStorage2D::getBaseTexture() const
return mTexture;
}
unsigned int TextureStorage2D::getRenderTargetSerial(GLenum target) const
{
return mRenderTargetSerial;
}
Texture2D::Texture2D(GLuint id) : Texture(id)
{
mTexture = NULL;
......@@ -1631,7 +1642,6 @@ void Texture2D::redefineImage(GLint level, GLenum format, GLsizei width, GLsizei
delete mTexture;
mTexture = NULL;
mDirtyImages = true;
mColorbufferProxy.set(NULL);
}
}
......@@ -1665,7 +1675,7 @@ void Texture2D::bindTexImage(egl::Surface *surface)
delete mTexture;
mTexture = new TextureStorage2D(surface->getOffscreenTexture());
mColorbufferProxy.set(NULL);
mDirtyImages = true;
mSurface = surface;
mSurface->setBoundTexture(this);
......@@ -1682,7 +1692,6 @@ void Texture2D::releaseTexImage()
{
delete mTexture;
mTexture = NULL;
mColorbufferProxy.set(NULL);
}
for (int i = 0; i < IMPLEMENTATION_MAX_TEXTURE_LEVELS; i++)
......@@ -1949,7 +1958,6 @@ void Texture2D::createTexture()
delete mTexture;
mTexture = new TextureStorage2D(levels, format, width, height, false);
mColorbufferProxy.set(NULL);
mDirtyImages = true;
}
......@@ -2017,7 +2025,7 @@ void Texture2D::convertToRenderTarget()
delete mTexture;
mTexture = newTexture;
mColorbufferProxy.set(NULL);
mDirtyImages = true;
}
......@@ -2117,7 +2125,7 @@ TextureStorage *Texture2D::getStorage() const
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 @@ IDirect3DBaseTexture9 *TextureStorageCubeMap::getBaseTexture() const
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 @@ TextureCubeMap::~TextureCubeMap()
}
delete mTexture;
mTexture = NULL;
}
GLenum TextureCubeMap::getTarget() const
......@@ -2391,7 +2405,6 @@ void TextureCubeMap::createTexture()
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 @@ void TextureCubeMap::convertToRenderTarget()
delete mTexture;
mTexture = newTexture;
for(int face = 0; face < 6; face++) mFaceProxies[face].set(NULL);
mDirtyImages = true;
}
......@@ -2503,7 +2515,6 @@ void TextureCubeMap::redefineImage(int face, GLint level, GLenum format, GLsizei
delete mTexture;
mTexture = NULL;
for(int face = 0; face < 6; face++) mFaceProxies[face].set(NULL);
mDirtyImages = true;
}
}
......
......@@ -143,17 +143,18 @@ class TextureStorage
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 @@ class Texture : public RefCountObject
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 @@ class TextureStorage2D : public TextureStorage
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 @@ class TextureStorageCubeMap : public TextureStorage
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 @@ class TextureCubeMap : public Texture
virtual Renderbuffer *getRenderbuffer(GLenum target);
static unsigned int faceIndex(GLenum face);
private:
DISALLOW_COPY_AND_ASSIGN(TextureCubeMap);
......@@ -363,8 +373,6 @@ class TextureCubeMap : public Texture
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);
......
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