Basic fragment programs run now.

Handling of constants might change.  For now, the st_fragment_program struct
contains a pipe_constant_buffer (not a pointer).
This commit is contained in:
Brian
2007-07-24 12:27:38 -06:00
parent ef3849ffa0
commit 43d7c1fe9d
4 changed files with 53 additions and 15 deletions

View File

@@ -122,18 +122,18 @@ struct pipe_clip_state {
};
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? */

View File

@@ -190,16 +190,21 @@ shade_quad( struct quad_stage *qs, struct quad_header *quad )
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] ) );
@@ -211,16 +216,33 @@ shade_quad( struct quad_stage *qs, struct quad_header *quad )
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? */
tgsi_exec_machine_run(
&machine );
/* run shader */
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
{

View File

@@ -29,6 +29,7 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
#include "shader/prog_parameter.h"
#include "st_context.h"
#include "pipe/p_context.h"
#include "st_atom.h"
@@ -50,23 +51,37 @@ static void compile_fs( struct st_context *st,
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)

View File

@@ -53,6 +53,7 @@ struct st_fragment_program
struct tgsi_token tokens[ST_FP_MAX_TOKENS];
GLboolean dirty;
struct pipe_constant_buffer constants;
#if 0
GLfloat (*cbuffer)[4];