diff options
author | Francisco Jerez <[email protected]> | 2010-11-10 20:18:33 +0100 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2010-11-11 14:50:50 +0100 |
commit | cdb38b5d3d1b93a90a91ad06c0f03efdfde6b525 (patch) | |
tree | 1ebfc5ddf9b1b1c11e1e7e08c8204e05507195bd /src/mesa/drivers/dri/nouveau | |
parent | dc524adee2cfd0f115800cd4ec3f8384010f154e (diff) |
dri/nouveau: Split hardware/software TNL instantiation more cleanly.
Diffstat (limited to 'src/mesa/drivers/dri/nouveau')
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_render_t.c | 69 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 41 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv10_context.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv10_driver.h | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv10_render.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv20_context.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv20_driver.h | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv20_render.c | 2 |
9 files changed, 84 insertions, 66 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c index 43164ec34f8..e0cf727d11d 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c @@ -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); -} diff --git a/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c b/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c index 0377c7ffc9d..f084f89d29e 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_swtnl_t.c @@ -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); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c index 3d8f43ffb4a..7a0eb9fc23d 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c @@ -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) +{ +} diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c index 78be401ba2a..de2c93ec815 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_context.c +++ b/src/mesa/drivers/dri/nouveau/nv10_context.c @@ -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; diff --git a/src/mesa/drivers/dri/nouveau/nv10_driver.h b/src/mesa/drivers/dri/nouveau/nv10_driver.h index dec3d64e7d2..6fdc4641623 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_driver.h +++ b/src/mesa/drivers/dri/nouveau/nv10_driver.h @@ -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 diff --git a/src/mesa/drivers/dri/nouveau/nv10_render.c b/src/mesa/drivers/dri/nouveau/nv10_render.c index 94ff3ed01e2..7115739b5aa 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_render.c +++ b/src/mesa/drivers/dri/nouveau/nv10_render.c @@ -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" diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c index c31fd39fac4..89200fb70da 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_context.c +++ b/src/mesa/drivers/dri/nouveau/nv20_context.c @@ -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; diff --git a/src/mesa/drivers/dri/nouveau/nv20_driver.h b/src/mesa/drivers/dri/nouveau/nv20_driver.h index 7fbe6ccfa68..f2a6097b937 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_driver.h +++ b/src/mesa/drivers/dri/nouveau/nv20_driver.h @@ -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 diff --git a/src/mesa/drivers/dri/nouveau/nv20_render.c b/src/mesa/drivers/dri/nouveau/nv20_render.c index 19fc1e81fa9..dbdb85da203 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_render.c +++ b/src/mesa/drivers/dri/nouveau/nv20_render.c @@ -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" |