i965/gs: implement EndPrimitive() functionality in the visitor.
[mesa.git] / src / mesa / drivers / dri / nouveau / nouveau_render_t.c
index 78379482832239338f150a01ef46f00b02f1c780..0063dac2d78ab2495d19f84e116ffd1545f09f12 100644 (file)
                }                                                       \
        } while (0)
 
-/*
- * Select an appropriate dispatch function for the given index buffer.
- */
-static dispatch_t
-get_array_dispatch(struct nouveau_array *a)
+static void
+dispatch_l(struct gl_context *ctx, unsigned int start, int delta,
+          unsigned int n)
 {
-       if (!a->fields) {
-               auto void f(struct gl_context *, unsigned int, int, unsigned int);
+       struct nouveau_pushbuf *push = context_push(ctx);
+       RENDER_LOCALS(ctx);
 
-               void f(struct gl_context *ctx, unsigned int start, int delta,
-                      unsigned int n) {
-                       struct nouveau_channel *chan = context_chan(ctx);
-                       RENDER_LOCALS(ctx);
-
-                       EMIT_VBO(L, ctx, start, delta, n);
-               };
-
-               return f;
-
-       } else if (a->type == GL_UNSIGNED_INT) {
-               auto void f(struct gl_context *, unsigned int, int, unsigned int);
-
-               void f(struct gl_context *ctx, unsigned int start, int delta,
-                      unsigned int n) {
-                       struct nouveau_channel *chan = context_chan(ctx);
-                       RENDER_LOCALS(ctx);
-
-                       EMIT_VBO(I32, ctx, start, delta, n);
-               };
+       EMIT_VBO(L, ctx, start, delta, n);
+}
 
-               return f;
+static void
+dispatch_i32(struct gl_context *ctx, unsigned int start, int delta,
+            unsigned int n)
+{
+       struct nouveau_pushbuf *push = context_push(ctx);
+       RENDER_LOCALS(ctx);
 
-       } else {
-               auto void f(struct gl_context *, unsigned int, int, unsigned int);
+       EMIT_VBO(I32, ctx, start, delta, n);
+}
 
-               void f(struct gl_context *ctx, unsigned int start, int delta,
-                      unsigned int n) {
-                       struct nouveau_channel *chan = context_chan(ctx);
-                       RENDER_LOCALS(ctx);
+static void
+dispatch_i16(struct gl_context *ctx, unsigned int start, int delta,
+            unsigned int n)
+{
+       struct nouveau_pushbuf *push = context_push(ctx);
+       RENDER_LOCALS(ctx);
 
-                       EMIT_VBO(I32, ctx, start, delta, n & 1);
-                       EMIT_VBO(I16, ctx, start, delta, n & ~1);
-               };
+       EMIT_VBO(I32, ctx, start, delta, n & 1);
+       EMIT_VBO(I16, ctx, start, delta, n & ~1);
+}
 
-               return f;
-       }
+/*
+ * Select an appropriate dispatch function for the given index buffer.
+ */
+static dispatch_t
+get_array_dispatch(struct nouveau_array *a)
+{
+       if (!a->fields)
+               return dispatch_l;
+       else if (a->type == GL_UNSIGNED_INT)
+               return dispatch_i32;
+       else
+               return dispatch_i16;
 }
 
 /*
@@ -173,6 +170,11 @@ get_max_vertices(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
                        case GL_UNSIGNED_BYTE:
                                max_out = MAX_OUT_I16;
                                break;
+
+                       default:
+                               assert(0);
+                               max_out = 0;
+                               break;
                        }
                } else {
                        max_out = MAX_OUT_L;
@@ -182,69 +184,26 @@ get_max_vertices(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
        }
 }
 
-#include "nouveau_vbo_t.c"
-#include "nouveau_swtnl_t.c"
-
 static void
 TAG(emit_material)(struct gl_context *ctx, struct nouveau_array *a,
                   const void *v)
 {
-       const int attr = a->attr - VERT_ATTRIB_GENERIC0;
-       const int state = ((int []) {
-                               NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT,
-                               NOUVEAU_STATE_MATERIAL_BACK_AMBIENT,
-                               NOUVEAU_STATE_MATERIAL_FRONT_DIFFUSE,
-                               NOUVEAU_STATE_MATERIAL_BACK_DIFFUSE,
-                               NOUVEAU_STATE_MATERIAL_FRONT_SPECULAR,
-                               NOUVEAU_STATE_MATERIAL_BACK_SPECULAR,
-                               NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT,
-                               NOUVEAU_STATE_MATERIAL_BACK_AMBIENT,
-                               NOUVEAU_STATE_MATERIAL_FRONT_SHININESS,
-                               NOUVEAU_STATE_MATERIAL_BACK_SHININESS
-                       }) [attr];
+       int attr = a->attr - VERT_ATTRIB_GENERIC0;
+       int state = ((int []) {
+                       NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT,
+                       NOUVEAU_STATE_MATERIAL_BACK_AMBIENT,
+                       NOUVEAU_STATE_MATERIAL_FRONT_DIFFUSE,
+                       NOUVEAU_STATE_MATERIAL_BACK_DIFFUSE,
+                       NOUVEAU_STATE_MATERIAL_FRONT_SPECULAR,
+                       NOUVEAU_STATE_MATERIAL_BACK_SPECULAR,
+                       NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT,
+                       NOUVEAU_STATE_MATERIAL_BACK_AMBIENT,
+                       NOUVEAU_STATE_MATERIAL_FRONT_SHININESS,
+                       NOUVEAU_STATE_MATERIAL_BACK_SHININESS
+               }) [attr];
 
        COPY_4V(ctx->Light.Material.Attrib[attr], (float *)v);
        _mesa_update_material(ctx, 1 << attr);
 
        context_drv(ctx)->emit[state](ctx, state);
 }
-
-static void
-TAG(render_prims)(struct gl_context *ctx, const struct gl_client_array **arrays,
-                 const struct _mesa_prim *prims, GLuint nr_prims,
-                 const struct _mesa_index_buffer *ib,
-                 GLboolean index_bounds_valid,
-                 GLuint min_index, GLuint max_index)
-{
-       struct nouveau_context *nctx = to_nouveau_context(ctx);
-
-       nouveau_validate_framebuffer(ctx);
-
-       if (nctx->fallback == HWTNL)
-               TAG(vbo_render_prims)(ctx, arrays, prims, nr_prims, ib,
-                                     index_bounds_valid, min_index, max_index);
-
-       if (nctx->fallback == SWTNL)
-               _tnl_vbo_draw_prims(ctx, arrays, prims, nr_prims, ib,
-                                   index_bounds_valid, min_index, max_index);
-}
-
-void
-TAG(render_init)(struct gl_context *ctx)
-{
-       struct nouveau_render_state *render = to_render_state(ctx);
-       int i;
-
-       for (i = 0; i < VERT_ATTRIB_MAX; i++)
-               render->map[i] = -1;
-
-       TAG(swtnl_init)(ctx);
-       vbo_set_draw_func(ctx, TAG(render_prims));
-       vbo_use_buffer_objects(ctx);
-}
-
-void
-TAG(render_destroy)(struct gl_context *ctx)
-{
-       TAG(swtnl_destroy)(ctx);
-}