ctx->Const.MaxRenderbufferSize = 2048;
_swrast_CreateContext(ctx);
- _vbo_CreateContext(ctx);
+ _vbo_CreateContext(ctx, false);
if (ctx->swrast_context) {
_tnl_CreateContext(ctx);
_swsetup_CreateContext(ctx);
_swrast_CreateContext(ctx);
}
- _vbo_CreateContext(ctx);
+ _vbo_CreateContext(ctx, true);
if (ctx->swrast_context) {
_tnl_CreateContext(ctx);
TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
if (ctx->Extensions.INTEL_performance_query)
brw_init_performance_queries(brw);
- vbo_use_buffer_objects(ctx);
-
brw->ctx.Cache = brw->screen->disk_cache;
if (driContextPriv->driScreenPriv->dri2.backgroundCallable &&
nouveau_scratch_init(ctx);
_mesa_meta_init(ctx);
_swrast_CreateContext(ctx);
- _vbo_CreateContext(ctx);
+ _vbo_CreateContext(ctx, true);
_tnl_CreateContext(ctx);
nouveau_span_functions_init(ctx);
_mesa_allow_light_in_model(ctx, GL_FALSE);
/* Overwrite our draw function */
ctx->Driver.Draw = TAG(vbo_draw);
- vbo_use_buffer_objects(ctx);
}
void
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext( ctx );
- _vbo_CreateContext( ctx );
+ _vbo_CreateContext( ctx, false );
_tnl_CreateContext( ctx );
_swsetup_CreateContext( ctx );
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext( ctx );
- _vbo_CreateContext( ctx );
+ _vbo_CreateContext( ctx, false );
_tnl_CreateContext( ctx );
_swsetup_CreateContext( ctx );
/* create module contexts */
_swrast_CreateContext( mesaCtx );
- _vbo_CreateContext( mesaCtx );
+ _vbo_CreateContext( mesaCtx, false );
_tnl_CreateContext( mesaCtx );
_swsetup_CreateContext( mesaCtx );
_swsetup_Wakeup( mesaCtx );
TNLcontext *tnl;
if (!_swrast_CreateContext( ctx ) ||
- !_vbo_CreateContext( ctx ) ||
+ !_vbo_CreateContext( ctx, false ) ||
!_tnl_CreateContext( ctx ) ||
!_swsetup_CreateContext( ctx )) {
_mesa_destroy_visual(osmesa->gl_visual);
/* Initialize the software rasterizer and helper modules.
*/
if (!_swrast_CreateContext( mesaCtx ) ||
- !_vbo_CreateContext( mesaCtx ) ||
+ !_vbo_CreateContext( mesaCtx, false ) ||
!_tnl_CreateContext( mesaCtx ) ||
!_swsetup_CreateContext( mesaCtx )) {
_mesa_free_context_data(&c->mesa);
&visual,
NULL, // share_list
&driver_functions);
- _vbo_CreateContext(&ctx);
+ _vbo_CreateContext(&ctx, false);
_mesa_override_extensions(&ctx);
ctx.Version = version;
st->ctx = ctx;
st->pipe = pipe;
-
- /* state tracker needs the VBO module */
- _vbo_CreateContext(ctx);
-
st->dirty = ST_ALL_STATES_MASK;
st->can_bind_const_buffer_as_vertex =
st->util_velems[2].src_format = PIPE_FORMAT_R32G32_FLOAT;
}
- /* we want all vertex data to be placed in buffer objects */
- vbo_use_buffer_objects(ctx);
-
/* Need these flags:
*/
ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
return NULL;
}
+ /* This must be done after extensions are initialized to enable persistent
+ * mappings immediately.
+ */
+ _vbo_CreateContext(ctx, true);
+
_mesa_initialize_dispatch_tables(ctx);
_mesa_initialize_vbo_vtxfmt(ctx);
st_init_driver_flags(st);
struct gl_context;
GLboolean
-_vbo_CreateContext(struct gl_context *ctx);
+_vbo_CreateContext(struct gl_context *ctx, bool use_buffer_objects);
void
_vbo_DestroyContext(struct gl_context *ctx);
const struct _mesa_index_buffer *ib,
GLuint *min_index, GLuint *max_index, GLuint nr_prims);
-void
-vbo_use_buffer_objects(struct gl_context *ctx);
-
void
vbo_sw_primitive_restart(struct gl_context *ctx,
const struct _mesa_prim *prim,
GLboolean
-_vbo_CreateContext(struct gl_context *ctx)
+_vbo_CreateContext(struct gl_context *ctx, bool use_buffer_objects)
{
struct vbo_context *vbo = CALLOC_STRUCT(vbo_context);
* will pretty much be permanently installed, which means that the
* vtxfmt mechanism can be removed now.
*/
- vbo_exec_init(ctx);
+ vbo_exec_init(ctx, use_buffer_objects);
if (ctx->API == API_OPENGL_COMPAT)
vbo_save_init(ctx);
void
-vbo_exec_init(struct gl_context *ctx)
+vbo_exec_init(struct gl_context *ctx, bool use_buffer_objects)
{
struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
exec->ctx = ctx;
- vbo_exec_vtx_init(exec);
+ vbo_exec_vtx_init(exec, use_buffer_objects);
ctx->Driver.NeedFlush = 0;
ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
void
-vbo_exec_init(struct gl_context *ctx);
+vbo_exec_init(struct gl_context *ctx, bool use_buffer_objects);
void
vbo_exec_destroy(struct gl_context *ctx);
void
-vbo_exec_vtx_init(struct vbo_exec_context *exec);
+vbo_exec_vtx_init(struct vbo_exec_context *exec, bool use_buffer_objects);
void
vbo_exec_vtx_destroy(struct vbo_exec_context *exec);
}
-/**
- * Tell the VBO module to use a real OpenGL vertex buffer object to
- * store accumulated immediate-mode vertex data.
- * This replaces the malloced buffer which was created in
- * vb_exec_vtx_init() below.
- */
-void
-vbo_use_buffer_objects(struct gl_context *ctx)
-{
- struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
- /* Any buffer name but 0 can be used here since this bufferobj won't
- * go into the bufferobj hashtable.
- */
- GLuint bufName = IMM_BUFFER_NAME;
-
- /* Make sure this func is only used once */
- assert(exec->vtx.bufferobj == ctx->Shared->NullBufferObj);
-
- _mesa_align_free(exec->vtx.buffer_map);
- exec->vtx.buffer_map = NULL;
- exec->vtx.buffer_ptr = NULL;
-
- /* Allocate a real buffer object now */
- _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL);
- exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName);
-
- /* Map the buffer. */
- vbo_exec_vtx_map(exec);
- assert(exec->vtx.buffer_ptr);
-}
-
-
static void
vbo_reset_all_attr(struct vbo_exec_context *exec)
{
void
-vbo_exec_vtx_init(struct vbo_exec_context *exec)
+vbo_exec_vtx_init(struct vbo_exec_context *exec, bool use_buffer_objects)
{
struct gl_context *ctx = exec->ctx;
- /* Allocate a buffer object. Will just reuse this object
- * continuously, unless vbo_use_buffer_objects() is called to enable
- * use of real VBOs.
- */
- _mesa_reference_buffer_object(ctx,
- &exec->vtx.bufferobj,
- ctx->Shared->NullBufferObj);
+ if (use_buffer_objects) {
+ /* Use buffer objects for immediate mode. */
+ struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
- assert(!exec->vtx.buffer_map);
- exec->vtx.buffer_map = _mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64);
- exec->vtx.buffer_ptr = exec->vtx.buffer_map;
+ exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, IMM_BUFFER_NAME);
+
+ /* Map the buffer. */
+ vbo_exec_vtx_map(exec);
+ assert(exec->vtx.buffer_ptr);
+ } else {
+ /* Use allocated memory for immediate mode. */
+ _mesa_reference_buffer_object(ctx,
+ &exec->vtx.bufferobj,
+ ctx->Shared->NullBufferObj);
+
+ exec->vtx.buffer_map = _mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64);
+ exec->vtx.buffer_ptr = exec->vtx.buffer_map;
+ }
vbo_exec_vtxfmt_init(exec);
_mesa_noop_vtxfmt_init(ctx, &exec->vtxfmt_noop);