vrend: Move dereferencing of VBOs from destroy_context to destroy_sub_context.

A vrend_context structure contains a current vrend_sub_context, which
in turn keeps references on various resources like textures, VBOs,
index buffers, etc. which are used for actual drawing operations.
Certain actions can change the current sub-context in use.

There is a split of what resources are cleaned up directly as part of
a context destruction and which are handled by the sub-context
destruction. VBOs, while referenced by sub-contexts, are cleaned up by
the context. To do that, it uses the at the time of destruction
current sub-context to access these. As a result, only the VBOs in the
active sub-context are cleaned up; every other sub-context referenced
by the context will keep references to the VBOs used.

The responsibility of VBO dereferencing is moved to the destruction of
the sub-context, so all VBOs, not just the one from the current
sub-context, are dereferenced during the destruction of a context.

Closes #198

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Robert Wetzel 4 years ago
parent 8c0906564e
commit 53774760dd
  1. 22
      src/vrend_renderer.c

@ -2954,23 +2954,29 @@ void vrend_set_single_vbo(struct vrend_context *ctx,
}
}
void vrend_set_num_vbo(struct vrend_context *ctx,
static void vrend_set_num_vbo_sub(struct vrend_sub_context *sub,
int num_vbo)
{
int old_num = ctx->sub->num_vbos;
int old_num = sub->num_vbos;
int i;
ctx->sub->num_vbos = num_vbo;
ctx->sub->old_num_vbos = old_num;
sub->num_vbos = num_vbo;
sub->old_num_vbos = old_num;
if (old_num != num_vbo)
ctx->sub->vbo_dirty = true;
sub->vbo_dirty = true;
for (i = num_vbo; i < old_num; i++) {
vrend_resource_reference((struct vrend_resource **)&ctx->sub->vbo[i].base.buffer, NULL);
ctx->sub->vbo[i].res_id = 0;
vrend_resource_reference((struct vrend_resource **)&sub->vbo[i].base.buffer, NULL);
sub->vbo[i].res_id = 0;
}
}
void vrend_set_num_vbo(struct vrend_context *ctx,
int num_vbo)
{
vrend_set_num_vbo_sub(ctx->sub, num_vbo);
}
void vrend_set_single_sampler_view(struct vrend_context *ctx,
@ -6359,6 +6365,7 @@ static void vrend_destroy_sub_context(struct vrend_sub_context *sub)
vrend_surface_reference(&sub->surf[i], NULL);
}
vrend_set_num_vbo_sub(sub, 0);
vrend_resource_reference((struct vrend_resource **)&sub->ib.buffer, NULL);
vrend_object_fini_ctx_table(sub->object_hash);
@ -6397,7 +6404,6 @@ void vrend_destroy_context(struct vrend_context *ctx)
vrend_set_num_sampler_views(ctx, PIPE_SHADER_COMPUTE, 0, 0);
vrend_set_streamout_targets(ctx, 0, 0, NULL);
vrend_set_num_vbo(ctx, 0);
vrend_set_index_buffer(ctx, 0, 0, 0);

Loading…
Cancel
Save