diff options
author | Marek Olšák <[email protected]> | 2012-04-10 06:00:17 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-04-24 01:39:22 +0200 |
commit | e0773da1e897164ed7597437070e32b867734ee5 (patch) | |
tree | 1653bdb8fab0d8e250f7fcc0ca225e7245043184 /src/gallium/auxiliary/cso_cache | |
parent | 79eafc14ca70a684b4ea8b89723c1dad3e61eb3d (diff) |
gallium: make user vertex buffers optional
This couldn't be split because it would break bisecting.
Summary:
* r300g,r600g: stop using u_vbuf
* r300g,r600g: also report that the FIXED vertex type is unsupported
* u_vbuf: refactor for use in the state tracker
* cso: wire up u_vbuf with cso_context
* st/mesa: conditionally install u_vbuf
Diffstat (limited to 'src/gallium/auxiliary/cso_cache')
-rw-r--r-- | src/gallium/auxiliary/cso_cache/cso_context.c | 66 | ||||
-rw-r--r-- | src/gallium/auxiliary/cso_cache/cso_context.h | 3 |
2 files changed, 65 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 9ec7a2a9676..1cd5f8de184 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -41,6 +41,7 @@ #include "util/u_inlines.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_vbuf.h" #include "tgsi/tgsi_parse.h" #include "cso_cache/cso_context.h" @@ -78,6 +79,7 @@ struct sampler_info struct cso_context { struct pipe_context *pipe; struct cso_cache *cache; + struct u_vbuf *vbuf; boolean has_geometry_shader; boolean has_streamout; @@ -268,6 +270,10 @@ out: return NULL; } +void cso_install_vbuf(struct cso_context *ctx, struct u_vbuf *vbuf) +{ + ctx->vbuf = vbuf; +} /** * Prior to context destruction, this function unbinds all state objects. @@ -780,11 +786,17 @@ enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, unsigned count, const struct pipe_vertex_element *states) { + struct u_vbuf *vbuf = ctx->vbuf; unsigned key_size, hash_key; struct cso_hash_iter iter; void *handle; struct cso_velems_state velems_state; + if (vbuf) { + u_vbuf_set_vertex_elements(vbuf, count, states); + return PIPE_OK; + } + /* need to include the count into the stored state data too. Otherwise first few count pipe_vertex_elements could be identical even if count is different, and there's no guarantee the hash would be different in that @@ -826,12 +838,26 @@ enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, void cso_save_vertex_elements(struct cso_context *ctx) { + struct u_vbuf *vbuf = ctx->vbuf; + + if (vbuf) { + u_vbuf_save_vertex_elements(vbuf); + return; + } + assert(!ctx->velements_saved); ctx->velements_saved = ctx->velements; } void cso_restore_vertex_elements(struct cso_context *ctx) { + struct u_vbuf *vbuf = ctx->vbuf; + + if (vbuf) { + u_vbuf_restore_vertex_elements(vbuf); + return; + } + if (ctx->velements != ctx->velements_saved) { ctx->velements = ctx->velements_saved; ctx->pipe->bind_vertex_elements_state(ctx->pipe, ctx->velements_saved); @@ -845,6 +871,13 @@ void cso_set_vertex_buffers(struct cso_context *ctx, unsigned count, const struct pipe_vertex_buffer *buffers) { + struct u_vbuf *vbuf = ctx->vbuf; + + if (vbuf) { + u_vbuf_set_vertex_buffers(vbuf, count, buffers); + return; + } + if (count != ctx->nr_vertex_buffers || memcmp(buffers, ctx->vertex_buffers, sizeof(struct pipe_vertex_buffer) * count) != 0) { @@ -856,6 +889,13 @@ void cso_set_vertex_buffers(struct cso_context *ctx, void cso_save_vertex_buffers(struct cso_context *ctx) { + struct u_vbuf *vbuf = ctx->vbuf; + + if (vbuf) { + u_vbuf_save_vertex_buffers(vbuf); + return; + } + util_copy_vertex_buffers(ctx->vertex_buffers_saved, &ctx->nr_vertex_buffers_saved, ctx->vertex_buffers, @@ -865,6 +905,12 @@ void cso_save_vertex_buffers(struct cso_context *ctx) void cso_restore_vertex_buffers(struct cso_context *ctx) { unsigned i; + struct u_vbuf *vbuf = ctx->vbuf; + + if (vbuf) { + u_vbuf_restore_vertex_buffers(vbuf); + return; + } util_copy_vertex_buffers(ctx->vertex_buffers, &ctx->nr_vertex_buffers, @@ -1298,16 +1344,28 @@ void cso_set_index_buffer(struct cso_context *cso, const struct pipe_index_buffer *ib) { - struct pipe_context *pipe = cso->pipe; - pipe->set_index_buffer(pipe, ib); + struct u_vbuf *vbuf = cso->vbuf; + + if (vbuf) { + u_vbuf_set_index_buffer(vbuf, ib); + } else { + struct pipe_context *pipe = cso->pipe; + pipe->set_index_buffer(pipe, ib); + } } void cso_draw_vbo(struct cso_context *cso, const struct pipe_draw_info *info) { - struct pipe_context *pipe = cso->pipe; - pipe->draw_vbo(pipe, info); + struct u_vbuf *vbuf = cso->vbuf; + + if (vbuf) { + u_vbuf_draw_vbo(vbuf, info); + } else { + struct pipe_context *pipe = cso->pipe; + pipe->draw_vbo(pipe, info); + } } void diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index d0f8bc29550..79279343c39 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -39,9 +39,12 @@ extern "C" { #endif struct cso_context; +struct u_vbuf; struct cso_context *cso_create_context( struct pipe_context *pipe ); +void cso_install_vbuf(struct cso_context *ctx, struct u_vbuf *vbuf); + void cso_release_all( struct cso_context *ctx ); void cso_destroy_context( struct cso_context *cso ); |