[Mesa-dev] [PATCH 6/6] virgl: use the new parent/child pools for transfers

Nicolai Hähnle nhaehnle at gmail.com
Tue Sep 27 18:21:20 UTC 2016


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

---
 src/gallium/drivers/virgl/virgl_buffer.c  | 4 ++--
 src/gallium/drivers/virgl/virgl_context.c | 5 ++---
 src/gallium/drivers/virgl/virgl_context.h | 2 +-
 src/gallium/drivers/virgl/virgl_screen.c  | 4 ++++
 src/gallium/drivers/virgl/virgl_screen.h  | 3 +++
 src/gallium/drivers/virgl/virgl_texture.c | 4 ++--
 6 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/virgl/virgl_buffer.c b/src/gallium/drivers/virgl/virgl_buffer.c
index de99796..2e63aeb 100644
--- a/src/gallium/drivers/virgl/virgl_buffer.c
+++ b/src/gallium/drivers/virgl/virgl_buffer.c
@@ -55,21 +55,21 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
    bool doflushwait = false;
 
    if ((usage & PIPE_TRANSFER_READ) && (vbuf->on_list == TRUE))
       doflushwait = true;
    else
       doflushwait = virgl_res_needs_flush_wait(vctx, &vbuf->base, usage);
 
    if (doflushwait)
       ctx->flush(ctx, NULL, 0);
 
-   trans = slab_alloc_st(&vctx->texture_transfer_pool);
+   trans = slab_alloc(&vctx->texture_transfer_pool);
    if (!trans)
       return NULL;
 
    trans->base.resource = resource;
    trans->base.level = level;
    trans->base.usage = usage;
    trans->base.box = *box;
    trans->base.stride = 0;
    trans->base.layer_stride = 0;
 
@@ -107,21 +107,21 @@ static void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
       if (!(transfer->usage & PIPE_TRANSFER_FLUSH_EXPLICIT)) {
          struct virgl_screen *vs = virgl_screen(ctx->screen);
          vbuf->base.clean = FALSE;
          vctx->num_transfers++;
          vs->vws->transfer_put(vs->vws, vbuf->base.hw_res,
                                &transfer->box, trans->base.stride, trans->base.layer_stride, trans->offset, transfer->level);
 
       }
    }
 
-   slab_free_st(&vctx->texture_transfer_pool, trans);
+   slab_free(&vctx->texture_transfer_pool, trans);
 }
 
 static void virgl_buffer_transfer_flush_region(struct pipe_context *ctx,
                                                struct pipe_transfer *transfer,
                                                const struct pipe_box *box)
 {
    struct virgl_context *vctx = virgl_context(ctx);
    struct virgl_buffer *vbuf = virgl_buffer(transfer->resource);
 
    if (!vbuf->on_list) {
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index a6c0597..e693a73 100644
--- a/src/gallium/drivers/virgl/virgl_context.c
+++ b/src/gallium/drivers/virgl/virgl_context.c
@@ -855,21 +855,21 @@ virgl_context_destroy( struct pipe_context *ctx )
    vctx->framebuffer.zsbuf = NULL;
    vctx->framebuffer.nr_cbufs = 0;
    virgl_encoder_destroy_sub_ctx(vctx, vctx->hw_sub_ctx_id);
    virgl_flush_eq(vctx, vctx);
 
    rs->vws->cmd_buf_destroy(vctx->cbuf);
    if (vctx->uploader)
       u_upload_destroy(vctx->uploader);
    util_primconvert_destroy(vctx->primconvert);
 
-   slab_destroy(&vctx->texture_transfer_pool);
+   slab_destroy_child(&vctx->texture_transfer_pool);
    FREE(vctx);
 }
 
 struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
                                           void *priv,
                                           unsigned flags)
 {
    struct virgl_context *vctx;
    struct virgl_screen *rs = virgl_screen(pscreen);
    vctx = CALLOC_STRUCT(virgl_context);
@@ -936,22 +936,21 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
 
    vctx->base.resource_copy_region = virgl_resource_copy_region;
    vctx->base.flush_resource = virgl_flush_resource;
    vctx->base.blit =  virgl_blit;
 
    virgl_init_context_resource_functions(&vctx->base);
    virgl_init_query_functions(vctx);
    virgl_init_so_functions(vctx);
 
    list_inithead(&vctx->to_flush_bufs);
-   slab_create(&vctx->texture_transfer_pool, sizeof(struct virgl_transfer),
-                    16);
+   slab_create_child(&vctx->texture_transfer_pool, rs->texture_transfer_pool);
 
    vctx->primconvert = util_primconvert_create(&vctx->base, rs->caps.caps.v1.prim_mask);
    vctx->uploader = u_upload_create(&vctx->base, 1024 * 1024,
                                      PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM);
    if (!vctx->uploader)
            goto fail;
 
    vctx->hw_sub_ctx_id = rs->sub_ctx_id++;
    virgl_encoder_create_sub_ctx(vctx, vctx->hw_sub_ctx_id);
 
diff --git a/src/gallium/drivers/virgl/virgl_context.h b/src/gallium/drivers/virgl/virgl_context.h
index 3b9901f..597ed49 100644
--- a/src/gallium/drivers/virgl/virgl_context.h
+++ b/src/gallium/drivers/virgl/virgl_context.h
@@ -49,21 +49,21 @@ struct virgl_textures_info {
 };
 
 struct virgl_context {
    struct pipe_context base;
    struct virgl_cmd_buf *cbuf;
 
    struct virgl_textures_info samplers[PIPE_SHADER_TYPES];
 
    struct pipe_framebuffer_state framebuffer;
 
-   struct slab_mempool texture_transfer_pool;
+   struct slab_child_pool texture_transfer_pool;
 
    struct pipe_index_buffer index_buffer;
    struct u_upload_mgr *uploader;
 
    struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
    unsigned num_vertex_buffers;
    boolean vertex_array_dirty;
 
    struct virgl_so_target so_targets[PIPE_MAX_SO_BUFFERS];
    unsigned num_so_targets;
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index dd135a7..5f98754 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -540,20 +540,22 @@ virgl_get_timestamp(struct pipe_screen *_screen)
 {
    return os_time_get_nano();
 }
 
 static void
 virgl_destroy_screen(struct pipe_screen *screen)
 {
    struct virgl_screen *vscreen = virgl_screen(screen);
    struct virgl_winsys *vws = vscreen->vws;
 
+   slab_destroy_parent(&vscreen->texture_transfer_pool);
+
    if (vws)
       vws->destroy(vws);
    FREE(vscreen);
 }
 
 struct pipe_screen *
 virgl_create_screen(struct virgl_winsys *vws)
 {
    struct virgl_screen *screen = CALLOC_STRUCT(virgl_screen);
 
@@ -574,13 +576,15 @@ virgl_create_screen(struct virgl_winsys *vws)
    screen->base.fence_reference = virgl_fence_reference;
    //screen->base.fence_signalled = virgl_fence_signalled;
    screen->base.fence_finish = virgl_fence_finish;
 
    virgl_init_screen_resource_functions(&screen->base);
 
    vws->get_caps(vws, &screen->caps);
 
    screen->refcnt = 1;
 
+   slab_create_parent(&screen->texture_transfer_pool, sizeof(struct virgl_transfer), 16);
+
    util_format_s3tc_init();
    return &screen->base;
 }
diff --git a/src/gallium/drivers/virgl/virgl_screen.h b/src/gallium/drivers/virgl/virgl_screen.h
index 8cac38d..dcf5816 100644
--- a/src/gallium/drivers/virgl/virgl_screen.h
+++ b/src/gallium/drivers/virgl/virgl_screen.h
@@ -17,34 +17,37 @@
  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #ifndef VIRGL_H
 #define VIRGL_H
 
 #include "pipe/p_screen.h"
+#include "util/slab.h"
 #include "virgl_winsys.h"
 
 struct virgl_screen {
    struct pipe_screen base;
 
    int refcnt;
 
    /* place for winsys to stash it's own stuff: */
    void *winsys_priv;
 
    struct virgl_winsys *vws;
 
    struct virgl_drm_caps caps;
 
+   struct slab_parent_pool texture_transfer_pool;
+
    uint32_t sub_ctx_id;
 };
 
 
 static inline struct virgl_screen *
 virgl_screen(struct pipe_screen *pipe)
 {
    return (struct virgl_screen *)pipe;
 }
 
diff --git a/src/gallium/drivers/virgl/virgl_texture.c b/src/gallium/drivers/virgl/virgl_texture.c
index 24bbc3c..150a5eb 100644
--- a/src/gallium/drivers/virgl/virgl_texture.c
+++ b/src/gallium/drivers/virgl/virgl_texture.c
@@ -138,21 +138,21 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
    const unsigned h = u_minify(vtex->base.u.b.height0, level);
    const unsigned nblocksy = util_format_get_nblocksy(format, h);
    bool is_depth = util_format_has_depth(util_format_description(resource->format));
    uint32_t l_stride;
    bool doflushwait;
 
    doflushwait = virgl_res_needs_flush_wait(vctx, &vtex->base, usage);
    if (doflushwait)
       ctx->flush(ctx, NULL, 0);
 
-   trans = slab_alloc_st(&vctx->texture_transfer_pool);
+   trans = slab_alloc(&vctx->texture_transfer_pool);
    if (!trans)
       return NULL;
 
    trans->base.resource = resource;
    trans->base.level = level;
    trans->base.usage = usage;
    trans->base.box = *box;
    trans->base.stride = vtex->stride[level];
    trans->base.layer_stride = trans->base.stride * nblocksy;
 
@@ -228,21 +228,21 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
          vctx->num_transfers++;
          vs->vws->transfer_put(vs->vws, vtex->base.hw_res,
                                &transfer->box, trans->base.stride, l_stride, trans->offset, transfer->level);
 
       }
    }
 
    if (trans->resolve_tmp)
       pipe_resource_reference((struct pipe_resource **)&trans->resolve_tmp, NULL);
 
-   slab_free_st(&vctx->texture_transfer_pool, trans);
+   slab_free(&vctx->texture_transfer_pool, trans);
 }
 
 
 static boolean
 vrend_resource_layout(struct virgl_texture *res,
                       uint32_t *total_size)
 {
    struct pipe_resource *pt = &res->base.u.b;
    unsigned level;
    unsigned width = pt->width0;
-- 
2.7.4



More information about the mesa-dev mailing list