summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-03-31 04:56:48 +0200
committerMarek Olšák <[email protected]>2012-04-24 01:39:21 +0200
commit31714ea4d5a20285f398286fe45b53d0609926dd (patch)
tree55bef20927e0c26953bfbfd5e7747e17bcdc564b /src/gallium/auxiliary/util
parent76c4760e5d8522780d770f9a0a62d710806206a0 (diff)
u_vbuf: override set_index_buffer
This makes u_vbuf_mgr call the driver instead of the other way around.
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.c35
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.h6
2 files changed, 30 insertions, 11 deletions
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index 50c35afd563..7883845de85 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -70,6 +70,9 @@ struct u_vbuf_priv {
struct translate_cache *translate_cache;
struct cso_cache *cso_cache;
+ /* The index buffer. */
+ struct pipe_index_buffer index_buffer;
+
/* Vertex element state bound by the state tracker. */
void *saved_ve;
/* and its associated helper structure for this module. */
@@ -93,6 +96,9 @@ struct u_vbuf_priv {
boolean incompatible_vb_layout;
/* Per-buffer flags. */
boolean incompatible_vb[PIPE_MAX_ATTRIBS];
+
+ void (*driver_set_index_buffer)(struct pipe_context *pipe,
+ const struct pipe_index_buffer *);
};
static void u_vbuf_init_format_caps(struct u_vbuf_priv *mgr)
@@ -124,6 +130,8 @@ static void u_vbuf_init_format_caps(struct u_vbuf_priv *mgr)
0, PIPE_BIND_VERTEX_BUFFER);
}
+static void u_vbuf_install(struct u_vbuf_priv *mgr);
+
struct u_vbuf *
u_vbuf_create(struct pipe_context *pipe,
unsigned upload_buffer_size,
@@ -146,7 +154,7 @@ u_vbuf_create(struct pipe_context *pipe,
fetch_alignment == U_VERTEX_FETCH_BYTE_ALIGNED;
u_vbuf_init_format_caps(mgr);
-
+ u_vbuf_install(mgr);
return &mgr->b;
}
@@ -195,6 +203,9 @@ void u_vbuf_destroy(struct u_vbuf *mgrb)
struct u_vbuf_priv *mgr = (struct u_vbuf_priv*)mgrb;
unsigned i;
+ assert(mgr->pipe->draw);
+ mgr->pipe->draw = NULL;
+
for (i = 0; i < mgr->b.nr_vertex_buffers; i++) {
pipe_resource_reference(&mgr->b.vertex_buffer[i].buffer, NULL);
}
@@ -256,7 +267,7 @@ u_vbuf_translate_buffers(struct u_vbuf_priv *mgr, struct translate_key *key,
/* Translate. */
if (unroll_indices) {
- struct pipe_index_buffer *ib = &mgr->b.index_buffer;
+ struct pipe_index_buffer *ib = &mgr->index_buffer;
struct pipe_transfer *transfer = NULL;
unsigned offset = ib->offset + start_index * ib->index_size;
uint8_t *map;
@@ -732,9 +743,11 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgrb,
mgr->b.nr_real_vertex_buffers = count;
}
-void u_vbuf_set_index_buffer(struct u_vbuf *mgr,
- const struct pipe_index_buffer *ib)
+static void u_vbuf_set_index_buffer(struct pipe_context *pipe,
+ const struct pipe_index_buffer *ib)
{
+ struct u_vbuf_priv *mgr = pipe->draw;
+
if (ib && ib->buffer) {
assert(ib->offset % ib->index_size == 0);
pipe_resource_reference(&mgr->index_buffer.buffer, ib->buffer);
@@ -743,6 +756,8 @@ void u_vbuf_set_index_buffer(struct u_vbuf *mgr,
} else {
pipe_resource_reference(&mgr->index_buffer.buffer, NULL);
}
+
+ mgr->driver_set_index_buffer(pipe, ib);
}
static void
@@ -1068,7 +1083,7 @@ u_vbuf_draw_begin(struct u_vbuf *mgrb,
max_index = info->max_index;
index_bounds_valid = true;
} else if (u_vbuf_need_minmax_index(mgr)) {
- u_vbuf_get_minmax_index(mgr->pipe, &mgr->b.index_buffer, info,
+ u_vbuf_get_minmax_index(mgr->pipe, &mgr->index_buffer, info,
&min_index, &max_index);
index_bounds_valid = true;
}
@@ -1161,3 +1176,13 @@ void u_vbuf_draw_end(struct u_vbuf *mgrb)
u_vbuf_translate_end(mgr);
}
}
+
+static void u_vbuf_install(struct u_vbuf_priv *mgr)
+{
+ struct pipe_context *pipe = mgr->pipe;
+ assert(!pipe->draw);
+
+ pipe->draw = mgr;
+ mgr->driver_set_index_buffer = pipe->set_index_buffer;
+ pipe->set_index_buffer = u_vbuf_set_index_buffer;
+}
diff --git a/src/gallium/auxiliary/util/u_vbuf.h b/src/gallium/auxiliary/util/u_vbuf.h
index 3669c9b874a..4a449fca972 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -67,9 +67,6 @@ struct u_vbuf {
struct pipe_vertex_buffer real_vertex_buffer[PIPE_MAX_ATTRIBS];
int nr_real_vertex_buffers;
- /* The index buffer. */
- struct pipe_index_buffer index_buffer;
-
/* This uploader can optionally be used by the driver.
*
* Allowed functions:
@@ -126,9 +123,6 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
unsigned count,
const struct pipe_vertex_buffer *bufs);
-void u_vbuf_set_index_buffer(struct u_vbuf *mgr,
- const struct pipe_index_buffer *ib);
-
enum u_vbuf_return_flags u_vbuf_draw_begin(struct u_vbuf *mgr,
struct pipe_draw_info *info);