translate: Take and respect a max_index argument.

This commit is contained in:
José Fonseca
2010-04-26 14:49:42 +01:00
parent b02f1c86f5
commit fc431a58dc
3 changed files with 24 additions and 8 deletions
+2 -1
View File
@@ -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,
@@ -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;
}
}
}
@@ -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",