diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c index fa2ff4306b4..1fc0d39f8bd 100644 --- a/src/mesa/main/dlist.c +++ b/src/mesa/main/dlist.c @@ -269,6 +269,10 @@ typedef enum { OPCODE_ACTIVE_STENCIL_FACE_EXT, /* GL_EXT_depth_bounds_test */ OPCODE_DEPTH_BOUNDS_EXT, + /* GL_ARB_vertex/fragment_program */ + OPCODE_PROGRAM_STRING_ARB, + OPCODE_PROGRAM_ENV_PARAMETER_ARB, + /* The following three are meta instructions */ OPCODE_ERROR, /* raise compiled-in error */ OPCODE_CONTINUE, @@ -440,17 +444,23 @@ void _mesa_destroy_list( GLcontext *ctx, GLuint list ) break; #if FEATURE_NV_vertex_program case OPCODE_LOAD_PROGRAM_NV: - FREE(n[4].data); + FREE(n[4].data); /* program string */ n += InstSize[n[0].opcode]; break; case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV: - FREE(n[2].data); + FREE(n[2].data); /* array of program ids */ n += InstSize[n[0].opcode]; break; #endif #if FEATURE_NV_fragment_program case OPCODE_PROGRAM_NAMED_PARAMETER_NV: - FREE(n[3].data); + FREE(n[3].data); /* parameter name */ + n += InstSize[n[0].opcode]; + break; +#endif +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_PROGRAM_STRING_ARB: + FREE(n[4].data); /* program string */ n += InstSize[n[0].opcode]; break; #endif @@ -685,6 +695,10 @@ void _mesa_init_lists( void ) InstSize[OPCODE_ACTIVE_STENCIL_FACE_EXT] = 2; /* GL_EXT_depth_bounds_test */ InstSize[OPCODE_DEPTH_BOUNDS_EXT] = 3; +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + InstSize[OPCODE_PROGRAM_STRING_ARB] = 5; + InstSize[OPCODE_PROGRAM_ENV_PARAMETER_ARB] = 7; +#endif } init_flag = 1; } @@ -4398,6 +4412,94 @@ static void save_DepthBoundsEXT( GLclampd zmin, GLclampd zmax ) +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + +static void +save_ProgramStringARB(GLenum target, GLenum format, GLsizei len, + const GLvoid *string) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + GLubyte *programCopy; + + programCopy = (GLubyte *) _mesa_malloc(len); + if (!programCopy) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); + return; + } + _mesa_memcpy(programCopy, string, len); + + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_STRING_ARB, 4 ); + if (n) { + n[1].e = target; + n[2].e = format; + n[3].i = len; + n[4].data = programCopy; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->ProgramStringARB)(target, format, len, string); + } +} + + +static void +save_ProgramEnvParameter4fARB(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx); + n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6 ); + if (n) { + n[1].e = target; + n[2].ui = index; + n[3].f = x; + n[4].f = y; + n[5].f = z; + n[6].f = w; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->ProgramEnvParameter4fARB)( target, index, x, y, z, w); + } +} + + +static void +save_ProgramEnvParameter4fvARB(GLenum target, GLuint index, + const GLfloat *params) +{ + save_ProgramEnvParameter4fARB(target, index, params[0], params[1], + params[2], params[3]); +} + + +static void +save_ProgramEnvParameter4dARB(GLenum target, GLuint index, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + save_ProgramEnvParameter4fARB(target, index, + (GLfloat) x, + (GLfloat) y, + (GLfloat) z, + (GLfloat) w); +} + + +static void +save_ProgramEnvParameter4dvARB(GLenum target, GLuint index, + const GLdouble *params) +{ + save_ProgramEnvParameter4fARB(target, index, + (GLfloat) params[0], + (GLfloat) params[1], + (GLfloat) params[2], + (GLfloat) params[3]); +} + +#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */ + + /* KW: Compile commands * @@ -5145,7 +5247,15 @@ execute_list( GLcontext *ctx, GLuint list ) case OPCODE_DEPTH_BOUNDS_EXT: (*ctx->Exec->DepthBoundsEXT)(n[1].f, n[2].f); break; - +#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program + case OPCODE_PROGRAM_STRING_ARB: + (*ctx->Exec->ProgramStringARB)(n[1].e, n[2].e, n[3].i, n[4].data); + break; + case OPCODE_PROGRAM_ENV_PARAMETER_ARB: + (*ctx->Exec->ProgramEnvParameter4fARB)(n[1].e, n[2].ui, n[3].f, + n[4].f, n[5].f, n[6].f); + break; +#endif case OPCODE_CONTINUE: n = (Node *) n[1].next; break; @@ -6129,8 +6239,9 @@ static void exec_MultiModeDrawElementsIBM(const GLenum *mode, -/* - * Assign all the pointers in