Merge branch 'mesa_7_6_branch'
[mesa.git] / src / gallium / drivers / nv40 / nv40_vbo.c
index f20183ddd4dfd3f3c4154a6b29b9d246c3ec6f04..b2753b8e2e052a655a7f89c28e5d3243ec5c84ed 100644 (file)
@@ -1,5 +1,6 @@
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
+#include "pipe/p_inlines.h"
 
 #include "nv40_context.h"
 #include "nv40_state.h"
@@ -70,7 +71,7 @@ static boolean
 nv40_vbo_set_idxbuf(struct nv40_context *nv40, struct pipe_buffer *ib,
                    unsigned ib_size)
 {
-       struct pipe_screen *pscreen = &nv40->screen->pipe;
+       struct pipe_screen *pscreen = &nv40->screen->base.base;
        unsigned type;
 
        if (!ib) {
@@ -108,7 +109,7 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
                       int attrib, struct pipe_vertex_element *ve,
                       struct pipe_vertex_buffer *vb)
 {
-       struct pipe_winsys *ws = nv40->pipe.winsys;
+       struct pipe_screen *pscreen = nv40->pipe.screen;
        struct nouveau_grobj *curie = nv40->screen->curie;
        unsigned type, ncomp;
        void *map;
@@ -116,7 +117,7 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
        if (nv40_vbo_format_to_hw(ve->src_format, &type, &ncomp))
                return FALSE;
 
-       map  = ws->_buffer_map(ws, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ);
+       map  = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ);
        map += vb->buffer_offset + ve->src_offset;
 
        switch (type) {
@@ -148,17 +149,17 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
                        so_data  (so, fui(v[0]));
                        break;
                default:
-                       ws->_buffer_unmap(ws, vb->buffer);
+                       pipe_buffer_unmap(pscreen, vb->buffer);
                        return FALSE;
                }
        }
                break;
        default:
-               ws->_buffer_unmap(ws, vb->buffer);
+               pipe_buffer_unmap(pscreen, vb->buffer);
                return FALSE;
        }
 
-       ws->_buffer_unmap(ws, vb->buffer);
+       pipe_buffer_unmap(pscreen, vb->buffer);
 
        return TRUE;
 }
@@ -168,7 +169,7 @@ nv40_draw_arrays(struct pipe_context *pipe,
                 unsigned mode, unsigned start, unsigned count)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
-       struct nouveau_channel *chan = nv40->nvws->channel;
+       struct nouveau_channel *chan = nv40->screen->base.channel;
        unsigned restart;
 
        nv40_vbo_set_idxbuf(nv40, NULL, 0);
@@ -227,7 +228,7 @@ static INLINE void
 nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv40->nvws->channel;
+       struct nouveau_channel *chan = nv40->screen->base.channel;
 
        while (count) {
                uint8_t *elts = (uint8_t *)ib + start;
@@ -276,7 +277,7 @@ static INLINE void
 nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv40->nvws->channel;
+       struct nouveau_channel *chan = nv40->screen->base.channel;
 
        while (count) {
                uint16_t *elts = (uint16_t *)ib + start;
@@ -325,7 +326,7 @@ static INLINE void
 nv40_draw_elements_u32(struct nv40_context *nv40, void *ib,
                       unsigned mode, unsigned start, unsigned count)
 {
-       struct nouveau_channel *chan = nv40->nvws->channel;
+       struct nouveau_channel *chan = nv40->screen->base.channel;
 
        while (count) {
                uint32_t *elts = (uint32_t *)ib + start;
@@ -367,10 +368,10 @@ nv40_draw_elements_inline(struct pipe_context *pipe,
                          unsigned mode, unsigned start, unsigned count)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
-       struct pipe_winsys *ws = pipe->winsys;
+       struct pipe_screen *pscreen = pipe->screen;
        void *map;
 
-       map = ws->_buffer_map(ws, ib, PIPE_BUFFER_USAGE_CPU_READ);
+       map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ);
        if (!ib) {
                NOUVEAU_ERR("failed mapping ib\n");
                return FALSE;
@@ -391,7 +392,7 @@ nv40_draw_elements_inline(struct pipe_context *pipe,
                break;
        }
 
-       ws->_buffer_unmap(ws, ib);
+       pipe_buffer_unmap(pscreen, ib);
        return TRUE;
 }
 
@@ -400,7 +401,7 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
                       unsigned mode, unsigned start, unsigned count)
 {
        struct nv40_context *nv40 = nv40_context(pipe);
-       struct nouveau_channel *chan = nv40->nvws->channel;
+       struct nouveau_channel *chan = nv40->screen->base.channel;
        unsigned restart;
 
        while (count) {
@@ -519,17 +520,20 @@ nv40_vbo_validate(struct nv40_context *nv40)
                        return FALSE;
                }
 
-               so_reloc(vtxbuf, vb->buffer, vb->buffer_offset + ve->src_offset,
-                        vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
-                        0, NV40TCL_VTXBUF_ADDRESS_DMA1);
+               so_reloc(vtxbuf, nouveau_bo(vb->buffer),
+                                vb->buffer_offset + ve->src_offset,
+                                vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
+                                0, NV40TCL_VTXBUF_ADDRESS_DMA1);
                so_data (vtxfmt, ((vb->stride << NV40TCL_VTXFMT_STRIDE_SHIFT) |
                                  (ncomp << NV40TCL_VTXFMT_SIZE_SHIFT) | type));
        }
 
        if (ib) {
+               struct nouveau_bo *bo = nouveau_bo(ib);
+
                so_method(vtxbuf, curie, NV40TCL_IDXBUF_ADDRESS, 2);
-               so_reloc (vtxbuf, ib, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
-               so_reloc (vtxbuf, ib, ib_format, vb_flags | NOUVEAU_BO_OR,
+               so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
+               so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR,
                          0, NV40TCL_IDXBUF_FORMAT_DMA1);
        }
 
@@ -537,10 +541,13 @@ nv40_vbo_validate(struct nv40_context *nv40)
        so_data  (vtxbuf, 0);
 
        so_ref(vtxbuf, &nv40->state.hw[NV40_STATE_VTXBUF]);
+       so_ref(NULL, &vtxbuf);
        nv40->state.dirty |= (1ULL << NV40_STATE_VTXBUF);
        so_ref(vtxfmt, &nv40->state.hw[NV40_STATE_VTXFMT]);
+       so_ref(NULL, &vtxfmt);
        nv40->state.dirty |= (1ULL << NV40_STATE_VTXFMT);
        so_ref(sattr, &nv40->state.hw[NV40_STATE_VTXATTR]);
+       so_ref(NULL, &sattr);
        nv40->state.dirty |= (1ULL << NV40_STATE_VTXATTR);
        return FALSE;
 }