gallium: add the u_vbuf pointer into pipe_context
authorMarek Olšák <marek.olsak@amd.com>
Sun, 27 Nov 2022 15:39:49 +0000 (10:39 -0500)
committerMarge Bot <emma+marge@anholt.net>
Sun, 11 Dec 2022 14:37:27 +0000 (14:37 +0000)
This will allow removing the draw_vbo wrapping in cso_context.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20025>

src/gallium/auxiliary/cso_cache/cso_context.c
src/gallium/include/pipe/p_context.h

index efce6f6..dbad1b2 100644 (file)
@@ -259,7 +259,9 @@ cso_init_vbuf(struct cso_context *cso, unsigned flags)
    if (caps.fallback_always ||
        (uses_user_vertex_buffers &&
         caps.fallback_only_for_user_vbuffers)) {
+      assert(!cso->pipe->vbuf);
       cso->vbuf = u_vbuf_create(cso->pipe, &caps);
+      cso->pipe->vbuf = cso->vbuf;
       cso->always_use_vbuf = caps.fallback_always;
       cso->vbuf_current = caps.fallback_always ? cso->vbuf : NULL;
    }
@@ -451,6 +453,8 @@ cso_destroy_context(struct cso_context *ctx)
 
    if (ctx->vbuf)
       u_vbuf_destroy(ctx->vbuf);
+
+   ctx->pipe->vbuf = NULL;
    FREE(ctx);
 }
 
index 9eff0d8..c59dde6 100644 (file)
@@ -83,6 +83,7 @@ union pipe_query_result;
 struct u_log_context;
 struct u_upload_mgr;
 struct util_debug_callback;
+struct u_vbuf;
 
 /**
  * Gallium rendering context.  Basically:
@@ -95,6 +96,7 @@ struct pipe_context {
 
    void *priv;  /**< context private data (for DRI for example) */
    void *draw;  /**< private, for draw module (temporary?) */
+   struct u_vbuf *vbuf; /**< for cso_context, don't use in drivers */
 
    /**
     * Stream uploaders created by the driver. All drivers, gallium frontends, and