svga: Implement index bias.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 19 Apr 2010 16:16:08 +0000 (18:16 +0200)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 19 Apr 2010 16:16:08 +0000 (18:16 +0200)
Untested.

src/gallium/drivers/svga/svga_draw.h
src/gallium/drivers/svga/svga_draw_elements.c
src/gallium/drivers/svga/svga_draw_private.h
src/gallium/drivers/svga/svga_pipe_draw.c
src/gallium/drivers/svga/svga_swtnl.h
src/gallium/drivers/svga/svga_swtnl_backend.c
src/gallium/drivers/svga/svga_swtnl_draw.c

index 81c7f8377de339cc13446e29de9e6417e700217a..a2403d802bebe46293498c9983127746de046632 100644 (file)
@@ -69,12 +69,12 @@ enum pipe_error
 svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
                                 struct pipe_resource *indexBuffer,
                                 unsigned index_size,
+                                int index_bias,
                                 unsigned min_index,
                                 unsigned max_index,
                                 unsigned prim, 
                                 unsigned start, 
-                                unsigned count,
-                                unsigned bias );
+                                unsigned count );
 
 enum pipe_error
 svga_hwtnl_flush( struct svga_hwtnl *hwtnl );
index 7ec4a058fc787ca39118ccc14a0a01356999b269..c4579177b77864350b078935bccdb1c178254382 100644 (file)
@@ -99,12 +99,12 @@ enum pipe_error
 svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
                                        struct pipe_resource *index_buffer,
                                        unsigned index_size,
+                                       int index_bias,
                                        unsigned min_index,
                                        unsigned max_index,
                                        unsigned prim, 
                                        unsigned start,
-                                       unsigned count,
-                                       unsigned bias )
+                                       unsigned count )
 {
    struct pipe_resource *upload_buffer = NULL;
    SVGA3dPrimitiveRange range;
@@ -143,7 +143,7 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
    range.indexArray.offset = index_offset;
    range.indexArray.stride = index_size;
    range.indexWidth = index_size;
-   range.indexBias = bias;
+   range.indexBias = index_bias;
       
    ret = svga_hwtnl_prim( hwtnl, &range, min_index, max_index, index_buffer );
    if (ret)
@@ -163,10 +163,10 @@ enum pipe_error
 svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
                                 struct pipe_resource *index_buffer,
                                 unsigned index_size,
+                                int index_bias,
                                 unsigned min_index,
                                 unsigned max_index,
-                                unsigned prim, unsigned start, unsigned count,
-                                unsigned bias)
+                                unsigned prim, unsigned start, unsigned count)
 {
    unsigned gen_prim, gen_size, gen_nr, gen_type;
    u_translate_func gen_func;
@@ -204,9 +204,10 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
        */
       return svga_hwtnl_simple_draw_range_elements( hwtnl, index_buffer,
                                                     index_size,
+                                                    index_bias,
                                                     min_index,
                                                     max_index,
-                                                    gen_prim, start, count, bias );
+                                                    gen_prim, start, count );
    }
    else {
       struct pipe_resource *gen_buf = NULL;
@@ -231,12 +232,12 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
       ret = svga_hwtnl_simple_draw_range_elements( hwtnl,
                                                    gen_buf,
                                                    gen_size,
+                                                   index_bias,
                                                    min_index,
                                                    max_index,
                                                    gen_prim,
                                                    0,
-                                                   gen_nr,
-                                                   bias );
+                                                   gen_nr );
       if (ret)
          goto done;
 
index b6fcd6854c54ae63534d5a73e32943826e1c1975..11afb59875bdc36add1807e0727cbbd7717dde1b 100644 (file)
@@ -147,12 +147,12 @@ enum pipe_error
 svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
                                        struct pipe_resource *indexBuffer,
                                        unsigned index_size,
+                                       int index_bias,
                                        unsigned min_index,
                                        unsigned max_index,
                                        unsigned prim, 
                                        unsigned start,
-                                       unsigned count,
-                                       unsigned bias );
+                                       unsigned count );
 
 
 #endif
index a05272b2e40ec53e1b5494a2a8a11de45576f5ef..58e930d98355f45a2ba81253423289db061741cb 100644 (file)
@@ -44,6 +44,7 @@ static enum pipe_error
 retry_draw_range_elements( struct svga_context *svga,
                            struct pipe_resource *index_buffer,
                            unsigned index_size,
+                           int index_bias,
                            unsigned min_index,
                            unsigned max_index,
                            unsigned prim, 
@@ -66,9 +67,9 @@ retry_draw_range_elements( struct svga_context *svga,
       goto retry;
 
    ret = svga_hwtnl_draw_range_elements( svga->hwtnl,
-                                         index_buffer, index_size,
+                                         index_buffer, index_size, index_bias,
                                          min_index, max_index,
-                                         prim, start, count, 0 );
+                                         prim, start, count );
    if (ret)
       goto retry;
 
@@ -86,7 +87,7 @@ retry:
    if (do_retry)
    {
       return retry_draw_range_elements( svga,
-                                        index_buffer, index_size,
+                                        index_buffer, index_size, index_bias,
                                         min_index, max_index,
                                         prim, start, count,
                                         FALSE );
@@ -152,6 +153,7 @@ static void
 svga_draw_range_elements( struct pipe_context *pipe,
                           struct pipe_resource *index_buffer,
                           unsigned index_size,
+                          int index_bias,
                           unsigned min_index,
                           unsigned max_index,
                           unsigned prim, unsigned start, unsigned count)
@@ -190,6 +192,7 @@ svga_draw_range_elements( struct pipe_context *pipe,
       ret = svga_swtnl_draw_range_elements( svga, 
                                             index_buffer, 
                                             index_size,
+                                            index_bias,
                                             min_index, max_index,
                                             prim,
                                             start, count );
@@ -199,6 +202,7 @@ svga_draw_range_elements( struct pipe_context *pipe,
          ret = retry_draw_range_elements( svga,
                                           index_buffer,
                                           index_size,
+                                          index_bias,
                                           min_index,
                                           max_index,
                                           prim,
@@ -225,11 +229,11 @@ svga_draw_range_elements( struct pipe_context *pipe,
 static void
 svga_draw_elements( struct pipe_context *pipe,
                     struct pipe_resource *index_buffer,
-                    unsigned index_size,
+                    unsigned index_size, int index_bias,
                     unsigned prim, unsigned start, unsigned count)
 {
    svga_draw_range_elements( pipe, index_buffer,
-                             index_size,
+                             index_size, index_bias,
                              0, 0xffffffff,
                              prim, start, count );
 }
@@ -238,7 +242,7 @@ static void
 svga_draw_arrays( struct pipe_context *pipe,
                   unsigned prim, unsigned start, unsigned count)
 {
-   svga_draw_range_elements(pipe, NULL, 0, 
+   svga_draw_range_elements(pipe, NULL, 0, 0,
                             start, start + count - 1, 
                             prim, 
                             start, count);
index 096ed410b5ba5af3725b948a80f6c21c6ac2732b..8724690f7e1da2489255801024d8da624e46db27 100644 (file)
@@ -42,6 +42,7 @@ enum pipe_error
 svga_swtnl_draw_range_elements(struct svga_context *svga,
                                struct pipe_resource *indexBuffer,
                                unsigned indexSize,
+                               int indexBias,
                                unsigned min_index,
                                unsigned max_index,
                                unsigned prim, 
index e64981360830069cecdc73f3cef27b5dececa96f..b0cbead8a5cb2d6362cb6fa9b48470bff449201a 100644 (file)
@@ -247,7 +247,7 @@ svga_vbuf_render_draw( struct vbuf_render *render,
    struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
    struct svga_context *svga = svga_render->svga;
    struct pipe_screen *screen = svga->pipe.screen;
-   unsigned bias = (svga_render->vbuf_offset - svga_render->vdecl_offset) / svga_render->vertex_size;
+   int bias = (svga_render->vbuf_offset - svga_render->vdecl_offset) / svga_render->vertex_size;
    boolean ret;
    size_t size = 2 * nr_indices;
 
@@ -280,19 +280,21 @@ svga_vbuf_render_draw( struct vbuf_render *render,
    ret = svga_hwtnl_draw_range_elements(svga->hwtnl,
                                         svga_render->ibuf,
                                         2,
+                                        bias,
                                         svga_render->min_index,
                                         svga_render->max_index,
                                         svga_render->prim,
-                                        svga_render->ibuf_offset / 2, nr_indices, bias);
+                                        svga_render->ibuf_offset / 2, nr_indices);
    if(ret != PIPE_OK) {
       svga_context_flush(svga, NULL);
       ret = svga_hwtnl_draw_range_elements(svga->hwtnl,
                                            svga_render->ibuf,
                                            2,
+                                           bias,
                                            svga_render->min_index,
                                            svga_render->max_index,
                                            svga_render->prim,
-                                           svga_render->ibuf_offset / 2, nr_indices, bias);
+                                           svga_render->ibuf_offset / 2, nr_indices);
       svga->swtnl.new_vbuf = TRUE;
       assert(ret == PIPE_OK);
    }
index f771dd59d32b1d89bfe3c10ee9581225f383603a..4504bf71fda363e79512cee28833901465c7ddf0 100644 (file)
@@ -39,6 +39,7 @@ enum pipe_error
 svga_swtnl_draw_range_elements(struct svga_context *svga,
                                struct pipe_resource *indexBuffer,
                                unsigned indexSize,
+                               int indexBias,
                                unsigned min_index,
                                unsigned max_index,
                                unsigned prim, unsigned start, unsigned count)
@@ -82,7 +83,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
                            &ib_transfer);
 
       draw_set_mapped_element_buffer_range(draw, 
-                                           indexSize, 
+                                           indexSize, indexBias,
                                            min_index,
                                            max_index,
                                            map);
@@ -118,7 +119,7 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
 
    if (indexBuffer) {
       pipe_buffer_unmap(&svga->pipe, indexBuffer, ib_transfer);
-      draw_set_mapped_element_buffer(draw, 0, NULL);
+      draw_set_mapped_element_buffer(draw, 0, 0, NULL);
    }
 
    if (svga->curr.cb[PIPE_SHADER_VERTEX]) {