} \
} while (0)
-/*
- * Select an appropriate dispatch function for the given index buffer.
- */
static void
-get_array_dispatch(struct nouveau_array_state *a, dispatch_t *dispatch)
+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);
-
- 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);
- };
-
- *dispatch = f;
+ struct nouveau_pushbuf *push = context_push(ctx);
+ RENDER_LOCALS(ctx);
- } 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);
- };
-
- *dispatch = f;
+ EMIT_VBO(L, ctx, start, delta, n);
+}
- } else {
- auto void f(struct gl_context *, unsigned int, int, unsigned int);
+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);
- 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(I32, ctx, start, delta, n & 1);
- EMIT_VBO(I16, ctx, start, delta, n & ~1);
- };
+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);
- *dispatch = f;
- }
+ EMIT_VBO(I32, ctx, start, delta, n & 1);
+ EMIT_VBO(I16, ctx, start, delta, n & ~1);
}
/*
- * Select appropriate element extraction functions for the given
- * array.
+ * Select an appropriate dispatch function for the given index buffer.
*/
-static void
-get_array_extract(struct nouveau_array_state *a,
- extract_u_t *extract_u, extract_f_t *extract_f)
+static dispatch_t
+get_array_dispatch(struct nouveau_array *a)
{
-#define EXTRACT(in_t, out_t, k) \
- ({ \
- auto out_t f(struct nouveau_array_state *, int, int); \
- out_t f(struct nouveau_array_state *a, int i, int j) { \
- in_t x = ((in_t *)(a->buf + i * a->stride))[j]; \
- \
- return (out_t)x / (k); \
- }; \
- f; \
- });
-
- switch (a->type) {
- case GL_BYTE:
- *extract_u = EXTRACT(char, unsigned, 1);
- *extract_f = EXTRACT(char, float, SCHAR_MAX);
- break;
- case GL_UNSIGNED_BYTE:
- *extract_u = EXTRACT(unsigned char, unsigned, 1);
- *extract_f = EXTRACT(unsigned char, float, UCHAR_MAX);
- break;
- case GL_SHORT:
- *extract_u = EXTRACT(short, unsigned, 1);
- *extract_f = EXTRACT(short, float, SHRT_MAX);
- break;
- case GL_UNSIGNED_SHORT:
- *extract_u = EXTRACT(unsigned short, unsigned, 1);
- *extract_f = EXTRACT(unsigned short, float, USHRT_MAX);
- break;
- case GL_INT:
- *extract_u = EXTRACT(int, unsigned, 1);
- *extract_f = EXTRACT(int, float, INT_MAX);
- break;
- case GL_UNSIGNED_INT:
- *extract_u = EXTRACT(unsigned int, unsigned, 1);
- *extract_f = EXTRACT(unsigned int, float, UINT_MAX);
- break;
- case GL_FLOAT:
- *extract_u = EXTRACT(float, unsigned, 1.0 / UINT_MAX);
- *extract_f = EXTRACT(float, float, 1);
- break;
-
- default:
- assert(0);
- }
+ if (!a->fields)
+ return dispatch_l;
+ else if (a->type == GL_UNSIGNED_INT)
+ return dispatch_i32;
+ else
+ return dispatch_i16;
}
/*
case GL_UNSIGNED_BYTE:
max_out = MAX_OUT_I16;
break;
+
+ default:
+ assert(0);
+ max_out = 0;
+ break;
}
} else {
max_out = MAX_OUT_L;
}
}
-#include "nouveau_vbo_t.c"
-#include "nouveau_swtnl_t.c"
-
static void
-TAG(emit_material)(struct gl_context *ctx, struct nouveau_array_state *a,
+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);
-}