[Mesa-dev] [PATCH 15/16] nine: Add drirc options

David Heidelberger david.heidelberger at ixit.cz
Sat Oct 18 04:55:05 PDT 2014


From: Axel Davy <axel.davy at ens.fr>

Signed-off-by: Axel Davy <axel.davy at ens.fr>
Signed-off-by: David Heidelberger <david.heidelberger at ixit.cz>
---
 src/gallium/state_trackers/nine/adapter9.h      |  1 +
 src/gallium/state_trackers/nine/swapchain9.c    |  7 ++++++
 src/gallium/targets/d3dadapter9/Makefile.am     |  9 ++++++-
 src/gallium/targets/d3dadapter9/drm.c           | 33 +++++++++++++++++++++++++
 src/mesa/drivers/dri/common/xmlpool/t_options.h | 22 +++++++++++++++++
 5 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/adapter9.h b/src/gallium/state_trackers/nine/adapter9.h
index 356402a..c0fe14c 100644
--- a/src/gallium/state_trackers/nine/adapter9.h
+++ b/src/gallium/state_trackers/nine/adapter9.h
@@ -37,6 +37,7 @@ struct d3dadapter9_context
     BOOL linear_framebuffer;
     BOOL throttling;
     int throttling_value;
+    int vsync_force;
 
     void (*destroy)( struct d3dadapter9_context *ctx );
 };
diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c
index f24247c..3195cc6 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -162,6 +162,13 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
     if (This->desired_fences > DRI_SWAP_FENCES_MAX)
         This->desired_fences = DRI_SWAP_FENCES_MAX;
 
+    if (This->actx->vsync_force) {
+        if (This->actx->vsync_force == 1)
+            pParams->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+        else /* (This->actx->vsync_force == 2) */
+            pParams->PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+    }
+
     /* Note: It is the role of the backend to fill if neccessary
      * BackBufferWidth and BackBufferHeight */
     ID3DPresent_SetPresentParameters(This->present, pParams);
diff --git a/src/gallium/targets/d3dadapter9/Makefile.am b/src/gallium/targets/d3dadapter9/Makefile.am
index 4cc84f9..b34fd8b 100644
--- a/src/gallium/targets/d3dadapter9/Makefile.am
+++ b/src/gallium/targets/d3dadapter9/Makefile.am
@@ -30,6 +30,11 @@ AM_CFLAGS = \
 	-I$(top_srcdir)/src/gallium/state_trackers/nine \
 	-I$(top_srcdir)/include/D3D9 \
 	-I$(top_srcdir)/src/loader \
+	-I$(top_srcdir)/src/mesa/drivers/dri/common/ \
+	-I$(top_builddir)/src/mesa/drivers/dri/common/ \
+	-I$(top_srcdir)/src/mesa/ \
+	-I$(top_srcdir)/src/mapi/ \
+	$(LIBDRM_CFLAGS) \
 	-DPIPE_SEARCH_DIR=\"$(GALLIUM_PIPE_LOADER_DIR)\" \
 	$(GALLIUM_PIPE_LOADER_DEFINES)
 
@@ -53,7 +58,9 @@ libd3dadapter9_la_LIBADD = \
 	$(top_builddir)/src/util/libmesautil.la \
 	$(GALLIUM_PIPE_LOADER_LIBS) \
 	$(LIBUDEV_LIBS) \
-	$(GALLIUM_COMMON_LIB_DEPS)
+	$(GALLIUM_COMMON_LIB_DEPS) \
+	-lm \
+	$(EXPAT_LIBS)
 
 if NEED_WINSYS_XLIB
 libd3dadapter9_la_LIBADD += \
diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c
index ed5a88f..c1af702 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -34,6 +34,9 @@
 #include "d3dadapter/d3dadapter9.h"
 #include "d3dadapter/drm.h"
 
+#include "xmlconfig.h"
+#include "xmlpool.h"
+
 #include <libdrm/drm.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
@@ -47,6 +50,14 @@
          (DWORD)((lo) & 0xFFFF) \
     ))
 
+const char __driConfigOptionsNine[] =
+DRI_CONF_BEGIN
+    DRI_CONF_SECTION_NINE
+        DRI_CONF_NINE_VSYNC(0)
+        DRI_CONF_NINE_THROTTLE(-2)
+    DRI_CONF_SECTION_END
+DRI_CONF_END;
+
 /* Regarding os versions, we should not define our own as that would simply be
  * weird. Defaulting to Win2k/XP seems sane considering the origin of D3D9. The
  * driver also defaults to being a generic D3D9 driver, which of course only
@@ -223,6 +234,9 @@ drm_create_adapter( int fd,
     int i, different_device;
     const struct drm_conf_ret *throttle_ret = NULL;
     const struct drm_conf_ret *dmabuf_ret = NULL;
+    driOptionCache defaultInitOptions;
+    driOptionCache userInitOptions;
+    int throttling_value_user;
 
     const char *paths[] = {
         getenv("D3D9_DRIVERS_PATH"),
@@ -274,6 +288,25 @@ drm_create_adapter( int fd,
     } else
         ctx->base.throttling = FALSE;
 
+    driParseOptionInfo(&defaultInitOptions, __driConfigOptionsNine);
+    driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0, "nine");
+    if (driCheckOption(&userInitOptions, "throttle_value", DRI_INT)) {
+        throttling_value_user = driQueryOptioni(&userInitOptions, "throttle_value");
+        if (throttling_value_user == -1)
+            ctx->base.throttling = FALSE;
+        else if (throttling_value_user >= 0) {
+            ctx->base.throttling = TRUE;
+            ctx->base.throttling_value = throttling_value_user;
+        }
+    }
+
+    ctx->base.vsync_force = 0;
+    if (driCheckOption(&userInitOptions, "vsync_force", DRI_ENUM))
+        ctx->base.vsync_force = driQueryOptioni(&userInitOptions, "vsync_force");
+
+    driDestroyOptionCache(&userInitOptions);
+    driDestroyOptionInfo(&defaultInitOptions);
+
     /* wrap it to create a software screen that can share resources */
     if (pipe_loader_sw_probe_wrapped(&ctx->swdev, ctx->base.hal)) {
         ctx->base.ref = NULL;
diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h
index b73a662..e93341b 100644
--- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -340,3 +340,25 @@ DRI_CONF_SECTION_BEGIN \
 DRI_CONF_OPT_BEGIN(device_id, string, def) \
         DRI_CONF_DESC(en,gettext("Define the graphic device to use if possible")) \
 DRI_CONF_OPT_END
+
+/**
+ * \brief Gallium-Nine specific configuration options
+ */
+
+#define DRI_CONF_SECTION_NINE \
+DRI_CONF_SECTION_BEGIN \
+        DRI_CONF_DESC(en,gettext("Gallium Nine"))
+
+#define DRI_CONF_NINE_VSYNC(def) \
+DRI_CONF_OPT_BEGIN_V(vsync_force,enum,def,"0:2") \
+        DRI_CONF_DESC_BEGIN(en,gettext("Force the usage of vsync")) \
+                DRI_CONF_ENUM(0,gettext("Obey application's choice")) \
+                DRI_CONF_ENUM(1,gettext("Never synchronize with vertical refresh")) \
+                DRI_CONF_ENUM(2,gettext("Always synchronize with vertical refresh")) \
+        DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_NINE_THROTTLE(def) \
+DRI_CONF_OPT_BEGIN(throttle_value, int, def) \
+        DRI_CONF_DESC(en,gettext("Define the throttling value. -1 for no throttling, -2 for default (usually 2), 0 for glfinish behaviour")) \
+DRI_CONF_OPT_END
-- 
2.1.2



More information about the mesa-dev mailing list