Commit c6209856 by jbauman@chromium.org

Cache the current program pointer

Hash table lookups are somewhat expensive, so cache a pointer to the current program for on a context. This gains about 3 fps (from 58) on a Native Client demo. BUG= TEST=webgl conformance tests Review URL: http://codereview.appspot.com/5206042 git-svn-id: https://angleproject.googlecode.com/svn/trunk@786 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 50297fc1
#define MAJOR_VERSION 0
#define MINOR_VERSION 0
#define BUILD_VERSION 0
#define BUILD_REVISION 785
#define BUILD_REVISION 786
#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
......
......@@ -381,6 +381,7 @@ void Context::markAllStateDirty()
mSampleStateDirty = true;
mDitherStateDirty = true;
mFrontFaceDirty = true;
mCachedCurrentProgram = NULL;
}
void Context::setClearColor(float red, float green, float blue, float alpha)
......@@ -893,6 +894,7 @@ void Context::deleteShader(GLuint shader)
void Context::deleteProgram(GLuint program)
{
mResourceManager->deleteProgram(program);
mCachedCurrentProgram = NULL;
}
void Context::deleteTexture(GLuint texture)
......@@ -1040,6 +1042,7 @@ void Context::useProgram(GLuint program)
{
Program *newProgram = mResourceManager->getProgram(program);
Program *oldProgram = mResourceManager->getProgram(priorProgram);
mCachedCurrentProgram = NULL;
if (newProgram)
{
......@@ -1105,7 +1108,11 @@ Buffer *Context::getElementArrayBuffer()
Program *Context::getCurrentProgram()
{
return mResourceManager->getProgram(mState.currentProgram);
if (!mCachedCurrentProgram)
{
mCachedCurrentProgram = mResourceManager->getProgram(mState.currentProgram);
}
return mCachedCurrentProgram;
}
Texture2D *Context::getTexture2D()
......
......@@ -544,6 +544,7 @@ class Context
D3DVIEWPORT9 mSetViewport;
bool mRenderTargetDescInitialized;
D3DSURFACE_DESC mRenderTargetDesc;
Program *mCachedCurrentProgram;
bool mSupportsShaderModel3;
bool mSupportsVertexTexture;
......
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