From: Brian Date: Tue, 24 Jul 2007 18:27:38 +0000 (-0600) Subject: Basic fragment programs run now. X-Git-Tag: 062012170305~17580^2~390^2~4674 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43d7c1fe9d2544b851afa2f1c1e245a63860e670;p=profile%2Fivi%2Fmesa.git 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). --- diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index e3f62a8..c370417 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -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? */ diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c index 536365f..846c330 100644 --- a/src/mesa/pipe/softpipe/sp_quad_fs.c +++ b/src/mesa/pipe/softpipe/sp_quad_fs.c @@ -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? */ + + /* 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 { diff --git a/src/mesa/state_tracker/st_atom_fs.c b/src/mesa/state_tracker/st_atom_fs.c index 2397828..9ca1807 100644 --- a/src/mesa/state_tracker/st_atom_fs.c +++ b/src/mesa/state_tracker/st_atom_fs.c @@ -29,6 +29,7 @@ * Keith Whitwell */ +#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) diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index b288879..f6d5f6d 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -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];