Merge branch 'gallium-0.2' into gallium-winsys-private
[mesa.git] / src / gallium / drivers / nv50 / nv50_vbo.c
index 3f0b66ae3659cff30e601c01c6a3a272ad731153..86471c00e03da2616d3f54498563ff48cae9aad1 100644 (file)
@@ -1,6 +1,27 @@
+/*
+ * Copyright 2008 Ben Skeggs
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
-#include "pipe/p_util.h"
 
 #include "nv50_context.h"
 
@@ -39,6 +60,10 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start,
        OUT_RING  (0);
        BEGIN_RING(tesla, 0x142c, 1);
        OUT_RING  (0);
+       BEGIN_RING(tesla, 0x1440, 1);
+       OUT_RING  (0);
+       BEGIN_RING(tesla, 0x1334, 1);
+       OUT_RING  (0);
 
        BEGIN_RING(tesla, NV50TCL_VERTEX_BEGIN, 1);
        OUT_RING  (nv50_prim(mode));
@@ -128,7 +153,7 @@ nv50_draw_elements(struct pipe_context *pipe,
 {
        struct nv50_context *nv50 = nv50_context(pipe);
        struct pipe_winsys *ws = pipe->winsys;
-       void *map = ws->buffer_map(ws, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ);
+       void *map = ws->_buffer_map(ws, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ);
 
        nv50_state_validate(nv50);
 
@@ -185,27 +210,29 @@ nv50_vbo_validate(struct nv50_context *nv50)
                case PIPE_FORMAT_R32G32_FLOAT:
                        so_data(vtxfmt, 0x7e200000 | i);
                        break;
+               case PIPE_FORMAT_R32_FLOAT:
+                       so_data(vtxfmt, 0x7e900000 | i);
+                       break;
                case PIPE_FORMAT_R8G8B8A8_UNORM:
                        so_data(vtxfmt, 0x24500000 | i);
                        break;
                default:
                {
-                       char fmt[128];
-                       pf_sprint_name(fmt, ve->src_format);
-                       NOUVEAU_ERR("invalid vbo format %s\n", fmt);
+                       NOUVEAU_ERR("invalid vbo format %s\n",
+                                   pf_name(ve->src_format));
                        assert(0);
                        return;
                }
                }
 
                so_method(vtxbuf, tesla, 0x900 + (i * 16), 3);
-               so_data  (vtxbuf, 0x20000000 | vb->pitch);
+               so_data  (vtxbuf, 0x20000000 | vb->stride);
                so_reloc (vtxbuf, vb->buffer, vb->buffer_offset +
-                         ve->src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
-                         NOUVEAU_BO_HIGH, 0, 0);
+                         ve->src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
+                         NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
                so_reloc (vtxbuf, vb->buffer, vb->buffer_offset +
-                         ve->src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD |
-                         NOUVEAU_BO_LOW, 0, 0);
+                         ve->src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
+                         NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
        }
 
        so_ref (vtxfmt, &nv50->state.vtxfmt);