diff options
author | Marek Olšák <[email protected]> | 2020-02-03 20:20:05 -0500 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-02-11 00:34:57 +0000 |
commit | a7d03103f30bfff532a0c6d6e22fa5e7a24cad27 (patch) | |
tree | 9ce416482ebbc2fbc188d1c7683da4a0096cdfa1 /src/mesa | |
parent | 7575a0a25120b9637d50fcf2b55a4859b505f781 (diff) |
vbo: merge use_buffer_objects into vbo_CreateContext to skip the big malloc
Reviewed-by: Mathias Fröhlich <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3766>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i915/intel_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/swrast/swrast.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/osmesa/osmesa.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 2 | ||||
-rw-r--r-- | src/mesa/main/tests/dispatch_sanity.cpp | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 12 | ||||
-rw-r--r-- | src/mesa/vbo/vbo.h | 5 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_context.c | 4 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec.c | 4 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec.h | 4 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_exec_api.c | 61 |
16 files changed, 39 insertions, 72 deletions
diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c index 993ad8bf05f..ab4a0bf4961 100644 --- a/src/mesa/drivers/dri/i915/intel_context.c +++ b/src/mesa/drivers/dri/i915/intel_context.c @@ -499,7 +499,7 @@ intelInitContext(struct intel_context *intel, ctx->Const.MaxRenderbufferSize = 2048; _swrast_CreateContext(ctx); - _vbo_CreateContext(ctx); + _vbo_CreateContext(ctx, false); if (ctx->swrast_context) { _tnl_CreateContext(ctx); _swsetup_CreateContext(ctx); diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index eda8ba2fe70..92b27cc6864 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -1000,7 +1000,7 @@ brwCreateContext(gl_api api, _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; @@ -1134,8 +1134,6 @@ brwCreateContext(gl_api api, 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 && diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c b/src/mesa/drivers/dri/nouveau/nouveau_context.c index 838e909ee3f..a63e0a19ddd 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_context.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c @@ -133,7 +133,7 @@ nouveau_context_init(struct gl_context *ctx, gl_api api, 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); diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c index f037bd2015d..280c0ecc291 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c @@ -569,7 +569,6 @@ TAG(vbo_init)(struct gl_context *ctx) /* Overwrite our draw function */ ctx->Driver.Draw = TAG(vbo_draw); - vbo_use_buffer_objects(ctx); } void diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index 82733ece9a0..4db7e9d005a 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -253,7 +253,7 @@ GLboolean r200CreateContext( gl_api api, /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); + _vbo_CreateContext( ctx, false ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index e880ccc1aab..d7ab93f5b87 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -216,7 +216,7 @@ r100CreateContext( gl_api api, /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); + _vbo_CreateContext( ctx, false ); _tnl_CreateContext( ctx ); _swsetup_CreateContext( ctx ); diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 2bf4f0b9fed..20ba8ff5106 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -809,7 +809,7 @@ dri_create_context(gl_api api, /* create module contexts */ _swrast_CreateContext( mesaCtx ); - _vbo_CreateContext( mesaCtx ); + _vbo_CreateContext( mesaCtx, false ); _tnl_CreateContext( mesaCtx ); _swsetup_CreateContext( mesaCtx ); _swsetup_Wakeup( mesaCtx ); diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index 9aeb4059a91..30e6c07e6aa 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -890,7 +890,7 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist) 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); diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 1e8e6a9d71a..88f6630ed6a 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -941,7 +941,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) /* 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); diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index 7298aa66308..0a86c127d05 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -110,7 +110,7 @@ DispatchSanity_test::SetUpCtx(gl_api api, unsigned int version) &visual, NULL, // share_list &driver_functions); - _vbo_CreateContext(&ctx); + _vbo_CreateContext(&ctx, false); _mesa_override_extensions(&ctx); ctx.Version = version; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index d66bd2b904b..2ec0532ce57 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -571,10 +571,6 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, 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 = @@ -617,9 +613,6 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, 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; @@ -809,6 +802,11 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, 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); diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h index 3dcc4485757..17d668e386f 100644 --- a/src/mesa/vbo/vbo.h +++ b/src/mesa/vbo/vbo.h @@ -42,7 +42,7 @@ extern "C" { 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); @@ -93,9 +93,6 @@ vbo_get_minmax_indices(struct gl_context *ctx, const struct _mesa_prim *prim, 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, GLuint nr_prims, diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c index 4ba0a22bf02..ac8f9973f98 100644 --- a/src/mesa/vbo/vbo_context.c +++ b/src/mesa/vbo/vbo_context.c @@ -159,7 +159,7 @@ vbo_exec_invalidate_state(struct gl_context *ctx) 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); @@ -181,7 +181,7 @@ _vbo_CreateContext(struct gl_context *ctx) * 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); diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c index c4d4bc6e0ef..e4775ba5c12 100644 --- a/src/mesa/vbo/vbo_exec.c +++ b/src/mesa/vbo/vbo_exec.c @@ -109,13 +109,13 @@ _vbo_attribute_alias_map[VP_MODE_MAX][VERT_ATTRIB_MAX] = { 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; diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h index 92556906a15..0d056b35dc9 100644 --- a/src/mesa/vbo/vbo_exec.h +++ b/src/mesa/vbo/vbo_exec.h @@ -122,13 +122,13 @@ struct vbo_exec_context 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); diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index 9d048363782..75895316293 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -979,38 +979,6 @@ vbo_exec_vtxfmt_init(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) { @@ -1029,21 +997,28 @@ 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); |