diff options
author | José Fonseca <jfonseca@vmware.com> | 2010-04-26 14:49:42 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2010-04-26 16:05:06 +0100 |
commit | fc431a58dc1446383edc11aec2a0b7de5b363e5e (patch) | |
tree | 6857e13f0b44bb5e24a4c7ebf66c68478249dd87 /src/gallium/auxiliary/translate | |
parent | b02f1c86f5bf8b1169776975491c7df929e94e2c (diff) |
translate: Take and respect a max_index argument.
Diffstat (limited to 'src/gallium/auxiliary/translate')
-rw-r--r-- | src/gallium/auxiliary/translate/translate.h | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/translate/translate_generic.c | 19 | ||||
-rw-r--r-- | src/gallium/auxiliary/translate/translate_sse.c | 10 |
3 files changed, 24 insertions, 8 deletions
diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h index 54ed2c1a4b..edd95e0788 100644 --- a/src/gallium/auxiliary/translate/translate.h +++ b/src/gallium/auxiliary/translate/translate.h @@ -76,7 +76,8 @@ struct translate { void (*set_buffer)( struct translate *, unsigned i, const void *ptr, - unsigned stride ); + unsigned stride, + unsigned max_index ); void (PIPE_CDECL *run_elts)( struct translate *, const unsigned *elts, diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c index c3ec9ae3f4..a9272fbb49 100644 --- a/src/gallium/auxiliary/translate/translate_generic.c +++ b/src/gallium/auxiliary/translate/translate_generic.c @@ -31,6 +31,7 @@ */ #include "util/u_memory.h" +#include "util/u_math.h" #include "pipe/p_state.h" #include "translate.h" @@ -58,6 +59,7 @@ struct translate_generic { char *input_ptr; unsigned input_stride; + unsigned max_index; } attrib[PIPE_MAX_ATTRIBS]; @@ -588,19 +590,22 @@ static void PIPE_CDECL generic_run_elts( struct translate *translate, for (attr = 0; attr < nr_attrs; attr++) { float data[4]; const char *src; + unsigned index; char *dst = (vert + tg->attrib[attr].output_offset); if (tg->attrib[attr].instance_divisor) { - src = tg->attrib[attr].input_ptr + - tg->attrib[attr].input_stride * - (instance_id / tg->attrib[attr].instance_divisor); + index = instance_id / tg->attrib[attr].instance_divisor; } else { - src = tg->attrib[attr].input_ptr + - tg->attrib[attr].input_stride * elt; + index = elt; } + index = MIN2(index, tg->attrib[attr].max_index); + + src = tg->attrib[attr].input_ptr + + tg->attrib[attr].input_stride * index; + tg->attrib[attr].fetch( src, data ); if (0) debug_printf("vert %d/%d attr %d: %f %f %f %f\n", @@ -670,7 +675,8 @@ static void PIPE_CDECL generic_run( struct translate *translate, static void generic_set_buffer( struct translate *translate, unsigned buf, const void *ptr, - unsigned stride ) + unsigned stride, + unsigned max_index ) { struct translate_generic *tg = translate_generic(translate); unsigned i; @@ -680,6 +686,7 @@ static void generic_set_buffer( struct translate *translate, tg->attrib[i].input_ptr = ((char *)ptr + tg->attrib[i].input_offset); tg->attrib[i].input_stride = stride; + tg->attrib[i].max_index = max_index; } } } diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c index c13e742738..ef3aa674a3 100644 --- a/src/gallium/auxiliary/translate/translate_sse.c +++ b/src/gallium/auxiliary/translate/translate_sse.c @@ -61,6 +61,7 @@ typedef void (PIPE_CDECL *run_elts_func)( struct translate *translate, struct translate_buffer { const void *base_ptr; unsigned stride; + unsigned max_index; }; struct translate_buffer_varient { @@ -423,6 +424,11 @@ static boolean init_inputs( struct translate_sse *p, } else { x86_mov(p->func, tmp_EAX, elt); } + + /* + * TODO: Respect translate_buffer::max_index. + */ + x86_imul(p->func, tmp_EAX, buf_stride); x86_add(p->func, tmp_EAX, buf_base_ptr); @@ -666,13 +672,15 @@ static boolean build_vertex_emit( struct translate_sse *p, static void translate_sse_set_buffer( struct translate *translate, unsigned buf, const void *ptr, - unsigned stride ) + unsigned stride, + unsigned max_index ) { struct translate_sse *p = (struct translate_sse *)translate; if (buf < p->nr_buffers) { p->buffer[buf].base_ptr = (char *)ptr; p->buffer[buf].stride = stride; + p->buffer[buf].max_index = max_index; } if (0) debug_printf("%s %d/%d: %p %d\n", |