mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 00:58:05 +02:00
state_tracker: Initialize the draw context only when needed.
It's only used for rarely-used deprecated GL features (feedback/rasterpos), so we can skip the memory allocation and initialization for it most of the time. Saves about 659k (out of 1605k) of maximum memory size according to massif on simulated vc4 glsl-algebraic-add-add-1 Reviewed-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
parent
c976e164d2
commit
2a808219b3
5 changed files with 38 additions and 14 deletions
|
|
@ -274,7 +274,10 @@ static void
|
|||
st_RenderMode(struct gl_context *ctx, GLenum newMode )
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct draw_context *draw = st->draw;
|
||||
struct draw_context *draw = st_get_draw_context(st);
|
||||
|
||||
if (!st->draw)
|
||||
return;
|
||||
|
||||
if (newMode == GL_RENDER) {
|
||||
/* restore normal VBO draw function */
|
||||
|
|
|
|||
|
|
@ -219,10 +219,13 @@ static void
|
|||
st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct draw_context *draw = st->draw;
|
||||
struct draw_context *draw = st_get_draw_context(st);
|
||||
struct rastpos_stage *rs;
|
||||
const struct gl_client_array **saved_arrays = ctx->Array._DrawArrays;
|
||||
|
||||
if (!st->draw)
|
||||
return;
|
||||
|
||||
if (ctx->VertexProgram._Current == NULL ||
|
||||
ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) {
|
||||
/* No vertex shader/program is enabled, used the simple/fast fixed-
|
||||
|
|
|
|||
|
|
@ -346,16 +346,6 @@ st_init_draw(struct st_context *st)
|
|||
|
||||
vbo_set_draw_func(ctx, st_draw_vbo);
|
||||
vbo_set_indirect_draw_func(ctx, st_indirect_draw_vbo);
|
||||
|
||||
st->draw = draw_create(st->pipe); /* for selection/feedback */
|
||||
|
||||
/* Disable draw options that might convert points/lines to tris, etc.
|
||||
* as that would foul-up feedback/selection mode.
|
||||
*/
|
||||
draw_wide_line_threshold(st->draw, 1000.0f);
|
||||
draw_wide_point_threshold(st->draw, 1000.0f);
|
||||
draw_enable_line_stipple(st->draw, FALSE);
|
||||
draw_enable_point_sprites(st->draw, FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -365,6 +355,31 @@ st_destroy_draw(struct st_context *st)
|
|||
draw_destroy(st->draw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for the draw_context, so that initialization of it can happen only
|
||||
* when needed (the TGSI exec machines take up quite a bit of memory).
|
||||
*/
|
||||
struct draw_context *
|
||||
st_get_draw_context(struct st_context *st)
|
||||
{
|
||||
if (!st->draw) {
|
||||
st->draw = draw_create(st->pipe);
|
||||
if (!st->draw) {
|
||||
_mesa_error(st->ctx, GL_OUT_OF_MEMORY, "feedback fallback allocation");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Disable draw options that might convert points/lines to tris, etc.
|
||||
* as that would foul-up feedback/selection mode.
|
||||
*/
|
||||
draw_wide_line_threshold(st->draw, 1000.0f);
|
||||
draw_wide_point_threshold(st->draw, 1000.0f);
|
||||
draw_enable_line_stipple(st->draw, FALSE);
|
||||
draw_enable_point_sprites(st->draw, FALSE);
|
||||
|
||||
return st->draw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw a quad with given position, texcoords and color.
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ void st_init_draw( struct st_context *st );
|
|||
|
||||
void st_destroy_draw( struct st_context *st );
|
||||
|
||||
struct draw_context *st_get_draw_context(struct st_context *st);
|
||||
|
||||
extern void
|
||||
st_draw_vbo(struct gl_context *ctx,
|
||||
const struct _mesa_prim *prims,
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
|||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct draw_context *draw = st->draw;
|
||||
struct draw_context *draw = st_get_draw_context(st);
|
||||
const struct st_vertex_program *vp;
|
||||
const struct pipe_shader_state *vs;
|
||||
struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS];
|
||||
|
|
@ -136,7 +136,8 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
|||
const GLubyte *low_addr = NULL;
|
||||
const void *mapped_indices = NULL;
|
||||
|
||||
assert(draw);
|
||||
if (!draw)
|
||||
return;
|
||||
|
||||
st_flush_bitmap_cache(st);
|
||||
st_invalidate_readpix_cache(st);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue