aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/translate/translate_generic.c
diff options
context:
space:
mode:
authorMichal Krol <[email protected]>2009-12-29 23:21:01 +0100
committerMichal Krol <[email protected]>2009-12-29 23:21:01 +0100
commit7ca0ce38340144794267609646048b3820d594ab (patch)
tree7c31399f0373cb652b682e9af0fedde839d58a77 /src/gallium/auxiliary/translate/translate_generic.c
parent7124fa16efe0f8ffb402bcd182f276032bed378d (diff)
Implement draw_arrays_instanced() in softpipe.
Modify the translate module to respect instance divisors and accept instance id as a parameter to calculate input vertex offset.
Diffstat (limited to 'src/gallium/auxiliary/translate/translate_generic.c')
-rw-r--r--src/gallium/auxiliary/translate/translate_generic.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c
index 266e7ee81e6..0fa99274099 100644
--- a/src/gallium/auxiliary/translate/translate_generic.c
+++ b/src/gallium/auxiliary/translate/translate_generic.c
@@ -49,6 +49,7 @@ struct translate_generic {
fetch_func fetch;
unsigned buffer;
unsigned input_offset;
+ unsigned instance_divisor;
emit_func emit;
unsigned output_offset;
@@ -607,6 +608,7 @@ static void PIPE_CDECL generic_run_elts( struct translate *translate,
static void PIPE_CDECL generic_run( struct translate *translate,
unsigned start,
unsigned count,
+ unsigned instance_id,
void *output_buffer )
{
struct translate_generic *tg = translate_generic(translate);
@@ -622,13 +624,20 @@ static void PIPE_CDECL generic_run( struct translate *translate,
for (attr = 0; attr < nr_attrs; attr++) {
float data[4];
-
- const char *src = (tg->attrib[attr].input_ptr +
- tg->attrib[attr].input_stride * elt);
+ const char *src;
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);
+ } else {
+ src = tg->attrib[attr].input_ptr +
+ tg->attrib[attr].input_stride * elt;
+ }
+
tg->attrib[attr].fetch( src, data );
if (0) debug_printf("vert %d attr %d: %f %f %f %f\n",
@@ -687,6 +696,7 @@ struct translate *translate_generic_create( const struct translate_key *key )
tg->attrib[i].fetch = get_fetch_func(key->element[i].input_format);
tg->attrib[i].buffer = key->element[i].input_buffer;
tg->attrib[i].input_offset = key->element[i].input_offset;
+ tg->attrib[i].instance_divisor = key->element[i].instance_divisor;
tg->attrib[i].emit = get_emit_func(key->element[i].output_format);
tg->attrib[i].output_offset = key->element[i].output_offset;