[Mesa-dev] [PATCH 1/5] st/dri: simplify throttling code

Marek Olšák maraeo at gmail.com
Tue Apr 23 01:23:44 UTC 2019


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

---
 src/gallium/state_trackers/dri/dri2.c         | 4 +---
 src/gallium/state_trackers/dri/dri_drawable.c | 2 +-
 src/gallium/state_trackers/dri/dri_screen.h   | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index efb43c0d797..7edef415505 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1926,24 +1926,22 @@ dri2_init_screen(__DRIscreen * sPriv)
 
       pscreen = pipe_loader_create_screen(screen->dev);
    }
 
    if (!pscreen)
        goto release_pipe;
 
    throttle_ret = pipe_loader_configuration(screen->dev, DRM_CONF_THROTTLE);
    dmabuf_ret = pipe_loader_configuration(screen->dev, DRM_CONF_SHARE_FD);
 
-   if (throttle_ret && throttle_ret->val.val_int != -1) {
-      screen->throttling_enabled = TRUE;
+   if (throttle_ret && throttle_ret->val.val_int > 0)
       screen->default_throttle_frames = throttle_ret->val.val_int;
-   }
 
    if (pscreen->resource_create_with_modifiers)
       dri2ImageExtension.createImageWithModifiers =
          dri2_create_image_with_modifiers;
 
    if (dmabuf_ret && dmabuf_ret->val.val_bool) {
       uint64_t cap;
 
       if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
           (cap & DRM_PRIME_CAP_IMPORT)) {
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index 92047584224..26bfdbecc53 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -540,21 +540,21 @@ dri_flush(__DRIcontext *cPriv,
       pipe->flush_resource(pipe, drawable->textures[ST_ATTACHMENT_BACK_LEFT]);
    }
 
    flush_flags = 0;
    if (flags & __DRI2_FLUSH_CONTEXT)
       flush_flags |= ST_FLUSH_FRONT;
    if (reason == __DRI2_THROTTLE_SWAPBUFFER)
       flush_flags |= ST_FLUSH_END_OF_FRAME;
 
    /* Flush the context and throttle if needed. */
-   if (dri_screen(ctx->sPriv)->throttling_enabled &&
+   if (dri_screen(ctx->sPriv)->default_throttle_frames &&
        drawable &&
        (reason == __DRI2_THROTTLE_SWAPBUFFER ||
         reason == __DRI2_THROTTLE_FLUSHFRONT)) {
       /* Throttle.
        *
        * This pulls a fence off the throttling queue and waits for it if the
        * number of fences on the throttling queue has reached the desired
        * number.
        *
        * Then flushes to insert a fence at the current rendering position, and
diff --git a/src/gallium/state_trackers/dri/dri_screen.h b/src/gallium/state_trackers/dri/dri_screen.h
index 30bde45ce42..85372cb97c8 100644
--- a/src/gallium/state_trackers/dri/dri_screen.h
+++ b/src/gallium/state_trackers/dri/dri_screen.h
@@ -50,22 +50,21 @@ struct dri_screen
 {
    /* st_api */
    struct st_manager base;
    struct st_api *st_api;
 
    /* on old libGL's invalidate doesn't get called as it should */
    boolean broken_invalidate;
 
    /* dri */
    __DRIscreen *sPriv;
-   boolean throttling_enabled;
-   int default_throttle_frames;
+   unsigned default_throttle_frames;
 
    struct st_config_options options;
 
    /* Which postprocessing filters are enabled. */
    unsigned pp_enabled[PP_FILTERS];
 
    /* drm */
    int fd;
    boolean can_share_buffer;
 
-- 
2.17.1



More information about the mesa-dev mailing list