summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2005-11-01 04:36:33 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2005-11-01 04:36:33 +0000
commit05051037101dfa053798cf5ad91d1975fd1aa6a7 (patch)
tree0cf21bc55a1c006a6f7fa99d7613e73428598fee /src/mesa/main
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.
Diffstat (limited to 'src/mesa/main')
-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
7 files changed, 92 insertions, 44 deletions
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 44de635c3f..ff764886bd 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 9db0b87ec1..698dbd33bf 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 633d8e8617..9bbc29e346 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 a722ac23f7..c22dda9f18 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 6bb343b766..aadd0a7e7f 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 7b74e3ad1b..18d704ce1b 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 6781b69815..cf64fb23df 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;
}