summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-11-01 04:36:33 +0000
committerBrian Paul <[email protected]>2005-11-01 04:36:33 +0000
commit05051037101dfa053798cf5ad91d1975fd1aa6a7 (patch)
tree0cf21bc55a1c006a6f7fa99d7613e73428598fee
parentffec105109f5b16bfe8282bd477d4aa32b550015 (diff)
Re-org and clean-up of vertx/fragment program limits (instructions,
temporaries, parameters, etc). glGetProgramivARB() now returns all the right things. Updated i915 and r300 code to initialize program native limits and current program's native instruction/temporary/etc counts.
-rw-r--r--src/mesa/drivers/dri/i915/i915_context.c17
-rw-r--r--src/mesa/drivers/dri/i915/i915_program.c18
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.c32
-rw-r--r--src/mesa/main/config.h2
-rw-r--r--src/mesa/main/context.c58
-rw-r--r--src/mesa/main/get.c6
-rw-r--r--src/mesa/main/get_gen.py2
-rw-r--r--src/mesa/main/mtypes.h58
-rw-r--r--src/mesa/main/texenvprogram.c8
-rw-r--r--src/mesa/main/varray.c2
-rw-r--r--src/mesa/shader/arbprogparse.c42
-rw-r--r--src/mesa/shader/arbprogram.c266
-rw-r--r--src/mesa/shader/program.c8
-rw-r--r--src/mesa/tnl/t_vp_build.c2
14 files changed, 283 insertions, 238 deletions
diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c
index 6e6af35c760..cd0eaf2470f 100644
--- a/src/mesa/drivers/dri/i915/i915_context.c
+++ b/src/mesa/drivers/dri/i915/i915_context.c
@@ -154,16 +154,15 @@ GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
* we'll still have to check and fallback each time.
*/
- ctx->Const.MaxFragmentProgramTemps = I915_MAX_TEMPORARY;
- ctx->Const.MaxFragmentProgramAttribs = 11; /* 8 tex, 2 color, fog */
- ctx->Const.MaxFragmentProgramLocalParams = I915_MAX_CONSTANT;
- ctx->Const.MaxFragmentProgramEnvParams = I915_MAX_CONSTANT;
- ctx->Const.MaxFragmentProgramAluInstructions = I915_MAX_ALU_INSN;
- ctx->Const.MaxFragmentProgramTexInstructions = I915_MAX_TEX_INSN;
- ctx->Const.MaxFragmentProgramInstructions = (I915_MAX_ALU_INSN +
+ ctx->Const.FragmentProgram.MaxNativeTemps = I915_MAX_TEMPORARY;
+ ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* 8 tex, 2 color, fog */
+ ctx->Const.FragmentProgram.MaxNativeParameters = I915_MAX_CONSTANT;
+ ctx->Const.FragmentProgram.MaxNativeAluInstructions = I915_MAX_ALU_INSN;
+ ctx->Const.FragmentProgram.MaxNativeTexInstructions = I915_MAX_TEX_INSN;
+ ctx->Const.FragmentProgram.MaxNativeInstructions = (I915_MAX_ALU_INSN +
I915_MAX_TEX_INSN);
- ctx->Const.MaxFragmentProgramTexIndirections = I915_MAX_TEX_INDIRECT;
- ctx->Const.MaxFragmentProgramAddressRegs = 0; /* I don't think we have one */
+ ctx->Const.FragmentProgram.MaxNativeTexIndirections = I915_MAX_TEX_INDIRECT;
+ ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* I don't think we have one */
driInitExtensions( ctx, i915_extensions, GL_FALSE );
diff --git a/src/mesa/drivers/dri/i915/i915_program.c b/src/mesa/drivers/dri/i915/i915_program.c
index a1d32791d44..45276fb6908 100644
--- a/src/mesa/drivers/dri/i915/i915_program.c
+++ b/src/mesa/drivers/dri/i915/i915_program.c
@@ -351,6 +351,9 @@ GLuint i915_emit_param4fv( struct i915_fragment_program *p,
void i915_program_error( struct i915_fragment_program *p, const char *msg )
{
+ /* XXX we shouldn't print anything to stdout, record GL error or
+ * call _mesa_problem()
+ */
fprintf(stderr, "%s\n", msg);
p->error = 1;
}
@@ -410,6 +413,21 @@ void i915_fini_program( struct i915_fragment_program *p )
if (p->nr_decl_insn > I915_MAX_DECL_INSN)
i915_program_error(p, "Exceeded max DECL instructions");
+ if (p->error) {
+ p->FragProg.Base.NumNativeInstructions = 0;
+ p->FragProg.NumNativeAluInstructions = 0;
+ p->FragProg.NumNativeTexInstructions = 0;
+ p->FragProg.NumNativeTexIndirections = 0;
+ }
+ else {
+ p->FragProg.Base.NumNativeInstructions = (p->nr_alu_insn +
+ p->nr_tex_insn +
+ p->nr_decl_insn);
+ p->FragProg.NumNativeAluInstructions = p->nr_alu_insn;
+ p->FragProg.NumNativeTexInstructions = p->nr_tex_insn;
+ p->FragProg.NumNativeTexIndirections = p->nr_tex_indirect;
+ }
+
p->declarations[0] |= program_size + decl_size - 2;
}
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
index 07eaaedfbe8..56b1f49affa 100644
--- a/src/mesa/drivers/dri/r300/r300_context.c
+++ b/src/mesa/drivers/dri/r300/r300_context.c
@@ -269,7 +269,9 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
#ifdef USER_BUFFERS
/* Needs further modifications */
- //ctx->Const.MaxArrayLockSize = (/*512*/RADEON_BUFFER_SIZE*16*1024) / (4*4);
+#if 0
+ ctx->Const.MaxArrayLockSize = (/*512*/RADEON_BUFFER_SIZE*16*1024) / (4*4);
+#endif
#endif
/* Initialize the software rasterizer and helper modules.
@@ -298,23 +300,21 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
_tnl_allow_vertex_fog(ctx, GL_TRUE);
/* currently bogus data */
- ctx->Const.MaxVertexProgramInstructions=VSF_MAX_FRAGMENT_LENGTH;
- ctx->Const.MaxVertexProgramAttribs=16; // r420
- ctx->Const.MaxVertexProgramTemps=VSF_MAX_FRAGMENT_TEMPS;
- ctx->Const.MaxVertexProgramLocalParams=256; // r420
- ctx->Const.MaxVertexProgramEnvParams=256; // r420
- ctx->Const.MaxVertexProgramAddressRegs=1;
+ ctx->Const.VertexProgram.MaxNativeInstructions=VSF_MAX_FRAGMENT_LENGTH;
+ ctx->Const.VertexProgram.MaxNativeAttribs=16; /* r420 */
+ ctx->Const.VertexProgram.MaxNativeTemps=VSF_MAX_FRAGMENT_TEMPS;
+ ctx->Const.VertexProgram.MaxNativeParameters=256; /* r420 */
+ ctx->Const.VertexProgram.MaxNativeAddressRegs=1;
#if USE_ARB_F_P
- ctx->Const.MaxFragmentProgramTemps = PFS_NUM_TEMP_REGS;
- ctx->Const.MaxFragmentProgramAttribs = 11; /* copy i915... */
- ctx->Const.MaxFragmentProgramLocalParams = PFS_NUM_CONST_REGS;
- ctx->Const.MaxFragmentProgramEnvParams = PFS_NUM_CONST_REGS;
- ctx->Const.MaxFragmentProgramAluInstructions = PFS_MAX_ALU_INST;
- ctx->Const.MaxFragmentProgramTexInstructions = PFS_MAX_TEX_INST;
- ctx->Const.MaxFragmentProgramInstructions = PFS_MAX_ALU_INST+PFS_MAX_TEX_INST;
- ctx->Const.MaxFragmentProgramTexIndirections = PFS_MAX_TEX_INDIRECT;
- ctx->Const.MaxFragmentProgramAddressRegs = 0; /* and these are?? */
+ ctx->Const.FragmentProgram.MaxNativeTemps = PFS_NUM_TEMP_REGS;
+ ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* copy i915... */
+ ctx->Const.FragmentProgram.MaxNativeParameters = PFS_NUM_CONST_REGS;
+ ctx->Const.FragmentProgram.MaxNativeAluInstructions = PFS_MAX_ALU_INST;
+ ctx->Const.FragmentProgram.MaxNativeTexInstructions = PFS_MAX_TEX_INST;
+ ctx->Const.FragmentProgram.MaxNativeInstructions = PFS_MAX_ALU_INST+PFS_MAX_TEX_INST;
+ ctx->Const.FragmentProgram.MaxNativeTexIndirections = PFS_MAX_TEX_INDIRECT;
+ ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* and these are?? */
ctx->_MaintainTexEnvProgram = GL_TRUE;
#endif
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 44de635c3f7..ff764886bd7 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -183,7 +183,7 @@
/** For GL_ARB_fragment_program */
/*@{*/
-#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 1
+#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 0
#define MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS 48
#define MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS 24
#define MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS 4
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 9db0b87ec10..698dbd33bfb 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -912,6 +912,23 @@ _mesa_init_current( GLcontext *ctx )
/**
+ * Init vertex/fragment program native limits from logical limits.
+ */
+static void
+init_natives(struct gl_program_constants *prog)
+{
+ prog->MaxNativeInstructions = prog->MaxInstructions;
+ prog->MaxNativeAluInstructions = prog->MaxAluInstructions;
+ prog->MaxNativeTexInstructions = prog->MaxTexInstructions;
+ prog->MaxNativeTexIndirections = prog->MaxTexIndirections;
+ prog->MaxNativeAttribs = prog->MaxAttribs;
+ prog->MaxNativeTemps = prog->MaxTemps;
+ prog->MaxNativeAddressRegs = prog->MaxAddressRegs;
+ prog->MaxNativeParameters = prog->MaxParameters;
+}
+
+
+/**
* Initialize fields of gl_constants (aka ctx->Const.*).
* Use defaults from config.h. The device drivers will often override
* some of these values (such as number of texture units).
@@ -956,25 +973,31 @@ _mesa_init_constants( GLcontext *ctx )
ctx->Const.MaxViewportWidth = MAX_WIDTH;
ctx->Const.MaxViewportHeight = MAX_HEIGHT;
#if FEATURE_ARB_vertex_program
- ctx->Const.MaxVertexProgramInstructions = MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS;
- ctx->Const.MaxVertexProgramAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS;
- ctx->Const.MaxVertexProgramTemps = MAX_NV_VERTEX_PROGRAM_TEMPS;
- ctx->Const.MaxVertexProgramLocalParams = MAX_NV_VERTEX_PROGRAM_PARAMS;
- ctx->Const.MaxVertexProgramEnvParams = MAX_NV_VERTEX_PROGRAM_PARAMS;/*XXX*/
- ctx->Const.MaxVertexProgramAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
+ ctx->Const.VertexProgram.MaxInstructions = MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS;
+ ctx->Const.VertexProgram.MaxAluInstructions = 0;
+ ctx->Const.VertexProgram.MaxTexInstructions = 0;
+ ctx->Const.VertexProgram.MaxTexIndirections = 0;
+ ctx->Const.VertexProgram.MaxAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS;
+ ctx->Const.VertexProgram.MaxTemps = MAX_NV_VERTEX_PROGRAM_TEMPS;
+ ctx->Const.VertexProgram.MaxParameters = MAX_NV_VERTEX_PROGRAM_PARAMS;
+ ctx->Const.VertexProgram.MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
+ ctx->Const.VertexProgram.MaxEnvParams = MAX_NV_VERTEX_PROGRAM_PARAMS;
+ ctx->Const.VertexProgram.MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
+ init_natives(&ctx->Const.VertexProgram);
#endif
#if FEATURE_ARB_fragment_program
- ctx->Const.MaxFragmentProgramInstructions = MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS;
- ctx->Const.MaxFragmentProgramAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS;
- ctx->Const.MaxFragmentProgramTemps = MAX_NV_FRAGMENT_PROGRAM_TEMPS;
- ctx->Const.MaxFragmentProgramLocalParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
- ctx->Const.MaxFragmentProgramEnvParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;/*XXX*/
- ctx->Const.MaxFragmentProgramAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
- ctx->Const.MaxFragmentProgramAluInstructions = MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS;
- ctx->Const.MaxFragmentProgramTexInstructions = MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS;
- ctx->Const.MaxFragmentProgramTexIndirections = MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS;
+ ctx->Const.FragmentProgram.MaxInstructions = MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS;
+ ctx->Const.FragmentProgram.MaxAluInstructions = MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS;
+ ctx->Const.FragmentProgram.MaxTexInstructions = MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS;
+ ctx->Const.FragmentProgram.MaxTexIndirections = MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS;
+ ctx->Const.FragmentProgram.MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS;
+ ctx->Const.FragmentProgram.MaxTemps = MAX_NV_FRAGMENT_PROGRAM_TEMPS;
+ ctx->Const.FragmentProgram.MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
+ ctx->Const.FragmentProgram.MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
+ ctx->Const.FragmentProgram.MaxEnvParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
+ ctx->Const.FragmentProgram.MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
+ init_natives(&ctx->Const.FragmentProgram);
#endif
-
ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES;
ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
@@ -987,6 +1010,7 @@ _mesa_init_constants( GLcontext *ctx )
ctx->Const.CheckArrayBounds = GL_FALSE;
#endif
+ /* GL_ARB_draw_buffers */
ctx->Const.MaxDrawBuffers = MAX_DRAW_BUFFERS;
/* GL_OES_read_format */
@@ -1000,6 +1024,8 @@ _mesa_init_constants( GLcontext *ctx )
/* sanity checks */
ASSERT(ctx->Const.MaxTextureUnits == MAX2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits));
+ ASSERT(ctx->Const.FragmentProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
+ ASSERT(ctx->Const.VertexProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
}
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 633d8e8617d..9bbc29e346c 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1707,7 +1707,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
break;
case GL_MAX_VERTEX_ATTRIBS_ARB:
CHECK_EXTENSION_B(ARB_vertex_program, pname);
- params[0] = INT_TO_BOOLEAN(ctx->Const.MaxVertexProgramAttribs);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.VertexProgram.MaxAttribs);
break;
case GL_FRAGMENT_PROGRAM_ARB:
CHECK_EXTENSION_B(ARB_fragment_program, pname);
@@ -3537,7 +3537,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
break;
case GL_MAX_VERTEX_ATTRIBS_ARB:
CHECK_EXTENSION_F(ARB_vertex_program, pname);
- params[0] = (GLfloat)(ctx->Const.MaxVertexProgramAttribs);
+ params[0] = (GLfloat)(ctx->Const.VertexProgram.MaxAttribs);
break;
case GL_FRAGMENT_PROGRAM_ARB:
CHECK_EXTENSION_F(ARB_fragment_program, pname);
@@ -5367,7 +5367,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
break;
case GL_MAX_VERTEX_ATTRIBS_ARB:
CHECK_EXTENSION_I(ARB_vertex_program, pname);
- params[0] = ctx->Const.MaxVertexProgramAttribs;
+ params[0] = ctx->Const.VertexProgram.MaxAttribs;
break;
case GL_FRAGMENT_PROGRAM_ARB:
CHECK_EXTENSION_I(ARB_fragment_program, pname);
diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py
index a722ac23f71..c22dda9f186 100644
--- a/src/mesa/main/get_gen.py
+++ b/src/mesa/main/get_gen.py
@@ -869,7 +869,7 @@ StateVars = [
# GL_ARB_vertex_program
( "GL_MAX_VERTEX_ATTRIBS_ARB", GLint,
- ["ctx->Const.MaxVertexProgramAttribs"], "", "ARB_vertex_program" ),
+ ["ctx->Const.VertexProgram.MaxAttribs"], "", "ARB_vertex_program" ),
# GL_ARB_fragment_program
( "GL_FRAGMENT_PROGRAM_ARB", GLboolean,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 6bb343b766d..aadd0a7e7fb 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1752,6 +1752,12 @@ struct program
GLuint NumParameters;
GLuint NumAttributes;
GLuint NumAddressRegs;
+ /* native, h/w counts */
+ GLuint NumNativeInstructions;
+ GLuint NumNativeTemporaries;
+ GLuint NumNativeParameters;
+ GLuint NumNativeAttributes;
+ GLuint NumNativeAddressRegs;
};
@@ -1780,6 +1786,9 @@ struct fragment_program
GLuint NumAluInstructions; /**< GL_ARB_fragment_program */
GLuint NumTexInstructions;
GLuint NumTexIndirections;
+ GLuint NumNativeAluInstructions; /**< GL_ARB_fragment_program */
+ GLuint NumNativeTexInstructions;
+ GLuint NumNativeTexIndirections;
GLenum FogOption;
struct program_parameter_list *Parameters; /**< array [NumParameters] */
@@ -2215,6 +2224,34 @@ struct gl_framebuffer
/**
+ * Limits for vertex and fragment programs.
+ */
+struct gl_program_constants
+{
+ /* logical limits */
+ GLuint MaxInstructions;
+ GLuint MaxAluInstructions; /* fragment programs only, for now */
+ GLuint MaxTexInstructions; /* fragment programs only, for now */
+ GLuint MaxTexIndirections; /* fragment programs only, for now */
+ GLuint MaxAttribs;
+ GLuint MaxTemps;
+ GLuint MaxAddressRegs; /* vertex program only, for now */
+ GLuint MaxParameters;
+ GLuint MaxLocalParams;
+ GLuint MaxEnvParams;
+ /* native/hardware limits */
+ GLuint MaxNativeInstructions;
+ GLuint MaxNativeAluInstructions; /* fragment programs only, for now */
+ GLuint MaxNativeTexInstructions; /* fragment programs only, for now */
+ GLuint MaxNativeTexIndirections; /* fragment programs only, for now */
+ GLuint MaxNativeAttribs;
+ GLuint MaxNativeTemps;
+ GLuint MaxNativeAddressRegs; /* vertex program only, for now */
+ GLuint MaxNativeParameters;
+};
+
+
+/**
* Constants which may be overridden by device driver during context creation
* but are never changed after that.
*/
@@ -2245,24 +2282,9 @@ struct gl_constants
GLfloat MaxShininess; /* GL_NV_light_max_exponent */
GLfloat MaxSpotExponent; /* GL_NV_light_max_exponent */
GLuint MaxViewportWidth, MaxViewportHeight;
- /* GL_ARB_vertex_program */
- GLuint MaxVertexProgramInstructions;
- GLuint MaxVertexProgramAttribs;
- GLuint MaxVertexProgramTemps;
- GLuint MaxVertexProgramLocalParams;
- GLuint MaxVertexProgramEnvParams;
- GLuint MaxVertexProgramAddressRegs;
- /* GL_ARB_fragment_program */
- GLuint MaxFragmentProgramInstructions;
- GLuint MaxFragmentProgramAttribs;
- GLuint MaxFragmentProgramTemps;
- GLuint MaxFragmentProgramLocalParams;
- GLuint MaxFragmentProgramEnvParams;
- GLuint MaxFragmentProgramAddressRegs;
- GLuint MaxFragmentProgramAluInstructions;
- GLuint MaxFragmentProgramTexInstructions;
- GLuint MaxFragmentProgramTexIndirections;
- /* vertex or fragment program */
+ struct gl_program_constants VertexProgram; /* GL_ARB_vertex_program */
+ struct gl_program_constants FragmentProgram; /* GL_ARB_fragment_program */
+ /* shared by vertex and fragment program: */
GLuint MaxProgramMatrices;
GLuint MaxProgramMatrixStackDepth;
/* vertex array / buffer object bounds checking */
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 7b74e3ad1b4..18d704ce1b6 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -400,7 +400,7 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p )
static void release_temps( struct texenv_fragment_program *p )
{
- GLuint max_temp = p->ctx->Const.MaxFragmentProgramTemps;
+ GLuint max_temp = p->ctx->Const.FragmentProgram.MaxTemps;
/* KW: To support tex_env_crossbar, don't release the registers in
* temps_output.
@@ -1058,13 +1058,13 @@ static void create_new_program(struct state_key *key, GLcontext *ctx,
} else
p.program->FogOption = GL_NONE;
- if (p.program->NumTexIndirections > ctx->Const.MaxFragmentProgramTexIndirections)
+ if (p.program->NumTexIndirections > ctx->Const.FragmentProgram.MaxTexIndirections)
program_error(&p, "Exceeded max nr indirect texture lookups");
- if (p.program->NumTexInstructions > ctx->Const.MaxFragmentProgramTexInstructions)
+ if (p.program->NumTexInstructions > ctx->Const.FragmentProgram.MaxTexInstructions)
program_error(&p, "Exceeded max TEX instructions");
- if (p.program->NumAluInstructions > ctx->Const.MaxFragmentProgramAluInstructions)
+ if (p.program->NumAluInstructions > ctx->Const.FragmentProgram.MaxAluInstructions)
program_error(&p, "Exceeded max ALU instructions");
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 6781b698150..cf64fb23df7 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -499,7 +499,7 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (index >= ctx->Const.MaxVertexProgramAttribs) {
+ if (index >= ctx->Const.VertexProgram.MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)");
return;
}
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 8370203eaa4..e8fe869d0bb 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -1324,10 +1324,10 @@ parse_program_single_item (GLcontext * ctx, GLubyte ** inst,
/* Check state_tokens[2] against the number of ENV parameters available */
if (((Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) &&
- (state_tokens[2] >= (GLint) ctx->Const.MaxFragmentProgramEnvParams))
+ (state_tokens[2] >= (GLint) ctx->Const.FragmentProgram.MaxEnvParams))
||
((Program->Base.Target == GL_VERTEX_PROGRAM_ARB) &&
- (state_tokens[2] >= (GLint) ctx->Const.MaxVertexProgramEnvParams))) {
+ (state_tokens[2] >= (GLint) ctx->Const.VertexProgram.MaxEnvParams))) {
_mesa_set_program_error (ctx, Program->Position,
"Invalid Program Env Parameter");
_mesa_error (ctx, GL_INVALID_OPERATION,
@@ -1344,10 +1344,10 @@ parse_program_single_item (GLcontext * ctx, GLubyte ** inst,
/* Check state_tokens[2] against the number of LOCAL parameters available */
if (((Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) &&
- (state_tokens[2] >= (GLint) ctx->Const.MaxFragmentProgramLocalParams))
+ (state_tokens[2] >= (GLint) ctx->Const.FragmentProgram.MaxLocalParams))
||
((Program->Base.Target == GL_VERTEX_PROGRAM_ARB) &&
- (state_tokens[2] >= (GLint) ctx->Const.MaxVertexProgramLocalParams))) {
+ (state_tokens[2] >= (GLint) ctx->Const.VertexProgram.MaxLocalParams))) {
_mesa_set_program_error (ctx, Program->Position,
"Invalid Program Local Parameter");
_mesa_error (ctx, GL_INVALID_OPERATION,
@@ -1742,18 +1742,18 @@ parse_param_elements (GLcontext * ctx, GLubyte ** inst,
out_of_range = 0;
if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
if (((state_tokens[1] == STATE_ENV)
- && (end_idx >= ctx->Const.MaxFragmentProgramEnvParams))
+ && (end_idx >= ctx->Const.FragmentProgram.MaxEnvParams))
|| ((state_tokens[1] == STATE_LOCAL)
&& (end_idx >=
- ctx->Const.MaxFragmentProgramLocalParams)))
+ ctx->Const.FragmentProgram.MaxLocalParams)))
out_of_range = 1;
}
else {
if (((state_tokens[1] == STATE_ENV)
- && (end_idx >= ctx->Const.MaxVertexProgramEnvParams))
+ && (end_idx >= ctx->Const.VertexProgram.MaxEnvParams))
|| ((state_tokens[1] == STATE_LOCAL)
&& (end_idx >=
- ctx->Const.MaxVertexProgramLocalParams)))
+ ctx->Const.VertexProgram.MaxLocalParams)))
out_of_range = 1;
}
if (out_of_range) {
@@ -1800,10 +1800,10 @@ parse_param_elements (GLcontext * ctx, GLubyte ** inst,
/* Make sure we haven't blown past our parameter limits */
if (((Program->Base.Target == GL_VERTEX_PROGRAM_ARB) &&
(Program->Base.NumParameters >=
- ctx->Const.MaxVertexProgramLocalParams))
+ ctx->Const.VertexProgram.MaxLocalParams))
|| ((Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB)
&& (Program->Base.NumParameters >=
- ctx->Const.MaxFragmentProgramLocalParams))) {
+ ctx->Const.FragmentProgram.MaxLocalParams))) {
_mesa_set_program_error (ctx, Program->Position,
"Too many parameter variables");
_mesa_error (ctx, GL_INVALID_OPERATION, "Too many parameter variables");
@@ -1958,10 +1958,10 @@ parse_temp (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
if (((Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) &&
(Program->Base.NumTemporaries >=
- ctx->Const.MaxFragmentProgramTemps))
+ ctx->Const.FragmentProgram.MaxTemps))
|| ((Program->Base.Target == GL_VERTEX_PROGRAM_ARB)
&& (Program->Base.NumTemporaries >=
- ctx->Const.MaxVertexProgramTemps))) {
+ ctx->Const.VertexProgram.MaxTemps))) {
_mesa_set_program_error (ctx, Program->Position,
"Too many TEMP variables declared");
_mesa_error (ctx, GL_INVALID_OPERATION,
@@ -2091,7 +2091,7 @@ parse_address (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
temp_var->type = vt_address;
if (Program->Base.NumAddressRegs >=
- ctx->Const.MaxVertexProgramAddressRegs) {
+ ctx->Const.VertexProgram.MaxAddressRegs) {
const char *msg = "Too many ADDRESS variables declared";
_mesa_set_program_error(ctx, Program->Position, msg);
@@ -3760,6 +3760,22 @@ parse_arb_program(GLcontext * ctx, GLubyte * inst, struct var_cache **vc_head,
}
Program->Base.NumInstructions++;
+ /*
+ * Initialize native counts to logical counts. The device driver may
+ * change them if program is translated into a hardware program.
+ */
+ Program->Base.NumNativeInstructions = Program->Base.NumInstructions;
+ Program->Base.NumNativeTemporaries = Program->Base.NumTemporaries;
+ Program->Base.NumNativeParameters = Program->Base.NumParameters;
+ Program->Base.NumNativeAttributes = Program->Base.NumAttributes;
+ Program->Base.NumNativeAddressRegs = Program->Base.NumAddressRegs;
+ if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+ struct fragment_program *fp = (struct fragment_program *) Program;
+ fp->NumNativeAluInstructions = fp->NumAluInstructions;
+ fp->NumNativeTexInstructions = fp->NumTexInstructions;
+ fp->NumNativeTexIndirections = fp->NumTexIndirections;
+ }
+
return err;
}
diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c
index 43baab4b0fd..f47f6733995 100644
--- a/src/mesa/shader/arbprogram.c
+++ b/src/mesa/shader/arbprogram.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.5
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -50,7 +50,7 @@ _mesa_EnableVertexAttribArrayARB(GLuint index)
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (index >= ctx->Const.MaxVertexProgramAttribs) {
+ if (index >= ctx->Const.VertexProgram.MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glEnableVertexAttribArrayARB(index)");
return;
@@ -69,7 +69,7 @@ _mesa_DisableVertexAttribArrayARB(GLuint index)
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (index >= ctx->Const.MaxVertexProgramAttribs) {
+ if (index >= ctx->Const.VertexProgram.MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glEnableVertexAttribArrayARB(index)");
return;
@@ -173,7 +173,7 @@ _mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer)
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (index >= ctx->Const.MaxVertexProgramAttribs) {
+ if (index >= ctx->Const.VertexProgram.MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)");
return;
}
@@ -259,7 +259,7 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
- if (index >= ctx->Const.MaxFragmentProgramEnvParams) {
+ if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
return;
}
@@ -267,7 +267,7 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
}
else if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
- if (index >= ctx->Const.MaxVertexProgramEnvParams) {
+ if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
return;
}
@@ -319,7 +319,7 @@ _mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index,
if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
- if (index >= ctx->Const.MaxFragmentProgramEnvParams) {
+ if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
return;
}
@@ -327,7 +327,7 @@ _mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index,
}
else if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
- if (index >= ctx->Const.MaxVertexProgramEnvParams) {
+ if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
return;
}
@@ -357,7 +357,7 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
&& ctx->Extensions.NV_fragment_program) ||
(target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program)) {
- if (index >= ctx->Const.MaxFragmentProgramLocalParams) {
+ if (index >= ctx->Const.FragmentProgram.MaxLocalParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
return;
}
@@ -365,7 +365,7 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
}
else if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
- if (index >= ctx->Const.MaxVertexProgramLocalParams) {
+ if (index >= ctx->Const.VertexProgram.MaxLocalParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
return;
}
@@ -437,12 +437,12 @@ _mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index,
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
prog = &(ctx->VertexProgram.Current->Base);
- maxParams = ctx->Const.MaxVertexProgramLocalParams;
+ maxParams = ctx->Const.VertexProgram.MaxLocalParams;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
prog = &(ctx->FragmentProgram.Current->Base);
- maxParams = ctx->Const.MaxFragmentProgramLocalParams;
+ maxParams = ctx->Const.FragmentProgram.MaxLocalParams;
}
else if (target == GL_FRAGMENT_PROGRAM_NV
&& ctx->Extensions.NV_fragment_program) {
@@ -486,6 +486,7 @@ _mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index,
void GLAPIENTRY
_mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
{
+ const struct gl_program_constants *limits;
struct program *prog;
GET_CURRENT_CONTEXT(ctx);
@@ -495,10 +496,12 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
prog = &(ctx->VertexProgram.Current->Base);
+ limits = &ctx->Const.VertexProgram;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
prog = &(ctx->FragmentProgram.Current->Base);
+ limits = &ctx->Const.FragmentProgram;
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
@@ -506,188 +509,150 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
}
ASSERT(prog);
+ ASSERT(limits);
+ /* Queries supported for both vertex and fragment programs */
switch (pname) {
case GL_PROGRAM_LENGTH_ARB:
- *params = prog->String ? (GLint)_mesa_strlen((char *) prog->String) : 0;
- break;
+ *params
+ = prog->String ? (GLint) _mesa_strlen((char *) prog->String) : 0;
+ return;
case GL_PROGRAM_FORMAT_ARB:
*params = prog->Format;
- break;
+ return;
case GL_PROGRAM_BINDING_ARB:
*params = prog->Id;
- break;
+ return;
case GL_PROGRAM_INSTRUCTIONS_ARB:
*params = prog->NumInstructions;
- break;
+ return;
case GL_MAX_PROGRAM_INSTRUCTIONS_ARB:
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramInstructions;
- else
- *params = ctx->Const.MaxFragmentProgramInstructions;
- break;
+ *params = limits->MaxInstructions;
+ return;
case GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB:
- *params = prog->NumInstructions;
- break;
+ *params = prog->NumNativeInstructions;
+ return;
case GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB:
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramInstructions;
- else
- *params = ctx->Const.MaxFragmentProgramInstructions;
- break;
+ *params = limits->MaxNativeInstructions;
+ return;
case GL_PROGRAM_TEMPORARIES_ARB:
*params = prog->NumTemporaries;
- break;
+ return;
case GL_MAX_PROGRAM_TEMPORARIES_ARB:
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramTemps;
- else
- *params = ctx->Const.MaxFragmentProgramTemps;
- break;
+ *params = limits->MaxTemps;
+ return;
case GL_PROGRAM_NATIVE_TEMPORARIES_ARB:
- /* XXX same as GL_PROGRAM_TEMPORARIES_ARB? */
- *params = prog->NumTemporaries;
- break;
+ *params = prog->NumNativeTemporaries;
+ return;
case GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB:
- /* XXX same as GL_MAX_PROGRAM_TEMPORARIES_ARB? */
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramTemps;
- else
- *params = ctx->Const.MaxFragmentProgramTemps;
- break;
+ *params = limits->MaxNativeTemps;
+ return;
case GL_PROGRAM_PARAMETERS_ARB:
*params = prog->NumParameters;
- break;
+ return;
case GL_MAX_PROGRAM_PARAMETERS_ARB:
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramLocalParams;
- else
- *params = ctx->Const.MaxFragmentProgramLocalParams;
- break;
+ *params = limits->MaxParameters;
+ return;
case GL_PROGRAM_NATIVE_PARAMETERS_ARB:
- /* XXX same as GL_MAX_PROGRAM_PARAMETERS_ARB? */
- *params = prog->NumParameters;
- break;
+ *params = prog->NumNativeParameters;
+ return;
case GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB:
- /* XXX same as GL_MAX_PROGRAM_PARAMETERS_ARB? */
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramLocalParams;
- else
- *params = ctx->Const.MaxFragmentProgramLocalParams;
- break;
+ *params = limits->MaxNativeParameters;
+ return;
case GL_PROGRAM_ATTRIBS_ARB:
*params = prog->NumAttributes;
- break;
+ return;
case GL_MAX_PROGRAM_ATTRIBS_ARB:
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramAttribs;
- else
- *params = ctx->Const.MaxFragmentProgramAttribs;
- break;
+ *params = limits->MaxAttribs;
+ return;
case GL_PROGRAM_NATIVE_ATTRIBS_ARB:
- /* XXX same as GL_PROGRAM_ATTRIBS_ARB? */
- *params = prog->NumAttributes;
- break;
+ *params = prog->NumNativeAttributes;
+ return;
case GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB:
- /* XXX same as GL_MAX_PROGRAM_ATTRIBS_ARB? */
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramAttribs;
- else
- *params = ctx->Const.MaxFragmentProgramAttribs;
- break;
+ *params = limits->MaxNativeAttribs;
+ return;
case GL_PROGRAM_ADDRESS_REGISTERS_ARB:
*params = prog->NumAddressRegs;
- break;
+ return;
case GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB:
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramAddressRegs;
- else
- *params = ctx->Const.MaxFragmentProgramAddressRegs;
- break;
+ *params = limits->MaxAddressRegs;
+ return;
case GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB:
- /* XXX same as GL_PROGRAM_ADDRESS_REGISTERS_ARB? */
- *params = prog->NumAddressRegs;
- break;
+ *params = prog->NumNativeAddressRegs;
+ return;
case GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB:
- /* XXX same as GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB? */
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramAddressRegs;
- else
- *params = ctx->Const.MaxFragmentProgramAddressRegs;
- break;
+ *params = limits->MaxNativeAddressRegs;
+ return;
case GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB:
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramLocalParams;
- else
- *params = ctx->Const.MaxFragmentProgramLocalParams;
- break;
+ *params = limits->MaxLocalParams;
+ return;
case GL_MAX_PROGRAM_ENV_PARAMETERS_ARB:
- if (target == GL_VERTEX_PROGRAM_ARB)
- *params = ctx->Const.MaxVertexProgramEnvParams;
- else
- *params = ctx->Const.MaxFragmentProgramEnvParams;
- break;
+ *params = limits->MaxEnvParams;
+ return;
case GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB:
+ /*
+ * XXX we may not really need a driver callback here.
+ * If the number of native instructions, registers, etc. used
+ * are all below the maximums, we could return true.
+ * The spec says that even if this query returns true, there's
+ * no guarantee that the program will run in hardware.
+ */
if (ctx->Driver.IsProgramNative)
*params = ctx->Driver.IsProgramNative( ctx, target, prog );
else
*params = GL_TRUE;
+ return;
+ default:
+ /* continue with fragment-program only queries below */
break;
+ }
- /*
- * The following apply to fragment programs only.
- */
- case GL_PROGRAM_ALU_INSTRUCTIONS_ARB:
- case GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB:
- if (target != GL_FRAGMENT_PROGRAM_ARB) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ /*
+ * The following apply to fragment programs only (at this time)
+ */
+ if (target == GL_FRAGMENT_PROGRAM_ARB) {
+ const struct fragment_program *fp = ctx->FragmentProgram.Current;
+ switch (pname) {
+ case GL_PROGRAM_ALU_INSTRUCTIONS_ARB:
+ *params = fp->NumNativeAluInstructions;
return;
- }
- *params = ctx->FragmentProgram.Current->NumAluInstructions;
- break;
- case GL_PROGRAM_TEX_INSTRUCTIONS_ARB:
- case GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB:
- if (target != GL_FRAGMENT_PROGRAM_ARB) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ case GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB:
+ *params = fp->NumAluInstructions;
return;
- }
- *params = ctx->FragmentProgram.Current->NumTexInstructions;
- break;
- case GL_PROGRAM_TEX_INDIRECTIONS_ARB:
- case GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB:
- if (target != GL_FRAGMENT_PROGRAM_ARB) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ case GL_PROGRAM_TEX_INSTRUCTIONS_ARB:
+ *params = fp->NumTexInstructions;
return;
- }
- *params = ctx->FragmentProgram.Current->NumTexIndirections;
- break;
- case GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB:
- case GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB:
- if (target != GL_FRAGMENT_PROGRAM_ARB) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ case GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB:
+ *params = fp->NumNativeTexInstructions;
return;
- }
- *params = ctx->Const.MaxFragmentProgramAluInstructions;
- break;
- case GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB:
- case GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB:
- if (target != GL_FRAGMENT_PROGRAM_ARB) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ case GL_PROGRAM_TEX_INDIRECTIONS_ARB:
+ *params = fp->NumTexIndirections;
return;
- }
- *params = ctx->Const.MaxFragmentProgramTexInstructions;
- break;
- case GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB:
- case GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB:
- if (target != GL_FRAGMENT_PROGRAM_ARB) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ case GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB:
+ *params = fp->NumNativeTexIndirections;
return;
- }
- *params = ctx->Const.MaxFragmentProgramTexIndirections;
- break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(pname)");
- return;
+ case GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB:
+ *params = limits->MaxAluInstructions;
+ return;
+ case GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB:
+ *params = limits->MaxNativeAluInstructions;
+ return;
+ case GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB:
+ *params = limits->MaxTexInstructions;
+ return;
+ case GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB:
+ *params = limits->MaxNativeTexInstructions;
+ return;
+ case GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB:
+ *params = limits->MaxTexIndirections;
+ return;
+ case GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB:
+ *params = limits->MaxNativeTexIndirections;
+ return;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(pname)");
+ return;
+ }
}
}
@@ -695,7 +660,7 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
void GLAPIENTRY
_mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string)
{
- struct program *prog;
+ const struct program *prog;
GET_CURRENT_CONTEXT(ctx);
if (!ctx->_CurrentProgram)
@@ -719,6 +684,5 @@ _mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string)
return;
}
- MEMCPY(string, prog->String, _mesa_strlen((char *) prog->String));
+ _mesa_memcpy(string, prog->String, _mesa_strlen((char *) prog->String));
}
-
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 70a9ced7a66..a054567e5fc 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -1291,7 +1291,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
if (reg[0] == 'R') {
/* Temp register */
GLint i = _mesa_atoi(reg + 1);
- if (i >= (GLint)ctx->Const.MaxVertexProgramTemps) {
+ if (i >= (GLint)ctx->Const.VertexProgram.MaxTemps) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glGetProgramRegisterfvMESA(registerName)");
return;
@@ -1301,7 +1301,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
else if (reg[0] == 'v' && reg[1] == '[') {
/* Vertex Input attribute */
GLuint i;
- for (i = 0; i < ctx->Const.MaxVertexProgramAttribs; i++) {
+ for (i = 0; i < ctx->Const.VertexProgram.MaxAttribs; i++) {
const char *name = _mesa_nv_vertex_input_register_name(i);
char number[10];
_mesa_sprintf(number, "%d", i);
@@ -1355,7 +1355,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
if (reg[0] == 'R') {
/* Temp register */
GLint i = _mesa_atoi(reg + 1);
- if (i >= (GLint)ctx->Const.MaxFragmentProgramTemps) {
+ if (i >= (GLint)ctx->Const.FragmentProgram.MaxTemps) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glGetProgramRegisterfvMESA(registerName)");
return;
@@ -1365,7 +1365,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
else if (reg[0] == 'f' && reg[1] == '[') {
/* Fragment input attribute */
GLuint i;
- for (i = 0; i < ctx->Const.MaxFragmentProgramAttribs; i++) {
+ for (i = 0; i < ctx->Const.FragmentProgram.MaxAttribs; i++) {
const char *name = _mesa_nv_fragment_input_register_name(i);
if (_mesa_strncmp(reg + 2, name, 4) == 0) {
COPY_4V(v, ctx->FragmentProgram.Machine.Inputs[i]);
diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c
index 3d1a288066c..8e52e7125c3 100644
--- a/src/mesa/tnl/t_vp_build.c
+++ b/src/mesa/tnl/t_vp_build.c
@@ -1504,7 +1504,7 @@ void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
create_new_program( key, ctx->_TnlProgram,
- ctx->Const.MaxVertexProgramTemps );
+ ctx->Const.VertexProgram.MaxTemps );
cache_item(tnl->vp_cache, hash, key, ctx->_TnlProgram );
}