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() ...@@ -407,7 +407,7 @@ void Context::markAllStateDirty()
mDitherStateDirty = true; mDitherStateDirty = true;
mFrontFaceDirty = true; mFrontFaceDirty = true;
mDxUniformsDirty = true; mDxUniformsDirty = true;
mCachedCurrentProgram = NULL; mCachedCurrentProgramBinary = NULL;
} }
void Context::markDxUniformsDirty() void Context::markDxUniformsDirty()
...@@ -983,7 +983,7 @@ void Context::deleteShader(GLuint shader) ...@@ -983,7 +983,7 @@ void Context::deleteShader(GLuint shader)
void Context::deleteProgram(GLuint program) void Context::deleteProgram(GLuint program)
{ {
mResourceManager->deleteProgram(program); mResourceManager->deleteProgram(program);
mCachedCurrentProgram = NULL; mCachedCurrentProgramBinary = NULL;
} }
void Context::deleteTexture(GLuint texture) void Context::deleteTexture(GLuint texture)
...@@ -1147,7 +1147,7 @@ void Context::useProgram(GLuint program) ...@@ -1147,7 +1147,7 @@ void Context::useProgram(GLuint program)
{ {
Program *newProgram = mResourceManager->getProgram(program); Program *newProgram = mResourceManager->getProgram(program);
Program *oldProgram = mResourceManager->getProgram(priorProgram); Program *oldProgram = mResourceManager->getProgram(priorProgram);
mCachedCurrentProgram = NULL; mCachedCurrentProgramBinary = NULL;
mDxUniformsDirty = true; mDxUniformsDirty = true;
if (newProgram) if (newProgram)
...@@ -1324,13 +1324,14 @@ Buffer *Context::getElementArrayBuffer() ...@@ -1324,13 +1324,14 @@ Buffer *Context::getElementArrayBuffer()
return mState.elementArrayBuffer.get(); 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() Texture2D *Context::getTexture2D()
...@@ -2016,8 +2017,7 @@ bool Context::applyRenderTarget(bool ignoreViewport) ...@@ -2016,8 +2017,7 @@ bool Context::applyRenderTarget(bool ignoreViewport)
if (mState.currentProgram && mDxUniformsDirty) if (mState.currentProgram && mDxUniformsDirty)
{ {
Program *programObject = getCurrentProgram(); ProgramBinary *programBinary = getCurrentProgramBinary();
ProgramBinary *programBinary = programObject->getProgramBinary();
GLint halfPixelSize = programBinary->getDxHalfPixelSizeLocation(); GLint halfPixelSize = programBinary->getDxHalfPixelSizeLocation();
GLfloat xy[2] = {1.0f / viewport.Width, -1.0f / viewport.Height}; GLfloat xy[2] = {1.0f / viewport.Width, -1.0f / viewport.Height};
...@@ -2046,8 +2046,7 @@ bool Context::applyRenderTarget(bool ignoreViewport) ...@@ -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 // Applies the fixed-function state (culling, depth test, alpha blending, stenciling, etc) to the Direct3D 9 device
void Context::applyState(GLenum drawMode) void Context::applyState(GLenum drawMode)
{ {
Program *programObject = getCurrentProgram(); ProgramBinary *programBinary = getCurrentProgramBinary();
ProgramBinary *programBinary = programObject->getProgramBinary();
Framebuffer *framebufferObject = getDrawFramebuffer(); Framebuffer *framebufferObject = getDrawFramebuffer();
...@@ -2312,7 +2311,7 @@ GLenum Context::applyVertexBuffer(GLint first, GLsizei count, GLsizei instances, ...@@ -2312,7 +2311,7 @@ GLenum Context::applyVertexBuffer(GLint first, GLsizei count, GLsizei instances,
return err; return err;
} }
ProgramBinary *programBinary = getCurrentProgram()->getProgramBinary(); ProgramBinary *programBinary = getCurrentProgramBinary();
return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, programBinary, instances, repeatDraw); return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, programBinary, instances, repeatDraw);
} }
...@@ -2336,8 +2335,7 @@ GLenum Context::applyIndexBuffer(const GLvoid *indices, GLsizei count, GLenum mo ...@@ -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 // Applies the shaders and shader constants to the Direct3D 9 device
void Context::applyShaders() void Context::applyShaders()
{ {
Program *programObject = getCurrentProgram(); ProgramBinary *programBinary = getCurrentProgramBinary();
ProgramBinary *programBinary = programObject->getProgramBinary();
if (programBinary->getSerial() != mAppliedProgramBinarySerial) if (programBinary->getSerial() != mAppliedProgramBinarySerial)
{ {
...@@ -2369,8 +2367,7 @@ void Context::applyTextures() ...@@ -2369,8 +2367,7 @@ void Context::applyTextures()
// and sets the texture and its addressing/filtering state (or NULL when inactive). // and sets the texture and its addressing/filtering state (or NULL when inactive).
void Context::applyTextures(SamplerType type) void Context::applyTextures(SamplerType type)
{ {
Program *programObject = getCurrentProgram(); ProgramBinary *programBinary = getCurrentProgramBinary();
ProgramBinary *programBinary = programObject->getProgramBinary();
int samplerCount = (type == SAMPLER_PIXEL) ? MAX_TEXTURE_IMAGE_UNITS : MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF; // Range of Direct3D 9 samplers of given sampler type 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; unsigned int *appliedTextureSerial = (type == SAMPLER_PIXEL) ? mAppliedTextureSerialPS : mAppliedTextureSerialVS;
...@@ -3022,7 +3019,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan ...@@ -3022,7 +3019,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan
applyShaders(); applyShaders();
applyTextures(); applyTextures();
if (!getCurrentProgram()->getProgramBinary()->validateSamplers(NULL)) if (!getCurrentProgramBinary()->validateSamplers(NULL))
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
...@@ -3112,7 +3109,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid ...@@ -3112,7 +3109,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid
applyShaders(); applyShaders();
applyTextures(); applyTextures();
if (!getCurrentProgram()->getProgramBinary()->validateSamplers(false)) if (!getCurrentProgramBinary()->validateSamplers(false))
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
......
...@@ -439,7 +439,7 @@ class Context ...@@ -439,7 +439,7 @@ class Context
Buffer *getArrayBuffer(); Buffer *getArrayBuffer();
Buffer *getElementArrayBuffer(); Buffer *getElementArrayBuffer();
Program *getCurrentProgram(); ProgramBinary *getCurrentProgramBinary();
Texture2D *getTexture2D(); Texture2D *getTexture2D();
TextureCubeMap *getTextureCubeMap(); TextureCubeMap *getTextureCubeMap();
Texture *getSamplerTexture(unsigned int sampler, TextureType type); Texture *getSamplerTexture(unsigned int sampler, TextureType type);
...@@ -597,7 +597,7 @@ class Context ...@@ -597,7 +597,7 @@ class Context
bool mRenderTargetDescInitialized; bool mRenderTargetDescInitialized;
D3DSURFACE_DESC mRenderTargetDesc; D3DSURFACE_DESC mRenderTargetDesc;
bool mDxUniformsDirty; bool mDxUniformsDirty;
Program *mCachedCurrentProgram; ProgramBinary *mCachedCurrentProgramBinary;
Framebuffer *mBoundDrawFramebuffer; Framebuffer *mBoundDrawFramebuffer;
bool mSupportsShaderModel3; bool mSupportsShaderModel3;
......
...@@ -128,8 +128,7 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat ...@@ -128,8 +128,7 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat
} }
const VertexAttributeArray &attribs = mContext->getVertexAttributes(); const VertexAttributeArray &attribs = mContext->getVertexAttributes();
Program *program = mContext->getCurrentProgram(); ProgramBinary *programBinary = mContext->getCurrentProgramBinary();
ProgramBinary *programBinary = program->getProgramBinary();
for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++) for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{ {
......
...@@ -5953,14 +5953,7 @@ void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) ...@@ -5953,14 +5953,7 @@ void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -6003,14 +5996,7 @@ void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) ...@@ -6003,14 +5996,7 @@ void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -6055,14 +6041,7 @@ void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) ...@@ -6055,14 +6041,7 @@ void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -6107,14 +6086,7 @@ void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) ...@@ -6107,14 +6086,7 @@ void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -6159,14 +6131,7 @@ void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) ...@@ -6159,14 +6131,7 @@ void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -6211,14 +6176,7 @@ void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) ...@@ -6211,14 +6176,7 @@ void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -6263,14 +6221,7 @@ void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) ...@@ -6263,14 +6221,7 @@ void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -6315,14 +6266,7 @@ void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) ...@@ -6315,14 +6266,7 @@ void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -6361,14 +6305,7 @@ void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean trans ...@@ -6361,14 +6305,7 @@ void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean trans
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -6407,14 +6344,7 @@ void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean trans ...@@ -6407,14 +6344,7 @@ void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean trans
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
...@@ -6453,14 +6383,7 @@ void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean trans ...@@ -6453,14 +6383,7 @@ void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean trans
if (context) if (context)
{ {
gl::Program *program = context->getCurrentProgram(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!program)
{
return error(GL_INVALID_OPERATION);
}
gl::ProgramBinary *programBinary = program->getProgramBinary();
if (!programBinary) if (!programBinary)
{ {
return error(GL_INVALID_OPERATION); 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