Commit 10ef2156 by Jamie Madill

Move Texture Serials to the base class.

It's reasonable to use the serial logic on both the GL and all other translated Renderers, since we check the logic on the GL-side. Serials give us a way to identify Textures that aren't raw pointers and aren't "id". "id" has issues when Textures are deleted, then re-allocated with the same value. BUG=angle:781 Change-Id: I1a2a8b6f4ea3db915574c957c143a81e0210ec7d Reviewed-on: https://chromium-review.googlesource.com/222922Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org>
parent 6948e301
...@@ -47,9 +47,12 @@ bool IsPointSampled(const gl::SamplerState &samplerState) ...@@ -47,9 +47,12 @@ bool IsPointSampled(const gl::SamplerState &samplerState)
return (samplerState.magFilter == GL_NEAREST && (samplerState.minFilter == GL_NEAREST || samplerState.minFilter == GL_NEAREST_MIPMAP_NEAREST)); return (samplerState.magFilter == GL_NEAREST && (samplerState.minFilter == GL_NEAREST || samplerState.minFilter == GL_NEAREST_MIPMAP_NEAREST));
} }
unsigned int Texture::mCurrentTextureSerial = 1;
Texture::Texture(rx::TextureImpl *impl, GLuint id, GLenum target) Texture::Texture(rx::TextureImpl *impl, GLuint id, GLenum target)
: RefCountObject(id), : RefCountObject(id),
mTexture(impl), mTexture(impl),
mTextureSerial(issueTextureSerial()),
mUsage(GL_NONE), mUsage(GL_NONE),
mImmutableLevelCount(0), mImmutableLevelCount(0),
mTarget(target) mTarget(target)
...@@ -154,10 +157,14 @@ Error Texture::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yof ...@@ -154,10 +157,14 @@ Error Texture::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yof
return mTexture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, source); return mTexture->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, source);
} }
unsigned int Texture::getTextureSerial() unsigned int Texture::getTextureSerial() const
{ {
rx::TextureStorage *texture = getNativeTexture(); return mTextureSerial;
return texture ? texture->getTextureSerial() : 0; }
unsigned int Texture::issueTextureSerial()
{
return mCurrentTextureSerial++;
} }
bool Texture::isImmutable() const bool Texture::isImmutable() const
......
...@@ -74,7 +74,9 @@ class Texture : public RefCountObject ...@@ -74,7 +74,9 @@ class Texture : public RefCountObject
virtual void generateMipmaps(); virtual void generateMipmaps();
virtual Error copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); virtual Error copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
unsigned int getTextureSerial(); // Texture serials provide a unique way of identifying a Texture that isn't a raw pointer.
// "id" is not good enough, as Textures can be deleted, then re-allocated with the same id.
unsigned int getTextureSerial() const;
bool isImmutable() const; bool isImmutable() const;
GLsizei immutableLevelCount(); GLsizei immutableLevelCount();
...@@ -86,6 +88,8 @@ class Texture : public RefCountObject ...@@ -86,6 +88,8 @@ class Texture : public RefCountObject
protected: protected:
int mipLevels() const; int mipLevels() const;
const rx::Image *getBaseLevelImage() const;
static unsigned int issueTextureSerial();
rx::TextureImpl *mTexture; rx::TextureImpl *mTexture;
...@@ -96,7 +100,8 @@ class Texture : public RefCountObject ...@@ -96,7 +100,8 @@ class Texture : public RefCountObject
GLenum mTarget; GLenum mTarget;
const rx::Image *getBaseLevelImage() const; const unsigned int mTextureSerial;
static unsigned int mCurrentTextureSerial;
private: private:
DISALLOW_COPY_AND_ASSIGN(Texture); DISALLOW_COPY_AND_ASSIGN(Texture);
......
...@@ -18,11 +18,8 @@ ...@@ -18,11 +18,8 @@
namespace rx namespace rx
{ {
unsigned int TextureStorage::mCurrentTextureSerial = 1;
TextureStorage::TextureStorage() TextureStorage::TextureStorage()
: mTextureSerial(issueTextureSerial()), : mFirstRenderTargetSerial(0),
mFirstRenderTargetSerial(0),
mRenderTargetSerialsLayerStride(0) mRenderTargetSerialsLayerStride(0)
{} {}
...@@ -38,14 +35,4 @@ unsigned int TextureStorage::getRenderTargetSerial(const gl::ImageIndex &index) ...@@ -38,14 +35,4 @@ unsigned int TextureStorage::getRenderTargetSerial(const gl::ImageIndex &index)
return mFirstRenderTargetSerial + static_cast<unsigned int>(index.mipIndex) + layerOffset; return mFirstRenderTargetSerial + static_cast<unsigned int>(index.mipIndex) + layerOffset;
} }
unsigned int TextureStorage::getTextureSerial() const
{
return mTextureSerial;
}
unsigned int TextureStorage::issueTextureSerial()
{
return mCurrentTextureSerial++;
}
} }
...@@ -58,11 +58,6 @@ class TextureStorage ...@@ -58,11 +58,6 @@ class TextureStorage
private: private:
DISALLOW_COPY_AND_ASSIGN(TextureStorage); DISALLOW_COPY_AND_ASSIGN(TextureStorage);
const unsigned int mTextureSerial;
static unsigned int issueTextureSerial();
static unsigned int mCurrentTextureSerial;
unsigned int mFirstRenderTargetSerial; unsigned int mFirstRenderTargetSerial;
unsigned int mRenderTargetSerialsLayerStride; unsigned int mRenderTargetSerialsLayerStride;
}; };
......
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