summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-04-24 20:16:50 +0200
committerMarek Olšák <[email protected]>2012-04-30 01:09:57 +0200
commit7a0545972694e6afc6c5ac60db563defa79c20d9 (patch)
tree3152ec74a8bb4a2dbd1a25a5ed6f7911faad1525 /src/mesa/state_tracker
parent507337864fa80caf9f26602324d2c28dd0a75d61 (diff)
st/mesa: make user constant buffers optional
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c19
-rw-r--r--src/mesa/state_tracker/st_context.c11
-rw-r--r--src/mesa/state_tracker/st_context.h2
3 files changed, 25 insertions, 7 deletions
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index 87bb51543f5..eb98161dbd0 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -38,6 +38,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
+#include "util/u_upload_mgr.h"
#include "st_debug.h"
#include "st_context.h"
@@ -77,15 +78,21 @@ void st_upload_constants( struct st_context *st,
* avoid gratuitous rendering synchronization.
* Let's use a user buffer to avoid an unnecessary copy.
*/
- cb.buffer = pipe_user_buffer_create(pipe->screen,
- params->ParameterValues,
- paramBytes,
- PIPE_BIND_CONSTANT_BUFFER);
- cb.buffer_offset = 0;
+ if (st->constbuf_uploader) {
+ cb.buffer = NULL;
+ u_upload_data(st->constbuf_uploader, 0, paramBytes,
+ params->ParameterValues, &cb.buffer_offset, &cb.buffer);
+ } else {
+ cb.buffer = pipe_user_buffer_create(pipe->screen,
+ params->ParameterValues,
+ paramBytes,
+ PIPE_BIND_CONSTANT_BUFFER);
+ cb.buffer_offset = 0;
+ }
cb.buffer_size = paramBytes;
if (ST_DEBUG & DEBUG_CONSTANTS) {
- debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n",
+ debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n",
__FUNCTION__, shader_type, params->NumParameters,
params->StateFlags);
_mesa_print_parameter_list(params);
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index d50c6be6c4d..a804e77af8b 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -163,6 +163,14 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe )
PIPE_BIND_INDEX_BUFFER);
}
+ if (!screen->get_param(screen, PIPE_CAP_USER_CONSTANT_BUFFERS)) {
+ unsigned alignment =
+ screen->get_param(screen, PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT);
+
+ st->constbuf_uploader = u_upload_create(pipe, 128 * 1024, alignment,
+ PIPE_BIND_CONSTANT_BUFFER);
+ }
+
st->cso_context = cso_create_context(pipe);
st_init_vbuf(st);
@@ -273,6 +281,9 @@ static void st_destroy_context_priv( struct st_context *st )
if (st->indexbuf_uploader) {
u_upload_destroy(st->indexbuf_uploader);
}
+ if (st->constbuf_uploader) {
+ u_upload_destroy(st->constbuf_uploader);
+ }
free( st );
}
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 8f557e81a7c..4e40d533e05 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -73,7 +73,7 @@ struct st_context
struct pipe_context *pipe;
- struct u_upload_mgr *uploader, *indexbuf_uploader;
+ struct u_upload_mgr *uploader, *indexbuf_uploader, *constbuf_uploader;
struct u_vbuf *vbuf;
struct draw_context *draw; /**< For selection/feedback/rastpos only */