Track texture serials instead of id's.

TRAC #15703 Issue=86 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@589 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 38e76e53
......@@ -321,10 +321,10 @@ void Context::markAllStateDirty()
{
for (int t = 0; t < MAX_TEXTURE_IMAGE_UNITS; t++)
{
mAppliedTexture[t] = 0;
mAppliedTextureSerial[t] = 0;
}
mAppliedProgram = 0;
mAppliedProgramSerial = 0;
mAppliedRenderTargetSerial = 0;
mAppliedDepthbufferSerial = 0;
mAppliedStencilbufferSerial = 0;
......@@ -2007,10 +2007,10 @@ void Context::applyShaders()
device->SetVertexShader(vertexShader);
device->SetPixelShader(pixelShader);
if (programObject->getSerial() != mAppliedProgram)
if (programObject->getSerial() != mAppliedProgramSerial)
{
programObject->dirtyAllUniforms();
mAppliedProgram = programObject->getSerial();
mAppliedProgramSerial = programObject->getSerial();
}
programObject->applyUniforms();
......@@ -2031,7 +2031,7 @@ void Context::applyTextures()
Texture *texture = getSamplerTexture(textureUnit, textureType);
if (mAppliedTexture[sampler] != texture->id() || texture->isDirty())
if (mAppliedTextureSerial[sampler] != texture->getSerial() || texture->isDirty())
{
IDirect3DBaseTexture9 *d3dTexture = texture->getTexture();
......@@ -2058,16 +2058,16 @@ void Context::applyTextures()
device->SetTexture(sampler, getIncompleteTexture(textureType)->getTexture());
}
mAppliedTexture[sampler] = texture->id();
mAppliedTextureSerial[sampler] = texture->getSerial();
texture->resetDirty();
}
}
else
{
if (mAppliedTexture[sampler] != 0)
if (mAppliedTextureSerial[sampler] != 0)
{
device->SetTexture(sampler, NULL);
mAppliedTexture[sampler] = 0;
mAppliedTextureSerial[sampler] = 0;
}
}
}
......
......@@ -483,8 +483,8 @@ class Context
bool mHasBeenCurrent;
unsigned int mAppliedTexture[MAX_TEXTURE_IMAGE_UNITS];
unsigned int mAppliedProgram;
unsigned int mAppliedTextureSerial[MAX_TEXTURE_IMAGE_UNITS];
unsigned int mAppliedProgramSerial;
unsigned int mAppliedRenderTargetSerial;
unsigned int mAppliedDepthbufferSerial;
unsigned int mAppliedStencilbufferSerial;
......
......@@ -24,6 +24,7 @@
namespace gl
{
unsigned int Texture::mCurrentSerial = 1;
Texture::Image::Image()
: width(0), height(0), dirty(false), surface(NULL), format(GL_NONE), type(GL_UNSIGNED_BYTE)
......@@ -38,7 +39,7 @@ Texture::Image::~Image()
}
}
Texture::Texture(GLuint id) : RefCountObject(id)
Texture::Texture(GLuint id) : RefCountObject(id), mSerial(issueSerial())
{
mMinFilter = GL_NEAREST_MIPMAP_LINEAR;
mMagFilter = GL_LINEAR;
......@@ -1159,6 +1160,11 @@ void Texture::resetDirty()
mDirty = false;
}
unsigned int Texture::getSerial() const
{
return mSerial;
}
GLint Texture::creationLevels(GLsizei width, GLsizei height, GLint maxlevel) const
{
if (isPow2(width) && isPow2(height))
......@@ -1182,6 +1188,11 @@ int Texture::levelCount() const
return getBaseTexture() ? getBaseTexture()->GetLevelCount() : 0;
}
unsigned int Texture::issueSerial()
{
return mCurrentSerial++;
}
Texture2D::Texture2D(GLuint id) : Texture(id)
{
mTexture = NULL;
......
......@@ -75,6 +75,7 @@ class Texture : public RefCountObject
bool isDirty() const;
void resetDirty();
unsigned int getSerial() 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.
......@@ -174,6 +175,12 @@ class Texture : public RefCountObject
int inputPitch, const void *input, size_t outputPitch, void *output) const;
void loadCompressedImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
int inputPitch, const void *input, size_t outputPitch, void *output) const;
static unsigned int issueSerial();
const unsigned int mSerial;
static unsigned int mCurrentSerial;
};
class Texture2D : public Texture
......
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