Beispiel #1
0
static void
vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
		const struct gl_client_array **arrays)
{
	struct nouveau_render_state *render = to_render_state(ctx);
	GLboolean imm = (render->mode == IMM);
	int i, attr;

	if (ib)
		nouveau_init_array(&render->ib, 0, 0, ib->count, ib->type,
				   ib->obj, ib->ptr, GL_TRUE, ctx);

	FOR_EACH_BOUND_ATTR(render, i, attr) {
		const struct gl_client_array *array = arrays[attr];

		nouveau_init_array(&render->attrs[attr], attr,
				   get_array_stride(ctx, array),
				   array->Size, array->Type,
				   imm ? array->BufferObj : NULL,
				   array->Ptr, imm, ctx);
	}
}
Beispiel #2
0
static void
vbo_emit_attr(struct gl_context *ctx, const struct gl_client_array **arrays,
	      int attr)
{
	struct nouveau_pushbuf *push = context_push(ctx);
	struct nouveau_render_state *render = to_render_state(ctx);
	const struct gl_client_array *array = arrays[attr];
	struct nouveau_array *a = &render->attrs[attr];
	RENDER_LOCALS(ctx);

	if (!array->StrideB) {
		if (attr >= VERT_ATTRIB_GENERIC0)
			/* nouveau_update_state takes care of materials. */
			return;

		/* Constant attribute. */
		nouveau_init_array(a, attr, array->StrideB, array->Size,
				   array->Type, array->BufferObj, array->Ptr,
				   GL_TRUE, ctx);
		EMIT_IMM(ctx, a, 0);
		nouveau_deinit_array(a);

	} else {
		/* Varying attribute. */
		struct nouveau_attr_info *info = &TAG(vertex_attrs)[attr];

		if (render->mode == VBO) {
			render->map[info->vbo_index] = attr;
			render->vertex_size += array->_ElementSize;
			render->attr_count = MAX2(render->attr_count,
						  info->vbo_index + 1);
		} else {
			render->map[render->attr_count++] = attr;
			render->vertex_size += 4 * info->imm_fields;
		}
	}
}