summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-10-10 22:45:50 +0000
committerBrian Paul <[email protected]>2006-10-10 22:45:50 +0000
commit81968ec49d9e06be0e095fa0084aa61b68b23d75 (patch)
treefa905da9fed031eed3e7c27ca2387101c6820dea
parentc61ecf373e58151aa7d3a4244ef139e015676b66 (diff)
a step toward moving run-time vertex program state out of GLcontext
-rw-r--r--src/mesa/main/mtypes.h39
-rw-r--r--src/mesa/shader/nvprogram.c7
-rw-r--r--src/mesa/shader/nvvertexec.c52
-rw-r--r--src/mesa/shader/program.c4
-rw-r--r--src/mesa/tnl/t_vb_program.c8
5 files changed, 61 insertions, 49 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ff6b053c230..799e647731a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1913,30 +1913,41 @@ struct gl_program_state
/**
- * State vars for GL_ARB/GL_NV_vertex_program
+ * Virtual vertex program machine state.
+ * Only used during program execution (may be moved someday):
+ */
+struct gl_vertex_program_machine
+{
+ GLfloat Temporaries[MAX_NV_VERTEX_PROGRAM_TEMPS][4];
+ GLfloat Inputs[MAX_NV_VERTEX_PROGRAM_INPUTS][4];
+ GLuint InputsSize[MAX_NV_VERTEX_PROGRAM_INPUTS];
+ GLfloat Outputs[MAX_NV_VERTEX_PROGRAM_OUTPUTS][4];
+ GLint AddressReg[4];
+};
+
+
+/**
+ * Context state for vertex programs.
*/
struct gl_vertex_program_state
{
- GLboolean Enabled; /**< GL_VERTEX_PROGRAM_ARB/NV */
- GLboolean _Enabled; /**< Enabled and valid program? */
- GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
- GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
+ GLboolean Enabled; /**< GL_VERTEX_PROGRAM_ARB/NV */
+ GLboolean _Enabled; /**< Enabled and valid program? */
+ GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
+ GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
struct gl_vertex_program *Current; /**< ptr to currently bound program */
const struct gl_vertex_program *_Current; /**< ptr to currently bound
program, including internal
(t_vp_build.c) programs */
+ GLfloat Parameters[MAX_NV_VERTEX_PROGRAM_PARAMS][4]; /**< Env params */
+
+ struct gl_vertex_program_machine Machine;
+
+ /* For GL_NV_vertex_program only: */
GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
- GLfloat Parameters[MAX_NV_VERTEX_PROGRAM_PARAMS][4]; /* Env params */
- /* Only used during program execution (may be moved someday): */
- GLfloat Temporaries[MAX_NV_VERTEX_PROGRAM_TEMPS][4];
- GLfloat Inputs[MAX_NV_VERTEX_PROGRAM_INPUTS][4];
- GLuint InputsSize[MAX_NV_VERTEX_PROGRAM_INPUTS];
- GLfloat Outputs[MAX_NV_VERTEX_PROGRAM_OUTPUTS][4];
- GLint AddressReg[4];
-
#if FEATURE_MESA_program_debug
GLprogramcallbackMESA Callback;
GLvoid *CallbackData;
@@ -1947,7 +1958,7 @@ struct gl_vertex_program_state
/**
- * Context state for GL_ARB/NV_fragment_program
+ * Context state for fragment programs.
*/
struct gl_fragment_program_state
{
diff --git a/src/mesa/shader/nvprogram.c b/src/mesa/shader/nvprogram.c
index 4e29e0b3f88..47d2b61a628 100644
--- a/src/mesa/shader/nvprogram.c
+++ b/src/mesa/shader/nvprogram.c
@@ -79,7 +79,7 @@ _mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
_mesa_init_vp_per_vertex_registers(ctx);
_mesa_init_vp_per_primitive_registers(ctx);
- COPY_4V(ctx->VertexProgram.Inputs[VERT_ATTRIB_POS], params);
+ COPY_4V(ctx->VertexProgram.Machine.Inputs[VERT_ATTRIB_POS], params);
_mesa_exec_vertex_program(ctx, vprog);
}
@@ -89,8 +89,9 @@ _mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
* \note Not compiled into display lists.
* \note Called from the GL API dispatcher.
*/
-GLboolean GLAPIENTRY _mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids,
- GLboolean *residences)
+GLboolean GLAPIENTRY
+_mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids,
+ GLboolean *residences)
{
GLint i, j;
GLboolean allResident = GL_TRUE;
diff --git a/src/mesa/shader/nvvertexec.c b/src/mesa/shader/nvvertexec.c
index c436f4f0451..19855936593 100644
--- a/src/mesa/shader/nvvertexec.c
+++ b/src/mesa/shader/nvvertexec.c
@@ -50,20 +50,20 @@ void
_mesa_init_vp_per_vertex_registers(GLcontext *ctx)
{
/* Input registers get initialized from the current vertex attribs */
- MEMCPY(ctx->VertexProgram.Inputs, ctx->Current.Attrib,
+ MEMCPY(ctx->VertexProgram.Machine.Inputs, ctx->Current.Attrib,
MAX_VERTEX_PROGRAM_ATTRIBS * 4 * sizeof(GLfloat));
if (ctx->VertexProgram.Current->IsNVProgram) {
GLuint i;
/* Output/result regs are initialized to [0,0,0,1] */
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_OUTPUTS; i++) {
- ASSIGN_4V(ctx->VertexProgram.Outputs[i], 0.0F, 0.0F, 0.0F, 1.0F);
+ ASSIGN_4V(ctx->VertexProgram.Machine.Outputs[i], 0.0F, 0.0F, 0.0F, 1.0F);
}
/* Temp regs are initialized to [0,0,0,0] */
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_TEMPS; i++) {
- ASSIGN_4V(ctx->VertexProgram.Temporaries[i], 0.0F, 0.0F, 0.0F, 0.0F);
+ ASSIGN_4V(ctx->VertexProgram.Machine.Temporaries[i], 0.0F, 0.0F, 0.0F, 0.0F);
}
- ASSIGN_4V(ctx->VertexProgram.AddressReg, 0, 0, 0, 0);
+ ASSIGN_4V(ctx->VertexProgram.Machine.AddressReg, 0, 0, 0, 0);
}
}
@@ -161,7 +161,7 @@ _mesa_init_vp_per_primitive_registers(GLcontext *ctx)
}
}
else {
- /* Using and ARB vertex program */
+ /* ARB vertex program */
if (ctx->VertexProgram.Current->Base.Parameters) {
/* Grab the state GL state and put into registers */
_mesa_load_state_parameters(ctx,
@@ -182,30 +182,30 @@ _mesa_dump_vp_state( const struct gl_vertex_program_state *state )
_mesa_printf("VertexIn:\n");
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_INPUTS; i++) {
_mesa_printf("%d: %f %f %f %f ", i,
- state->Inputs[i][0],
- state->Inputs[i][1],
- state->Inputs[i][2],
- state->Inputs[i][3]);
+ state->Machine.Inputs[i][0],
+ state->Machine.Inputs[i][1],
+ state->Machine.Inputs[i][2],
+ state->Machine.Inputs[i][3]);
}
_mesa_printf("\n");
_mesa_printf("VertexOut:\n");
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_OUTPUTS; i++) {
_mesa_printf("%d: %f %f %f %f ", i,
- state->Outputs[i][0],
- state->Outputs[i][1],
- state->Outputs[i][2],
- state->Outputs[i][3]);
+ state->Machine.Outputs[i][0],
+ state->Machine.Outputs[i][1],
+ state->Machine.Outputs[i][2],
+ state->Machine.Outputs[i][3]);
}
_mesa_printf("\n");
_mesa_printf("Registers:\n");
for (i = 0; i < MAX_NV_VERTEX_PROGRAM_TEMPS; i++) {
_mesa_printf("%d: %f %f %f %f ", i,
- state->Temporaries[i][0],
- state->Temporaries[i][1],
- state->Temporaries[i][2],
- state->Temporaries[i][3]);
+ state->Machine.Temporaries[i][0],
+ state->Machine.Temporaries[i][1],
+ state->Machine.Temporaries[i][2],
+ state->Machine.Temporaries[i][3]);
}
_mesa_printf("\n");
@@ -231,7 +231,7 @@ get_register_pointer( const struct prog_src_register *source,
const struct gl_vertex_program_state *state )
{
if (source->RelAddr) {
- const GLint reg = source->Index + state->AddressReg[0];
+ const GLint reg = source->Index + state->Machine.AddressReg[0];
ASSERT( (source->File == PROGRAM_ENV_PARAM) ||
(source->File == PROGRAM_STATE_VAR) );
if (reg < 0 || reg > MAX_NV_VERTEX_PROGRAM_PARAMS)
@@ -245,14 +245,14 @@ get_register_pointer( const struct prog_src_register *source,
switch (source->File) {
case PROGRAM_TEMPORARY:
ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_TEMPS);
- return state->Temporaries[source->Index];
+ return state->Machine.Temporaries[source->Index];
case PROGRAM_INPUT:
ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_INPUTS);
- return state->Inputs[source->Index];
+ return state->Machine.Inputs[source->Index];
case PROGRAM_OUTPUT:
/* This is only needed for the PRINT instruction */
ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_OUTPUTS);
- return state->Outputs[source->Index];
+ return state->Machine.Outputs[source->Index];
case PROGRAM_LOCAL_PARAM:
ASSERT(source->Index < MAX_PROGRAM_LOCAL_PARAMS);
return state->Current->Base.LocalParams[source->Index];
@@ -329,10 +329,10 @@ store_vector4( const struct prog_dst_register *dest,
GLfloat *dst;
switch (dest->File) {
case PROGRAM_TEMPORARY:
- dst = state->Temporaries[dest->Index];
+ dst = state->Machine.Temporaries[dest->Index];
break;
case PROGRAM_OUTPUT:
- dst = state->Outputs[dest->Index];
+ dst = state->Machine.Outputs[dest->Index];
break;
case PROGRAM_ENV_PARAM:
{
@@ -390,9 +390,9 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct gl_vertex_program *progra
* by the MVP matrix and store in the vertex position result register.
*/
if (ctx->VertexProgram.Current->IsPositionInvariant) {
- TRANSFORM_POINT( ctx->VertexProgram.Outputs[VERT_RESULT_HPOS],
+ TRANSFORM_POINT( ctx->VertexProgram.Machine.Outputs[VERT_RESULT_HPOS],
ctx->_ModelProjectMatrix.m,
- ctx->VertexProgram.Inputs[VERT_ATTRIB_POS]);
+ ctx->VertexProgram.Machine.Inputs[VERT_ATTRIB_POS]);
/* XXX: This could go elsewhere */
ctx->VertexProgram.Current->Base.OutputsWritten |= VERT_BIT_POS;
@@ -636,7 +636,7 @@ _mesa_exec_vertex_program(GLcontext *ctx, const struct gl_vertex_program *progra
{
GLfloat t[4];
fetch_vector4( &inst->SrcReg[0], state, t );
- state->AddressReg[0] = (GLint) FLOORF(t[0]);
+ state->Machine.AddressReg[0] = (GLint) FLOORF(t[0]);
}
break;
case OPCODE_DPH:
diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c
index 8aed74110c0..ceceef0c5df 100644
--- a/src/mesa/shader/program.c
+++ b/src/mesa/shader/program.c
@@ -2099,7 +2099,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
"glGetProgramRegisterfvMESA(registerName)");
return;
}
- COPY_4V(v, ctx->VertexProgram.Temporaries[i]);
+ COPY_4V(v, ctx->VertexProgram.Machine.Temporaries[i]);
}
else if (reg[0] == 'v' && reg[1] == '[') {
/* Vertex Input attribute */
@@ -2110,7 +2110,7 @@ _mesa_GetProgramRegisterfvMESA(GLenum target,
_mesa_sprintf(number, "%d", i);
if (_mesa_strncmp(reg + 2, name, 4) == 0 ||
_mesa_strncmp(reg + 2, number, _mesa_strlen(number)) == 0) {
- COPY_4V(v, ctx->VertexProgram.Inputs[i]);
+ COPY_4V(v, ctx->VertexProgram.Machine.Inputs[i]);
return;
}
}
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 36ee4b2f46a..b8828ec36ac 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -118,7 +118,7 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
const GLuint size = VB->AttribPtr[attr]->size;
const GLuint stride = VB->AttribPtr[attr]->stride;
const GLfloat *data = (GLfloat *) (ptr + stride * i);
- COPY_CLEAN_4V(ctx->VertexProgram.Inputs[attr], size, data);
+ COPY_CLEAN_4V(ctx->VertexProgram.Machine.Inputs[attr], size, data);
}
}
@@ -129,19 +129,19 @@ run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
/* Fixup fog an point size results if needed */
if (ctx->Fog.Enabled &&
(program->Base.OutputsWritten & (1 << VERT_RESULT_FOGC)) == 0) {
- ctx->VertexProgram.Outputs[VERT_RESULT_FOGC][0] = 1.0;
+ ctx->VertexProgram.Machine.Outputs[VERT_RESULT_FOGC][0] = 1.0;
}
if (ctx->VertexProgram.PointSizeEnabled &&
(program->Base.OutputsWritten & (1 << VERT_RESULT_PSIZ)) == 0) {
- ctx->VertexProgram.Outputs[VERT_RESULT_PSIZ][0] = ctx->Point.Size;
+ ctx->VertexProgram.Machine.Outputs[VERT_RESULT_PSIZ][0] = ctx->Point.Size;
}
/* copy the output registers into the VB->attribs arrays */
/* XXX (optimize) could use a conditional and smaller loop limit here */
for (attr = 0; attr < 15; attr++) {
COPY_4V(store->attribs[attr].data[i],
- ctx->VertexProgram.Outputs[attr]);
+ ctx->VertexProgram.Machine.Outputs[attr]);
}
}