};
-struct pipe_fs_state {
- GLuint inputs_read; /* FRAG_ATTRIB_* */
- const struct tgsi_token *tokens;
-
-};
-
struct pipe_constant_buffer {
GLfloat constant[PIPE_MAX_CONSTANT][4];
GLuint nr_constants;
};
+struct pipe_fs_state {
+ GLuint inputs_read; /* FRAG_ATTRIB_* */
+ const struct tgsi_token *tokens;
+ struct pipe_constant_buffer *constants; /* XXX temporary? */
+};
+
struct pipe_depth_state
{
GLuint enabled:1; /**< depth test enabled? */
struct tgsi_exec_vector outputs[FRAG_ATTRIB_MAX + 1];
struct tgsi_exec_vector *ainputs;
struct tgsi_exec_vector *aoutputs;
- GLuint i, total;
+ GLuint i /*, total*/;
+
+#ifdef DEBUG
+ memset(&machine, 0, sizeof(machine));
+#endif
ainputs = (struct tgsi_exec_vector *) tgsi_align_128bit( inputs );
aoutputs = (struct tgsi_exec_vector *) tgsi_align_128bit( outputs );
+#if 0
for( i = total = 0; i < PIPE_ATTRIB_MAX; i++ ) {
GLuint attr;
attr = softpipe->fp_attr_to_slot[i];
- if( attr ) {
+ if( attr || total == 0) {
assert( total < FRAG_ATTRIB_MAX );
assert( attr < FRAG_ATTRIB_MAX );
assert( sizeof( ainputs[0] ) == sizeof( exec.attr[0] ) );
total++;
}
}
+#else
+ /* load input registers */
+ /* XXX simpler than above, but might not be right... */
+ for (i = 0; i < softpipe->nr_attrs; i++) {
+ memcpy(
+ &ainputs[i],
+ exec.attr[i],
+ sizeof( ainputs[0] ) );
+ }
+#endif
+ /* init machine state */
tgsi_exec_machine_init(
&machine,
softpipe->fs.tokens );
machine.Inputs = ainputs;
machine.Outputs = aoutputs;
+ machine.Consts = softpipe->fs.constants->constant; /* XXX alignment? */
+
+ /* run shader */
+ tgsi_exec_machine_run( &machine );
- tgsi_exec_machine_run(
- &machine );
+ /* store result color */
+ memcpy(quad->outputs.color,
+ &aoutputs[FRAG_ATTRIB_COL0].xyzw[0].f[0],
+ sizeof(quad->outputs.color));
}
#else
{
* Keith Whitwell <keith@tungstengraphics.com>
*/
+#include "shader/prog_parameter.h"
#include "st_context.h"
#include "pipe/p_context.h"
#include "st_atom.h"
static void update_fs( struct st_context *st )
{
struct pipe_fs_state fs;
- struct st_fragment_program *fp;
+ struct st_fragment_program *fp = NULL;
+ struct gl_program_parameter_list *params = NULL;
if (st->ctx->Shader.CurrentProgram &&
- st->ctx->Shader.CurrentProgram->LinkStatus) {
- fp = st_fragment_program(st->ctx->Shader.CurrentProgram->FragmentProgram);
+ st->ctx->Shader.CurrentProgram->LinkStatus &&
+ st->ctx->Shader.CurrentProgram->FragmentProgram) {
+ struct gl_fragment_program *f
+ = st->ctx->Shader.CurrentProgram->FragmentProgram;
+ fp = st_fragment_program(f);
+ params = f->Base.Parameters;
}
else if (st->ctx->FragmentProgram._Current) {
fp = st_fragment_program(st->ctx->FragmentProgram._Current);
+ params = st->ctx->FragmentProgram._Current->Base.Parameters;
}
- memset( &fs, 0, sizeof(fs) );
+ if (fp && params) {
+ /* load program's constants array */
+ fp->constants.nr_constants = params->NumParameters;
+ memcpy(fp->constants.constant,
+ params->ParameterValues,
+ params->NumParameters * sizeof(GLfloat) * 4);
+ }
if (fp->dirty)
compile_fs( st, fp );
-
+
+ memset( &fs, 0, sizeof(fs) );
fs.inputs_read = fp->Base.Base.InputsRead;
fs.tokens = &fp->tokens[0];
+ fs.constants = &fp->constants;
if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0 ||
fp->dirty)
struct tgsi_token tokens[ST_FP_MAX_TOKENS];
GLboolean dirty;
+ struct pipe_constant_buffer constants;
#if 0
GLfloat (*cbuffer)[4];