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:
@@ -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 {
|
struct pipe_constant_buffer {
|
||||||
GLfloat constant[PIPE_MAX_CONSTANT][4];
|
GLfloat constant[PIPE_MAX_CONSTANT][4];
|
||||||
GLuint nr_constants;
|
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
|
struct pipe_depth_state
|
||||||
{
|
{
|
||||||
GLuint enabled:1; /**< depth test enabled? */
|
GLuint enabled:1; /**< depth test enabled? */
|
||||||
|
@@ -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 outputs[FRAG_ATTRIB_MAX + 1];
|
||||||
struct tgsi_exec_vector *ainputs;
|
struct tgsi_exec_vector *ainputs;
|
||||||
struct tgsi_exec_vector *aoutputs;
|
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 );
|
ainputs = (struct tgsi_exec_vector *) tgsi_align_128bit( inputs );
|
||||||
aoutputs = (struct tgsi_exec_vector *) tgsi_align_128bit( outputs );
|
aoutputs = (struct tgsi_exec_vector *) tgsi_align_128bit( outputs );
|
||||||
|
|
||||||
|
#if 0
|
||||||
for( i = total = 0; i < PIPE_ATTRIB_MAX; i++ ) {
|
for( i = total = 0; i < PIPE_ATTRIB_MAX; i++ ) {
|
||||||
GLuint attr;
|
GLuint attr;
|
||||||
|
|
||||||
attr = softpipe->fp_attr_to_slot[i];
|
attr = softpipe->fp_attr_to_slot[i];
|
||||||
if( attr ) {
|
if( attr || total == 0) {
|
||||||
assert( total < FRAG_ATTRIB_MAX );
|
assert( total < FRAG_ATTRIB_MAX );
|
||||||
assert( attr < FRAG_ATTRIB_MAX );
|
assert( attr < FRAG_ATTRIB_MAX );
|
||||||
assert( sizeof( ainputs[0] ) == sizeof( exec.attr[0] ) );
|
assert( sizeof( ainputs[0] ) == sizeof( exec.attr[0] ) );
|
||||||
@@ -211,16 +216,33 @@ shade_quad( struct quad_stage *qs, struct quad_header *quad )
|
|||||||
total++;
|
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(
|
tgsi_exec_machine_init(
|
||||||
&machine,
|
&machine,
|
||||||
softpipe->fs.tokens );
|
softpipe->fs.tokens );
|
||||||
|
|
||||||
machine.Inputs = ainputs;
|
machine.Inputs = ainputs;
|
||||||
machine.Outputs = aoutputs;
|
machine.Outputs = aoutputs;
|
||||||
|
machine.Consts = softpipe->fs.constants->constant; /* XXX alignment? */
|
||||||
|
|
||||||
tgsi_exec_machine_run(
|
/* run shader */
|
||||||
&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
|
#else
|
||||||
{
|
{
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
* Keith Whitwell <keith@tungstengraphics.com>
|
* Keith Whitwell <keith@tungstengraphics.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "shader/prog_parameter.h"
|
||||||
#include "st_context.h"
|
#include "st_context.h"
|
||||||
#include "pipe/p_context.h"
|
#include "pipe/p_context.h"
|
||||||
#include "st_atom.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 )
|
static void update_fs( struct st_context *st )
|
||||||
{
|
{
|
||||||
struct pipe_fs_state fs;
|
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 &&
|
if (st->ctx->Shader.CurrentProgram &&
|
||||||
st->ctx->Shader.CurrentProgram->LinkStatus) {
|
st->ctx->Shader.CurrentProgram->LinkStatus &&
|
||||||
fp = st_fragment_program(st->ctx->Shader.CurrentProgram->FragmentProgram);
|
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) {
|
else if (st->ctx->FragmentProgram._Current) {
|
||||||
fp = st_fragment_program(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)
|
if (fp->dirty)
|
||||||
compile_fs( st, fp );
|
compile_fs( st, fp );
|
||||||
|
|
||||||
|
memset( &fs, 0, sizeof(fs) );
|
||||||
fs.inputs_read = fp->Base.Base.InputsRead;
|
fs.inputs_read = fp->Base.Base.InputsRead;
|
||||||
fs.tokens = &fp->tokens[0];
|
fs.tokens = &fp->tokens[0];
|
||||||
|
fs.constants = &fp->constants;
|
||||||
|
|
||||||
if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0 ||
|
if (memcmp(&fs, &st->state.fs, sizeof(fs)) != 0 ||
|
||||||
fp->dirty)
|
fp->dirty)
|
||||||
|
@@ -53,6 +53,7 @@ struct st_fragment_program
|
|||||||
struct tgsi_token tokens[ST_FP_MAX_TOKENS];
|
struct tgsi_token tokens[ST_FP_MAX_TOKENS];
|
||||||
GLboolean dirty;
|
GLboolean dirty;
|
||||||
|
|
||||||
|
struct pipe_constant_buffer constants;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
GLfloat (*cbuffer)[4];
|
GLfloat (*cbuffer)[4];
|
||||||
|
Reference in New Issue
Block a user