diff options
author | Eric Anholt <[email protected]> | 2016-08-02 12:28:27 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2016-08-04 08:48:27 -0700 |
commit | 2a808219b3f9a50bc5bf3c5290db6a55cd707de7 (patch) | |
tree | 031d59393725abe6c51ae74e458dfa859ce4548d /src/mesa/state_tracker/st_draw.c | |
parent | c976e164d262d2d2bfd8087dcbb7bd91995ae887 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker/st_draw.c')
-rw-r--r-- | src/mesa/state_tracker/st_draw.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index b248dafc9a2..f4af23da97f 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -346,8 +346,29 @@ 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); +} + + +void +st_destroy_draw(struct st_context *st) +{ + draw_destroy(st->draw); +} - st->draw = draw_create(st->pipe); /* for selection/feedback */ +/** + * 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. @@ -356,16 +377,10 @@ st_init_draw(struct st_context *st) draw_wide_point_threshold(st->draw, 1000.0f); draw_enable_line_stipple(st->draw, FALSE); draw_enable_point_sprites(st->draw, FALSE); -} - -void -st_destroy_draw(struct st_context *st) -{ - draw_destroy(st->draw); + return st->draw; } - /** * Draw a quad with given position, texcoords and color. */ |