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: https://angleproject.googlecode.com/svn/trunk@1235 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 39c9d952
......@@ -407,7 +407,7 @@ void Context::markAllStateDirty()
mDitherStateDirty = true;
mFrontFaceDirty = true;
mDxUniformsDirty = true;
mCachedCurrentProgram = NULL;
mCachedCurrentProgramBinary = NULL;
}
void Context::markDxUniformsDirty()
......@@ -983,7 +983,7 @@ void Context::deleteShader(GLuint shader)
void Context::deleteProgram(GLuint program)
{
mResourceManager->deleteProgram(program);
mCachedCurrentProgram = NULL;
mCachedCurrentProgramBinary = NULL;
}
void Context::deleteTexture(GLuint texture)
......@@ -1147,7 +1147,7 @@ void Context::useProgram(GLuint program)
{
Program *newProgram = mResourceManager->getProgram(program);
Program *oldProgram = mResourceManager->getProgram(priorProgram);
mCachedCurrentProgram = NULL;
mCachedCurrentProgramBinary = NULL;
mDxUniformsDirty = true;
if (newProgram)
......@@ -1324,13 +1324,14 @@ Buffer *Context::getElementArrayBuffer()
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 @@ bool Context::applyRenderTarget(bool ignoreViewport)
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 @@ bool Context::applyRenderTarget(bool ignoreViewport)
// 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 @@ GLenum Context::applyVertexBuffer(GLint first, GLsizei count, GLsizei instances,
return err;
}
ProgramBinary *programBinary = getCurrentProgram()->getProgramBinary();
ProgramBinary *programBinary = getCurrentProgramBinary();
return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, programBinary, instances, repeatDraw);
}
......@@ -2336,8 +2335,7 @@ GLenum Context::applyIndexBuffer(const GLvoid *indices, GLsizei count, GLenum mo
// 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 @@ void Context::applyTextures()
// 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 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan
applyShaders();
applyTextures();
if (!getCurrentProgram()->getProgramBinary()->validateSamplers(NULL))
if (!getCurrentProgramBinary()->validateSamplers(NULL))
{
return error(GL_INVALID_OPERATION);
}
......@@ -3112,7 +3109,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid
applyShaders();
applyTextures();
if (!getCurrentProgram()->getProgramBinary()->validateSamplers(false))
if (!getCurrentProgramBinary()->validateSamplers(false))
{
return error(GL_INVALID_OPERATION);
}
......
......@@ -439,7 +439,7 @@ class Context
Buffer *getArrayBuffer();
Buffer *getElementArrayBuffer();
Program *getCurrentProgram();
ProgramBinary *getCurrentProgramBinary();
Texture2D *getTexture2D();
TextureCubeMap *getTextureCubeMap();
Texture *getSamplerTexture(unsigned int sampler, TextureType type);
......@@ -597,7 +597,7 @@ class Context
bool mRenderTargetDescInitialized;
D3DSURFACE_DESC mRenderTargetDesc;
bool mDxUniformsDirty;
Program *mCachedCurrentProgram;
ProgramBinary *mCachedCurrentProgramBinary;
Framebuffer *mBoundDrawFramebuffer;
bool mSupportsShaderModel3;
......
......@@ -128,8 +128,7 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat
}
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++)
{
......
......@@ -5953,14 +5953,7 @@ void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
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 @@ void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
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 @@ void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
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 @@ void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
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 @@ void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
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 @@ void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
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 @@ void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
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 @@ void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
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 @@ void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean trans
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 @@ void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean trans
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 @@ void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean trans
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);
......
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