Brian Paul wrote:
> Rune Petersen wrote:
>> Brian Paul wrote:
>
>>> It seems to me that in ctx->Driver.ProgramStringNotify() you can add any
>>> extra parameters you need to the program's parameters list.
>>
>> I would prefer to make driver specific version of
>> _mesa_add_state_reference() for internal state vars.
>>
>> No matter how this is done, the driver needs to call add_parameter() to
>> safely add to the parameter list.
>>
>> Would it be all right if I made add_parameter non static?
>
> You can't use _mesa_add_state_reference()? Perhaps a new
> _mesa_add_driver_state() function otherwise?
>
Turns out I was just being silly, yes _mesa_add_driver_state() will do
just fine.
>
>>> Then, during state validation in the driver you can load/update any
>>> parameters you might have added.
>>
>> I think it is a good idea.
>>
>>
>>> In _mesa_fetch_state() we could change the default case for switch
>>> (state[i]) to be silent when it sees any state tokens it doesn't
>>> understand (rather than call _mesa_problem()).
>> Provided it is only done for STATE_INTERNAL, it should be pretty safe.
>> Also I was thinking adding something like STATE_INTERNAL_DRIVER or some
>> such so the drivers have a safe place to start adding there own vars.
>>
>>> Does that sound feasible?
>> yes, and it would be less intrusive.
>
> OK. I think the next step would be for you to post a patch with
> whatever you need changed. Then we'll understand the details better.
The program.[ch] changes should be straight forward, the only sore point
is the new state index name (STATE_INTERNAL_DRIVER).
The r300_state.c changes is incomplete, but shows how I intend to update
the state vars. _mesa_add_driver_state() will be used to add them to the
parameter list.
Rune Petersen
Index: r300_state.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/r300/r300_state.c,v
retrieving revision 1.166
diff -u -r1.166 r300_state.c
--- r300_state.c 15 Oct 2006 18:22:28 -0000 1.166
+++ r300_state.c 4 Nov 2006 20:07:14 -0000
@@ -1045,6 +1045,50 @@
#endif
}
+static void r300FetchStateParameter(GLcontext *ctx, const enum state_index
state[],
+ GLfloat *value)
+{
+ switch(state[0])
+ {
+ case STATE_INTERNAL:
+ switch(state[1])
+ {
+ case STATE_R300_WINDOW_DIMENSION:
+ break;
+ default:;
+ }
+ default:;
+ }
+}
+
+/**
+ * Update R300's own internal state parameters.
+ * For now just STATE_R300_WINDOW_DIMENSION
+ */
+static void r300UpdateStateParameters(GLcontext * ctx, GLuint new_state)
+{
+ struct r300_vertex_program_cont *vpc;
+ struct gl_program_parameter_list *paramList;
+ GLuint i;
+
+ if(!(new_state & _NEW_BUFFERS))
+ return;
+
+ vpc = (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
+ paramList = vpc->mesa_program.Base.Parameters;
+
+ if (!paramList)
+ return;
+
+ for (i = 0; i < paramList->NumParameters; i++) {
+ if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR){
+ r300FetchStateParameter(ctx,
+ paramList->Parameters[i].StateIndexes,
+ paramList->ParameterValues[i]);
+ }
+ }
+}
+
/* =============================================================
* Polygon state
*/
@@ -1813,6 +1872,9 @@
if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL)) {
r300UpdateDrawBuffer(ctx);
}
+
+ r300UpdateStateParameters(ctx, new_state);
+
#ifndef CB_DPATH
/* Go inefficiency! */
r300ResetHwState(r300);
Index: program.c
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/shader/program.c,v
retrieving revision 1.59
diff -u -r1.59 program.c
--- program.c 10 Oct 2006 22:45:50 -0000 1.59
+++ program.c 4 Nov 2006 19:03:48 -0000
@@ -927,7 +927,9 @@
break;
}
default:
- _mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()");
+ /* unknown state indexes are silently ignored
+ * should be handled by the driver.
+ */
return;
}
}
@@ -1000,7 +1002,9 @@
case STATE_TEXRECT_SCALE:
return _NEW_TEXTURE;
default:
- _mesa_problem(NULL, "unexpected int. state in make_state_flags()");
+ /* unknown state indexes are silently ignored and
+ * no flag set, since it is handled by the driver.
+ */
return 0;
}
@@ -1272,7 +1276,7 @@
case STATE_INTERNAL:
break;
default:
- _mesa_problem(NULL, "Invalid state in maka_state_string");
+ _mesa_problem(NULL, "Invalid state in make_state_string");
break;
}
Index: program.h
===================================================================
RCS file: /cvs/mesa/Mesa/src/mesa/shader/program.h,v
retrieving revision 1.22
diff -u -r1.22 program.h
--- program.h 20 Sep 2006 14:30:22 -0000 1.22
+++ program.h 4 Nov 2006 19:03:48 -0000
@@ -189,7 +189,8 @@
STATE_INTERNAL, /* Mesa additions */
STATE_NORMAL_SCALE,
STATE_TEXRECT_SCALE,
- STATE_POSITION_NORMALIZED /* normalized light position */
+ STATE_POSITION_NORMALIZED, /* normalized light position */
+ STATE_INTERNAL_DRIVER /* first available state index for drivers
(must be last) */
};
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel