From 6d8dbd3d1ec888300fb0e9ac3cf61808ba8ecc2b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Sat, 12 Sep 2009 14:12:35 -0700 Subject: [PATCH] tgsi/ureg: VS inputs don't have any semantic tags, just an index Fix ureg_DECL_vs_input to reflect this and fix up all callers. --- src/gallium/auxiliary/tgsi/tgsi_ureg.c | 72 +++++++++---------- src/gallium/auxiliary/tgsi/tgsi_ureg.h | 3 +- src/gallium/auxiliary/util/u_simple_shaders.c | 4 +- .../state_trackers/xorg/xorg_exa_tgsi.c | 15 ++-- 4 files changed, 44 insertions(+), 50 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index e24a0ad776e..55a4e5b2e92 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -87,8 +87,10 @@ struct ureg_program unsigned semantic_name; unsigned semantic_index; unsigned interp; - } input[UREG_MAX_INPUT]; - unsigned nr_inputs; + } fs_input[UREG_MAX_INPUT]; + unsigned nr_fs_inputs; + + unsigned vs_inputs[UREG_MAX_INPUT/32]; struct { unsigned semantic_name; @@ -232,25 +234,25 @@ ureg_src_register( unsigned file, -static struct ureg_src -ureg_DECL_input( struct ureg_program *ureg, - unsigned name, - unsigned index, - unsigned interp_mode ) +struct ureg_src +ureg_DECL_fs_input( struct ureg_program *ureg, + unsigned name, + unsigned index, + unsigned interp_mode ) { unsigned i; - for (i = 0; i < ureg->nr_inputs; i++) { - if (ureg->input[i].semantic_name == name && - ureg->input[i].semantic_index == index) + for (i = 0; i < ureg->nr_fs_inputs; i++) { + if (ureg->fs_input[i].semantic_name == name && + ureg->fs_input[i].semantic_index == index) goto out; } - if (ureg->nr_inputs < UREG_MAX_INPUT) { - ureg->input[i].semantic_name = name; - ureg->input[i].semantic_index = index; - ureg->input[i].interp = interp_mode; - ureg->nr_inputs++; + if (ureg->nr_fs_inputs < UREG_MAX_INPUT) { + ureg->fs_input[i].semantic_name = name; + ureg->fs_input[i].semantic_index = index; + ureg->fs_input[i].interp = interp_mode; + ureg->nr_fs_inputs++; } else { set_bad( ureg ); @@ -261,25 +263,14 @@ out: } - -struct ureg_src -ureg_DECL_fs_input( struct ureg_program *ureg, - unsigned name, - unsigned index, - unsigned interp ) -{ - assert(ureg->processor == TGSI_PROCESSOR_FRAGMENT); - return ureg_DECL_input( ureg, name, index, interp ); -} - - struct ureg_src ureg_DECL_vs_input( struct ureg_program *ureg, - unsigned name, unsigned index ) { assert(ureg->processor == TGSI_PROCESSOR_VERTEX); - return ureg_DECL_input( ureg, name, index, TGSI_INTERPOLATE_CONSTANT ); + + ureg->vs_inputs[index/32] |= 1 << (index % 32); + return ureg_src_register( TGSI_FILE_INPUT, index ); } @@ -781,13 +772,22 @@ static void emit_decls( struct ureg_program *ureg ) { unsigned i; - for (i = 0; i < ureg->nr_inputs; i++) { - emit_decl( ureg, - TGSI_FILE_INPUT, - i, - ureg->input[i].semantic_name, - ureg->input[i].semantic_index, - ureg->input[i].interp ); + if (ureg->processor == TGSI_PROCESSOR_VERTEX) { + for (i = 0; i < UREG_MAX_INPUT; i++) { + if (ureg->vs_inputs[i/32] & (1 << (i%32))) { + emit_decl_range( ureg, TGSI_FILE_INPUT, i, 1 ); + } + } + } + else { + for (i = 0; i < ureg->nr_fs_inputs; i++) { + emit_decl( ureg, + TGSI_FILE_INPUT, + i, + ureg->fs_input[i].semantic_name, + ureg->fs_input[i].semantic_index, + ureg->fs_input[i].interp ); + } } for (i = 0; i < ureg->nr_outputs; i++) { diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index acbca59040c..3bc1b775030 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -116,8 +116,7 @@ ureg_DECL_fs_input( struct ureg_program *, struct ureg_src ureg_DECL_vs_input( struct ureg_program *, - unsigned semantic_name, - unsigned semantic_index ); + unsigned index ); struct ureg_dst ureg_DECL_output( struct ureg_program *, diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c index e5fc9b0ceeb..0d706f9449d 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/src/gallium/auxiliary/util/u_simple_shaders.c @@ -61,9 +61,7 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, struct ureg_src src; struct ureg_dst dst; - src = ureg_DECL_vs_input( ureg, - semantic_names[i], - semantic_indexes[i]); + src = ureg_DECL_vs_input( ureg, i ); dst = ureg_DECL_output( ureg, semantic_names[i], diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index 694eded09a2..978dc209c0d 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -241,6 +241,7 @@ create_vs(struct pipe_context *pipe, boolean is_fill = vs_traits & VS_FILL; boolean is_composite = vs_traits & VS_COMPOSITE; boolean has_mask = vs_traits & VS_MASK; + unsigned input_slot = 0; ureg = ureg_create(TGSI_PROCESSOR_VERTEX); if (ureg == NULL) @@ -252,30 +253,26 @@ create_vs(struct pipe_context *pipe, /* it has to be either a fill or a composite op */ debug_assert(is_fill ^ is_composite); - src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_POSITION, 0); + src = ureg_DECL_vs_input(ureg, input_slot++); dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 0); src = vs_normalize_coords(ureg, src, const0, const1); ureg_MOV(ureg, dst, src); - if (is_composite) { - src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_GENERIC, 1); + src = ureg_DECL_vs_input(ureg, input_slot++); dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 1); ureg_MOV(ureg, dst, src); } + if (is_fill) { - src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_COLOR, 0); + src = ureg_DECL_vs_input(ureg, input_slot++); dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0); ureg_MOV(ureg, dst, src); } if (has_mask) { - src = ureg_DECL_vs_input(ureg, - TGSI_SEMANTIC_GENERIC, 2); + src = ureg_DECL_vs_input(ureg, input_slot++); dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 2); ureg_MOV(ureg, dst, src); } -- 2.30.2