Add glActiveShaderProgram and direct glUniform* to right program

This commit is contained in:
baldurk
2014-11-23 16:37:23 +00:00
parent e3bc5bb84b
commit 841d77485c
6 changed files with 40 additions and 3 deletions
+1
View File
@@ -329,6 +329,7 @@ WrappedOpenGL::WrappedOpenGL(const char *logfile, const GLHookSet &funcs)
m_ReadFramebufferRecord = NULL;
m_Renderbuffer = ResourceId();
m_TextureUnit = 0;
m_ProgramPipeline = 0;
m_Program = 0;
m_LastIndexSize = eGL_NONE;
+3
View File
@@ -118,7 +118,9 @@ class WrappedOpenGL
GLResourceRecord *m_ReadFramebufferRecord;
ResourceId m_Renderbuffer;
GLint m_TextureUnit;
GLuint m_ProgramPipeline;
GLuint m_Program;
GLuint GetUniformProgram();
// internals
Serialiser *m_pSerialiser;
@@ -507,6 +509,7 @@ class WrappedOpenGL
IMPLEMENT_FUNCTION_SERIALISED(void, glValidateProgram(GLuint program));
IMPLEMENT_FUNCTION_SERIALISED(void, glGenProgramPipelines(GLsizei n, GLuint *pipelines));
IMPLEMENT_FUNCTION_SERIALISED(void, glBindProgramPipeline(GLuint pipeline));
IMPLEMENT_FUNCTION_SERIALISED(void, glActiveShaderProgram(GLuint pipeline, GLuint program));
IMPLEMENT_FUNCTION_SERIALISED(void, glDeleteProgramPipelines(GLsizei n, const GLuint *pipelines));
IMPLEMENT_FUNCTION_SERIALISED(void, glValidateProgramPipeline(GLuint pipeline));
IMPLEMENT_FUNCTION_SERIALISED(void, glGenBuffers(GLsizei n, GLuint *buffers));
+1
View File
@@ -262,6 +262,7 @@ struct GLHookSet
PFNGLVALIDATEPROGRAMPROC glValidateProgram;
PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines;
PFNGLBINDPROGRAMPIPELINEPROC glBindProgramPipeline;
PFNGLACTIVESHADERPROGRAMPROC glActiveShaderProgram;
PFNGLDELETEPROGRAMPIPELINESPROC glDeleteProgramPipelines;
PFNGLVALIDATEPROGRAMPIPELINEPROC glValidateProgramPipeline;
PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback; // aliases glDebugMessageCallbackARB
+2
View File
@@ -280,6 +280,7 @@
HookExtension(PFNGLVALIDATEPROGRAMPROC, glValidateProgram); \
HookExtension(PFNGLGENPROGRAMPIPELINESPROC, glGenProgramPipelines); \
HookExtension(PFNGLBINDPROGRAMPIPELINEPROC, glBindProgramPipeline); \
HookExtension(PFNGLACTIVESHADERPROGRAMPROC, glActiveShaderProgram); \
HookExtension(PFNGLDELETEPROGRAMPIPELINESPROC, glDeleteProgramPipelines); \
HookExtension(PFNGLVALIDATEPROGRAMPIPELINEPROC, glValidateProgramPipeline); \
HookExtension(PFNGLDEBUGMESSAGECALLBACKPROC, glDebugMessageCallback); \
@@ -936,6 +937,7 @@
HookWrapper1(void, glValidateProgram, GLuint, program); \
HookWrapper2(void, glGenProgramPipelines, GLsizei, n, GLuint *, pipelines); \
HookWrapper1(void, glBindProgramPipeline, GLuint, pipeline); \
HookWrapper2(void, glActiveShaderProgram, GLuint, pipeline, GLuint, program); \
HookWrapper2(void, glDeleteProgramPipelines, GLsizei, n, const GLuint *, pipelines); \
HookWrapper1(void, glValidateProgramPipeline, GLuint, pipeline); \
HookWrapper2(void, glDebugMessageCallback, GLDEBUGPROC, callback, const void *, userParam); \
@@ -826,6 +826,8 @@ void WrappedOpenGL::glBindProgramPipeline(GLuint pipeline)
{
m_Real.glBindProgramPipeline(pipeline);
m_ProgramPipeline = pipeline;
if(m_State == WRITING_CAPFRAME)
{
SCOPED_SERIALISE_CONTEXT(BIND_PROGRAMPIPE);
@@ -835,6 +837,34 @@ void WrappedOpenGL::glBindProgramPipeline(GLuint pipeline)
}
}
void WrappedOpenGL::glActiveShaderProgram(GLuint pipeline, GLuint program)
{
m_Real.glActiveShaderProgram(pipeline, program);
}
GLuint WrappedOpenGL::GetUniformProgram()
{
// program gets first dibs, if one is bound then that's where glUniform* calls go.
if(m_Program != 0)
{
return m_Program;
}
else if(m_ProgramPipeline != 0)
{
GLuint ret = 0;
// otherwise, query the active program for the pipeline (could cache this above in glActiveShaderProgram)
// we do this query every time instead of caching the result, since I think it's unlikely that we'll ever
// hit this path (most people using separable programs will use the glProgramUniform* interface).
// That way we don't pay the cost of a potentially expensive query unless we really need it.
m_Real.glGetProgramPipelineiv(m_ProgramPipeline, eGL_ACTIVE_PROGRAM, (GLint *)&ret);
return ret;
}
return 0;
}
void WrappedOpenGL::glDeleteProgramPipelines(GLsizei n, const GLuint *pipelines)
{
for(GLsizei i=0; i < n; i++)
@@ -274,7 +274,7 @@ void WrappedOpenGL::CONCAT(CONCAT(FUNCNAME, count), suffix)(FUNCPARAMS, __VA_ARG
#define FUNCNAME glUniform
#define FUNCPARAMS GLint location
#define FUNCARGPASS location
#define PROGRAM m_Program
#define PROGRAM GetUniformProgram()
#define ARRAYLIST v0
@@ -375,7 +375,7 @@ void WrappedOpenGL::CONCAT(CONCAT(FUNCNAME, unicount), CONCAT(suffix, v))(FUNCPA
#define FUNCNAME glUniform
#define FUNCPARAMS GLint location
#define FUNCARGPASS location
#define PROGRAM m_Program
#define PROGRAM GetUniformProgram()
UNIFORM_FUNC(1, f, GLfloat)
UNIFORM_FUNC(1, i, GLint)
@@ -451,7 +451,7 @@ void WrappedOpenGL::CONCAT(CONCAT(FUNCNAME, dim), suffix)(FUNCPARAMS, GLsizei co
#define FUNCNAME glUniformMatrix
#define FUNCPARAMS GLint location
#define FUNCARGPASS location
#define PROGRAM m_Program
#define PROGRAM GetUniformProgram()
UNIFORM_FUNC(2, fv, GLfloat)
UNIFORM_FUNC(2x3, fv, GLfloat)