mesa: new _NEW_PROGRAM_CONSTANTS flag
This state flag will be used to indicate that vertex/fragment program constants have changed. _NEW_PROGRAM will be used to indicate changes to the vertex/fragment shader itself, or misc related state. _NEW_PROGRAM_CONSTANTS is also set whenever a program parameter that's tracking GL state has changed. For example, if the projection matrix is in the parameter list, calling glFrustum() will cause _NEW_PROGRAM_CONSTANTS to be set. This will let to remove the need for dynamic state atoms in some drivers. For now, we still set _NEW_PROGRAM in all the places we used to. We'll no longer set _NEW_PROGRAM in glUniform() after drivers/etc have been updated.
This commit is contained in:
parent
8a22e24fae
commit
64e331eb52
|
@ -2615,6 +2615,7 @@ struct gl_matrix_stack
|
|||
#define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
|
||||
#define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
|
||||
#define _NEW_CURRENT_ATTRIB 0x10000000 /**< __GLcontextRec::Current */
|
||||
#define _NEW_PROGRAM_CONSTANTS 0x20000000
|
||||
#define _NEW_ALL ~0
|
||||
/*@}*/
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "pixel.h"
|
||||
#endif
|
||||
#include "shader/program.h"
|
||||
#include "shader/prog_parameter.h"
|
||||
#include "state.h"
|
||||
#include "stencil.h"
|
||||
#include "texenvprogram.h"
|
||||
|
@ -303,6 +304,36 @@ update_program(GLcontext *ctx)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0.
|
||||
*/
|
||||
static GLbitfield
|
||||
update_program_constants(GLcontext *ctx)
|
||||
{
|
||||
GLbitfield new_state = 0x0;
|
||||
|
||||
if (ctx->FragmentProgram._Current) {
|
||||
const struct gl_program_parameter_list *params =
|
||||
ctx->FragmentProgram._Current->Base.Parameters;
|
||||
if (params && params->StateFlags & ctx->NewState) {
|
||||
new_state |= _NEW_PROGRAM_CONSTANTS;
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->VertexProgram._Current) {
|
||||
const struct gl_program_parameter_list *params =
|
||||
ctx->VertexProgram._Current->Base.Parameters;
|
||||
if (params && params->StateFlags & ctx->NewState) {
|
||||
new_state |= _NEW_PROGRAM_CONSTANTS;
|
||||
}
|
||||
}
|
||||
|
||||
return new_state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
update_viewport_matrix(GLcontext *ctx)
|
||||
{
|
||||
|
@ -554,6 +585,10 @@ _mesa_update_state_locked( GLcontext *ctx )
|
|||
new_prog_state |= update_program( ctx );
|
||||
}
|
||||
|
||||
|
||||
out:
|
||||
new_prog_state |= update_program_constants(ctx);
|
||||
|
||||
/*
|
||||
* Give the driver a chance to act upon the new_state flags.
|
||||
* The driver might plug in different span functions, for example.
|
||||
|
@ -563,7 +598,6 @@ _mesa_update_state_locked( GLcontext *ctx )
|
|||
* Set ctx->NewState to zero to avoid recursion if
|
||||
* Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?)
|
||||
*/
|
||||
out:
|
||||
new_state = ctx->NewState | new_prog_state;
|
||||
ctx->NewState = 0;
|
||||
ctx->Driver.UpdateState(ctx, new_state);
|
||||
|
|
|
@ -489,7 +489,7 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
|
|||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
|
||||
|
||||
if (target == GL_FRAGMENT_PROGRAM_ARB
|
||||
&& ctx->Extensions.ARB_fragment_program) {
|
||||
|
@ -537,7 +537,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
|
|||
GLfloat * dest;
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
|
||||
|
||||
if (count <= 0) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameters4fv(count)");
|
||||
|
@ -595,8 +595,6 @@ _mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index,
|
|||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
|
||||
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
if (target == GL_FRAGMENT_PROGRAM_ARB
|
||||
|
@ -633,7 +631,7 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
|
|||
struct gl_program *prog;
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
|
||||
|
||||
if ((target == GL_FRAGMENT_PROGRAM_NV
|
||||
&& ctx->Extensions.NV_fragment_program) ||
|
||||
|
@ -687,7 +685,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
|
|||
GLint i;
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
|
||||
|
||||
if (count <= 0) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fv(count)");
|
||||
|
|
|
@ -706,7 +706,7 @@ _mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
|
|||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
|
||||
|
||||
prog = _mesa_lookup_program(ctx, id);
|
||||
if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) {
|
||||
|
|
|
@ -1789,7 +1789,7 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
|
|||
return;
|
||||
}
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
|
||||
|
||||
uniform = &shProg->Uniforms->Uniforms[location];
|
||||
|
||||
|
@ -1929,7 +1929,7 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
|
|||
return;
|
||||
}
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
|
||||
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
|
||||
|
||||
uniform = &shProg->Uniforms->Uniforms[location];
|
||||
|
||||
|
|
Loading…
Reference in New Issue