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 */
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-
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.
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.
*/
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,
{
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];
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);