📄 state.c
字号:
SET_GetBufferSubDataARB(exec, _mesa_GetBufferSubDataARB);
SET_IsBufferARB(exec, _mesa_IsBufferARB);
SET_MapBufferARB(exec, _mesa_MapBufferARB);
SET_UnmapBufferARB(exec, _mesa_UnmapBufferARB);
#endif
/* ARB 29. GL_ARB_occlusion_query */
#if FEATURE_ARB_occlusion_query
SET_GenQueriesARB(exec, _mesa_GenQueriesARB);
SET_DeleteQueriesARB(exec, _mesa_DeleteQueriesARB);
SET_IsQueryARB(exec, _mesa_IsQueryARB);
SET_BeginQueryARB(exec, _mesa_BeginQueryARB);
SET_EndQueryARB(exec, _mesa_EndQueryARB);
SET_GetQueryivARB(exec, _mesa_GetQueryivARB);
SET_GetQueryObjectivARB(exec, _mesa_GetQueryObjectivARB);
SET_GetQueryObjectuivARB(exec, _mesa_GetQueryObjectuivARB);
#endif
/* ARB 37. GL_ARB_draw_buffers */
SET_DrawBuffersARB(exec, _mesa_DrawBuffersARB);
#if FEATURE_ARB_shader_objects
SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB);
SET_GetHandleARB(exec, _mesa_GetHandleARB);
SET_DetachObjectARB(exec, _mesa_DetachObjectARB);
SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB);
SET_ShaderSourceARB(exec, _mesa_ShaderSourceARB);
SET_CompileShaderARB(exec, _mesa_CompileShaderARB);
SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB);
SET_AttachObjectARB(exec, _mesa_AttachObjectARB);
SET_LinkProgramARB(exec, _mesa_LinkProgramARB);
SET_UseProgramObjectARB(exec, _mesa_UseProgramObjectARB);
SET_ValidateProgramARB(exec, _mesa_ValidateProgramARB);
SET_Uniform1fARB(exec, _mesa_Uniform1fARB);
SET_Uniform2fARB(exec, _mesa_Uniform2fARB);
SET_Uniform3fARB(exec, _mesa_Uniform3fARB);
SET_Uniform4fARB(exec, _mesa_Uniform4fARB);
SET_Uniform1iARB(exec, _mesa_Uniform1iARB);
SET_Uniform2iARB(exec, _mesa_Uniform2iARB);
SET_Uniform3iARB(exec, _mesa_Uniform3iARB);
SET_Uniform4iARB(exec, _mesa_Uniform4iARB);
SET_Uniform1fvARB(exec, _mesa_Uniform1fvARB);
SET_Uniform2fvARB(exec, _mesa_Uniform2fvARB);
SET_Uniform3fvARB(exec, _mesa_Uniform3fvARB);
SET_Uniform4fvARB(exec, _mesa_Uniform4fvARB);
SET_Uniform1ivARB(exec, _mesa_Uniform1ivARB);
SET_Uniform2ivARB(exec, _mesa_Uniform2ivARB);
SET_Uniform3ivARB(exec, _mesa_Uniform3ivARB);
SET_Uniform4ivARB(exec, _mesa_Uniform4ivARB);
SET_UniformMatrix2fvARB(exec, _mesa_UniformMatrix2fvARB);
SET_UniformMatrix3fvARB(exec, _mesa_UniformMatrix3fvARB);
SET_UniformMatrix4fvARB(exec, _mesa_UniformMatrix4fvARB);
SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB);
SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB);
SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB);
SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB);
SET_GetUniformLocationARB(exec, _mesa_GetUniformLocationARB);
SET_GetActiveUniformARB(exec, _mesa_GetActiveUniformARB);
SET_GetUniformfvARB(exec, _mesa_GetUniformfvARB);
SET_GetUniformivARB(exec, _mesa_GetUniformivARB);
SET_GetShaderSourceARB(exec, _mesa_GetShaderSourceARB);
#endif /* FEATURE_ARB_shader_objects */
#if FEATURE_ARB_vertex_shader
SET_BindAttribLocationARB(exec, _mesa_BindAttribLocationARB);
SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB);
SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB);
#endif /* FEATURE_ARB_vertex_shader */
/* GL_ATI_fragment_shader */
#if FEATURE_ATI_fragment_shader
SET_GenFragmentShadersATI(exec, _mesa_GenFragmentShadersATI);
SET_BindFragmentShaderATI(exec, _mesa_BindFragmentShaderATI);
SET_DeleteFragmentShaderATI(exec, _mesa_DeleteFragmentShaderATI);
SET_BeginFragmentShaderATI(exec, _mesa_BeginFragmentShaderATI);
SET_EndFragmentShaderATI(exec, _mesa_EndFragmentShaderATI);
SET_PassTexCoordATI(exec, _mesa_PassTexCoordATI);
SET_SampleMapATI(exec, _mesa_SampleMapATI);
SET_ColorFragmentOp1ATI(exec, _mesa_ColorFragmentOp1ATI);
SET_ColorFragmentOp2ATI(exec, _mesa_ColorFragmentOp2ATI);
SET_ColorFragmentOp3ATI(exec, _mesa_ColorFragmentOp3ATI);
SET_AlphaFragmentOp1ATI(exec, _mesa_AlphaFragmentOp1ATI);
SET_AlphaFragmentOp2ATI(exec, _mesa_AlphaFragmentOp2ATI);
SET_AlphaFragmentOp3ATI(exec, _mesa_AlphaFragmentOp3ATI);
SET_SetFragmentShaderConstantATI(exec, _mesa_SetFragmentShaderConstantATI);
#endif
#if FEATURE_EXT_framebuffer_object
SET_IsRenderbufferEXT(exec, _mesa_IsRenderbufferEXT);
SET_BindRenderbufferEXT(exec, _mesa_BindRenderbufferEXT);
SET_DeleteRenderbuffersEXT(exec, _mesa_DeleteRenderbuffersEXT);
SET_GenRenderbuffersEXT(exec, _mesa_GenRenderbuffersEXT);
SET_RenderbufferStorageEXT(exec, _mesa_RenderbufferStorageEXT);
SET_GetRenderbufferParameterivEXT(exec, _mesa_GetRenderbufferParameterivEXT);
SET_IsFramebufferEXT(exec, _mesa_IsFramebufferEXT);
SET_BindFramebufferEXT(exec, _mesa_BindFramebufferEXT);
SET_DeleteFramebuffersEXT(exec, _mesa_DeleteFramebuffersEXT);
SET_GenFramebuffersEXT(exec, _mesa_GenFramebuffersEXT);
SET_CheckFramebufferStatusEXT(exec, _mesa_CheckFramebufferStatusEXT);
SET_FramebufferTexture1DEXT(exec, _mesa_FramebufferTexture1DEXT);
SET_FramebufferTexture2DEXT(exec, _mesa_FramebufferTexture2DEXT);
SET_FramebufferTexture3DEXT(exec, _mesa_FramebufferTexture3DEXT);
SET_FramebufferRenderbufferEXT(exec, _mesa_FramebufferRenderbufferEXT);
SET_GetFramebufferAttachmentParameterivEXT(exec, _mesa_GetFramebufferAttachmentParameterivEXT);
SET_GenerateMipmapEXT(exec, _mesa_GenerateMipmapEXT);
#endif
}
/**********************************************************************/
/** \name State update logic */
/*@{*/
static void
update_separate_specular( GLcontext *ctx )
{
if (NEED_SECONDARY_COLOR(ctx))
ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
else
ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
}
/**
* Update state dependent on vertex arrays.
*/
static void
update_arrays( GLcontext *ctx )
{
GLuint i, min;
/* find min of _MaxElement values for all enabled arrays */
/* 0 */
if (ctx->VertexProgram._Enabled
&& ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled) {
min = ctx->Array.VertexAttrib[VERT_ATTRIB_POS]._MaxElement;
}
else if (ctx->Array.Vertex.Enabled) {
min = ctx->Array.Vertex._MaxElement;
}
else {
/* can't draw anything without vertex positions! */
min = 0;
}
/* 1 */
if (ctx->VertexProgram._Enabled
&& ctx->Array.VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) {
min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_WEIGHT]._MaxElement);
}
/* no conventional vertex weight array */
/* 2 */
if (ctx->VertexProgram._Enabled
&& ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL]._MaxElement);
}
else if (ctx->Array.Normal.Enabled) {
min = MIN2(min, ctx->Array.Normal._MaxElement);
}
/* 3 */
if (ctx->VertexProgram._Enabled
&& ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR0]._MaxElement);
}
else if (ctx->Array.Color.Enabled) {
min = MIN2(min, ctx->Array.Color._MaxElement);
}
/* 4 */
if (ctx->VertexProgram._Enabled
&& ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR1]._MaxElement);
}
else if (ctx->Array.SecondaryColor.Enabled) {
min = MIN2(min, ctx->Array.SecondaryColor._MaxElement);
}
/* 5 */
if (ctx->VertexProgram._Enabled
&& ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_FOG]._MaxElement);
}
else if (ctx->Array.FogCoord.Enabled) {
min = MIN2(min, ctx->Array.FogCoord._MaxElement);
}
/* 6 */
if (ctx->VertexProgram._Enabled
&& ctx->Array.VertexAttrib[VERT_ATTRIB_SIX].Enabled) {
min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_SIX]._MaxElement);
}
/* 7 */
if (ctx->VertexProgram._Enabled
&& ctx->Array.VertexAttrib[VERT_ATTRIB_SEVEN].Enabled) {
min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_SEVEN]._MaxElement);
}
/* 8..15 */
for (i = VERT_ATTRIB_TEX0; i < VERT_ATTRIB_MAX; i++) {
if (ctx->VertexProgram._Enabled
&& ctx->Array.VertexAttrib[i].Enabled) {
min = MIN2(min, ctx->Array.VertexAttrib[i]._MaxElement);
}
else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits
&& ctx->Array.TexCoord[i - VERT_ATTRIB_TEX0].Enabled) {
min = MIN2(min, ctx->Array.TexCoord[i - VERT_ATTRIB_TEX0]._MaxElement);
}
}
if (ctx->Array.Index.Enabled) {
min = MIN2(min, ctx->Array.Index._MaxElement);
}
if (ctx->Array.EdgeFlag.Enabled) {
min = MIN2(min, ctx->Array.EdgeFlag._MaxElement);
}
/* _MaxElement is one past the last legal array element */
ctx->Array._MaxElement = min;
}
/**
* Update derived vertex/fragment program state.
*/
static void
update_program(GLcontext *ctx)
{
/* For now, just set the _Enabled (really enabled) flags.
* In the future we may have to check other state to be sure we really
* have a runable program or shader.
*/
ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
&& ctx->VertexProgram.Current->Instructions;
ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
&& ctx->FragmentProgram.Current->Instructions;
ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
&& ctx->ATIFragmentShader.Current->Instructions;
ctx->FragmentProgram._Current = ctx->FragmentProgram.Current;
ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled;
if (ctx->_MaintainTexEnvProgram && !ctx->FragmentProgram._Enabled) {
if (!ctx->_TexEnvProgram)
ctx->_TexEnvProgram = (struct fragment_program *)
ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
ctx->FragmentProgram._Current = ctx->_TexEnvProgram;
ctx->FragmentProgram._Active = GL_TRUE;
}
}
/**
* If __GLcontextRec::NewState is non-zero then this function \b must be called
* before rendering any primitive. Basically, function pointers and
* miscellaneous flags are updated to reflect the current state of the state
* machine.
*
* Calls dd_function_table::UpdateState to perform any internal state
* management necessary.
*
* \sa _mesa_update_modelview_project(), _mesa_update_texture(),
* _mesa_update_buffer_bounds(), _mesa_update_polygon(),
* _mesa_update_lighting() and _mesa_update_tnl_spaces().
*/
void
_mesa_update_state( GLcontext *ctx )
{
GLuint new_state = ctx->NewState;
if (MESA_VERBOSE & VERBOSE_STATE)
_mesa_print_state("_mesa_update_state", new_state);
if (new_state & _NEW_PROGRAM)
update_program( ctx );
if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
_mesa_update_modelview_project( ctx, new_state );
if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX))
_mesa_update_texture( ctx, new_state );
if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL))
_mesa_update_framebuffer(ctx);
if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
_mesa_update_draw_buffer_bounds( ctx );
if (new_state & _NEW_POINT)
_mesa_update_point( ctx );
if (new_state & _NEW_POLYGON)
_mesa_update_polygon( ctx );
if (new_state & _NEW_LIGHT)
_mesa_update_lighting( ctx );
if (new_state & _IMAGE_NEW_TRANSFER_STATE)
_mesa_update_pixel( ctx, new_state );
if (new_state & _DD_NEW_SEPARATE_SPECULAR)
update_separate_specular( ctx );
if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
update_arrays( ctx );
if (ctx->_MaintainTexEnvProgram) {
if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG))
_mesa_UpdateTexEnvProgram(ctx);
}
/* ctx->_NeedEyeCoords is now up to date.
*
* If the truth value of this variable has changed, update for the
* new lighting space and recompute the positions of lights and the
* normal transform.
*
* If the lighting space hasn't changed, may still need to recompute
* light positions & normal transforms for other reasons.
*/
if (new_state & _MESA_NEW_NEED_EYE_COORDS)
_mesa_update_tnl_spaces( ctx, new_state );
/*
* Give the driver a chance to act upon the new_state flags.
* The driver might plug in different span functions, for example.
* Also, this is where the driver can invalidate the state of any
* active modules (such as swrast_setup, swrast, tnl, etc).
*
* Set ctx->NewState to zero to avoid recursion if
* Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?)
*/
new_state = ctx->NewState;
ctx->NewState = 0;
ctx->Driver.UpdateState(ctx, new_state);
ctx->Array.NewState = 0;
}
/*@}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -