summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers/xorg/xorg_dri2.c
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2010-01-22 12:17:02 -0700
committerBrian Paul <brianp@vmware.com>2010-01-22 12:17:02 -0700
commitcd8614b0287dc5a69725ec4ee0208fad61f7789e (patch)
tree3ee089b8384e7a60c5c3a3cc87f2a633bd724bbe /src/gallium/state_trackers/xorg/xorg_dri2.c
parent2b20b604277e3cdf7afb2431b50dbb05da12ff1c (diff)
parent64871747bb7b611ffe429fbf1724bd98ee25dd84 (diff)
Merge branch 'mesa_7_7_branch'
Conflicts: src/gallium/auxiliary/draw/draw_context.c src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c src/gallium/auxiliary/pipebuffer/Makefile src/gallium/auxiliary/pipebuffer/SConscript src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c src/gallium/auxiliary/tgsi/tgsi_scan.c src/gallium/drivers/i915/i915_surface.c src/gallium/drivers/i915/i915_texture.c src/gallium/drivers/llvmpipe/lp_setup.c src/gallium/drivers/llvmpipe/lp_tex_sample_c.c src/gallium/drivers/llvmpipe/lp_texture.c src/gallium/drivers/softpipe/sp_prim_vbuf.c src/gallium/state_trackers/xorg/xorg_dri2.c src/gallium/winsys/drm/intel/gem/intel_drm_api.c src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c src/gallium/winsys/drm/radeon/core/radeon_drm.c src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c src/mesa/state_tracker/st_cb_clear.c
Diffstat (limited to 'src/gallium/state_trackers/xorg/xorg_dri2.c')
-rw-r--r--src/gallium/state_trackers/xorg/xorg_dri2.c47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
index fd82f4fa1d..e6a89c7645 100644
--- a/src/gallium/state_trackers/xorg/xorg_dri2.c
+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
@@ -44,9 +44,12 @@
#include "util/u_rect.h"
/* Make all the #if cases in the code esier to read */
-/* XXX can it be set to 1? */
#ifndef DRI2INFOREC_VERSION
-#define DRI2INFOREC_VERSION 0
+#define DRI2INFOREC_VERSION 1
+#endif
+
+#if DRI2INFOREC_VERSION == 2
+static Bool set_format_in_do_create_buffer;
#endif
typedef struct {
@@ -147,7 +150,9 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form
buffer->driverPrivate = private;
buffer->flags = 0; /* not tiled */
#if DRI2INFOREC_VERSION == 2
- ((DRI2Buffer2Ptr)buffer)->format = 0;
+ /* ABI forwards/backwards compatibility */
+ if (set_format_in_do_create_buffer)
+ ((DRI2Buffer2Ptr)buffer)->format = 0;
#elif DRI2INFOREC_VERSION >= 3
buffer->format = 0;
#endif
@@ -211,7 +216,9 @@ dri2_destroy_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer)
xfree(buffer);
}
-#else /* DRI2INFOREC_VERSION < 2 */
+#endif /* DRI2INFOREC_VERSION >= 2 */
+
+#if DRI2INFOREC_VERSION <= 2
static DRI2BufferPtr
dri2_create_buffers(DrawablePtr pDraw, unsigned int *attachments, int count)
@@ -261,7 +268,7 @@ dri2_destroy_buffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
}
}
-#endif /* DRI2INFOREC_VERSION >= 2 */
+#endif /* DRI2INFOREC_VERSION <= 2 */
static void
dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
@@ -369,12 +376,17 @@ xorg_dri2_init(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
DRI2InfoRec dri2info;
+ int major, minor;
+
+ if (xf86LoaderCheckSymbol("DRI2Version")) {
+ DRI2Version(&major, &minor);
+ } else {
+ /* Assume version 1.0 */
+ major = 1;
+ minor = 0;
+ }
-#if DRI2INFOREC_VERSION >= 2
dri2info.version = DRI2INFOREC_VERSION;
-#else
- dri2info.version = 1;
-#endif
dri2info.fd = ms->fd;
dri2info.driverName = pScrn->driverName;
@@ -383,7 +395,22 @@ xorg_dri2_init(ScreenPtr pScreen)
#if DRI2INFOREC_VERSION >= 2
dri2info.CreateBuffer = dri2_create_buffer;
dri2info.DestroyBuffer = dri2_destroy_buffer;
-#else
+#endif
+
+ /* For X servers in the 1.6.x series there where two DRI2 version.
+ * This allows us to build one binary that works on both servers.
+ */
+#if DRI2INFOREC_VERSION == 2
+ if (minor == 0) {
+ set_format_in_do_create_buffer = FALSE;
+ dri2info.CreateBuffers = dri2_create_buffers;
+ dri2info.DestroyBuffers = dri2_destroy_buffers;
+ } else
+ set_format_in_do_create_buffer = FALSE;
+#endif
+
+ /* For version 1 set these unconditionaly. */
+#if DRI2INFOREC_VERSION == 1
dri2info.CreateBuffers = dri2_create_buffers;
dri2info.DestroyBuffers = dri2_destroy_buffers;
#endif