st/dri: Hook up throttling based on the drm driver_descriptor configuration
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 12 Oct 2011 09:00:12 +0000 (11:00 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Fri, 14 Oct 2011 07:53:11 +0000 (09:53 +0200)
Hooks up throttling if there is a configuration function present and
it indicates that throttling is desired.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
src/gallium/state_trackers/dri/common/dri_drawable.c
src/gallium/state_trackers/dri/common/dri_screen.h
src/gallium/state_trackers/dri/drm/dri2.c

index ca9e1307db9f6f9722bfc5571e3c5b3759970fe4..340404e6aa400b83447ef37ae4e3227c19c2707e 100644 (file)
@@ -137,7 +137,9 @@ dri_create_buffer(__DRIscreen * sPriv,
    drawable->screen = screen;
    drawable->sPriv = sPriv;
    drawable->dPriv = dPriv;
-   drawable->desired_fences = 2;
+   drawable->desired_fences = screen->default_throttle_frames;
+   if (drawable->desired_fences > DRI_SWAP_FENCES_MAX)
+      drawable->desired_fences = DRI_SWAP_FENCES_MAX;
 
    dPriv->driverPrivate = (void *)drawable;
    p_atomic_set(&drawable->base.stamp, 1);
index 8cb0a102c8d5e09cc3ece5a2ff83d58310fa68f3..4e865b9c551ed89cc636572dee048993ce2c1bfb 100644 (file)
@@ -54,6 +54,7 @@ struct dri_screen
 
    /* dri */
    __DRIscreen *sPriv;
+   int default_throttle_frames;
 
    /**
     * Configuration cache with default values for all contexts
index 2b6919ddd0b03fd3327d32de462b9f122de3f7cb..f3c9e1053cb868757a88a94005459f38f2454044 100644 (file)
@@ -623,6 +623,19 @@ static const __DRIextension *dri_screen_extensions[] = {
    NULL
 };
 
+static const __DRIextension *dri_screen_extensions_throttle[] = {
+   &driReadDrawableExtension,
+   &driCopySubBufferExtension.base,
+   &driSwapControlExtension.base,
+   &driMediaStreamCounterExtension.base,
+   &driTexBufferExtension.base,
+   &dri2FlushExtension.base,
+   &dri2ImageExtension.base,
+   &dri2ConfigQueryExtension.base,
+   &dri2ThrottleExtension.base,
+   NULL
+};
+
 /**
  * This is the driver specific part of the createNewScreen entry point.
  *
@@ -634,6 +647,7 @@ dri2_init_screen(__DRIscreen * sPriv)
    const __DRIconfig **configs;
    struct dri_screen *screen;
    struct pipe_screen *pscreen;
+   const struct drm_conf_ret *throttle_ret = NULL;
 
    screen = CALLOC_STRUCT(dri_screen);
    if (!screen)
@@ -643,9 +657,17 @@ dri2_init_screen(__DRIscreen * sPriv)
    screen->fd = sPriv->fd;
 
    sPriv->private = (void *)screen;
-   sPriv->extensions = dri_screen_extensions;
 
    pscreen = driver_descriptor.create_screen(screen->fd);
+   if (driver_descriptor.configuration)
+      throttle_ret = driver_descriptor.configuration(DRM_CONF_THROTTLE);
+
+   if (throttle_ret && throttle_ret->val.val_int != -1) {
+      sPriv->extensions = dri_screen_extensions_throttle;
+      screen->default_throttle_frames = throttle_ret->val.val_int;
+   } else
+      sPriv->extensions = dri_screen_extensions;
+
    /* dri_init_screen_helper checks pscreen for us */
 
    configs = dri_init_screen_helper(screen, pscreen, 32);