r300g: Add VBO dumper for SW TCL.
[mesa.git] / src / gallium / drivers / nvfx / nvfx_vbo.c
index 5ffbdfcb2a65f3a8c2b85a74bcd861c8ca058a30..520bae5aed2b82fd3a89598a71884219531407c1 100644 (file)
@@ -8,6 +8,7 @@
 #include "nvfx_resource.h"
 
 #include "nouveau/nouveau_channel.h"
+#include "nouveau/nouveau_class.h"
 #include "nouveau/nouveau_pushbuf.h"
 #include "nouveau/nouveau_util.h"
 
@@ -122,11 +123,12 @@ nvfx_vbo_static_attrib(struct nvfx_context *nvfx,
        struct pipe_transfer *transfer;
        struct nouveau_channel* chan = nvfx->screen->base.channel;
        void *map;
+       float *v;
 
        map  = pipe_buffer_map(&nvfx->pipe, vb->buffer, PIPE_TRANSFER_READ, &transfer);
-       map += vb->buffer_offset + ve->src_offset;
+       map = (uint8_t *) map + vb->buffer_offset + ve->src_offset;
 
-       float *v = map;
+       v = map;
 
        switch (ncomp) {
        case 4:
@@ -167,17 +169,17 @@ nvfx_draw_arrays(struct pipe_context *pipe,
 
        nvfx_vbo_set_idxbuf(nvfx, NULL, 0);
        if (nvfx->screen->force_swtnl || !nvfx_state_validate(nvfx)) {
-               nvfx_draw_elements_swtnl(pipe, NULL, 0,
+               nvfx_draw_elements_swtnl(pipe, NULL, 0, 0,
                                            mode, start, count);
                 return;
        }
 
        while (count) {
-               unsigned vc, nr;
+               unsigned vc, nr, avail;
 
                nvfx_state_emit(nvfx);
 
-               unsigned avail = AVAIL_RING(chan);
+               avail = AVAIL_RING(chan);
                avail -= 16 + (avail >> 10); /* for the BEGIN_RING_NIs, conservatively assuming one every 1024, plus 16 for safety */
 
                vc = nouveau_vbuf_split(avail, 6, 256,
@@ -229,11 +231,11 @@ nvfx_draw_elements_u08(struct nvfx_context *nvfx, void *ib,
 
        while (count) {
                uint8_t *elts = (uint8_t *)ib + start;
-               unsigned vc, push, restart = 0;
+               unsigned vc, push, restart = 0, avail;
 
                nvfx_state_emit(nvfx);
 
-               unsigned avail = AVAIL_RING(chan);
+               avail = AVAIL_RING(chan);
                avail -= 16 + (avail >> 10); /* for the BEGIN_RING_NIs, conservatively assuming one every 1024, plus 16 for safety */
 
                vc = nouveau_vbuf_split(avail, 6, 2,
@@ -282,11 +284,11 @@ nvfx_draw_elements_u16(struct nvfx_context *nvfx, void *ib,
 
        while (count) {
                uint16_t *elts = (uint16_t *)ib + start;
-               unsigned vc, push, restart = 0;
+               unsigned vc, push, restart = 0, avail;
 
                nvfx_state_emit(nvfx);
 
-               unsigned avail = AVAIL_RING(chan);
+               avail = AVAIL_RING(chan);
                avail -= 16 + (avail >> 10); /* for the BEGIN_RING_NIs, conservatively assuming one every 1024, plus 16 for safety */
 
                vc = nouveau_vbuf_split(avail, 6, 2,
@@ -335,11 +337,11 @@ nvfx_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
 
        while (count) {
                uint32_t *elts = (uint32_t *)ib + start;
-               unsigned vc, push, restart = 0;
+               unsigned vc, push, restart = 0, avail;
 
                nvfx_state_emit(nvfx);
 
-               unsigned avail = AVAIL_RING(chan);
+               avail = AVAIL_RING(chan);
                avail -= 16 + (avail >> 10); /* for the BEGIN_RING_NIs, conservatively assuming one every 1024, plus 16 for safety */
 
                vc = nouveau_vbuf_split(avail, 5, 1,
@@ -372,7 +374,8 @@ nvfx_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
 
 static void
 nvfx_draw_elements_inline(struct pipe_context *pipe,
-                         struct pipe_resource *ib, unsigned ib_size,
+                         struct pipe_resource *ib,
+                         unsigned ib_size, int ib_bias,
                          unsigned mode, unsigned start, unsigned count)
 {
        struct nvfx_context *nvfx = nvfx_context(pipe);
@@ -385,6 +388,8 @@ nvfx_draw_elements_inline(struct pipe_context *pipe,
                return;
        }
 
+       assert(ib_bias == 0);
+
        switch (ib_size) {
        case 1:
                nvfx_draw_elements_u08(nvfx, map, mode, start, count);
@@ -413,11 +418,11 @@ nvfx_draw_elements_vbo(struct pipe_context *pipe,
        unsigned restart = 0;
 
        while (count) {
-               unsigned nr, vc;
+               unsigned nr, vc, avail;
 
                nvfx_state_emit(nvfx);
 
-               unsigned avail = AVAIL_RING(chan);
+               avail = AVAIL_RING(chan);
                avail -= 16 + (avail >> 10); /* for the BEGIN_RING_NIs, conservatively assuming one every 1024, plus 16 for safety */
 
                vc = nouveau_vbuf_split(avail, 6, 256,
@@ -460,7 +465,8 @@ nvfx_draw_elements_vbo(struct pipe_context *pipe,
 
 void
 nvfx_draw_elements(struct pipe_context *pipe,
-                  struct pipe_resource *indexBuffer, unsigned indexSize,
+                  struct pipe_resource *indexBuffer,
+                  unsigned indexSize, int indexBias,
                   unsigned mode, unsigned start, unsigned count)
 {
        struct nvfx_context *nvfx = nvfx_context(pipe);
@@ -468,15 +474,17 @@ nvfx_draw_elements(struct pipe_context *pipe,
 
        idxbuf = nvfx_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
        if (nvfx->screen->force_swtnl || !nvfx_state_validate(nvfx)) {
-               nvfx_draw_elements_swtnl(pipe, indexBuffer, indexSize,
-                                           mode, start, count);
+               nvfx_draw_elements_swtnl(pipe,
+                                        indexBuffer, indexSize, indexBias,
+                                        mode, start, count);
                return;
        }
 
        if (idxbuf) {
                nvfx_draw_elements_vbo(pipe, mode, start, count);
        } else {
-               nvfx_draw_elements_inline(pipe, indexBuffer, indexSize,
+               nvfx_draw_elements_inline(pipe,
+                                         indexBuffer, indexSize, indexBias,
                                          mode, start, count);
        }