st/nine: Add new driconf options to control DISCARD behaviour
authorAxel Davy <axel.davy@ens.fr>
Sat, 19 Nov 2016 12:11:15 +0000 (13:11 +0100)
committerAxel Davy <axel.davy@ens.fr>
Tue, 20 Dec 2016 22:44:21 +0000 (23:44 +0100)
See the patch for the new controls added.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/adapter9.h
src/gallium/state_trackers/nine/swapchain9.c
src/gallium/targets/d3dadapter9/drm.c
src/mesa/drivers/dri/common/xmlpool/t_options.h

index aaf7435fcdadad1ffd36089d7625a0834dd8a84f..4a71540ab4a17d4d2bb718dbc22f805e2ab70b0e 100644 (file)
@@ -39,6 +39,8 @@ struct d3dadapter9_context
     int throttling_value;
     int vblank_mode;
     BOOL thread_submit;
+    BOOL discard_delayed_release;
+    BOOL tearfree_discard;
 
     void (*destroy)( struct d3dadapter9_context *ctx );
 };
index 79530f5319ef575eaa825fc6783271aa2704e364..8a405f2374ca98602a966aade7574a1b1ceb21bb 100644 (file)
@@ -72,8 +72,8 @@ NineSwapChain9_ctor( struct NineSwapChain9 *This,
         D3DPRESENT_PARAMETERS2 params2;
 
         memset(&params2, 0, sizeof(D3DPRESENT_PARAMETERS2));
-        params2.AllowDISCARDDelayedRelease = TRUE;
-        params2.TearFreeDISCARD = FALSE;
+        params2.AllowDISCARDDelayedRelease = This->actx->discard_delayed_release;
+        params2.TearFreeDISCARD = This->actx->tearfree_discard;
         ID3DPresent_SetPresentParameters2(pPresent, &params2);
     }
 
index 767a17a55da5344e1fb048f572ff3b6d83900db5..e0c2e26c02f6b567c6e7f9d9eafaa989d6f6d4a7 100644 (file)
@@ -56,6 +56,8 @@ DRI_CONF_BEGIN
         DRI_CONF_NINE_OVERRIDEVENDOR(-1)
         DRI_CONF_NINE_THROTTLE(-2)
         DRI_CONF_NINE_THREADSUBMIT("false")
+        DRI_CONF_NINE_ALLOWDISCARDDELAYEDRELEASE("true")
+        DRI_CONF_NINE_TEARFREEDISCARD("false")
     DRI_CONF_SECTION_END
 DRI_CONF_END;
 
@@ -284,6 +286,21 @@ drm_create_adapter( int fd,
         override_vendorid = driQueryOptioni(&userInitOptions, "override_vendorid");
     }
 
+    if (driCheckOption(&userInitOptions, "discard_delayed_release", DRI_BOOL))
+        ctx->base.discard_delayed_release = driQueryOptionb(&userInitOptions, "discard_delayed_release");
+    else
+        ctx->base.discard_delayed_release = TRUE;
+
+    if (driCheckOption(&userInitOptions, "tearfree_discard", DRI_BOOL))
+        ctx->base.tearfree_discard = driQueryOptionb(&userInitOptions, "tearfree_discard");
+    else
+        ctx->base.tearfree_discard = FALSE;
+
+    if (ctx->base.tearfree_discard && !ctx->base.discard_delayed_release) {
+        ERR("tearfree_discard requires discard_delayed_release\n");
+        ctx->base.tearfree_discard = FALSE;
+    }
+
     driDestroyOptionCache(&userInitOptions);
     driDestroyOptionInfo(&defaultInitOptions);
 
index 341c3763deedee64616eac06446d7f0d85803e42..7b78105eb8ca657b79a3fb4a4dc30e8974dd214b 100644 (file)
@@ -376,3 +376,13 @@ DRI_CONF_OPT_END
 DRI_CONF_OPT_BEGIN(override_vendorid, int, def) \
         DRI_CONF_DESC(en,"Define the vendor_id to report. This allows faking another hardware vendor.") \
 DRI_CONF_OPT_END
+
+#define DRI_CONF_NINE_ALLOWDISCARDDELAYEDRELEASE(def) \
+DRI_CONF_OPT_BEGIN_B(discard_delayed_release, def) \
+        DRI_CONF_DESC(en,gettext("Whether to allow the display server to release buffers with a delay when using d3d's presentation mode DISCARD. Default to true. Set to false if suffering from lag (thread_submit=true can also help in this situation).")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_NINE_TEARFREEDISCARD(def) \
+DRI_CONF_OPT_BEGIN_B(tearfree_discard, def) \
+        DRI_CONF_DESC(en,gettext("Whether to make d3d's presentation mode DISCARD (games usually use that mode) Tear Free. If rendering above screen refresh, some frames will get skipped. false by default.")) \
+DRI_CONF_OPT_END