SET_GetProgramParameterdvNV(exec, _mesa_GetProgramParameterdvNV);
SET_GetProgramivNV(exec, _mesa_GetProgramivNV);
SET_GetProgramStringNV(exec, _mesa_GetProgramStringNV);
- SET_GetTrackMatrixivNV(exec, _mesa_GetTrackMatrixivNV);
SET_GetVertexAttribdvNV(exec, _mesa_GetVertexAttribdvNV);
SET_GetVertexAttribfvNV(exec, _mesa_GetVertexAttribfvNV);
SET_GetVertexAttribivNV(exec, _mesa_GetVertexAttribivNV);
SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB); /* alias to ProgramParameter4fvNV */
SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV);
SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV);
- SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV);
SET_VertexAttribPointerNV(exec, _mesa_VertexAttribPointerNV);
/* glVertexAttrib*NV functions handled in api_loopback.c */
}
OPCODE_EXECUTE_PROGRAM_NV,
OPCODE_REQUEST_RESIDENT_PROGRAMS_NV,
OPCODE_LOAD_PROGRAM_NV,
- OPCODE_TRACK_MATRIX_NV,
/* GL_NV_fragment_program */
OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
OPCODE_PROGRAM_NAMED_PARAMETER_NV,
}
}
-
-static void GLAPIENTRY
-save_TrackMatrixNV(GLenum target, GLuint address,
- GLenum matrix, GLenum transform)
-{
- GET_CURRENT_CONTEXT(ctx);
- Node *n;
- ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
- n = alloc_instruction(ctx, OPCODE_TRACK_MATRIX_NV, 4);
- if (n) {
- n[1].e = target;
- n[2].ui = address;
- n[3].e = matrix;
- n[4].e = transform;
- }
- if (ctx->ExecuteFlag) {
- CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform));
- }
-}
-
-
/*
* GL_NV_fragment_program
*/
CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i,
(const GLubyte *) n[4].data));
break;
- case OPCODE_TRACK_MATRIX_NV:
- CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e));
- break;
case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
CALL_ProgramLocalParameter4fARB(ctx->Exec,
(n[1].e, n[2].ui, n[3].f, n[4].f,
SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV);
SET_GetProgramivNV(table, _mesa_GetProgramivNV);
SET_GetProgramStringNV(table, _mesa_GetProgramStringNV);
- SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV);
SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV);
SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV);
SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV);
SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV);
SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV);
- SET_TrackMatrixNV(table, save_TrackMatrixNV);
SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV);
/* 244. GL_ATI_envmap_bumpmap */
ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->TextureMatrixStack));
ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit];
break;
- case GL_MATRIX0_NV:
- case GL_MATRIX1_NV:
- case GL_MATRIX2_NV:
- case GL_MATRIX3_NV:
- case GL_MATRIX4_NV:
- case GL_MATRIX5_NV:
- case GL_MATRIX6_NV:
- case GL_MATRIX7_NV:
- if (ctx->API == API_OPENGL && ctx->Extensions.NV_vertex_program) {
- ctx->CurrentStack = &ctx->ProgramMatrixStack[mode - GL_MATRIX0_NV];
- }
- else {
- _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" );
- return;
- }
- break;
case GL_MATRIX0_ARB:
case GL_MATRIX1_ARB:
case GL_MATRIX2_ARB:
GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
- /* For GL_NV_vertex_program only: */
- GLenum TrackMatrix[MAX_PROGRAM_ENV_PARAMS / 4];
- GLenum TrackMatrixTransform[MAX_PROGRAM_ENV_PARAMS / 4];
-
/** Should fixed-function T&L be implemented with a vertex prog? */
GLboolean _MaintainTnlProgram;
}
}
-
-/**
- * Get matrix tracking information.
- * \note Not compiled into display lists.
- * \note Called from the GL API dispatcher.
- */
-void GLAPIENTRY
-_mesa_GetTrackMatrixivNV(GLenum target, GLuint address,
- GLenum pname, GLint *params)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (target == GL_VERTEX_PROGRAM_NV
- && ctx->Extensions.NV_vertex_program) {
- GLuint i;
-
- if ((address & 0x3) || address >= MAX_NV_VERTEX_PROGRAM_PARAMS) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetTrackMatrixivNV(address)");
- return;
- }
-
- i = address / 4;
-
- switch (pname) {
- case GL_TRACK_MATRIX_NV:
- params[0] = (GLint) ctx->VertexProgram.TrackMatrix[i];
- return;
- case GL_TRACK_MATRIX_TRANSFORM_NV:
- params[0] = (GLint) ctx->VertexProgram.TrackMatrixTransform[i];
- return;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTrackMatrixivNV");
- return;
- }
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetTrackMatrixivNV");
- return;
- }
-}
-
-
/**
* Get a vertex (or vertex array) attribute.
* \note Not compiled into display lists.
}
-
-/**
- * Setup tracking of matrices into program parameter registers.
- * \note Called from the GL API dispatcher.
- */
-void GLAPIENTRY
-_mesa_TrackMatrixNV(GLenum target, GLuint address,
- GLenum matrix, GLenum transform)
-{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- FLUSH_VERTICES(ctx, _NEW_PROGRAM);
-
- if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) {
- if (address & 0x3) {
- /* addr must be multiple of four */
- _mesa_error(ctx, GL_INVALID_VALUE, "glTrackMatrixNV(address)");
- return;
- }
-
- switch (matrix) {
- case GL_NONE:
- case GL_MODELVIEW:
- case GL_PROJECTION:
- case GL_TEXTURE:
- case GL_COLOR:
- case GL_MODELVIEW_PROJECTION_NV:
- case GL_MATRIX0_NV:
- case GL_MATRIX1_NV:
- case GL_MATRIX2_NV:
- case GL_MATRIX3_NV:
- case GL_MATRIX4_NV:
- case GL_MATRIX5_NV:
- case GL_MATRIX6_NV:
- case GL_MATRIX7_NV:
- /* OK, fallthrough */
- break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(matrix)");
- return;
- }
-
- switch (transform) {
- case GL_IDENTITY_NV:
- case GL_INVERSE_NV:
- case GL_TRANSPOSE_NV:
- case GL_INVERSE_TRANSPOSE_NV:
- /* OK, fallthrough */
- break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(transform)");
- return;
- }
-
- ctx->VertexProgram.TrackMatrix[address / 4] = matrix;
- ctx->VertexProgram.TrackMatrixTransform[address / 4] = transform;
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(target)");
- return;
- }
-}
-
-
void GLAPIENTRY
_mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
GLfloat x, GLfloat y, GLfloat z, GLfloat w)
extern void GLAPIENTRY
_mesa_GetProgramStringNV(GLuint id, GLenum pname, GLubyte *program);
-extern void GLAPIENTRY
-_mesa_GetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint *params);
-
extern void GLAPIENTRY
_mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params);
_mesa_ProgramParameters4fvNV(GLenum target, GLuint index, GLsizei num,
const GLfloat *params);
-extern void GLAPIENTRY
-_mesa_TrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform);
-
-
extern void GLAPIENTRY
_mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
GLfloat x, GLfloat y, GLfloat z, GLfloat w);
}
}
}
-
-
-/**
- * Copy the 16 elements of a matrix into four consecutive program
- * registers starting at 'pos'.
- */
-static void
-load_matrix(GLfloat registers[][4], GLuint pos, const GLfloat mat[16])
-{
- GLuint i;
- for (i = 0; i < 4; i++) {
- registers[pos + i][0] = mat[0 + i];
- registers[pos + i][1] = mat[4 + i];
- registers[pos + i][2] = mat[8 + i];
- registers[pos + i][3] = mat[12 + i];
- }
-}
-
-
-/**
- * As above, but transpose the matrix.
- */
-static void
-load_transpose_matrix(GLfloat registers[][4], GLuint pos,
- const GLfloat mat[16])
-{
- memcpy(registers[pos], mat, 16 * sizeof(GLfloat));
-}
-
-
-/**
- * Load current vertex program's parameter registers with tracked
- * matrices (if NV program). This only needs to be done per
- * glBegin/glEnd, not per-vertex.
- */
-void
-_mesa_load_tracked_matrices(struct gl_context *ctx)
-{
- GLuint i;
-
- for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS / 4; i++) {
- /* point 'mat' at source matrix */
- GLmatrix *mat;
- if (ctx->VertexProgram.TrackMatrix[i] == GL_MODELVIEW) {
- mat = ctx->ModelviewMatrixStack.Top;
- }
- else if (ctx->VertexProgram.TrackMatrix[i] == GL_PROJECTION) {
- mat = ctx->ProjectionMatrixStack.Top;
- }
- else if (ctx->VertexProgram.TrackMatrix[i] == GL_TEXTURE) {
- GLuint unit = MIN2(ctx->Texture.CurrentUnit,
- Elements(ctx->TextureMatrixStack) - 1);
- mat = ctx->TextureMatrixStack[unit].Top;
- }
- else if (ctx->VertexProgram.TrackMatrix[i]==GL_MODELVIEW_PROJECTION_NV) {
- /* XXX verify the combined matrix is up to date */
- mat = &ctx->_ModelProjectMatrix;
- }
- else if (ctx->VertexProgram.TrackMatrix[i] >= GL_MATRIX0_NV &&
- ctx->VertexProgram.TrackMatrix[i] <= GL_MATRIX7_NV) {
- GLuint n = ctx->VertexProgram.TrackMatrix[i] - GL_MATRIX0_NV;
- ASSERT(n < Elements(ctx->ProgramMatrixStack));
- mat = ctx->ProgramMatrixStack[n].Top;
- }
- else {
- /* no matrix is tracked, but we leave the register values as-is */
- assert(ctx->VertexProgram.TrackMatrix[i] == GL_NONE);
- continue;
- }
-
- /* load the matrix values into sequential registers */
- if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_IDENTITY_NV) {
- load_matrix(ctx->VertexProgram.Parameters, i*4, mat->m);
- }
- else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_INVERSE_NV) {
- _math_matrix_analyse(mat); /* update the inverse */
- ASSERT(!_math_matrix_is_dirty(mat));
- load_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv);
- }
- else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_TRANSPOSE_NV) {
- load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->m);
- }
- else {
- assert(ctx->VertexProgram.TrackMatrixTransform[i]
- == GL_INVERSE_TRANSPOSE_NV);
- _math_matrix_analyse(mat); /* update the inverse */
- ASSERT(!_math_matrix_is_dirty(mat));
- load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv);
- }
- }
-}
_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]);
-extern void
-_mesa_load_tracked_matrices(struct gl_context *ctx);
-
#ifdef __cplusplus
}
void
_mesa_init_program(struct gl_context *ctx)
{
- GLuint i;
-
/*
* If this assertion fails, we need to increase the field
* size for register indexes (see INST_INDEX_BITS).
_mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current,
ctx->Shared->DefaultVertexProgram);
assert(ctx->VertexProgram.Current);
- for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS / 4; i++) {
- ctx->VertexProgram.TrackMatrix[i] = GL_NONE;
- ctx->VertexProgram.TrackMatrixTransform[i] = GL_IDENTITY_NV;
- }
ctx->VertexProgram.Cache = _mesa_new_program_cache();
ctx->FragmentProgram.Enabled = GL_FALSE;
if (!program)
return GL_TRUE;
- if (program->IsNVProgram) {
- _mesa_load_tracked_matrices(ctx);
- }
- else {
- /* ARB program or vertex shader */
- _mesa_load_state_parameters(ctx, program->Base.Parameters);
- }
+ /* ARB program or vertex shader */
+ _mesa_load_state_parameters(ctx, program->Base.Parameters);
/* make list of outputs to save some time below */
numOutputs = 0;
GLuint max_index,
struct gl_transform_feedback_object *tfb_vertcount );
-extern void
-_mesa_load_tracked_matrices(struct gl_context *ctx);
-
extern void
_tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4]);