diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/main/arbprogram.c | 40 | ||||
-rw-r--r-- | src/mesa/main/config.h | 11 | ||||
-rw-r--r-- | src/mesa/main/context.c | 8 | ||||
-rw-r--r-- | src/mesa/main/get.c | 16 | ||||
-rw-r--r-- | src/mesa/main/matrix.c | 35 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 5 |
6 files changed, 69 insertions, 46 deletions
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c index 639a4d33a3e..fd5abf0a93d 100644 --- a/src/mesa/main/arbprogram.c +++ b/src/mesa/main/arbprogram.c @@ -30,13 +30,15 @@ #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 */ @@ -554,7 +556,7 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, _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 @@ -563,7 +565,7 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index, _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 { @@ -612,7 +614,7 @@ _mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index, _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 @@ -621,7 +623,7 @@ _mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index, _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 { @@ -639,46 +641,37 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index, 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; } @@ -760,6 +753,7 @@ _mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index, } ASSERT(prog); + ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS); COPY_4V(params, prog->LocalParams[index]); } diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index f537a539e6d..e7e8e541382 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -53,10 +53,6 @@ /* 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 @@ -174,6 +170,13 @@ #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 diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 88dea9e1db5..c8d21e471bc 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,5 +1,3 @@ -/* $Id: context.c,v 1.199 2003/04/17 01:48:20 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -1007,6 +1005,8 @@ init_attrib_groups( GLcontext *ctx ) 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 */ @@ -1020,8 +1020,8 @@ init_attrib_groups( GLcontext *ctx ) 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 */ diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index c7d21d84945..65c41065cf9 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1371,11 +1371,11 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) 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); @@ -2859,11 +2859,11 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) 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); @@ -4321,11 +4321,11 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) 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); @@ -5821,11 +5821,11 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) 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); diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c index af046a3c8f0..83d2ff425ee 100644 --- a/src/mesa/main/matrix.c +++ b/src/mesa/main/matrix.c @@ -1,5 +1,3 @@ -/* $Id: matrix.c,v 1.46 2003/03/01 01:50:21 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 5.1 @@ -132,14 +130,39 @@ _mesa_MatrixMode( GLenum mode ) 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; } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index e931f49de88..edea218095f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1240,7 +1240,7 @@ struct program 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; @@ -1424,6 +1424,9 @@ struct gl_constants { GLuint MaxFragmentProgramAluInstructions; GLuint MaxFragmentProgramTexInstructions; GLuint MaxFragmentProgramTexIndirections; + /* vertex or fragment program */ + GLuint MaxProgramMatrices; + GLuint MaxProgramMatrixStackDepth; }; |