#include "glheader.h"
+#include "arbprogram.h"
#include "context.h"
#include "hash.h"
#include "imports.h"
#include "macros.h"
#include "mtypes.h"
#include "nvprogram.h"
-#include "arbprogram.h"
+#include "nvfragprog.h"
+#include "nvvertprog.h"
/* XXX temporary */
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
return;
}
- index += MAX_NV_FRAGMENT_PROGRAM_TEMPS; /* XXX fix */
+ index += FP_PROG_REG_START;
ASSIGN_4V(ctx->FragmentProgram.Machine.Registers[index], x, y, z, w);
}
if (target == GL_VERTEX_PROGRAM_ARB
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
return;
}
- index += MAX_NV_VERTEX_PROGRAM_TEMPS; /* XXX fix */
+ index += VP_PROG_REG_START;
ASSIGN_4V(ctx->VertexProgram.Machine.Registers[index], x, y, z, w);
}
else {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
return;
}
- index += MAX_NV_FRAGMENT_PROGRAM_TEMPS; /* XXX fix */
+ index += FP_PROG_REG_START;
COPY_4V(params, ctx->FragmentProgram.Machine.Registers[index]);
}
if (target == GL_VERTEX_PROGRAM_ARB
_mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
return;
}
- index += MAX_NV_VERTEX_PROGRAM_TEMPS; /* XXX fix */
+ index += VP_PROG_REG_START;
COPY_4V(params, ctx->VertexProgram.Machine.Registers[index]);
}
else {
GLfloat x, GLfloat y, GLfloat z, GLfloat w)
{
GET_CURRENT_CONTEXT(ctx);
+ struct program *prog;
ASSERT_OUTSIDE_BEGIN_END(ctx);
if ((target == GL_FRAGMENT_PROGRAM_NV
&& ctx->Extensions.NV_fragment_program) ||
(target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program)) {
- struct fragment_program *fprog = ctx->FragmentProgram.Current;
- if (!fprog) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB");
- return;
- }
if (index >= ctx->Const.MaxFragmentProgramLocalParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
return;
}
- fprog->Base.LocalParams[index][0] = x;
- fprog->Base.LocalParams[index][1] = y;
- fprog->Base.LocalParams[index][2] = z;
- fprog->Base.LocalParams[index][3] = w;
+ prog = &(ctx->FragmentProgram.Current->Base);
}
else if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
- struct vertex_program *vprog = ctx->VertexProgram.Current;
- if (!vprog) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB");
- return;
- }
if (index >= ctx->Const.MaxVertexProgramLocalParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
return;
}
- vprog->Base.LocalParams[index][0] = x;
- vprog->Base.LocalParams[index][1] = y;
- vprog->Base.LocalParams[index][2] = z;
- vprog->Base.LocalParams[index][3] = w;
+ prog = &(ctx->VertexProgram.Current->Base);
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB");
return;
}
+
+ ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
+ prog->LocalParams[index][0] = x;
+ prog->LocalParams[index][1] = y;
+ prog->LocalParams[index][2] = z;
+ prog->LocalParams[index][3] = w;
}
}
ASSERT(prog);
+ ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
COPY_4V(params, prog->LocalParams[index]);
}
/* Maximum color matrix stack depth: */
#define MAX_COLOR_STACK_DEPTH 4
-/* Vertex program matrix stacks: */
-#define MAX_PROGRAM_MATRICES 8
-#define MAX_PROGRAM_STACK_DEPTH 4
-
/* Maximum attribute stack depth: */
#define MAX_ATTRIB_STACK_DEPTH 16
#define MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS 24
#define MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS 4
+/* Any program target/extension */
+#define MAX_PROGRAM_LOCAL_PARAMS 96
+#define MAX_PROGRAM_MATRICES 8
+#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4
+
+
+
/*
* Mesa-specific parameters
-/* $Id: context.c,v 1.199 2003/04/17 01:48:20 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
ctx->Const.MaxFragmentProgramTexInstructions = MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS;
ctx->Const.MaxFragmentProgramTexIndirections = MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS;
#endif
+ ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES;
+ ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
/* Initialize matrix stacks */
init_matrix_stack(&ctx->TextureMatrixStack[i], MAX_TEXTURE_STACK_DEPTH,
_NEW_TEXTURE_MATRIX);
for (i = 0; i < MAX_PROGRAM_MATRICES; i++)
- init_matrix_stack(&ctx->ProgramMatrixStack[i], MAX_PROGRAM_STACK_DEPTH,
- _NEW_TRACK_MATRIX);
+ init_matrix_stack(&ctx->ProgramMatrixStack[i],
+ MAX_PROGRAM_MATRIX_STACK_DEPTH, _NEW_TRACK_MATRIX);
ctx->CurrentStack = &ctx->ModelviewMatrixStack;
/* Init combined Modelview*Projection matrix */
break;
case GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV:
CHECK_EXTENSION_B(NV_vertex_program, pname);
- *params = (MAX_PROGRAM_STACK_DEPTH > 0) ? GL_TRUE : GL_FALSE;
+ *params = (ctx->Const.MaxProgramMatrixStackDepth > 0) ? GL_TRUE : GL_FALSE;
break;
case GL_MAX_TRACK_MATRICES_NV:
CHECK_EXTENSION_B(NV_vertex_program, pname);
- *params = (MAX_PROGRAM_MATRICES > 0) ? GL_TRUE : GL_FALSE;
+ *params = (ctx->Const.MaxProgramMatrices > 0) ? GL_TRUE : GL_FALSE;
break;
case GL_CURRENT_MATRIX_STACK_DEPTH_NV:
CHECK_EXTENSION_B(NV_vertex_program, pname);
break;
case GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV:
CHECK_EXTENSION_D(NV_vertex_program, pname);
- *params = (GLdouble) MAX_PROGRAM_STACK_DEPTH;
+ *params = (GLdouble) ctx->Const.MaxProgramMatrixStackDepth;
break;
case GL_MAX_TRACK_MATRICES_NV:
CHECK_EXTENSION_D(NV_vertex_program, pname);
- *params = (GLdouble) MAX_PROGRAM_MATRICES;
+ *params = (GLdouble) ctx->Const.MaxProgramMatrices;
break;
case GL_CURRENT_MATRIX_STACK_DEPTH_NV:
CHECK_EXTENSION_D(NV_vertex_program, pname);
break;
case GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV:
CHECK_EXTENSION_F(NV_vertex_program, pname);
- *params = (GLfloat) MAX_PROGRAM_STACK_DEPTH;
+ *params = (GLfloat) ctx->Const.MaxProgramMatrixStackDepth;
break;
case GL_MAX_TRACK_MATRICES_NV:
CHECK_EXTENSION_F(NV_vertex_program, pname);
- *params = (GLfloat) MAX_PROGRAM_MATRICES;
+ *params = (GLfloat) ctx->Const.MaxProgramMatrices;
break;
case GL_CURRENT_MATRIX_STACK_DEPTH_NV:
CHECK_EXTENSION_F(NV_vertex_program, pname);
break;
case GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV:
CHECK_EXTENSION_I(NV_vertex_program, pname);
- *params = MAX_PROGRAM_STACK_DEPTH;
+ *params = ctx->Const.MaxProgramMatrixStackDepth;
break;
case GL_MAX_TRACK_MATRICES_NV:
CHECK_EXTENSION_I(NV_vertex_program, pname);
- *params = MAX_PROGRAM_MATRICES;
+ *params = ctx->Const.MaxProgramMatrices;
break;
case GL_CURRENT_MATRIX_STACK_DEPTH_NV:
CHECK_EXTENSION_I(NV_vertex_program, pname);
-/* $Id: matrix.c,v 1.46 2003/03/01 01:50:21 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
* Version: 5.1
case GL_MATRIX5_NV:
case GL_MATRIX6_NV:
case GL_MATRIX7_NV:
- if (!ctx->Extensions.NV_vertex_program) {
- _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode" );
+ if (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:
+ case GL_MATRIX3_ARB:
+ case GL_MATRIX4_ARB:
+ case GL_MATRIX5_ARB:
+ case GL_MATRIX6_ARB:
+ case GL_MATRIX7_ARB:
+ if (ctx->Extensions.ARB_vertex_program ||
+ ctx->Extensions.ARB_fragment_program) {
+ const GLint m = mode - GL_MATRIX0_ARB;
+ if (m > ctx->Const.MaxProgramMatrices) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glMatrixMode(GL_MATRIX%d_ARB)", m);
+ return;
+ }
+ ctx->CurrentStack = &ctx->ProgramMatrixStack[m];
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" );
return;
}
- ctx->CurrentStack = &ctx->ProgramMatrixStack[mode - GL_MATRIX0_NV];
break;
default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode" );
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" );
return;
}
GLenum Format; /* String encoding format */
GLint RefCount;
GLboolean Resident;
- GLfloat LocalParams[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4];
+ GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];
GLuint NumInstructions; /* GL_ARB_vertex/fragment_program */
GLuint NumTemporaries;
GLuint NumParameters;
GLuint MaxFragmentProgramAluInstructions;
GLuint MaxFragmentProgramTexInstructions;
GLuint MaxFragmentProgramTexIndirections;
+ /* vertex or fragment program */
+ GLuint MaxProgramMatrices;
+ GLuint MaxProgramMatrixStackDepth;
};