From 4cfc8c775c751dd2b2b43f3ca58ae9798a84c0f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 20 Nov 2011 03:36:49 +0100 Subject: [PATCH] u_vbuf_mgr: add set_index_buffer function It will use the index buffer soon. --- src/gallium/auxiliary/util/u_vbuf_mgr.c | 13 +++++++++++++ src/gallium/auxiliary/util/u_vbuf_mgr.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/gallium/auxiliary/util/u_vbuf_mgr.c b/src/gallium/auxiliary/util/u_vbuf_mgr.c index 5d3f137ecb3..15cdfaead2a 100644 --- a/src/gallium/auxiliary/util/u_vbuf_mgr.c +++ b/src/gallium/auxiliary/util/u_vbuf_mgr.c @@ -520,6 +520,19 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf_mgr *mgrb, mgr->b.nr_real_vertex_buffers = count; } +void u_vbuf_set_index_buffer(struct u_vbuf_mgr *mgr, + const struct pipe_index_buffer *ib) +{ + if (ib && ib->buffer) { + assert(ib->offset % ib->index_size == 0); + pipe_resource_reference(&mgr->index_buffer.buffer, ib->buffer); + mgr->index_buffer.offset = ib->offset; + mgr->index_buffer.index_size = ib->index_size; + } else { + pipe_resource_reference(&mgr->index_buffer.buffer, NULL); + } +} + static void u_vbuf_upload_buffers(struct u_vbuf_priv *mgr, int min_index, int max_index, diff --git a/src/gallium/auxiliary/util/u_vbuf_mgr.h b/src/gallium/auxiliary/util/u_vbuf_mgr.h index d854e4449b3..8d39db34677 100644 --- a/src/gallium/auxiliary/util/u_vbuf_mgr.h +++ b/src/gallium/auxiliary/util/u_vbuf_mgr.h @@ -69,6 +69,8 @@ struct u_vbuf_mgr { /* Precomputed max_index for hardware vertex buffers. */ unsigned max_index; + /* The index buffer. */ + struct pipe_index_buffer index_buffer; /* This uploader can optionally be used by the driver. * @@ -126,6 +128,9 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf_mgr *mgr, unsigned count, const struct pipe_vertex_buffer *bufs); +void u_vbuf_set_index_buffer(struct u_vbuf_mgr *mgr, + const struct pipe_index_buffer *ib); + enum u_vbuf_return_flags u_vbuf_draw_begin(struct u_vbuf_mgr *mgr, const struct pipe_draw_info *info); -- 2.30.2