vrend: Don't ref-count when UBO's are bound on the host side

v2: Instead of releasing the UBO's at the end don't reference count them.
    The guest keeps track of these resources and their reference counts,
    so it will not release the UBO's without re-setting the binding during
    the live time of a client progra, However, at final clean up the UBO's
    are not rebound before the resourse is released in the guest side resulting
    in the memory leak. When we skip the ref-counting on the host side the
    resourses are cleaned up correctly without breaking the program otherwise.

Fixes resource leaks:
Direct leak of 2448 byte(s) in 9 object(s) allocated from:
    #0 0x7fe3151aba68 in __interceptor_calloc (/usr/lib64/gcc/x86_64-pc-linux-gnu/7.3.0/libasan.so+0xdba68)
    #1 0x7fe314b89ea6 in vrend_renderer_resource_create ../../../../virgl-gitlab/src/vrend_renderer.c:5834
    #2 0x7fe314b52b44 in virgl_renderer_resource_create ../../../../virgl-gitlab/src/virglrenderer.c:63
    #3 0x560533f27852 in vtest_create_resource2 ../../../../virgl-gitlab/vtest/vtest_renderer.c:432
    #4 0x560533f254fa in vtest_main_run_renderer ../../../../virgl-gitlab/vtest/vtest_server.c:359
    #5 0x560533f244df in main ../../../../virgl-gitlab/vtest/vtest_server.c:105
    #6 0x7fe313919ac9 in __libc_start_main (/lib64/libc.so.6+0x21ac9)

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Gert Wollny 6 years ago committed by Dave Airlie
parent 70ae2c3894
commit 474addf576
  1. 4
      src/vrend_renderer.c

@ -2432,13 +2432,13 @@ void vrend_set_uniform_buffer(struct vrend_context *ctx,
report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle); report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res_handle);
return; return;
} }
vrend_resource_reference((struct vrend_resource **)&ctx->sub->cbs[shader][index].buffer, res); ctx->sub->cbs[shader][index].buffer = (struct pipe_resource *)res;
ctx->sub->cbs[shader][index].buffer_offset = offset; ctx->sub->cbs[shader][index].buffer_offset = offset;
ctx->sub->cbs[shader][index].buffer_size = length; ctx->sub->cbs[shader][index].buffer_size = length;
ctx->sub->const_bufs_used_mask[shader] |= (1 << index); ctx->sub->const_bufs_used_mask[shader] |= (1 << index);
} else { } else {
vrend_resource_reference((struct vrend_resource **)&ctx->sub->cbs[shader][index].buffer, NULL); ctx->sub->cbs[shader][index].buffer = NULL;
ctx->sub->cbs[shader][index].buffer_offset = 0; ctx->sub->cbs[shader][index].buffer_offset = 0;
ctx->sub->cbs[shader][index].buffer_size = 0; ctx->sub->cbs[shader][index].buffer_size = 0;
ctx->sub->const_bufs_used_mask[shader] &= ~(1 << index); ctx->sub->const_bufs_used_mask[shader] &= ~(1 << index);

Loading…
Cancel
Save