From 890809d71b6ab40c56d341a5dad9f5e6b06469d0 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Fri, 18 Dec 2009 15:54:28 +0100 Subject: [PATCH] gallium: fix mesa to tgsi translation for edgeflags test apps (progs/trivial/tri-edgeflags and similar) seem to work now --- src/mesa/state_tracker/st_mesa_to_tgsi.c | 15 ++++++++++++- src/mesa/state_tracker/st_mesa_to_tgsi.h | 3 ++- src/mesa/state_tracker/st_program.c | 28 +++++++++++++----------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 72bd17bf41d..7b334e21d23 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -718,6 +718,16 @@ emit_face_var( struct st_translate *t, t->inputs[t->inputMapping[FRAG_ATTRIB_FACE]] = ureg_src(face_temp); } +static void +emit_edgeflags( struct st_translate *t, + const struct gl_program *program ) +{ + struct ureg_program *ureg = t->ureg; + struct ureg_dst edge_dst = t->outputs[t->outputMapping[VERT_RESULT_EDGE]]; + struct ureg_src edge_src = t->inputs[t->inputMapping[VERT_ATTRIB_EDGEFLAG]]; + + ureg_MOV( ureg, edge_dst, edge_src ); +} /** * Translate Mesa program to TGSI format. @@ -752,7 +762,8 @@ st_translate_mesa_program( GLuint numOutputs, const GLuint outputMapping[], const ubyte outputSemanticName[], - const ubyte outputSemanticIndex[] ) + const ubyte outputSemanticIndex[], + boolean passthrough_edgeflags ) { struct st_translate translate, *t; unsigned i; @@ -823,6 +834,8 @@ st_translate_mesa_program( outputSemanticName[i], outputSemanticIndex[i] ); } + if (passthrough_edgeflags) + emit_edgeflags( t, program ); } /* Declare address register. diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h index 9dae373edef..e3c5bd1d94d 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -54,7 +54,8 @@ st_translate_mesa_program( GLuint numOutputs, const GLuint outputMapping[], const ubyte outputSemanticName[], - const ubyte outputSemanticIndex[] ); + const ubyte outputSemanticIndex[], + boolean passthrough_edgeflags ); void st_free_tokens(const struct tgsi_token *tokens); diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 45ab8504ae5..fcc04782de2 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -185,6 +185,10 @@ st_prepare_vertex_program(struct st_context *st, } } } + /* similar hack to above, presetup potentially unused edgeflag output */ + stvp->result_to_output[VERT_RESULT_EDGE] = stvp->num_outputs; + stvp->output_semantic_name[stvp->num_outputs] = TGSI_SEMANTIC_EDGEFLAG; + stvp->output_semantic_index[stvp->num_outputs] = 0; } @@ -197,12 +201,18 @@ st_translate_vertex_program(struct st_context *st, struct pipe_context *pipe = st->pipe; struct ureg_program *ureg; enum pipe_error error; + unsigned num_outputs; ureg = ureg_create( TGSI_PROCESSOR_VERTEX ); if (ureg == NULL) return NULL; vpv->num_inputs = stvp->num_inputs; + num_outputs = stvp->num_outputs; + if (key->passthrough_edgeflags) { + vpv->num_inputs++; + num_outputs++; + } error = st_translate_mesa_program(st->ctx, @@ -210,29 +220,21 @@ st_translate_vertex_program(struct st_context *st, ureg, &stvp->Base.Base, /* inputs */ - stvp->num_inputs, + vpv->num_inputs, stvp->input_to_index, NULL, /* input semantic name */ NULL, /* input semantic index */ NULL, /* outputs */ - stvp->num_outputs, + num_outputs, stvp->result_to_output, stvp->output_semantic_name, - stvp->output_semantic_index ); + stvp->output_semantic_index, + key->passthrough_edgeflags ); if (error) goto fail; - /* Edgeflags will be the last input: - */ - if (key->passthrough_edgeflags) { - ureg_MOV( ureg, - ureg_DECL_output( ureg, TGSI_SEMANTIC_EDGEFLAG, 0 ), - ureg_DECL_vs_input( ureg, vpv->num_inputs )); - vpv->num_inputs++; - } - vpv->state.tokens = ureg_get_tokens( ureg, NULL ); ureg_destroy( ureg ); @@ -430,7 +432,7 @@ st_translate_fragment_program(struct st_context *st, fs_num_outputs, outputMapping, fs_output_semantic_name, - fs_output_semantic_index ); + fs_output_semantic_index, FALSE ); stfp->state.tokens = ureg_get_tokens( ureg, NULL ); ureg_destroy( ureg ); -- 2.30.2