Cache the current program binary instead of the current program.
Trac #21270
Bug=351
Signed-off-by: Nicolas Capens
Everywhere we used the currentProgram it was immediately used to get the program's binary.
git-svn-id: http://angleproject.googlecode.com/svn/trunk@1235 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 92ebbe4..a109370 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -407,7 +407,7 @@
mDitherStateDirty = true;
mFrontFaceDirty = true;
mDxUniformsDirty = true;
- mCachedCurrentProgram = NULL;
+ mCachedCurrentProgramBinary = NULL;
}
void Context::markDxUniformsDirty()
@@ -983,7 +983,7 @@
void Context::deleteProgram(GLuint program)
{
mResourceManager->deleteProgram(program);
- mCachedCurrentProgram = NULL;
+ mCachedCurrentProgramBinary = NULL;
}
void Context::deleteTexture(GLuint texture)
@@ -1147,7 +1147,7 @@
{
Program *newProgram = mResourceManager->getProgram(program);
Program *oldProgram = mResourceManager->getProgram(priorProgram);
- mCachedCurrentProgram = NULL;
+ mCachedCurrentProgramBinary = NULL;
mDxUniformsDirty = true;
if (newProgram)
@@ -1324,13 +1324,14 @@
return mState.elementArrayBuffer.get();
}
-Program *Context::getCurrentProgram()
+ProgramBinary *Context::getCurrentProgramBinary()
{
- if (!mCachedCurrentProgram)
+ if (!mCachedCurrentProgramBinary)
{
- mCachedCurrentProgram = mResourceManager->getProgram(mState.currentProgram);
+ Program *program = mResourceManager->getProgram(mState.currentProgram);
+ mCachedCurrentProgramBinary = program->getProgramBinary();
}
- return mCachedCurrentProgram;
+ return mCachedCurrentProgramBinary;
}
Texture2D *Context::getTexture2D()
@@ -2016,8 +2017,7 @@
if (mState.currentProgram && mDxUniformsDirty)
{
- Program *programObject = getCurrentProgram();
- ProgramBinary *programBinary = programObject->getProgramBinary();
+ ProgramBinary *programBinary = getCurrentProgramBinary();
GLint halfPixelSize = programBinary->getDxHalfPixelSizeLocation();
GLfloat xy[2] = {1.0f / viewport.Width, -1.0f / viewport.Height};
@@ -2046,8 +2046,7 @@
// Applies the fixed-function state (culling, depth test, alpha blending, stenciling, etc) to the Direct3D 9 device
void Context::applyState(GLenum drawMode)
{
- Program *programObject = getCurrentProgram();
- ProgramBinary *programBinary = programObject->getProgramBinary();
+ ProgramBinary *programBinary = getCurrentProgramBinary();
Framebuffer *framebufferObject = getDrawFramebuffer();
@@ -2312,7 +2311,7 @@
return err;
}
- ProgramBinary *programBinary = getCurrentProgram()->getProgramBinary();
+ ProgramBinary *programBinary = getCurrentProgramBinary();
return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, programBinary, instances, repeatDraw);
}
@@ -2336,8 +2335,7 @@
// Applies the shaders and shader constants to the Direct3D 9 device
void Context::applyShaders()
{
- Program *programObject = getCurrentProgram();
- ProgramBinary *programBinary = programObject->getProgramBinary();
+ ProgramBinary *programBinary = getCurrentProgramBinary();
if (programBinary->getSerial() != mAppliedProgramBinarySerial)
{
@@ -2369,8 +2367,7 @@
// and sets the texture and its addressing/filtering state (or NULL when inactive).
void Context::applyTextures(SamplerType type)
{
- Program *programObject = getCurrentProgram();
- ProgramBinary *programBinary = programObject->getProgramBinary();
+ ProgramBinary *programBinary = getCurrentProgramBinary();
int samplerCount = (type == SAMPLER_PIXEL) ? MAX_TEXTURE_IMAGE_UNITS : MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF; // Range of Direct3D 9 samplers of given sampler type
unsigned int *appliedTextureSerial = (type == SAMPLER_PIXEL) ? mAppliedTextureSerialPS : mAppliedTextureSerialVS;
@@ -3022,7 +3019,7 @@
applyShaders();
applyTextures();
- if (!getCurrentProgram()->getProgramBinary()->validateSamplers(NULL))
+ if (!getCurrentProgramBinary()->validateSamplers(NULL))
{
return error(GL_INVALID_OPERATION);
}
@@ -3112,7 +3109,7 @@
applyShaders();
applyTextures();
- if (!getCurrentProgram()->getProgramBinary()->validateSamplers(false))
+ if (!getCurrentProgramBinary()->validateSamplers(false))
{
return error(GL_INVALID_OPERATION);
}
diff --git a/src/libGLESv2/Context.h b/src/libGLESv2/Context.h
index b1acb34..253c489 100644
--- a/src/libGLESv2/Context.h
+++ b/src/libGLESv2/Context.h
@@ -439,7 +439,7 @@
Buffer *getArrayBuffer();
Buffer *getElementArrayBuffer();
- Program *getCurrentProgram();
+ ProgramBinary *getCurrentProgramBinary();
Texture2D *getTexture2D();
TextureCubeMap *getTextureCubeMap();
Texture *getSamplerTexture(unsigned int sampler, TextureType type);
@@ -597,7 +597,7 @@
bool mRenderTargetDescInitialized;
D3DSURFACE_DESC mRenderTargetDesc;
bool mDxUniformsDirty;
- Program *mCachedCurrentProgram;
+ ProgramBinary *mCachedCurrentProgramBinary;
Framebuffer *mBoundDrawFramebuffer;
bool mSupportsShaderModel3;
diff --git a/src/libGLESv2/VertexDataManager.cpp b/src/libGLESv2/VertexDataManager.cpp
index 70f475f..a95275f 100644
--- a/src/libGLESv2/VertexDataManager.cpp
+++ b/src/libGLESv2/VertexDataManager.cpp
@@ -128,8 +128,7 @@
}
const VertexAttributeArray &attribs = mContext->getVertexAttributes();
- Program *program = mContext->getCurrentProgram();
- ProgramBinary *programBinary = program->getProgramBinary();
+ ProgramBinary *programBinary = mContext->getCurrentProgramBinary();
for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 9f3e591..5a70a84 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -5953,14 +5953,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);
@@ -6003,14 +5996,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);
@@ -6055,14 +6041,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);
@@ -6107,14 +6086,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);
@@ -6159,14 +6131,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);
@@ -6211,14 +6176,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);
@@ -6263,14 +6221,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);
@@ -6315,14 +6266,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);
@@ -6361,14 +6305,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);
@@ -6407,14 +6344,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);
@@ -6453,14 +6383,7 @@
if (context)
{
- gl::Program *program = context->getCurrentProgram();
-
- if (!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = program->getProgramBinary();
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return error(GL_INVALID_OPERATION);