diff options
author | marha <marha@users.sourceforge.net> | 2012-04-20 17:39:30 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-04-20 17:39:30 +0200 |
commit | ae228baa2cfe88bd7c7de40d5038ad2cc1ecffa4 (patch) | |
tree | b18ae337e913f36a95f97530f6a792e9366a393c /mesalib/src/mesa/state_tracker/st_cb_clear.c | |
parent | 4207bc7b2972aed9a45756fae8c48957d323fa21 (diff) | |
parent | 0e3699334faf92f508b6c187a261548b656b0dd3 (diff) | |
download | vcxsrv-ae228baa2cfe88bd7c7de40d5038ad2cc1ecffa4.tar.gz vcxsrv-ae228baa2cfe88bd7c7de40d5038ad2cc1ecffa4.tar.bz2 vcxsrv-ae228baa2cfe88bd7c7de40d5038ad2cc1ecffa4.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
xorg-server/dix/dispatch.c
xorg-server/dix/resource.c
Diffstat (limited to 'mesalib/src/mesa/state_tracker/st_cb_clear.c')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_clear.c | 95 |
1 files changed, 24 insertions, 71 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c index 193583372..3cd8756f2 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_clear.c +++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c @@ -53,6 +53,7 @@ #include "util/u_inlines.h" #include "util/u_simple_shaders.h" #include "util/u_draw_quad.h" +#include "util/u_upload_mgr.h" #include "cso_cache/cso_context.h" @@ -87,10 +88,6 @@ st_destroy_clear(struct st_context *st) cso_delete_vertex_shader(st->cso_context, st->clear.vs); st->clear.vs = NULL; } - if (st->clear.vbuf) { - pipe_resource_reference(&st->clear.vbuf, NULL); - st->clear.vbuf = NULL; - } } @@ -140,78 +137,50 @@ draw_quad(struct st_context *st, const union pipe_color_union *color) { struct pipe_context *pipe = st->pipe; + struct pipe_resource *vbuf = NULL; + GLuint i, offset; + float (*vertices)[2][4]; /**< vertex pos + color */ - /* XXX: Need to improve buffer_write to allow NO_WAIT (as well as - * no_flush) updates to buffers where we know there is no conflict - * with previous data. Currently using max_slots > 1 will cause - * synchronous rendering if the driver flushes its command buffers - * between one bitmap and the next. Our flush hook below isn't - * sufficient to catch this as the driver doesn't tell us when it - * flushes its own command buffers. Until this gets fixed, pay the - * price of allocating a new buffer for each bitmap cache-flush to - * avoid synchronous rendering. - */ - const GLuint max_slots = 1; /* 1024 / sizeof(st->clear.vertices); */ - GLuint i; - - if (st->clear.vbuf_slot >= max_slots) { - pipe_resource_reference(&st->clear.vbuf, NULL); - st->clear.vbuf_slot = 0; - } - - if (!st->clear.vbuf) { - st->clear.vbuf = pipe_buffer_create(pipe->screen, - PIPE_BIND_VERTEX_BUFFER, - PIPE_USAGE_STREAM, - max_slots * sizeof(st->clear.vertices)); - } - - if (!st->clear.vbuf) { - /* ran out of memory */ + u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]), &offset, &vbuf, + (void**)&vertices); + if (!vbuf) { return; } /* positions */ - st->clear.vertices[0][0][0] = x0; - st->clear.vertices[0][0][1] = y0; + vertices[0][0][0] = x0; + vertices[0][0][1] = y0; - st->clear.vertices[1][0][0] = x1; - st->clear.vertices[1][0][1] = y0; + vertices[1][0][0] = x1; + vertices[1][0][1] = y0; - st->clear.vertices[2][0][0] = x1; - st->clear.vertices[2][0][1] = y1; + vertices[2][0][0] = x1; + vertices[2][0][1] = y1; - st->clear.vertices[3][0][0] = x0; - st->clear.vertices[3][0][1] = y1; + vertices[3][0][0] = x0; + vertices[3][0][1] = y1; /* same for all verts: */ for (i = 0; i < 4; i++) { - st->clear.vertices[i][0][2] = z; - st->clear.vertices[i][0][3] = 1.0; - st->clear.vertices[i][1][0] = color->f[0]; - st->clear.vertices[i][1][1] = color->f[1]; - st->clear.vertices[i][1][2] = color->f[2]; - st->clear.vertices[i][1][3] = color->f[3]; + vertices[i][0][2] = z; + vertices[i][0][3] = 1.0; + vertices[i][1][0] = color->f[0]; + vertices[i][1][1] = color->f[1]; + vertices[i][1][2] = color->f[2]; + vertices[i][1][3] = color->f[3]; } - /* put vertex data into vbuf */ - pipe_buffer_write_nooverlap(st->pipe, st->clear.vbuf, - st->clear.vbuf_slot - * sizeof(st->clear.vertices), - sizeof(st->clear.vertices), - st->clear.vertices); + u_upload_unmap(st->uploader); /* draw */ util_draw_vertex_buffer(pipe, st->cso_context, - st->clear.vbuf, - st->clear.vbuf_slot * sizeof(st->clear.vertices), + vbuf, offset, PIPE_PRIM_TRIANGLE_FAN, 4, /* verts */ 2); /* attribs/vert */ - /* Increment slot */ - st->clear.vbuf_slot++; + pipe_resource_reference(&vbuf, NULL); } @@ -465,22 +434,6 @@ check_clear_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb } - -/** - * Called when we need to flush. - */ -void -st_flush_clear(struct st_context *st) -{ - /* Release vertex buffer to avoid synchronous rendering if we were - * to map it in the next frame. - */ - pipe_resource_reference(&st->clear.vbuf, NULL); - st->clear.vbuf_slot = 0; -} - - - /** * Called via ctx->Driver.Clear() */ |