dri/nouveau: Split hardware/software TNL instantiation more cleanly.
authorFrancisco Jerez <currojerez@riseup.net>
Wed, 10 Nov 2010 19:18:33 +0000 (20:18 +0100)
committerFrancisco Jerez <currojerez@riseup.net>
Thu, 11 Nov 2010 13:50:50 +0000 (14:50 +0100)
src/mesa/drivers/dri/nouveau/nouveau_render_t.c
src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c
src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
src/mesa/drivers/dri/nouveau/nv10_context.c
src/mesa/drivers/dri/nouveau/nv10_driver.h
src/mesa/drivers/dri/nouveau/nv10_render.c
src/mesa/drivers/dri/nouveau/nv20_context.c
src/mesa/drivers/dri/nouveau/nv20_driver.h
src/mesa/drivers/dri/nouveau/nv20_render.c

index 43164ec34f81179a19fb6c28241d4f75c1560a32..e0cf727d11d809c584d372f4b9acb49fe80d6b41 100644 (file)
@@ -187,69 +187,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);
-}
index 0377c7ffc9d54dc5b39030005a6149adf3159622..f084f89d29ef9066e56439220e25fe21330eb3ff 100644 (file)
@@ -310,7 +310,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);
@@ -341,7 +341,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);
index 3d8f43ffb4aa7d978059fecb3e2046009f21b1f2..7a0eb9fc23dcc32576600e4b0336af565e791b01 100644 (file)
@@ -456,3 +456,44 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
 
        vbo_deinit_arrays(ctx, ib, arrays);
 }
+
+/* VBO rendering entry points. */
+
+static void
+TAG(vbo_check_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(vbo_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;
+
+       vbo_set_draw_func(ctx, TAG(vbo_check_render_prims));
+       vbo_use_buffer_objects(ctx);
+}
+
+void
+TAG(vbo_destroy)(struct gl_context *ctx)
+{
+}
index 78be401ba2abad03e4b9b7ef8ee1a1d0959844c6..de2c93ec8155670cdcd3965eacde3a22cc58a210 100644 (file)
@@ -411,7 +411,8 @@ nv10_context_destroy(struct gl_context *ctx)
        struct nouveau_context *nctx = to_nouveau_context(ctx);
 
        nv04_surface_takedown(ctx);
-       nv10_render_destroy(ctx);
+       nv10_swtnl_destroy(ctx);
+       nv10_vbo_destroy(ctx);
 
        nouveau_grobj_free(&nctx->hw.eng3d);
 
@@ -467,7 +468,8 @@ nv10_context_create(struct nouveau_screen *screen, const struct gl_config *visua
                goto fail;
 
        nv10_hwctx_init(ctx);
-       nv10_render_init(ctx);
+       nv10_vbo_init(ctx);
+       nv10_swtnl_init(ctx);
 
        return ctx;
 
index dec3d64e7d220d9a89a6bb86615035ca65dd7dab..6fdc4641623c49d53c38cadbda2742108df64205 100644 (file)
@@ -45,10 +45,16 @@ nv10_transform_depth(struct gl_context *ctx, float z);
 
 /* nv10_render.c */
 void
-nv10_render_init(struct gl_context *ctx);
+nv10_vbo_init(struct gl_context *ctx);
 
 void
-nv10_render_destroy(struct gl_context *ctx);
+nv10_vbo_destroy(struct gl_context *ctx);
+
+void
+nv10_swtnl_init(struct gl_context *ctx);
+
+void
+nv10_swtnl_destroy(struct gl_context *ctx);
 
 /* nv10_state_fb.c */
 void
index 94ff3ed01e274361199214a3254e64c3db15baa4..7115739b5aa17697f9f7ffe81ff9f8e25ab7cfdb 100644 (file)
@@ -193,3 +193,5 @@ nv10_render_bind_vertices(struct gl_context *ctx)
 
 #define TAG(x) nv10_##x
 #include "nouveau_render_t.c"
+#include "nouveau_vbo_t.c"
+#include "nouveau_swtnl_t.c"
index c31fd39fac44f1904b38c2907dea849981611e35..89200fb70da63573b50455a57a54c070fc1ae44e 100644 (file)
@@ -425,7 +425,8 @@ nv20_context_destroy(struct gl_context *ctx)
        struct nouveau_context *nctx = to_nouveau_context(ctx);
 
        nv04_surface_takedown(ctx);
-       nv20_render_destroy(ctx);
+       nv20_swtnl_destroy(ctx);
+       nv20_vbo_destroy(ctx);
 
        nouveau_grobj_free(&nctx->hw.eng3d);
 
@@ -478,7 +479,8 @@ nv20_context_create(struct nouveau_screen *screen, const struct gl_config *visua
                goto fail;
 
        nv20_hwctx_init(ctx);
-       nv20_render_init(ctx);
+       nv20_vbo_init(ctx);
+       nv20_swtnl_init(ctx);
 
        return ctx;
 
index 7fbe6ccfa689f0f9ade54ad3884dfea9623a4089..f2a6097b937b6df212dc2a4789d88db546b61466 100644 (file)
@@ -39,10 +39,16 @@ extern const struct nouveau_driver nv20_driver;
 
 /* nv20_render.c */
 void
-nv20_render_init(struct gl_context *ctx);
+nv20_vbo_init(struct gl_context *ctx);
 
 void
-nv20_render_destroy(struct gl_context *ctx);
+nv20_vbo_destroy(struct gl_context *ctx);
+
+void
+nv20_swtnl_init(struct gl_context *ctx);
+
+void
+nv20_swtnl_destroy(struct gl_context *ctx);
 
 /* nv20_state_fb.c */
 void
index 19fc1e81fa9f9542e1a78d18e22ac197c5dea45c..dbdb85da203f89a1ed1ae848d6b8167f9fef51f6 100644 (file)
@@ -217,3 +217,5 @@ nv20_render_bind_vertices(struct gl_context *ctx)
 
 #define TAG(x) nv20_##x
 #include "nouveau_render_t.c"
+#include "nouveau_vbo_t.c"
+#include "nouveau_swtnl_t.c"