diff options
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c')
-rw-r--r-- | lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c b/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c index 7ff705a91..e628a143d 100644 --- a/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c +++ b/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c @@ -29,7 +29,7 @@ #include "draw_fs.h" #include "draw_gs.h" - +#include "draw_tess.h" #include "util/u_debug.h" #include "util/u_memory.h" #include "util/u_prim.h" @@ -59,8 +59,14 @@ needs_primid(const struct draw_context *draw) { const struct draw_fragment_shader *fs = draw->fs.fragment_shader; const struct draw_geometry_shader *gs = draw->gs.geometry_shader; + const struct draw_tess_eval_shader *tes = draw->tes.tess_eval_shader; if (fs && fs->info.uses_primid) { - return !gs || !gs->info.uses_primid; + if (gs) + return !gs->info.uses_primid; + else if (tes) + return !tes->info.uses_primid; + else + return TRUE; } return FALSE; } @@ -70,6 +76,9 @@ draw_prim_assembler_is_required(const struct draw_context *draw, const struct draw_prim_info *prim_info, const struct draw_vertex_info *vert_info) { + /* viewport index requires primitive boundaries to get correct vertex */ + if (draw_current_shader_uses_viewport_index(draw)) + return TRUE; switch (prim_info->prim) { case PIPE_PRIM_LINES_ADJACENCY: case PIPE_PRIM_LINE_STRIP_ADJACENCY: @@ -81,6 +90,16 @@ draw_prim_assembler_is_required(const struct draw_context *draw, } } +static void +add_prim(struct draw_assembler *asmblr, unsigned length) +{ + struct draw_prim_info *output_prims = asmblr->output_prims; + + output_prims->primitive_lengths = realloc(output_prims->primitive_lengths, sizeof(unsigned) * (output_prims->primitive_count + 1)); + output_prims->primitive_lengths[output_prims->primitive_count] = length; + output_prims->primitive_count++; +} + /* * Copy the vertex header along with its data from the current * vertex buffer into a buffer holding vertices arranged @@ -141,7 +160,8 @@ prim_point(struct draw_assembler *asmblr, inject_primid(asmblr, idx, asmblr->primid++); } indices[0] = idx; - + + add_prim(asmblr, 1); copy_verts(asmblr, indices, 1); } @@ -158,6 +178,7 @@ prim_line(struct draw_assembler *asmblr, indices[0] = i0; indices[1] = i1; + add_prim(asmblr, 2); copy_verts(asmblr, indices, 2); } @@ -176,6 +197,7 @@ prim_tri(struct draw_assembler *asmblr, indices[1] = i1; indices[2] = i2; + add_prim(asmblr, 3); copy_verts(asmblr, indices, 3); } @@ -246,7 +268,7 @@ draw_prim_assembler_run(struct draw_context *draw, output_verts->vertex_size = input_verts->vertex_size; output_verts->stride = input_verts->stride; output_verts->verts = (struct vertex_header*)MALLOC( - input_verts->vertex_size * max_verts); + input_verts->vertex_size * max_verts + DRAW_EXTRA_VERTICES_PADDING); output_verts->count = 0; @@ -263,7 +285,6 @@ draw_prim_assembler_run(struct draw_context *draw, } } - output_prims->primitive_lengths[0] = output_verts->count; output_prims->count = output_verts->count; } |