mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
st/mesa: use u_upload_mgr to upload vertices for glClear fallback
This commit is contained in:
parent
6c1fbe912f
commit
2b151bbb95
4 changed files with 11 additions and 66 deletions
|
|
@ -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,36 +137,8 @@ draw_quad(struct st_context *st,
|
|||
const union pipe_color_union *color)
|
||||
{
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
|
||||
/* 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 */
|
||||
return;
|
||||
}
|
||||
struct pipe_resource *vbuf = NULL;
|
||||
GLuint i, offset;
|
||||
|
||||
/* positions */
|
||||
st->clear.vertices[0][0][0] = x0;
|
||||
|
|
@ -194,24 +163,22 @@ draw_quad(struct st_context *st,
|
|||
st->clear.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_data(st->uploader, 0, sizeof(st->clear.vertices),
|
||||
st->clear.vertices, &offset, &vbuf);
|
||||
if (!vbuf) {
|
||||
return;
|
||||
}
|
||||
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 +432,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()
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -40,9 +40,6 @@ 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);
|
||||
|
|
|
|||
|
|
@ -85,7 +85,6 @@ void st_flush( struct st_context *st,
|
|||
* successive frames:
|
||||
*/
|
||||
st_flush_bitmap(st);
|
||||
st_flush_clear(st);
|
||||
util_blit_flush(st->blit);
|
||||
util_gen_mipmap_flush(st->gen_mipmap);
|
||||
|
||||
|
|
|
|||
|
|
@ -171,8 +171,6 @@ struct st_context
|
|||
void *vs;
|
||||
void *fs;
|
||||
float vertices[4][2][4]; /**< vertex pos + color */
|
||||
struct pipe_resource *vbuf;
|
||||
unsigned vbuf_slot;
|
||||
boolean enable_ds_separate;
|
||||
} clear;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue