i965/gs: implement EndPrimitive() functionality in the visitor.
[mesa.git] / src / mesa / drivers / dri / nouveau / nouveau_swtnl_t.c
index 9cf963a9335cf49a1f07faf3dac6a75f5b427d09..0753c3a001903c90c414013bbb9693f56e4ac544 100644 (file)
@@ -118,12 +118,12 @@ swtnl_choose_attrs(struct gl_context *ctx)
        for (i = 0; i < VERT_ATTRIB_MAX; i++) {
                struct nouveau_attr_info *ha = &TAG(vertex_attrs)[i];
                struct swtnl_attr_info *sa = &swtnl_attrs[i];
-               struct nouveau_array_state *a = &render->attrs[i];
+               struct nouveau_array *a = &render->attrs[i];
 
                if (!sa->fields)
                        continue; /* Unsupported attribute. */
 
-               if (RENDERINPUTS_TEST(tnl->render_inputs_bitset, i)) {
+               if (tnl->render_inputs_bitset & BITFIELD64_BIT(i)) {
                        if (sa->fields > 0)
                                fields = sa->fields;
                        else
@@ -165,14 +165,15 @@ swtnl_bind_vertices(struct gl_context *ctx)
 {
        struct nouveau_render_state *render = to_render_state(ctx);
        struct nouveau_swtnl_state *swtnl = &render->swtnl;
+       struct tnl_clipspace *vtx = &TNL_CONTEXT(ctx)->clipspace;
        int i;
 
-       for (i = 0; i < render->attr_count; i++) {
-               int attr = render->map[i];
+       for (i = 0; i < vtx->attr_count; i++) {
+               struct tnl_clipspace_attr *ta = &vtx->attr[i];
+               struct nouveau_array *a = &render->attrs[ta->attrib];
 
-               if (attr >= 0)
-                       nouveau_bo_ref(swtnl->vbo,
-                                      &render->attrs[attr].bo);
+               nouveau_bo_ref(swtnl->vbo, &a->bo);
+               a->offset = swtnl->offset + ta->vertoffset;
        }
 
        TAG(render_bind_vertices)(ctx);
@@ -184,6 +185,8 @@ swtnl_unbind_vertices(struct gl_context *ctx)
        struct nouveau_render_state *render = to_render_state(ctx);
        int i, attr;
 
+       TAG(render_release_vertices)(ctx);
+
        FOR_EACH_BOUND_ATTR(render, i, attr) {
                nouveau_bo_ref(NULL, &render->attrs[attr].bo);
                render->map[i] = -1;
@@ -195,28 +198,28 @@ swtnl_unbind_vertices(struct gl_context *ctx)
 static void
 swtnl_flush_vertices(struct gl_context *ctx)
 {
-       struct nouveau_channel *chan = context_chan(ctx);
+       struct nouveau_pushbuf *push = context_push(ctx);
        struct nouveau_swtnl_state *swtnl = &to_render_state(ctx)->swtnl;
-       unsigned push, start = 0, count = swtnl->vertex_count;
+       unsigned npush, start = 0, count = swtnl->vertex_count;
        RENDER_LOCALS(ctx);
 
        swtnl_bind_vertices(ctx);
 
        while (count) {
-               push = get_max_vertices(ctx, NULL, AVAIL_RING(chan));
-               push = MIN2(push / 12 * 12, count);
-               count -= push;
+               npush = get_max_vertices(ctx, NULL, PUSH_AVAIL(push));
+               npush = MIN2(npush / 12 * 12, count);
+               count -= npush;
 
-               if (!push) {
-                       FIRE_RING(chan);
+               if (!npush) {
+                       PUSH_KICK(push);
                        continue;
                }
 
                BATCH_BEGIN(nvgl_primitive(swtnl->primitive));
-               EMIT_VBO(L, ctx, start, 0, push);
+               EMIT_VBO(L, ctx, start, 0, npush);
                BATCH_END();
 
-               FIRE_RING(chan);
+               PUSH_KICK(push);
        }
 
        swtnl_alloc_vertices(ctx);
@@ -309,7 +312,7 @@ swtnl_quad(struct gl_context *ctx, GLuint v1, GLuint v2, GLuint v3, GLuint v4)
 }
 
 /* TnL initialization. */
-static void
+void
 TAG(swtnl_init)(struct gl_context *ctx)
 {
        TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -340,7 +343,7 @@ TAG(swtnl_init)(struct gl_context *ctx)
        swtnl_alloc_vertices(ctx);
 }
 
-static void
+void
 TAG(swtnl_destroy)(struct gl_context *ctx)
 {
        nouveau_bo_ref(NULL, &to_render_state(ctx)->swtnl.vbo);