X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fauxiliary%2Fdraw%2Fdraw_pt_vcache.c;h=914c87a9dc485a38c8d63c4a6a7f51d8431a8b57;hb=0b8e1980276a3935e6748e2f459313ffd2681146;hp=1a0527be63a8380ea9e5962fd7a0d9cf9c71e302;hpb=e363ec1d08858735c6f2b1454c43f39c96d5bab6;p=mesa.git diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c index 1a0527be63a..914c87a9dc4 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache.c +++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c @@ -54,7 +54,7 @@ struct vcache_frontend { unsigned draw_count; unsigned fetch_count; unsigned fetch_max; - + struct draw_pt_middle_end *middle; unsigned input_prim; @@ -64,14 +64,15 @@ struct vcache_frontend { unsigned opt; }; -static INLINE void +static INLINE void vcache_flush( struct vcache_frontend *vcache ) { if (vcache->middle_prim != vcache->output_prim) { vcache->middle_prim = vcache->output_prim; - vcache->middle->prepare( vcache->middle, - vcache->middle_prim, - vcache->opt, + vcache->middle->prepare( vcache->middle, + vcache->input_prim, + vcache->middle_prim, + vcache->opt, &vcache->fetch_max ); } @@ -183,8 +184,16 @@ vcache_quad( struct vcache_frontend *vcache, unsigned i2, unsigned i3 ) { - vcache_triangle( vcache, i0, i1, i3 ); - vcache_triangle( vcache, i1, i2, i3 ); + if (vcache->draw->rasterizer->flatshade_first) { + /* pass last quad vertex as first triangle vertex */ + vcache_triangle( vcache, i3, i0, i1 ); + vcache_triangle( vcache, i3, i1, i2 ); + } + else { + /* pass last quad vertex as last triangle vertex */ + vcache_triangle( vcache, i0, i1, i3 ); + vcache_triangle( vcache, i1, i2, i3 ); + } } static INLINE void @@ -195,18 +204,20 @@ vcache_ef_quad( struct vcache_frontend *vcache, unsigned i3 ) { if (vcache->draw->rasterizer->flatshade_first) { + /* pass last quad vertex as first triangle vertex */ vcache_triangle_flags( vcache, ( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_0 | DRAW_PIPE_EDGE_FLAG_1 ), - i0, i1, i2 ); + i3, i0, i1 ); vcache_triangle_flags( vcache, - ( DRAW_PIPE_EDGE_FLAG_2 | - DRAW_PIPE_EDGE_FLAG_1 ), - i0, i2, i3 ); + ( DRAW_PIPE_EDGE_FLAG_1 | + DRAW_PIPE_EDGE_FLAG_2 ), + i3, i1, i2 ); } else { + /* pass last quad vertex as last triangle vertex */ vcache_triangle_flags( vcache, ( DRAW_PIPE_RESET_STIPPLE | DRAW_PIPE_EDGE_FLAG_0 | @@ -329,6 +340,7 @@ static INLINE void vcache_check_run( struct draw_pt_front_end *frontend, pt_elt_func get_elt, const void *elts, + int elt_bias, unsigned draw_count ) { struct vcache_frontend *vcache = (struct vcache_frontend *)frontend; @@ -345,24 +357,29 @@ vcache_check_run( struct draw_pt_front_end *frontend, if (0) debug_printf("fetch_count %d fetch_max %d draw_count %d\n", fetch_count, vcache->fetch_max, draw_count); - - if (max_index == 0xffffffff || + + if (elt_bias + max_index >= DRAW_PIPE_MAX_VERTICES || + fetch_count >= UNDEFINED_VERTEX_ID || fetch_count > draw_count) { if (0) debug_printf("fail\n"); goto fail; } - + if (vcache->middle_prim != vcache->input_prim) { vcache->middle_prim = vcache->input_prim; - vcache->middle->prepare( vcache->middle, - vcache->middle_prim, - vcache->opt, + vcache->middle->prepare( vcache->middle, + vcache->input_prim, + vcache->middle_prim, + vcache->opt, &vcache->fetch_max ); } + assert((elt_bias >= 0 && min_index + elt_bias >= min_index) || + (elt_bias < 0 && min_index + elt_bias < min_index)); + if (min_index == 0 && - index_size == 2) + index_size == 2) { transformed_elts = (const ushort *)elts; } @@ -394,6 +411,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, default: assert(0); + FREE(storage); return; } } @@ -422,6 +440,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, default: assert(0); + FREE(storage); return; } } @@ -430,7 +449,7 @@ vcache_check_run( struct draw_pt_front_end *frontend, if (fetch_count < UNDEFINED_VERTEX_ID) ok = vcache->middle->run_linear_elts( vcache->middle, - min_index, /* start */ + min_index + elt_bias, /* start */ fetch_count, transformed_elts, draw_count ); @@ -444,15 +463,16 @@ vcache_check_run( struct draw_pt_front_end *frontend, fetch_count, draw_count); fail: - vcache_run( frontend, get_elt, elts, draw_count ); + vcache_run( frontend, get_elt, elts, elt_bias, draw_count ); } -static void +static void vcache_prepare( struct draw_pt_front_end *frontend, - unsigned prim, + unsigned in_prim, + unsigned out_prim, struct draw_pt_middle_end *middle, unsigned opt ) { @@ -462,13 +482,13 @@ vcache_prepare( struct draw_pt_front_end *frontend, { vcache->base.run = vcache_run_extras; } - else + else { vcache->base.run = vcache_check_run; } - vcache->input_prim = prim; - vcache->output_prim = u_reduced_prim(prim); + vcache->input_prim = in_prim; + vcache->output_prim = u_reduced_prim(out_prim); vcache->middle = middle; vcache->opt = opt; @@ -477,7 +497,8 @@ vcache_prepare( struct draw_pt_front_end *frontend, * doing so: */ vcache->middle_prim = (opt & PT_PIPELINE) ? vcache->output_prim : vcache->input_prim; - middle->prepare( middle, vcache->middle_prim, opt, &vcache->fetch_max ); + middle->prepare( middle, vcache->input_prim, + vcache->middle_prim, opt, &vcache->fetch_max ); }