[Mesa-dev] [PATCH 13/14] nine: Add drirc options (v2)
David Heidelberger
david.heidelberger at ixit.cz
Mon Oct 20 05:37:56 PDT 2014
From: Axel Davy <axel.davy at ens.fr>
Implements vblank_mode and throttling, which allows us change default ratio
between framerate and input lag.
Signed-off-by: David Heidelberger <david.heidelberger at ixit.cz>
Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
src/gallium/state_trackers/nine/adapter9.h | 1 +
src/gallium/state_trackers/nine/swapchain9.c | 5 ++++
src/gallium/targets/d3dadapter9/Makefile.am | 9 ++++++-
src/gallium/targets/d3dadapter9/drm.c | 36 +++++++++++++++++++++++++
src/mesa/drivers/dri/common/xmlpool/t_options.h | 13 +++++++++
5 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/src/gallium/state_trackers/nine/adapter9.h b/src/gallium/state_trackers/nine/adapter9.h
index 356402a..8eeb190 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 vblank_mode;
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 305c9f4..fe47161 100644
--- a/src/gallium/state_trackers/nine/swapchain9.c
+++ b/src/gallium/state_trackers/nine/swapchain9.c
@@ -162,6 +162,11 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
if (This->desired_fences > DRI_SWAP_FENCES_MAX)
This->desired_fences = DRI_SWAP_FENCES_MAX;
+ if (This->actx->vblank_mode == 0)
+ pParams->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+ else if (This->actx->vblank_mode == 3)
+ 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..a6d46b9 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,16 @@
(DWORD)((lo) & 0xFFFF) \
))
+const char __driConfigOptionsNine[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_NINE
+ 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 +236,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 +290,26 @@ 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;
+ }
+ }
+
+ if (driCheckOption(&userInitOptions, "vblank_mode", DRI_ENUM))
+ ctx->base.vblank_mode = driQueryOptioni(&userInitOptions, "vblank_mode");
+ else
+ ctx->base.vblank_mode = 1;
+
+ 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..e4f6937 100644
--- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -340,3 +340,16 @@ 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_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