aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-04-20 17:07:15 +0200
committermarha <marha@users.sourceforge.net>2012-04-20 17:07:15 +0200
commit0e3699334faf92f508b6c187a261548b656b0dd3 (patch)
tree28d7e84df7b54a3e6f85bf83e38efba937288fd3 /mesalib/src/mesa/state_tracker
parentc1194ccd395fdbb23c9ab56bc340ee20a5feeb82 (diff)
downloadvcxsrv-0e3699334faf92f508b6c187a261548b656b0dd3.tar.gz
vcxsrv-0e3699334faf92f508b6c187a261548b656b0dd3.tar.bz2
vcxsrv-0e3699334faf92f508b6c187a261548b656b0dd3.zip
fontconfig libX11 mesa pixman xserver git update 20 april 2012
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bitmap.c124
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c95
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.h101
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c33
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawtex.c26
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_flush.c324
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h20
8 files changed, 316 insertions, 410 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
index 7c0254d8d..09152c79a 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
@@ -52,6 +52,7 @@
#include "util/u_inlines.h"
#include "util/u_draw_quad.h"
#include "util/u_simple_shaders.h"
+#include "util/u_upload_mgr.h"
#include "program/prog_instruction.h"
#include "cso_cache/cso_context.h"
@@ -327,12 +328,13 @@ make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height,
return pt;
}
-static GLuint
+static void
setup_bitmap_vertex_data(struct st_context *st, bool normalized,
int x, int y, int width, int height,
- float z, const float color[4])
+ float z, const float color[4],
+ struct pipe_resource **vbuf,
+ unsigned *vbuf_offset)
{
- struct pipe_context *pipe = st->pipe;
const struct gl_framebuffer *fb = st->ctx->DrawBuffer;
const GLfloat fb_width = (GLfloat)fb->Width;
const GLfloat fb_height = (GLfloat)fb->Height;
@@ -346,8 +348,8 @@ setup_bitmap_vertex_data(struct st_context *st, bool normalized,
const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0);
const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0);
const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0);
- const GLuint max_slots = 1; /* 4096 / sizeof(st->bitmap.vertices); */
GLuint i;
+ float (*vertices)[3][4]; /**< vertex pos + color + texcoord */
if(!normalized)
{
@@ -355,77 +357,48 @@ setup_bitmap_vertex_data(struct st_context *st, bool normalized,
tBot = (GLfloat) height;
}
- /* 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.
- */
- if (st->bitmap.vbuf_slot >= max_slots) {
- pipe_resource_reference(&st->bitmap.vbuf, NULL);
- st->bitmap.vbuf_slot = 0;
- }
-
- if (!st->bitmap.vbuf) {
- st->bitmap.vbuf = pipe_buffer_create(pipe->screen,
- PIPE_BIND_VERTEX_BUFFER,
- PIPE_USAGE_STREAM,
- max_slots *
- sizeof(st->bitmap.vertices));
- if (!st->bitmap.vbuf) {
- /* out of memory */
- return 0;
- }
+ u_upload_alloc(st->uploader, 0, 4 * sizeof(vertices[0]), vbuf_offset, vbuf,
+ (void**)&vertices);
+ if (!vbuf) {
+ return;
}
/* Positions are in clip coords since we need to do clipping in case
* the bitmap quad goes beyond the window bounds.
*/
- st->bitmap.vertices[0][0][0] = clip_x0;
- st->bitmap.vertices[0][0][1] = clip_y0;
- st->bitmap.vertices[0][2][0] = sLeft;
- st->bitmap.vertices[0][2][1] = tTop;
-
- st->bitmap.vertices[1][0][0] = clip_x1;
- st->bitmap.vertices[1][0][1] = clip_y0;
- st->bitmap.vertices[1][2][0] = sRight;
- st->bitmap.vertices[1][2][1] = tTop;
+ vertices[0][0][0] = clip_x0;
+ vertices[0][0][1] = clip_y0;
+ vertices[0][2][0] = sLeft;
+ vertices[0][2][1] = tTop;
+
+ vertices[1][0][0] = clip_x1;
+ vertices[1][0][1] = clip_y0;
+ vertices[1][2][0] = sRight;
+ vertices[1][2][1] = tTop;
- st->bitmap.vertices[2][0][0] = clip_x1;
- st->bitmap.vertices[2][0][1] = clip_y1;
- st->bitmap.vertices[2][2][0] = sRight;
- st->bitmap.vertices[2][2][1] = tBot;
+ vertices[2][0][0] = clip_x1;
+ vertices[2][0][1] = clip_y1;
+ vertices[2][2][0] = sRight;
+ vertices[2][2][1] = tBot;
- st->bitmap.vertices[3][0][0] = clip_x0;
- st->bitmap.vertices[3][0][1] = clip_y1;
- st->bitmap.vertices[3][2][0] = sLeft;
- st->bitmap.vertices[3][2][1] = tBot;
+ vertices[3][0][0] = clip_x0;
+ vertices[3][0][1] = clip_y1;
+ vertices[3][2][0] = sLeft;
+ vertices[3][2][1] = tBot;
/* same for all verts: */
for (i = 0; i < 4; i++) {
- st->bitmap.vertices[i][0][2] = z;
- st->bitmap.vertices[i][0][3] = 1.0f;
- st->bitmap.vertices[i][1][0] = color[0];
- st->bitmap.vertices[i][1][1] = color[1];
- st->bitmap.vertices[i][1][2] = color[2];
- st->bitmap.vertices[i][1][3] = color[3];
- st->bitmap.vertices[i][2][2] = 0.0; /*R*/
- st->bitmap.vertices[i][2][3] = 1.0; /*Q*/
+ vertices[i][0][2] = z;
+ vertices[i][0][3] = 1.0f;
+ vertices[i][1][0] = color[0];
+ vertices[i][1][1] = color[1];
+ vertices[i][1][2] = color[2];
+ vertices[i][1][3] = color[3];
+ vertices[i][2][2] = 0.0; /*R*/
+ vertices[i][2][3] = 1.0; /*Q*/
}
- /* put vertex data into vbuf */
- pipe_buffer_write_nooverlap(st->pipe,
- st->bitmap.vbuf,
- st->bitmap.vbuf_slot
- * sizeof(st->bitmap.vertices),
- sizeof st->bitmap.vertices,
- st->bitmap.vertices);
-
- return st->bitmap.vbuf_slot++ * sizeof st->bitmap.vertices;
+ u_upload_unmap(st->uploader);
}
@@ -446,6 +419,7 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
struct st_fp_variant_key key;
GLuint maxSize;
GLuint offset;
+ struct pipe_resource *vbuf = NULL;
memset(&key, 0, sizeof(key));
key.st = st;
@@ -551,12 +525,11 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
z = z * 2.0f - 1.0f;
/* draw textured quad */
- offset = setup_bitmap_vertex_data(st,
- sv->texture->target != PIPE_TEXTURE_RECT,
- x, y, width, height, z, color);
+ setup_bitmap_vertex_data(st, sv->texture->target != PIPE_TEXTURE_RECT,
+ x, y, width, height, z, color, &vbuf, &offset);
- if (st->bitmap.vbuf) {
- util_draw_vertex_buffer(pipe, st->cso_context, st->bitmap.vbuf, offset,
+ if (vbuf) {
+ util_draw_vertex_buffer(pipe, st->cso_context, vbuf, offset,
PIPE_PRIM_TRIANGLE_FAN,
4, /* verts */
3); /* attribs/vert */
@@ -573,6 +546,8 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_restore_vertex_elements(cso);
cso_restore_vertex_buffers(cso);
cso_restore_stream_outputs(cso);
+
+ pipe_resource_reference(&vbuf, NULL);
}
@@ -709,18 +684,12 @@ st_flush_bitmap_cache(struct st_context *st)
/**
- * Flush bitmap cache and release vertex buffer.
+ * Flush bitmap cache.
*/
void
st_flush_bitmap( struct st_context *st )
{
st_flush_bitmap_cache(st);
-
- /* Release vertex buffer to avoid synchronous rendering if we were
- * to map it in the next frame.
- */
- pipe_resource_reference(&st->bitmap.vbuf, NULL);
- st->bitmap.vbuf_slot = 0;
}
@@ -914,11 +883,6 @@ st_destroy_bitmap(struct st_context *st)
st->bitmap.vs = NULL;
}
- if (st->bitmap.vbuf) {
- pipe_resource_reference(&st->bitmap.vbuf, NULL);
- st->bitmap.vbuf = NULL;
- }
-
if (cache) {
if (cache->trans) {
pipe_transfer_unmap(pipe, cache->trans);
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()
*/
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.h b/mesalib/src/mesa/state_tracker/st_cb_clear.h
index 8eafae5a4..e9297de9c 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.h
@@ -1,52 +1,49 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#ifndef ST_CB_CLEAR_H
-#define ST_CB_CLEAR_H
-
-
-struct dd_function_table;
-struct st_context;
-
-extern void
-st_init_clear(struct st_context *st);
-
-
-extern void
-st_destroy_clear(struct st_context *st);
-
-extern void
-st_flush_clear(struct st_context *st);
-
-
-extern void
-st_init_clear_functions(struct dd_function_table *functions);
-
-
-#endif /* ST_CB_CLEAR_H */
-
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#ifndef ST_CB_CLEAR_H
+#define ST_CB_CLEAR_H
+
+
+struct dd_function_table;
+struct st_context;
+
+extern void
+st_init_clear(struct st_context *st);
+
+
+extern void
+st_destroy_clear(struct st_context *st);
+
+
+extern void
+st_init_clear_functions(struct dd_function_table *functions);
+
+
+#endif /* ST_CB_CLEAR_H */
+
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 18d0e53d4..5e078a85e 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -66,6 +66,7 @@
#include "util/u_inlines.h"
#include "util/u_math.h"
#include "util/u_tile.h"
+#include "util/u_upload_mgr.h"
#include "cso_cache/cso_context.h"
@@ -554,7 +555,15 @@ draw_quad(struct gl_context *ctx, GLfloat x0, GLfloat y0, GLfloat z,
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
- GLfloat verts[4][3][4]; /* four verts, three attribs, XYZW */
+ GLfloat (*verts)[3][4]; /* four verts, three attribs, XYZW */
+ struct pipe_resource *buf = NULL;
+ unsigned offset;
+
+ u_upload_alloc(st->uploader, 0, 4 * sizeof(verts[0]), &offset, &buf,
+ (void**)&verts);
+ if (!buf) {
+ return;
+ }
/* setup vertex data */
{
@@ -618,22 +627,12 @@ draw_quad(struct gl_context *ctx, GLfloat x0, GLfloat y0, GLfloat z,
}
}
- {
- struct pipe_resource *buf;
-
- /* allocate/load buffer object with vertex data */
- buf = pipe_buffer_create(pipe->screen,
- PIPE_BIND_VERTEX_BUFFER,
- PIPE_USAGE_STATIC,
- sizeof(verts));
- pipe_buffer_write(st->pipe, buf, 0, sizeof(verts), verts);
-
- util_draw_vertex_buffer(pipe, st->cso_context, buf, 0,
- PIPE_PRIM_QUADS,
- 4, /* verts */
- 3); /* attribs/vert */
- pipe_resource_reference(&buf, NULL);
- }
+ u_upload_unmap(st->uploader);
+ util_draw_vertex_buffer(pipe, st->cso_context, buf, offset,
+ PIPE_PRIM_QUADS,
+ 4, /* verts */
+ 3); /* attribs/vert */
+ pipe_resource_reference(&buf, NULL);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
index 6144eb99c..d57e629f1 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c
@@ -29,6 +29,7 @@
#include "pipe/p_shader_tokens.h"
#include "util/u_draw_quad.h"
#include "util/u_simple_shaders.h"
+#include "util/u_upload_mgr.h"
#include "cso_cache/cso_context.h"
@@ -107,13 +108,13 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
struct st_context *st = ctx->st;
struct pipe_context *pipe = st->pipe;
struct cso_context *cso = ctx->st->cso_context;
- struct pipe_resource *vbuffer;
- struct pipe_transfer *vbuffer_transfer;
+ struct pipe_resource *vbuffer = NULL;
GLuint i, numTexCoords, numAttribs;
GLboolean emitColor;
uint semantic_names[2 + MAX_TEXTURE_UNITS];
uint semantic_indexes[2 + MAX_TEXTURE_UNITS];
struct pipe_vertex_element velements[2 + MAX_TEXTURE_UNITS];
+ unsigned offset;
st_validate_state(st);
@@ -134,12 +135,6 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
/* total number of attributes per vertex */
numAttribs = 1 + emitColor + numTexCoords;
-
- /* create the vertex buffer */
- vbuffer = pipe_buffer_create(pipe->screen, PIPE_BIND_VERTEX_BUFFER,
- PIPE_USAGE_STREAM,
- numAttribs * 4 * 4 * sizeof(GLfloat));
-
/* load vertex buffer */
{
#define SET_ATTRIB(VERT, ATTR, X, Y, Z, W) \
@@ -153,10 +148,15 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
} while (0)
const GLfloat x0 = x, y0 = y, x1 = x + width, y1 = y + height;
- GLfloat *vbuf = (GLfloat *) pipe_buffer_map(pipe, vbuffer,
- PIPE_TRANSFER_WRITE,
- &vbuffer_transfer);
+ GLfloat *vbuf = NULL;
GLuint attr;
+
+ u_upload_alloc(st->uploader, 0,
+ numAttribs * 4 * 4 * sizeof(GLfloat),
+ &offset, &vbuffer, (void**)&vbuf);
+ if (!vbuffer) {
+ return;
+ }
z = CLAMP(z, 0.0f, 1.0f);
@@ -220,7 +220,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
}
}
- pipe_buffer_unmap(pipe, vbuffer_transfer);
+ u_upload_unmap(st->uploader);
#undef SET_ATTRIB
}
@@ -269,7 +269,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
util_draw_vertex_buffer(pipe, cso, vbuffer,
- 0, /* offset */
+ offset, /* offset */
PIPE_PRIM_TRIANGLE_FAN,
4, /* verts */
numAttribs); /* attribs/vert */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.c b/mesalib/src/mesa/state_tracker/st_cb_flush.c
index c029fad48..4e40a93f5 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_flush.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_flush.c
@@ -1,165 +1,159 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Brian Paul
- */
-
-#include "main/glheader.h"
-#include "main/macros.h"
-#include "main/context.h"
-#include "st_context.h"
-#include "st_cb_bitmap.h"
-#include "st_cb_flush.h"
-#include "st_cb_clear.h"
-#include "st_cb_fbo.h"
-#include "st_manager.h"
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_screen.h"
-#include "util/u_gen_mipmap.h"
-#include "util/u_blit.h"
-
-
-/** Check if we have a front color buffer and if it's been drawn to. */
-static INLINE GLboolean
-is_front_buffer_dirty(struct st_context *st)
-{
- struct gl_framebuffer *fb = st->ctx->DrawBuffer;
- struct st_renderbuffer *strb
- = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
- return strb && strb->defined;
-}
-
-
-/**
- * Tell the screen to display the front color buffer on-screen.
- */
-static void
-display_front_buffer(struct st_context *st)
-{
- struct gl_framebuffer *fb = st->ctx->DrawBuffer;
- struct st_renderbuffer *strb
- = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
-
- if (strb) {
- /* Hook for copying "fake" frontbuffer if necessary:
- */
- st_manager_flush_frontbuffer(st);
- }
-}
-
-
-void st_flush( struct st_context *st,
- struct pipe_fence_handle **fence )
-{
- FLUSH_CURRENT(st->ctx, 0);
-
- /* Release any vertex buffers that might potentially be accessed in
- * successive frames:
- */
- st_flush_bitmap(st);
- st_flush_clear(st);
- util_blit_flush(st->blit);
- util_gen_mipmap_flush(st->gen_mipmap);
-
- st->pipe->flush( st->pipe, fence );
-}
-
-
-/**
- * Flush, and wait for completion.
- */
-void st_finish( struct st_context *st )
-{
- struct pipe_fence_handle *fence = NULL;
-
- st_flush(st, &fence);
-
- if(fence) {
- st->pipe->screen->fence_finish(st->pipe->screen, fence,
- PIPE_TIMEOUT_INFINITE);
- st->pipe->screen->fence_reference(st->pipe->screen, &fence, NULL);
- }
-}
-
-
-
-/**
- * Called via ctx->Driver.Flush()
- */
-static void st_glFlush(struct gl_context *ctx)
-{
- struct st_context *st = st_context(ctx);
-
- /* Don't call st_finish() here. It is not the state tracker's
- * responsibilty to inject sleeps in the hope of avoiding buffer
- * synchronization issues. Calling finish() here will just hide
- * problems that need to be fixed elsewhere.
- */
- st_flush(st, NULL);
-
- if (is_front_buffer_dirty(st)) {
- display_front_buffer(st);
- }
-}
-
-
-/**
- * Called via ctx->Driver.Finish()
- */
-static void st_glFinish(struct gl_context *ctx)
-{
- struct st_context *st = st_context(ctx);
-
- st_finish(st);
-
- if (is_front_buffer_dirty(st)) {
- display_front_buffer(st);
- }
-}
-
-
-void st_init_flush_functions(struct dd_function_table *functions)
-{
- functions->Flush = st_glFlush;
- functions->Finish = st_glFinish;
-
- /* Windows opengl32.dll calls glFinish prior to every swapbuffers.
- * This is unnecessary and degrades performance. Luckily we have some
- * scope to work around this, as the externally-visible behaviour of
- * Finish() is identical to Flush() in all cases - no differences in
- * rendering or ReadPixels are visible if we opt not to wait here.
- *
- * Only set this up on windows to avoid suprise elsewhere.
- */
-#ifdef PIPE_OS_WINDOWS
- functions->Finish = st_glFlush;
-#endif
-}
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+ /*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Brian Paul
+ */
+
+#include "main/glheader.h"
+#include "main/macros.h"
+#include "main/context.h"
+#include "st_context.h"
+#include "st_cb_bitmap.h"
+#include "st_cb_flush.h"
+#include "st_cb_clear.h"
+#include "st_cb_fbo.h"
+#include "st_manager.h"
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_screen.h"
+#include "util/u_gen_mipmap.h"
+#include "util/u_blit.h"
+
+
+/** Check if we have a front color buffer and if it's been drawn to. */
+static INLINE GLboolean
+is_front_buffer_dirty(struct st_context *st)
+{
+ struct gl_framebuffer *fb = st->ctx->DrawBuffer;
+ struct st_renderbuffer *strb
+ = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+ return strb && strb->defined;
+}
+
+
+/**
+ * Tell the screen to display the front color buffer on-screen.
+ */
+static void
+display_front_buffer(struct st_context *st)
+{
+ struct gl_framebuffer *fb = st->ctx->DrawBuffer;
+ struct st_renderbuffer *strb
+ = st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+
+ if (strb) {
+ /* Hook for copying "fake" frontbuffer if necessary:
+ */
+ st_manager_flush_frontbuffer(st);
+ }
+}
+
+
+void st_flush( struct st_context *st,
+ struct pipe_fence_handle **fence )
+{
+ FLUSH_CURRENT(st->ctx, 0);
+
+ st_flush_bitmap(st);
+
+ st->pipe->flush( st->pipe, fence );
+}
+
+
+/**
+ * Flush, and wait for completion.
+ */
+void st_finish( struct st_context *st )
+{
+ struct pipe_fence_handle *fence = NULL;
+
+ st_flush(st, &fence);
+
+ if(fence) {
+ st->pipe->screen->fence_finish(st->pipe->screen, fence,
+ PIPE_TIMEOUT_INFINITE);
+ st->pipe->screen->fence_reference(st->pipe->screen, &fence, NULL);
+ }
+}
+
+
+
+/**
+ * Called via ctx->Driver.Flush()
+ */
+static void st_glFlush(struct gl_context *ctx)
+{
+ struct st_context *st = st_context(ctx);
+
+ /* Don't call st_finish() here. It is not the state tracker's
+ * responsibilty to inject sleeps in the hope of avoiding buffer
+ * synchronization issues. Calling finish() here will just hide
+ * problems that need to be fixed elsewhere.
+ */
+ st_flush(st, NULL);
+
+ if (is_front_buffer_dirty(st)) {
+ display_front_buffer(st);
+ }
+}
+
+
+/**
+ * Called via ctx->Driver.Finish()
+ */
+static void st_glFinish(struct gl_context *ctx)
+{
+ struct st_context *st = st_context(ctx);
+
+ st_finish(st);
+
+ if (is_front_buffer_dirty(st)) {
+ display_front_buffer(st);
+ }
+}
+
+
+void st_init_flush_functions(struct dd_function_table *functions)
+{
+ functions->Flush = st_glFlush;
+ functions->Finish = st_glFinish;
+
+ /* Windows opengl32.dll calls glFinish prior to every swapbuffers.
+ * This is unnecessary and degrades performance. Luckily we have some
+ * scope to work around this, as the externally-visible behaviour of
+ * Finish() is identical to Flush() in all cases - no differences in
+ * rendering or ReadPixels are visible if we opt not to wait here.
+ *
+ * Only set this up on windows to avoid suprise elsewhere.
+ */
+#ifdef PIPE_OS_WINDOWS
+ functions->Finish = st_glFlush;
+#endif
+}
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index a3fd4dbcb..0245fd92b 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -63,6 +63,7 @@
#include "st_program.h"
#include "pipe/p_context.h"
#include "util/u_inlines.h"
+#include "util/u_upload_mgr.h"
#include "cso_cache/cso_context.h"
@@ -130,6 +131,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe )
st->dirty.mesa = ~0;
st->dirty.st = ~0;
+ st->uploader = u_upload_create(st->pipe, 65536, 4, PIPE_BIND_VERTEX_BUFFER);
st->cso_context = cso_create_context(pipe);
st_init_atoms( st );
@@ -235,6 +237,7 @@ static void st_destroy_context_priv( struct st_context *st )
st->default_texture = NULL;
}
+ u_upload_destroy(st->uploader);
free( st );
}
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index da03719fd..e3d65d97a 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -40,14 +40,15 @@ struct draw_stage;
struct gen_mipmap_state;
struct st_context;
struct st_fragment_program;
+struct u_upload_mgr;
-#define ST_NEW_MESA 0x1 /* Mesa state has changed */
-#define ST_NEW_FRAGMENT_PROGRAM 0x2
-#define ST_NEW_VERTEX_PROGRAM 0x4
-#define ST_NEW_FRAMEBUFFER 0x8
-#define ST_NEW_EDGEFLAGS_DATA 0x10
-#define ST_NEW_GEOMETRY_PROGRAM 0x20
+#define ST_NEW_MESA (1 << 0) /* Mesa state has changed */
+#define ST_NEW_FRAGMENT_PROGRAM (1 << 1)
+#define ST_NEW_VERTEX_PROGRAM (1 << 2)
+#define ST_NEW_FRAMEBUFFER (1 << 3)
+#define ST_NEW_EDGEFLAGS_DATA (1 << 4)
+#define ST_NEW_GEOMETRY_PROGRAM (1 << 5)
struct st_state_flags {
@@ -71,6 +72,7 @@ struct st_context
struct pipe_context *pipe;
+ struct u_upload_mgr *uploader;
struct draw_context *draw; /**< For selection/feedback/rastpos only */
struct draw_stage *feedback_stage; /**< For GL_FEEDBACK rendermode */
struct draw_stage *selection_stage; /**< For GL_SELECT rendermode */
@@ -153,9 +155,6 @@ struct st_context
struct pipe_sampler_state samplers[2];
enum pipe_format tex_format;
void *vs;
- float vertices[4][3][4]; /**< vertex pos + color + texcoord */
- struct pipe_resource *vbuf;
- unsigned vbuf_slot; /* next free slot in vbuf */
struct bitmap_cache *cache;
} bitmap;
@@ -171,9 +170,6 @@ struct st_context
struct pipe_viewport_state viewport;
void *vs;
void *fs;
- float vertices[4][2][4]; /**< vertex pos + color */
- struct pipe_resource *vbuf;
- unsigned vbuf_slot;
boolean enable_ds_separate;
} clear;