[Mesa-dev] [PATCH 11/12] gallium/hud: update the HUD interface for multiple contexts

Marek Olšák maraeo at gmail.com
Tue Nov 21 17:46:11 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

This is the boring subset of the following commit.
All new parameters are optional.
---
 src/gallium/auxiliary/hud/hud_context.c          | 7 ++++---
 src/gallium/auxiliary/hud/hud_context.h          | 7 ++++---
 src/gallium/state_trackers/dri/dri_context.c     | 4 ++--
 src/gallium/state_trackers/dri/dri_drawable.c    | 3 ++-
 src/gallium/state_trackers/glx/xlib/xm_api.c     | 6 +++---
 src/gallium/state_trackers/nine/device9.c        | 2 +-
 src/gallium/state_trackers/nine/swapchain9.c     | 2 +-
 src/gallium/state_trackers/wgl/stw_context.c     | 8 ++++----
 src/gallium/state_trackers/wgl/stw_framebuffer.c | 2 +-
 9 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 7502416..783dafd 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -674,21 +674,22 @@ hud_stop_queries(struct hud_context *hud, struct pipe_context *pipe)
       }
 
       hud_pane_accumulate_vertices(hud, pane);
    }
 
    /* unmap the uploader's vertex buffer before drawing */
    u_upload_unmap(pipe->stream_uploader);
 }
 
 void
-hud_run(struct hud_context *hud, struct pipe_resource *tex)
+hud_run(struct hud_context *hud, struct cso_context *cso,
+        struct pipe_resource *tex)
 {
    hud_stop_queries(hud, hud->record_pipe);
    hud_draw_results(hud, tex);
    hud_start_queries(hud, hud->record_pipe);
 }
 
 static void
 fixup_bytes(enum pipe_driver_query_type type, int position, uint64_t *exp10)
 {
    if (type == PIPE_DRIVER_QUERY_TYPE_BYTES && position % 3 == 0)
@@ -1677,21 +1678,21 @@ hud_unset_record_context(struct hud_context *hud)
    hud->record_pipe = NULL;
 }
 
 static void
 hud_set_record_context(struct hud_context *hud, struct pipe_context *pipe)
 {
    hud->record_pipe = pipe;
 }
 
 struct hud_context *
-hud_create(struct cso_context *cso)
+hud_create(struct cso_context *cso, struct hud_context *share)
 {
    struct pipe_screen *screen = cso_get_pipe_context(cso)->screen;
    struct hud_context *hud;
    unsigned i;
    const char *env = debug_get_option("GALLIUM_HUD", NULL);
 #ifdef PIPE_OS_UNIX
    unsigned signo = debug_get_num_option("GALLIUM_HUD_TOGGLE_SIGNAL", 0);
    static boolean sig_handled = FALSE;
    struct sigaction action = {};
 #endif
@@ -1783,21 +1784,21 @@ hud_create(struct cso_context *cso)
       sig_handled = TRUE;
    }
 #endif
 
    hud_set_record_context(hud, cso_get_pipe_context(cso));
    hud_parse_env_var(hud, screen, env);
    return hud;
 }
 
 void
-hud_destroy(struct hud_context *hud)
+hud_destroy(struct hud_context *hud, struct cso_context *cso)
 {
    hud_unset_record_context(hud);
    hud_unset_draw_context(hud);
    pipe_resource_reference(&hud->font.texture, NULL);
    FREE(hud);
 }
 
 void
 hud_add_queue_for_monitoring(struct hud_context *hud,
                              struct util_queue_monitoring *queue_info)
diff --git a/src/gallium/auxiliary/hud/hud_context.h b/src/gallium/auxiliary/hud/hud_context.h
index 97aa709..128d4ef 100644
--- a/src/gallium/auxiliary/hud/hud_context.h
+++ b/src/gallium/auxiliary/hud/hud_context.h
@@ -28,23 +28,24 @@
 #ifndef HUD_CONTEXT_H
 #define HUD_CONTEXT_H
 
 struct hud_context;
 struct cso_context;
 struct pipe_context;
 struct pipe_resource;
 struct util_queue_monitoring;
 
 struct hud_context *
-hud_create(struct cso_context *cso);
+hud_create(struct cso_context *cso, struct hud_context *share);
 
 void
-hud_destroy(struct hud_context *hud);
+hud_destroy(struct hud_context *hud, struct cso_context *cso);
 
 void
-hud_run(struct hud_context *hud, struct pipe_resource *tex);
+hud_run(struct hud_context *hud, struct cso_context *cso,
+        struct pipe_resource *tex);
 
 void
 hud_add_queue_for_monitoring(struct hud_context *hud,
                              struct util_queue_monitoring *queue_info);
 
 #endif
diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c
index 2f69f25..d4ac8ad 100644
--- a/src/gallium/state_trackers/dri/dri_context.c
+++ b/src/gallium/state_trackers/dri/dri_context.c
@@ -161,21 +161,21 @@ dri_create_context(gl_api api, const struct gl_config * visual,
 	 *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
 	 break;
       }
       goto fail;
    }
    ctx->st->st_manager_private = (void *) ctx;
    ctx->stapi = stapi;
 
    if (ctx->st->cso_context) {
       ctx->pp = pp_init(ctx->st->pipe, screen->pp_enabled, ctx->st->cso_context);
-      ctx->hud = hud_create(ctx->st->cso_context);
+      ctx->hud = hud_create(ctx->st->cso_context, NULL);
    }
 
    /* Do this last. */
    if (ctx->st->start_thread &&
          driQueryOptionb(&screen->dev->option_cache, "mesa_glthread")) {
 
       if (backgroundCallable && backgroundCallable->base.version >= 2 &&
             backgroundCallable->isThreadSafe) {
 
          if (backgroundCallable->isThreadSafe(cPriv->loaderPrivate))
@@ -199,21 +199,21 @@ dri_create_context(gl_api api, const struct gl_config * visual,
    free(ctx);
    return GL_FALSE;
 }
 
 void
 dri_destroy_context(__DRIcontext * cPriv)
 {
    struct dri_context *ctx = dri_context(cPriv);
 
    if (ctx->hud) {
-      hud_destroy(ctx->hud);
+      hud_destroy(ctx->hud, ctx->st->cso_context);
    }
 
    if (ctx->pp)
       pp_free(ctx->pp);
 
    /* No particular reason to wait for command completion before
     * destroying a context, but we flush the context here
     * to avoid having to add code elsewhere to cope with flushing a
     * partially destroyed context.
     */
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index 53dbfd7..92ce9d2 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -512,21 +512,22 @@ dri_flush(__DRIcontext *cPriv,
              drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT]) {
             swap_msaa_buffers = TRUE;
          }
 
          /* FRONT_LEFT is resolved in drawable->flush_frontbuffer. */
       }
 
       dri_postprocessing(ctx, drawable, ST_ATTACHMENT_BACK_LEFT);
 
       if (ctx->hud) {
-         hud_run(ctx->hud, drawable->textures[ST_ATTACHMENT_BACK_LEFT]);
+         hud_run(ctx->hud, ctx->st->cso_context,
+                 drawable->textures[ST_ATTACHMENT_BACK_LEFT]);
       }
 
       pipe->flush_resource(pipe, drawable->textures[ST_ATTACHMENT_BACK_LEFT]);
 
       if (pipe->invalidate_resource &&
           (flags & __DRI2_FLUSH_INVALIDATE_ANCILLARY)) {
          if (drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL])
             pipe->invalidate_resource(pipe, drawable->textures[ST_ATTACHMENT_DEPTH_STENCIL]);
          if (drawable->msaa_textures[ST_ATTACHMENT_DEPTH_STENCIL])
             pipe->invalidate_resource(pipe, drawable->msaa_textures[ST_ATTACHMENT_DEPTH_STENCIL]);
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index 79bf45d..934c0ab 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -1028,37 +1028,37 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list,
       goto no_st;
    }
 
    c->st = stapi->create_context(stapi, xmdpy->smapi, &attribs,
          &ctx_err, (share_list) ? share_list->st : NULL);
    if (c->st == NULL)
       goto no_st;
 
    c->st->st_manager_private = (void *) c;
 
-   c->hud = hud_create(c->st->cso_context);
+   c->hud = hud_create(c->st->cso_context, NULL);
 
    return c;
 
 no_st:
    free(c);
 no_xmesa_context:
    return NULL;
 }
 
 
 
 PUBLIC
 void XMesaDestroyContext( XMesaContext c )
 {
    if (c->hud) {
-      hud_destroy(c->hud);
+      hud_destroy(c->hud, NULL);
    }
 
    c->st->destroy(c->st);
 
    /* FIXME: We should destroy the screen here, but if we do so, surfaces may 
     * outlive it, causing segfaults
    struct pipe_screen *screen = c->st->pipe->screen; 
    screen->destroy(screen);
    */
 
@@ -1350,21 +1350,21 @@ XMesaContext XMesaGetCurrentContext( void )
  */
 PUBLIC
 void XMesaSwapBuffers( XMesaBuffer b )
 {
    XMesaContext xmctx = XMesaGetCurrentContext();
 
    /* Need to draw HUD before flushing */
    if (xmctx && xmctx->hud) {
       struct pipe_resource *back =
          xmesa_get_framebuffer_resource(b->stfb, ST_ATTACHMENT_BACK_LEFT);
-      hud_run(xmctx->hud, back);
+      hud_run(xmctx->hud, NULL, back);
    }
 
    if (xmctx && xmctx->xm_buffer == b) {
       xmctx->st->flush( xmctx->st, ST_FLUSH_FRONT, NULL);
    }
 
    xmesa_swap_st_framebuffer(b->stfb);
 }
 
 
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index f1c50d6..34f903a 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -198,21 +198,21 @@ NineDevice9_ctor( struct NineDevice9 *This,
     if (!This->context.pipe || !This->pipe_secondary) { return E_OUTOFMEMORY; } /* guess */
     This->pipe_sw = This->screen_sw->context_create(This->screen_sw, NULL, 0);
     if (!This->pipe_sw) { return E_OUTOFMEMORY; }
 
     This->context.cso = cso_create_context(This->context.pipe, 0);
     if (!This->context.cso) { return E_OUTOFMEMORY; } /* also a guess */
     This->cso_sw = cso_create_context(This->pipe_sw, 0);
     if (!This->cso_sw) { return E_OUTOFMEMORY; }
 
     /* Create first, it messes up our state. */
-    This->hud = hud_create(This->context.cso); /* NULL result is fine */
+    This->hud = hud_create(This->context.cso, NULL); /* NULL result is fine */
 
     /* Available memory counter. Updated only for allocations with this device
      * instance. This is the Win 7 behavior.
      * Win XP shares this counter across multiple devices. */
     This->available_texture_mem = This->screen->get_param(This->screen, PIPE_CAP_VIDEO_MEMORY);
     if (This->available_texture_mem < 4096)
         This->available_texture_mem <<= 20;
     else
         This->available_texture_mem = UINT_MAX;
     /* We cap texture memory usage to 80% of what is reported free initially
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index 096d582..f24a7d0 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -599,21 +599,21 @@ handle_draw_cursor_and_hud( struct NineSwapChain9 *This, struct pipe_resource *r
             blit.dst.box.x, blit.dst.box.y);
 
         blit.alpha_blend = TRUE;
         pipe = NineDevice9_GetPipe(This->base.device);
         pipe->blit(pipe, &blit);
     }
 
     if (device->hud && resource) {
         /* Implicit use of context pipe */
         (void)NineDevice9_GetPipe(This->base.device);
-        hud_run(device->hud, resource); /* XXX: no offset */
+        hud_run(device->hud, NULL, resource); /* XXX: no offset */
         /* HUD doesn't clobber stipple */
         nine_state_restore_non_cso(device);
     }
 }
 
 struct end_present_struct {
     struct pipe_screen *screen;
     struct pipe_fence_handle *fence_to_wait;
     ID3DPresent *present;
     D3DWindowBuffer *present_handle;
diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c
index 2155fbf..a9e4024 100644
--- a/src/gallium/state_trackers/wgl/stw_context.c
+++ b/src/gallium/state_trackers/wgl/stw_context.c
@@ -271,34 +271,34 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext,
    }
 
    ctx->st = stw_dev->stapi->create_context(stw_dev->stapi,
          stw_dev->smapi, &attribs, &ctx_err, shareCtx ? shareCtx->st : NULL);
    if (ctx->st == NULL)
       goto no_st_ctx;
 
    ctx->st->st_manager_private = (void *) ctx;
 
    if (ctx->st->cso_context) {
-      ctx->hud = hud_create(ctx->st->cso_context);
+      ctx->hud = hud_create(ctx->st->cso_context, NULL);
    }
 
    stw_lock_contexts(stw_dev);
    if (handle) {
       /* We're replacing the context data for this handle. See the
        * wglCreateContextAttribsARB() function.
        */
       struct stw_context *old_ctx =
          stw_lookup_context_locked((unsigned) handle);
       if (old_ctx) {
          /* free the old context data associated with this handle */
          if (old_ctx->hud) {
-            hud_destroy(old_ctx->hud);
+            hud_destroy(old_ctx->hud, NULL);
          }
          ctx->st->destroy(old_ctx->st);
          FREE(old_ctx);
       }
 
       /* replace table entry */
       handle_table_set(stw_dev->ctx_table, (unsigned) handle, ctx);
    }
    else {
       /* create new table entry */
@@ -309,21 +309,21 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, DHGLRC hShareContext,
 
    stw_unlock_contexts(stw_dev);
 
    if (!ctx->dhglrc)
       goto no_hglrc;
 
    return ctx->dhglrc;
 
 no_hglrc:
    if (ctx->hud) {
-      hud_destroy(ctx->hud);
+      hud_destroy(ctx->hud, NULL);
    }
    ctx->st->destroy(ctx->st);
 no_st_ctx:
    FREE(ctx);
 no_ctx:
    return 0;
 }
 
 
 BOOL APIENTRY
@@ -341,21 +341,21 @@ DrvDeleteContext(DHGLRC dhglrc)
    stw_unlock_contexts(stw_dev);
 
    if (ctx) {
       struct stw_context *curctx = stw_current_context();
 
       /* Unbind current if deleting current context. */
       if (curctx == ctx)
          stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL);
 
       if (ctx->hud) {
-         hud_destroy(ctx->hud);
+         hud_destroy(ctx->hud, NULL);
       }
 
       ctx->st->destroy(ctx->st);
       FREE(ctx);
 
       ret = TRUE;
    }
 
    return ret;
 }
diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c
index 47e76c6..232ab1d 100644
--- a/src/gallium/state_trackers/wgl/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c
@@ -634,21 +634,21 @@ DrvSwapBuffers(HDC hdc)
       return TRUE;
    }
 
    ctx = stw_current_context();
    if (ctx) {
       if (ctx->hud) {
          /* Display the HUD */
          struct pipe_resource *back =
             stw_get_framebuffer_resource(fb->stfb, ST_ATTACHMENT_BACK_LEFT);
          if (back) {
-            hud_run(ctx->hud, back);
+            hud_run(ctx->hud, NULL, back);
          }
       }
 
       if (ctx->current_framebuffer == fb) {
          /* flush current context */
          ctx->st->flush(ctx->st, ST_FLUSH_END_OF_FRAME, NULL);
       }
    }
 
    if (stw_dev->swap_interval != 0) {
-- 
2.7.4



More information about the mesa-dev mailing list