diff options
author | Zack Rusin <[email protected]> | 2010-06-15 08:05:51 -0400 |
---|---|---|
committer | Zack Rusin <[email protected]> | 2010-06-15 09:12:20 -0400 |
commit | a192b5eeafae80f9f9e7e7e442abc5b44d583d1a (patch) | |
tree | dac505a2bd9ee02cfc5d163c81a0587a7989625f /src/gallium/auxiliary/draw/draw_gs.c | |
parent | 92e521a79982f19279f72c34772d33c9c28e2bed (diff) |
draw: finish the new pipeline setup
Keith came up with a new way of running the pipeline which involves passing
a few info structs around (for fetch, vertices and prims) and allows us
to correctly handle cases where we endup with multiple primitives generated
by the pipeline itself.
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_gs.c')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_gs.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c index 787d93aef15..5d8fe10d77f 100644 --- a/src/gallium/auxiliary/draw/draw_gs.c +++ b/src/gallium/auxiliary/draw/draw_gs.c @@ -171,9 +171,10 @@ draw_geometry_fetch_outputs(struct draw_geometry_shader *shader, /* Unswizzle all output results. */ - shader->emitted_primitives += num_primitives; for (prim_idx = 0; prim_idx < num_primitives; ++prim_idx) { unsigned num_verts_per_prim = machine->Primitives[prim_idx]; + shader->primitive_lengths[prim_idx + shader->emitted_primitives] = + machine->Primitives[prim_idx]; shader->emitted_vertices += num_verts_per_prim; for (j = 0; j < num_verts_per_prim; j++) { int idx = (prim_idx * num_verts_per_prim + j) * @@ -199,6 +200,7 @@ draw_geometry_fetch_outputs(struct draw_geometry_shader *shader, } } *p_output = output; + shader->emitted_primitives += num_primitives; } @@ -333,57 +335,60 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader, struct draw_vertex_info *output_verts, struct draw_prim_info *output_prims ) { - const float (*input)[4] = input_verts->verts; + const float (*input)[4] = (const float (*)[4])input_verts->verts->data; unsigned input_stride = input_verts->vertex_size; unsigned vertex_size = input_verts->vertex_size; struct tgsi_exec_machine *machine = shader->machine; unsigned int i; unsigned num_in_primitives = u_gs_prims_for_vertices(input_prim->prim, input_verts->count); + unsigned max_out_prims = u_gs_prims_for_vertices(shader->output_primitive, + shader->max_output_vertices) + * num_in_primitives; output_verts->vertex_size = input_verts->vertex_size; output_verts->stride = input_verts->vertex_size; - output_verts->count = draw_max_output_vertices(draw, + output_verts->count = draw_max_output_vertices(shader->draw, input_prim->prim, input_verts->count); output_verts->verts = - (struct vertex_header *)MALLOC(vert_info.vertex_size * - vert_info.count); + (struct vertex_header *)MALLOC(input_verts->vertex_size * + num_in_primitives * + shader->max_output_vertices); if (0) debug_printf("%s count = %d (prims = %d)\n", __FUNCTION__, - count, num_in_primitives); + input_verts->count, num_in_primitives); shader->emitted_vertices = 0; shader->emitted_primitives = 0; shader->vertex_size = vertex_size; - shader->tmp_output = (float (*)[4])input_verts->verts->data; + shader->tmp_output = (float (*)[4])output_verts->verts->data; shader->in_prim_idx = 0; shader->input_vertex_stride = input_stride; shader->input = input; + if (shader->primitive_lengths) { + FREE(shader->primitive_lengths); + } + shader->primitive_lengths = MALLOC(max_out_prims * sizeof(unsigned)); for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { machine->Consts[i] = constants[i]; } - gs_run(shader, pipe_prim, count); - - if (shader->emitted_vertices > 0) { - memcpy(output, pipeline_verts->data, - shader->info.num_outputs * 4 * sizeof(float) + - vertex_size * (shader->emitted_vertices -1)); - } + gs_run(shader, input_prim, input_verts, output_prims, output_verts); - - /* Update prim_info: + /* Update prim_info: */ output_prims->linear = TRUE; output_prims->elts = NULL; - output_prims->primitive_lengths = machine->foo; - output_prims->primitive_count = machine->bar; + output_prims->start = 0; + output_prims->prim = shader->output_primitive; + output_prims->primitive_lengths = shader->primitive_lengths; + output_prims->primitive_count = shader->emitted_primitives; return shader->emitted_vertices; } |