summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Hourihane <alanh@tungstengraphics.com>2008-09-11 17:32:18 +0100
committerAlan Hourihane <alanh@tungstengraphics.com>2008-09-11 17:32:18 +0100
commit47ad296a183929c2007c35c60d722b4ac680417d (patch)
tree62bcc7af01606d32d7f137ccf8f342c9b0a6774a
parentb6458225039ef4cf5c91080e7547ed73fb264c46 (diff)
parent4d42c5bebf8740ebfc15571d24b6c92f79e09263 (diff)
Merge branch 'master' of git+ssh://git.freedesktop.org/git/mesa/mesa into gallium-0.2
Conflicts: src/mesa/drivers/dri/i915/intel_ioctl.c src/mesa/main/texstore.c src/mesa/tnl/t_vp_build.c src/mesa/vbo/vbo_exec_draw.c
-rw-r--r--configs/default2
-rw-r--r--configure.ac21
-rw-r--r--docs/contents.html1
-rw-r--r--docs/download.html2
-rw-r--r--docs/intro.html7
-rw-r--r--docs/lists.html13
-rw-r--r--docs/news.html10
-rw-r--r--docs/relnotes-7.1.html25
-rw-r--r--include/GL/internal/dri_interface.h83
-rw-r--r--include/GL/internal/dri_sarea.h134
-rw-r--r--src/glx/x11/dri2.c113
-rw-r--r--src/glx/x11/dri2.h23
-rw-r--r--src/glx/x11/dri2_glx.c128
-rw-r--r--src/glx/x11/dri_glx.c6
-rw-r--r--src/glx/x11/glxclient.h5
-rw-r--r--src/glx/x11/glxcmds.c3
-rw-r--r--src/mesa/Makefile.mgw2
-rw-r--r--src/mesa/drivers/dri/Makefile2
-rw-r--r--src/mesa/drivers/dri/common/dri_util.c254
-rw-r--r--src/mesa/drivers/dri/common/dri_util.h26
-rw-r--r--src/mesa/drivers/dri/i915/Makefile3
-rw-r--r--src/mesa/drivers/dri/i915/i830_metaops.c1
-rw-r--r--src/mesa/drivers/dri/i915/i830_tex.c2
-rw-r--r--src/mesa/drivers/dri/i915/i830_texblend.c1
-rw-r--r--src/mesa/drivers/dri/i915/i830_texstate.c1
-rw-r--r--src/mesa/drivers/dri/i915/i915_metaops.c1
-rw-r--r--src/mesa/drivers/dri/i915/i915_tex.c2
-rw-r--r--src/mesa/drivers/dri/i915/i915_texstate.c3
-rw-r--r--src/mesa/drivers/dri/i915/intel_ioctl.c659
-rw-r--r--src/mesa/drivers/dri/i915/intel_pixel_read.c1
-rw-r--r--src/mesa/drivers/dri/i965/Makefile3
-rw-r--r--src/mesa/drivers/dri/i965/brw_cc.c12
-rw-r--r--src/mesa/drivers/dri/i965/brw_clip_state.c12
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c1
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.h1
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c1
-rw-r--r--src/mesa/drivers/dri/i965/brw_eu_emit.c13
-rw-r--r--src/mesa/drivers/dri/i965/brw_gs_state.c10
-rw-r--r--src/mesa/drivers/dri/i965/brw_sf_state.c20
-rw-r--r--src/mesa/drivers/dri/i965/brw_state_upload.c1
-rw-r--r--src/mesa/drivers/dri/i965/brw_tex.c1
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_state.c10
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_glsl.c4
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_sampler_state.c12
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_state.c31
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_surface_state.c36
l---------src/mesa/drivers/dri/i965/intel_ioctl.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.c41
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.h5
-rw-r--r--src/mesa/drivers/dri/intel/intel_blit.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_blit.h2
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffer_objects.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffers.c3
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c298
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.h4
-rw-r--r--src/mesa/drivers/dri/intel/intel_ioctl.c185
-rw-r--r--src/mesa/drivers/dri/intel/intel_ioctl.h46
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_bitmap.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_copy.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_draw.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.c8
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.h6
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c192
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.h7
-rw-r--r--src/mesa/drivers/dri/intel/intel_span.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_format.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c3
-rw-r--r--src/mesa/drivers/windows/gdi/wmesa.c227
-rw-r--r--src/mesa/main/arrayobj.c33
-rw-r--r--src/mesa/main/attrib.c89
-rw-r--r--src/mesa/main/bufferobj.c188
-rw-r--r--src/mesa/main/bufferobj.h11
-rw-r--r--src/mesa/main/extensions.c4
-rw-r--r--src/mesa/main/framebuffer.c12
-rw-r--r--src/mesa/main/getstring.c14
-rw-r--r--src/mesa/main/imports.c2
-rw-r--r--src/mesa/main/light.c1
-rw-r--r--src/mesa/main/texstore.c7
-rw-r--r--src/mesa/main/varray.c15
-rw-r--r--src/mesa/tnl/t_vp_build.c431
-rw-r--r--src/mesa/vbo/vbo_exec_api.c8
-rw-r--r--src/mesa/vbo/vbo_exec_draw.c39
-rw-r--r--src/mesa/vbo/vbo_save.c16
-rw-r--r--src/mesa/vbo/vbo_save_api.c17
-rw-r--r--src/mesa/vbo/vbo_save_draw.c28
85 files changed, 1605 insertions, 2049 deletions
diff --git a/configs/default b/configs/default
index 76d03f5c5a..a6ac0b7280 100644
--- a/configs/default
+++ b/configs/default
@@ -9,7 +9,7 @@ CONFIG_NAME = default
# Version info
MESA_MAJOR=7
-MESA_MINOR=1
+MESA_MINOR=3
MESA_TINY=0
MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY)
diff --git a/configure.ac b/configure.ac
index c87dce6546..463821be6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@ AC_CANONICAL_HOST
dnl Versions for external dependencies
LIBDRM_REQUIRED=2.3.1
-DRI2PROTO_REQUIRED=1.1
+DRI2PROTO_REQUIRED=1.99.1
dnl Check for progs
AC_PROG_CPP
@@ -595,20 +595,6 @@ AC_ARG_ENABLE([driglx-direct],
[enable direct rendering in GLX for DRI @<:@default=enabled@:>@])],
[driglx_direct="$enableval"],
[driglx_direct="yes"])
-dnl ttm support
-AC_ARG_ENABLE([ttm-api],
- [AS_HELP_STRING([--enable-ttm-api],
- [enable TTM API users @<:@default=disabled@:>@])],
- [ttmapi="$enableval"],
- [ttmapi="no"])
-
-if test "x$ttmapi" = "xyes"; then
- save_CFLAGS=$CFLAGS
- CFLAGS=$LIBDRM_CFLAGS
- AC_CHECK_HEADERS([xf86mm.h],[],[AC_MSG_ERROR([xf86mm.h required for TTM.])],[#include "stdint.h"\n#include "drm.h"])
- CFLAGS=$save_CFLAGS
-fi
-
dnl Which drivers to build - default is chosen by platform
AC_ARG_WITH([dri-drivers],
[AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
@@ -650,10 +636,6 @@ if test "$mesa_driver" = dri; then
DEFINES="$DEFINES -DGLX_USE_TLS -DPTHREADS"
fi
- if test "x$ttmapi" = xyes; then
- DEFINES="$DEFINES -DTTM_API"
- fi
-
if test "x$USING_EGL" = x1; then
PROGRAM_DIRS="egl"
fi
@@ -1050,7 +1032,6 @@ else
echo " DRI drivers: $dri_dirs"
fi
echo " DRI driver dir: $DRI_DRIVER_INSTALL_DIR"
- echo " TTM API support: $ttmapi"
fi
dnl Libraries
diff --git a/docs/contents.html b/docs/contents.html
index 3feb8cae94..257b13f68a 100644
--- a/docs/contents.html
+++ b/docs/contents.html
@@ -48,6 +48,7 @@ a:visited {
<li><a href="lists.html" target="MainFrame">Mailing Lists</a>
<li><a href="bugs.html" target="MainFrame">Bug Database</a>
<li><a href="webmaster.html" target="MainFrame">Webmaster</a>
+<li><a href="http://dri.freedesktop.org/" target="MainFrame">Wiki</a>
</ul>
<b>User Topics</b>
diff --git a/docs/download.html b/docs/download.html
index 4a9804955a..2d587f35f9 100644
--- a/docs/download.html
+++ b/docs/download.html
@@ -9,6 +9,8 @@
<H1>Downloading</H1>
<p>
+Current development release: <b>7.1</b>
+<br>
Last stable release: <b>7.0.4</b>
</p>
diff --git a/docs/intro.html b/docs/intro.html
index 0e37322823..aae2e6e192 100644
--- a/docs/intro.html
+++ b/docs/intro.html
@@ -22,9 +22,10 @@ for modern GPUs.
<p>
Mesa ties into several other open-source projects: the
-<a href="http://dri.sf.net/" target="_parent">Direct Rendering Infrastructure</a>
-and <a href="http://x.org" target="_parent">X.org</a> to provide OpenGL
-support to users of X on Linux, FreeBSD and other operating systems.
+<a href="http://dri.freedesktop.org/" target="_parent">Direct Rendering
+Infrastructure</a> and <a href="http://x.org" target="_parent">X.org</a> to
+provide OpenGL support to users of X on Linux, FreeBSD and other operating
+systems.
</p>
diff --git a/docs/lists.html b/docs/lists.html
index a2cad129cf..5227fbd055 100644
--- a/docs/lists.html
+++ b/docs/lists.html
@@ -9,7 +9,7 @@
<H1>Mailing Lists</H1>
-<p>There are four Mesa mailing lists:
+<p>There are four Mesa 3D / DRI mailing lists:
</p>
<ul>
@@ -19,14 +19,14 @@ versions are sent to this list.
</li>
<br>
<li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-users"
-target="_parent">mesa3d-users</a> - intended for users of the Mesa library.
+target="_parent">mesa3d-users</a> - intended for users of the Mesa and DRI.
Newbie questions are appropriate, but please try the general OpenGL
-resources and Mesa documentation first.
+resources and Mesa/DRI documentation first.
</li>
<br>
<li><a href="https://lists.sourceforge.net/lists/listinfo/mesa3d-dev"
-target="_parent">mesa3d-dev</a> - for discussion of Mesa development.
-Not for beginners.
+target="_parent">mesa3d-dev</a> - for discussion of Mesa and Direct Rendering
+Infrastructure development. Not for beginners.
</li>
<br>
<li><a href="http://lists.freedesktop.org/mailman/listinfo/mesa-commit"
@@ -37,6 +37,9 @@ Note: the old mesa3d-cvs list is no longer in use.
</li>
</ul>
+<p>For mailing lists about Direct Rendering Modules (drm) in Linux/BSD
+kernels, see <a href="http://dri.freedesktop.org/wiki/MailingLists">wiki</a>.
+
<p>
<b>Notice</b>: non-member posts to any of these lists will be automatically
rejected.
diff --git a/docs/news.html b/docs/news.html
index 1bf6436484..6d0d83659b 100644
--- a/docs/news.html
+++ b/docs/news.html
@@ -11,6 +11,16 @@
<H1>News</H1>
+<h2>August 26, 2008</h2>
+<p>
+<a href="relnotes-7.1.html">Mesa 7.1</a> is released.
+This is a new development release.
+It should be relatively stable, but those especially concerned about
+stability should wait for the 7.2 release or use Mesa 7.0.4 (the
+previous stable release).
+</p>
+
+
<h2>August 16, 2008</h2>
<p>
<a href="relnotes-7.0.4.html">Mesa 7.0.4</a> is released.
diff --git a/docs/relnotes-7.1.html b/docs/relnotes-7.1.html
index abcbc3186e..e8a39c8d34 100644
--- a/docs/relnotes-7.1.html
+++ b/docs/relnotes-7.1.html
@@ -8,28 +8,46 @@
<body bgcolor="#eeeeee">
-<H1>Mesa 7.1 Release Notes / May XX, 2008</H1>
+<H1>Mesa 7.1 Release Notes / August 26, 2008</H1>
<p>
Mesa 7.1 is a new development release.
There have been many internal code changes since Mesa 7.0.x.
It should be relatively stable, but those who are especially concerned about
-stability should wait for Mesa 7.2.
+stability should wait for Mesa 7.2 or use Mesa 7.0.4 (the previous stable
+release).
+</p>
+</>
+Note that this version of Mesa does not use the GEM memory manager.
+The master branch of git uses GEM.
+</p>
+<p>
+DRM version 2.3.1 should be used with Mesa 7.1
</p>
<h2>MD5 checksums</h2>
<pre>
-TBD
+971c2fe6e6949dc5ba200a6f97a6dc81 MesaLib-7.1.tar.gz
+6bff7f532d16f90f944a400c8bd7074d MesaLib-7.1.tar.bz2
+d48224bf9d54c3da6776adb4869ba024 MesaLib-7.1.zip
+3de268420efca43e9a19ab506cdfc993 MesaDemos-7.1.tar.gz
+abfc9775e1462363af8ec160d1feb01f MesaDemos-7.1.tar.bz2
+f7b3623387c4036e9895cd9ac0dfad99 MesaDemos-7.1.zip
+fdf348f78cd09304b6ff801ef8acc8eb MesaGLUT-7.1.tar.gz
+f6d88a4eeb02e98c7e92f1c895d3c76b MesaGLUT-7.1.tar.bz2
+4dc102a5ca51e1c41dde87d3f8c7b22a MesaGLUT-7.1.zip
</pre>
<h2>New features</h2>
<ul>
<li>autoconf-based configuration (and clean-up of Makefiles)
+<li>Assorted DRI driver enhancements
<li>Reduced dependencies between X server and Mesa
<li>GL_EXT_texture_from_pixmap extension for Xlib driver
<li>Support for the GL shading language with i965 driver (implemented by Intel)
+<li>ATI R500 series support (Radeon X1300&#8211;X1950) in r300 DRI driver
</ul>
@@ -37,6 +55,7 @@ TBD
<ul>
<li>Numerous GLSL fixes
<li>Fixed some error code/detection bugs in the GLSL-related API functions
+<li>Lots of DRI driver fixes.
</ul>
diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index e7780d2e26..e4cc16b866 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -75,6 +75,10 @@ typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;
typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension;
typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension;
typedef struct __DRIswrastExtensionRec __DRIswrastExtension;
+typedef struct __DRIbufferRec __DRIbuffer;
+typedef struct __DRIdri2ExtensionRec __DRIdri2Extension;
+typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension;
+
/*@}*/
@@ -343,29 +347,6 @@ struct __DRIdamageExtensionRec {
void *loaderPrivate);
};
-/**
- * DRI2 Loader extension. This extension describes the basic
- * functionality the loader needs to provide for the DRI driver.
- */
-#define __DRI_LOADER "DRI_Loader"
-#define __DRI_LOADER_VERSION 1
-struct __DRIloaderExtensionRec {
- __DRIextension base;
-
- /**
- * Ping the windowing system to get it to reemit info for the
- * specified drawable in the DRI2 event buffer.
- *
- * \param draw the drawable for which to request info
- * \param tail the new event buffer tail pointer
- */
- void (*reemitDrawableInfo)(__DRIdrawable *draw, unsigned int *tail,
- void *loaderPrivate);
-
- void (*postDamage)(__DRIdrawable *draw, struct drm_clip_rect *rects,
- int num_rects, void *loaderPrivate);
-};
-
#define __DRI_SWRAST_IMAGE_OP_DRAW 1
#define __DRI_SWRAST_IMAGE_OP_CLEAR 2
#define __DRI_SWRAST_IMAGE_OP_SWAP 3
@@ -633,4 +614,60 @@ struct __DRIswrastExtensionRec {
void *loaderPrivate);
};
+/**
+ * DRI2 Loader extension.
+ */
+#define __DRI_BUFFER_FRONT_LEFT 0
+#define __DRI_BUFFER_BACK_LEFT 1
+#define __DRI_BUFFER_FRONT_RIGHT 2
+#define __DRI_BUFFER_BACK_RIGHT 3
+#define __DRI_BUFFER_DEPTH 4
+#define __DRI_BUFFER_STENCIL 5
+#define __DRI_BUFFER_ACCUM 6
+
+struct __DRIbufferRec {
+ unsigned int attachment;
+ unsigned int name;
+ unsigned int pitch;
+ unsigned int cpp;
+ unsigned int flags;
+};
+
+#define __DRI_DRI2_LOADER "DRI_DRI2Loader"
+#define __DRI_DRI2_LOADER_VERSION 1
+struct __DRIdri2LoaderExtensionRec {
+ __DRIextension base;
+
+ __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
+ int *width, int *height,
+ unsigned int *attachments, int count,
+ int *out_count, void *loaderPrivate);
+};
+
+/**
+ * This extension provides alternative screen, drawable and context
+ * constructors for DRI2.
+ */
+#define __DRI_DRI2 "DRI_DRI2"
+#define __DRI_DRI2_VERSION 1
+
+struct __DRIdri2ExtensionRec {
+ __DRIextension base;
+
+ __DRIscreen *(*createNewScreen)(int screen, int fd,
+ const __DRIextension **extensions,
+ const __DRIconfig ***driver_configs,
+ void *loaderPrivate);
+
+ __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
+ const __DRIconfig *config,
+ void *loaderPrivate);
+
+ __DRIcontext *(*createNewContext)(__DRIscreen *screen,
+ const __DRIconfig *config,
+ __DRIcontext *shared,
+ void *loaderPrivate);
+
+};
+
#endif
diff --git a/include/GL/internal/dri_sarea.h b/include/GL/internal/dri_sarea.h
deleted file mode 100644
index 849161fbc1..0000000000
--- a/include/GL/internal/dri_sarea.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2007 Red Hat, Inc
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef DRI_SAREA_H
-#define DRI_SAREA_H
-
-#include <drm.h>
-
-/* The DRI2 SAREA holds a list of self-describing blocks. Each block
- * is 8 byte aligned and has a common 32-bit header word. The upper
- * 16 bits describe the type of the block and the lower 16 bits the
- * size. DRI2 only defines a couple of blocks and allows drivers to
- * define driver specific blocks using type codes from 0x8000 and up.
- * The type code 0x0000 defines the end of the sarea. */
-
-#define DRI2_SAREA_BLOCK_HEADER(type, size) (((type) << 16) | (size))
-#define DRI2_SAREA_BLOCK_TYPE(b) ((b) >> 16)
-#define DRI2_SAREA_BLOCK_SIZE(b) ((b) & 0xffff)
-#define DRI2_SAREA_BLOCK_NEXT(p) \
- ((void *) ((unsigned char *) (p) + \
- DRI2_SAREA_BLOCK_SIZE(*(unsigned int *) p)))
-
-#define DRI2_SAREA_BLOCK_END 0x0000
-#define DRI2_SAREA_BLOCK_LOCK 0x0001
-#define DRI2_SAREA_BLOCK_EVENT_BUFFER 0x0002
-
-/* Chipset specific blocks start at 0x8000, 0xffff is reserved. */
-
-typedef struct __DRILock __DRILock;
-typedef struct __DRIEventBuffer __DRIEventBuffer;
-typedef struct __DRIDrawableBuffer __DRIDrawableBuffer;
-typedef struct __DRIDrawableConfigEvent __DRIDrawableConfigEvent;
-typedef struct __DRIBufferAttachEvent __DRIBufferAttachEvent;
-
-struct __DRILock {
- unsigned int block_header;
- drm_hw_lock_t lock;
-
- /* We use this with DRM_CAS to allocate lock IDs for the real lock.*/
- unsigned int next_id;
-};
-
-struct __DRIEventBuffer {
- unsigned int block_header;
- unsigned int head; /* last valid event */
- unsigned int prealloc; /* event currently being written */
- unsigned int size; /* size of data */
- unsigned char data[0];
-};
-
-enum {
- /* the four standard color buffers */
- DRI_DRAWABLE_BUFFER_FRONT_LEFT = 0,
- DRI_DRAWABLE_BUFFER_BACK_LEFT = 1,
- DRI_DRAWABLE_BUFFER_FRONT_RIGHT = 2,
- DRI_DRAWABLE_BUFFER_BACK_RIGHT = 3,
- /* optional aux buffer */
- DRI_DRAWABLE_BUFFER_AUX0 = 4,
- DRI_DRAWABLE_BUFFER_AUX1 = 5,
- DRI_DRAWABLE_BUFFER_AUX2 = 6,
- DRI_DRAWABLE_BUFFER_AUX3 = 7,
- DRI_DRAWABLE_BUFFER_DEPTH = 8,
- DRI_DRAWABLE_BUFFER_STENCIL = 9,
- DRI_DRAWABLE_BUFFER_ACCUM = 10,
- /* generic renderbuffers */
- DRI_DRAWABLE_BUFFER_COLOR0 = 11,
- DRI_DRAWABLE_BUFFER_COLOR1 = 12,
- DRI_DRAWABLE_BUFFER_COLOR2 = 13,
- DRI_DRAWABLE_BUFFER_COLOR3 = 14,
- DRI_DRAWABLE_BUFFER_COLOR4 = 15,
- DRI_DRAWABLE_BUFFER_COLOR5 = 16,
- DRI_DRAWABLE_BUFFER_COLOR6 = 17,
- DRI_DRAWABLE_BUFFER_COLOR7 = 18,
- DRI_DRAWABLE_BUFFER_COUNT = 19
-};
-
-struct __DRIDrawableBuffer {
- unsigned int attachment;
- unsigned int handle;
- unsigned int pitch;
- unsigned short cpp;
-
- /* Upper 8 bits are driver specific, lower 8 bits generic. The
- * bits can inidicate buffer properties such as tiled, swizzled etc. */
- unsigned short flags;
-};
-
-#define DRI2_EVENT_HEADER(type, size) (((type) << 16) | (size))
-#define DRI2_EVENT_TYPE(b) ((b) >> 16)
-#define DRI2_EVENT_SIZE(b) ((b) & 0xffff)
-
-#define DRI2_EVENT_PAD 0x0000
-#define DRI2_EVENT_DRAWABLE_CONFIG 0x0001
-#define DRI2_EVENT_BUFFER_ATTACH 0x0002
-
-struct __DRIDrawableConfigEvent {
- unsigned int event_header;
- unsigned int drawable;
- short x;
- short y;
- unsigned int width;
- unsigned int height;
- unsigned int num_rects;
- struct drm_clip_rect rects[0];
-};
-
-struct __DRIBufferAttachEvent {
- unsigned int event_header;
- unsigned int drawable;
- __DRIDrawableBuffer buffer;
-};
-
-#endif /* DRI_SAREA_H */
diff --git a/src/glx/x11/dri2.c b/src/glx/x11/dri2.c
index e7044ab424..dc60af90c1 100644
--- a/src/glx/x11/dri2.c
+++ b/src/glx/x11/dri2.c
@@ -122,7 +122,11 @@ Bool DRI2Connect(Display *dpy, int screen,
return False;
}
- *sareaHandle = rep.sareaHandle;
+ if (rep.driverNameLength == 0 && rep.busIdLength == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
*driverName = Xmalloc(rep.driverNameLength + 1);
if (*driverName == NULL) {
@@ -150,7 +154,7 @@ Bool DRI2Connect(Display *dpy, int screen,
UnlockDisplay(dpy);
SyncHandle();
- return rep.sareaHandle != 0;
+ return True;
}
Bool DRI2AuthConnection(Display *dpy, int screen, drm_magic_t magic)
@@ -179,74 +183,119 @@ Bool DRI2AuthConnection(Display *dpy, int screen, drm_magic_t magic)
return rep.authenticated;
}
-Bool DRI2CreateDrawable(Display *dpy, XID drawable,
- unsigned int *handle, unsigned int *head)
+void DRI2CreateDrawable(Display *dpy, XID drawable)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2CreateDrawableReply rep;
xDRI2CreateDrawableReq *req;
- XextCheckExtension (dpy, info, dri2ExtensionName, False);
+ XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
LockDisplay(dpy);
GetReq(DRI2CreateDrawable, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2CreateDrawable;
req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+DRI2Buffer *DRI2GetBuffers(Display *dpy, XID drawable,
+ int *width, int *height,
+ unsigned int *attachments, int count,
+ int *outCount)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ xDRI2GetBuffersReply rep;
+ xDRI2GetBuffersReq *req;
+ DRI2Buffer *buffers;
+ xDRI2Buffer repBuffer;
+ CARD32 *p;
+ int i;
+
+ XextCheckExtension (dpy, info, dri2ExtensionName, False);
+
+ LockDisplay(dpy);
+ GetReqExtra(DRI2GetBuffers, count * 4, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2ReqType = X_DRI2GetBuffers;
+ req->drawable = drawable;
+ req->count = count;
+ p = (CARD32 *) &req[1];
+ for (i = 0; i < count; i++)
+ p[i] = attachments[i];
+
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
- return False;
+ return NULL;
+ }
+
+ *width = rep.width;
+ *height = rep.height;
+ *outCount = rep.count;
+
+ buffers = Xmalloc(count * sizeof buffers[0]);
+ if (buffers == NULL) {
+ _XEatData(dpy, rep.count * sizeof repBuffer);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+
+ for (i = 0; i < rep.count; i++) {
+ _XReadPad(dpy, (char *) &repBuffer, sizeof repBuffer);
+ buffers[i].attachment = repBuffer.attachment;
+ buffers[i].name = repBuffer.name;
+ buffers[i].pitch = repBuffer.pitch;
+ buffers[i].cpp = repBuffer.cpp;
+ buffers[i].flags = repBuffer.flags;
}
+
UnlockDisplay(dpy);
SyncHandle();
- *handle = rep.handle;
- *head = rep.head;
-
- return True;
+ return buffers;
}
-void DRI2DestroyDrawable(Display *dpy, XID drawable)
+void DRI2SwapBuffers(Display *dpy, XID drawable,
+ int x, int y, int width, int height)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2DestroyDrawableReq *req;
+ xDRI2SwapBuffersReq *req;
+ xDRI2SwapBuffersReply rep;
XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
- XSync(dpy, GL_FALSE);
-
LockDisplay(dpy);
- GetReq(DRI2DestroyDrawable, req);
+ GetReq(DRI2SwapBuffers, req);
req->reqType = info->codes->major_opcode;
- req->dri2ReqType = X_DRI2DestroyDrawable;
+ req->dri2ReqType = X_DRI2SwapBuffers;
req->drawable = drawable;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+
+ _XReply(dpy, (xReply *)&rep, 0, xFalse);
+
UnlockDisplay(dpy);
SyncHandle();
}
-Bool DRI2ReemitDrawableInfo(Display *dpy, XID drawable, unsigned int *head)
+void DRI2DestroyDrawable(Display *dpy, XID drawable)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2ReemitDrawableInfoReply rep;
- xDRI2ReemitDrawableInfoReq *req;
+ xDRI2DestroyDrawableReq *req;
- XextCheckExtension (dpy, info, dri2ExtensionName, False);
+ XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
+
+ XSync(dpy, GL_FALSE);
LockDisplay(dpy);
- GetReq(DRI2ReemitDrawableInfo, req);
+ GetReq(DRI2DestroyDrawable, req);
req->reqType = info->codes->major_opcode;
- req->dri2ReqType = X_DRI2ReemitDrawableInfo;
+ req->dri2ReqType = X_DRI2DestroyDrawable;
req->drawable = drawable;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- return False;
- }
UnlockDisplay(dpy);
SyncHandle();
-
- *head = rep.head;
-
- return True;
}
diff --git a/src/glx/x11/dri2.h b/src/glx/x11/dri2.h
index 1dfd0448b2..e57c4ce644 100644
--- a/src/glx/x11/dri2.h
+++ b/src/glx/x11/dri2.h
@@ -33,6 +33,14 @@
#ifndef _DRI2_H_
#define _DRI2_H_
+typedef struct {
+ unsigned int attachment;
+ unsigned int name;
+ unsigned int pitch;
+ unsigned int cpp;
+ unsigned int flags;
+} DRI2Buffer;
+
extern Bool
DRI2QueryExtension(Display *display, int *eventBase, int *errorBase);
extern Bool
@@ -42,12 +50,17 @@ DRI2Connect(Display *display, int screen,
char **driverName, char **busId, unsigned int *sareaHandle);
extern Bool
DRI2AuthConnection(Display *display, int screen, drm_magic_t magic);
-extern Bool
-DRI2CreateDrawable(Display *display, XID drawable,
- unsigned int *handle, unsigned int *head);
+extern void
+DRI2CreateDrawable(Display *display, XID drawable);
extern void
DRI2DestroyDrawable(Display *display, XID handle);
-extern Bool
-DRI2ReemitDrawableInfo(Display *dpy, XID handle, unsigned int *head);
+extern DRI2Buffer *
+DRI2GetBuffers(Display *dpy, XID drawable,
+ int *width, int *height,
+ unsigned int *attachments, int count,
+ int *outCount);
+extern void
+DRI2SwapBuffers(Display *dpy, XID drawable,
+ int x, int y, int width, int height);
#endif
diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c
index 0be65bce62..c56adfa558 100644
--- a/src/glx/x11/dri2_glx.c
+++ b/src/glx/x11/dri2_glx.c
@@ -49,6 +49,7 @@
typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
+typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate;
struct __GLXDRIdisplayPrivateRec {
__GLXDRIdisplay base;
@@ -67,6 +68,13 @@ struct __GLXDRIcontextPrivateRec {
__GLXscreenConfigs *psc;
};
+struct __GLXDRIdrawablePrivateRec {
+ __GLXDRIdrawable base;
+ __DRIbuffer buffers[5];
+ int bufferCount;
+ int width, height;
+};
+
static void dri2DestroyContext(__GLXDRIcontext *context,
__GLXscreenConfigs *psc, Display *dpy)
{
@@ -104,7 +112,6 @@ static __GLXDRIcontext *dri2CreateContext(__GLXscreenConfigs *psc,
{
__GLXDRIcontextPrivate *pcp, *pcp_shared;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
- const __DRIcoreExtension *core = psc->core;
__DRIcontext *shared = NULL;
if (shareList) {
@@ -118,8 +125,8 @@ static __GLXDRIcontext *dri2CreateContext(__GLXscreenConfigs *psc,
pcp->psc = psc;
pcp->driContext =
- (*core->createNewContext)(psc->__driScreen,
- config->driConfig, shared, pcp);
+ (*psc->dri2->createNewContext)(psc->__driScreen,
+ config->driConfig, shared, pcp);
gc->__driContext = pcp->driContext;
if (pcp->driContext == NULL) {
@@ -148,45 +155,40 @@ static __GLXDRIdrawable *dri2CreateDrawable(__GLXscreenConfigs *psc,
GLXDrawable drawable,
const __GLcontextModes *modes)
{
- __GLXDRIdrawable *pdraw;
+ __GLXDRIdrawablePrivate *pdraw;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
- unsigned int handle, head;
- const __DRIcoreExtension *core = psc->core;
pdraw = Xmalloc(sizeof(*pdraw));
if (!pdraw)
return NULL;
- pdraw->destroyDrawable = dri2DestroyDrawable;
- pdraw->xDrawable = xDrawable;
- pdraw->drawable = drawable;
- pdraw->psc = psc;
-
- fprintf(stderr, "calling DRI2CreateDrawable, XID 0x%lx, GLX ID 0x%lx\n",
- xDrawable, drawable);
-
- if (!DRI2CreateDrawable(psc->dpy, xDrawable, &handle, &head)) {
- Xfree(pdraw);
- return NULL;
- }
+ pdraw->base.destroyDrawable = dri2DestroyDrawable;
+ pdraw->base.xDrawable = xDrawable;
+ pdraw->base.drawable = drawable;
+ pdraw->base.psc = psc;
- fprintf(stderr, "success, head 0x%x, handle 0x%x\n", head, handle);
+ DRI2CreateDrawable(psc->dpy, xDrawable);
/* Create a new drawable */
- pdraw->driDrawable =
- (*core->createNewDrawable)(psc->__driScreen,
- config->driConfig,
- handle,
- head,
- pdraw);
-
- if (!pdraw->driDrawable) {
+ pdraw->base.driDrawable =
+ (*psc->dri2->createNewDrawable)(psc->__driScreen,
+ config->driConfig, pdraw);
+
+ if (!pdraw->base.driDrawable) {
DRI2DestroyDrawable(psc->dpy, drawable);
Xfree(pdraw);
return NULL;
}
- return pdraw;
+ return &pdraw->base;
+}
+
+static void dri2SwapBuffers(__GLXDRIdrawable *pdraw)
+{
+ __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
+
+ DRI2SwapBuffers(pdraw->psc->dpy, pdraw->drawable,
+ 0, 0, priv->width, priv->height);
}
static void dri2DestroyScreen(__GLXscreenConfigs *psc)
@@ -197,46 +199,39 @@ static void dri2DestroyScreen(__GLXscreenConfigs *psc)
psc->__driScreen = NULL;
}
-
-static void dri2ReemitDrawableInfo(__DRIdrawable *draw, unsigned int *tail,
- void *loaderPrivate)
+static __DRIbuffer *
+dri2GetBuffers(__DRIdrawable *driDrawable,
+ int *width, int *height,
+ unsigned int *attachments, int count,
+ int *out_count, void *loaderPrivate)
{
- __GLXDRIdrawable *pdraw = loaderPrivate;
-
- DRI2ReemitDrawableInfo(pdraw->psc->dpy, pdraw->drawable, tail);
-}
-
-static void dri2PostDamage(__DRIdrawable *draw,
- struct drm_clip_rect *rects,
- int numRects, void *loaderPrivate)
-{
- XRectangle *xrects;
- XserverRegion region;
- __GLXDRIdrawable *glxDraw = loaderPrivate;
- __GLXscreenConfigs *psc = glxDraw->psc;
- Display *dpy = psc->dpy;
+ __GLXDRIdrawablePrivate *pdraw = loaderPrivate;
+ DRI2Buffer *buffers;
int i;
- xrects = malloc(sizeof(XRectangle) * numRects);
- if (xrects == NULL)
- return;
-
- for (i = 0; i < numRects; i++) {
- xrects[i].x = rects[i].x1;
- xrects[i].y = rects[i].y1;
- xrects[i].width = rects[i].x2 - rects[i].x1;
- xrects[i].height = rects[i].y2 - rects[i].y1;
+ buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable,
+ width, height, attachments, count, out_count);
+ pdraw->width = *width;
+ pdraw->height = *height;
+
+ /* This assumes the DRI2 buffer attachment tokens matches the
+ * __DRIbuffer tokens. */
+ for (i = 0; i < *out_count; i++) {
+ pdraw->buffers[i].attachment = buffers[i].attachment;
+ pdraw->buffers[i].name = buffers[i].name;
+ pdraw->buffers[i].pitch = buffers[i].pitch;
+ pdraw->buffers[i].cpp = buffers[i].cpp;
+ pdraw->buffers[i].flags = buffers[i].flags;
}
- region = XFixesCreateRegion(dpy, xrects, numRects);
- free(xrects);
- XDamageAdd(dpy, glxDraw->xDrawable, region);
- XFixesDestroyRegion(dpy, region);
+
+ Xfree(buffers);
+
+ return pdraw->buffers;
}
-static const __DRIloaderExtension dri2LoaderExtension = {
- { __DRI_LOADER, __DRI_LOADER_VERSION },
- dri2ReemitDrawableInfo,
- dri2PostDamage
+static const __DRIdri2LoaderExtension dri2LoaderExtension = {
+ { __DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION },
+ dri2GetBuffers,
};
static const __DRIextension *loader_extensions[] = {
@@ -279,10 +274,12 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
for (i = 0; extensions[i]; i++) {
if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
psc->core = (__DRIcoreExtension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_DRI2) == 0)
+ psc->dri2 = (__DRIdri2Extension *) extensions[i];
}
- if (psc->core == NULL) {
- ErrorMessageF("core dri extension not found\n");
+ if (psc->core == NULL || psc->dri2 == NULL) {
+ ErrorMessageF("core dri or dri2 extension not found\n");
goto handle_error;
}
@@ -301,7 +298,7 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
}
psc->__driScreen =
- psc->core->createNewScreen(screen, psc->fd, sareaHandle,
+ psc->dri2->createNewScreen(screen, psc->fd,
loader_extensions, &driver_configs, psc);
if (psc->__driScreen == NULL) {
ErrorMessageF("failed to create dri screen\n");
@@ -316,6 +313,7 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
psp->destroyScreen = dri2DestroyScreen;
psp->createContext = dri2CreateContext;
psp->createDrawable = dri2CreateDrawable;
+ psp->swapBuffers = dri2SwapBuffers;
Xfree(driverName);
Xfree(busID);
diff --git a/src/glx/x11/dri_glx.c b/src/glx/x11/dri_glx.c
index 08c83a2310..39bf6c430b 100644
--- a/src/glx/x11/dri_glx.c
+++ b/src/glx/x11/dri_glx.c
@@ -570,6 +570,11 @@ static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
return pdraw;
}
+static void driSwapBuffers(__GLXDRIdrawable *pdraw)
+{
+ (*pdraw->psc->core->swapBuffers)(pdraw->driDrawable);
+}
+
static void driDestroyScreen(__GLXscreenConfigs *psc)
{
/* Free the direct rendering per screen data */
@@ -641,6 +646,7 @@ static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
psp->destroyScreen = driDestroyScreen;
psp->createContext = driCreateContext;
psp->createDrawable = driCreateDrawable;
+ psp->swapBuffers = driSwapBuffers;
return psp;
}
diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
index 8aa13da478..4f96b7df04 100644
--- a/src/glx/x11/glxclient.h
+++ b/src/glx/x11/glxclient.h
@@ -122,6 +122,8 @@ struct __GLXDRIscreenRec {
XID drawable,
GLXDrawable glxDrawable,
const __GLcontextModes *modes);
+
+ void (*swapBuffers)(__GLXDRIdrawable *pdraw);
};
struct __GLXDRIcontextRec {
@@ -140,8 +142,8 @@ struct __GLXDRIdrawableRec {
XID xDrawable;
XID drawable;
__GLXscreenConfigs *psc;
- __DRIdrawable *driDrawable;
GLenum textureTarget;
+ __DRIdrawable *driDrawable;
};
/*
@@ -468,6 +470,7 @@ struct __GLXscreenConfigsRec {
const __DRIcoreExtension *core;
const __DRIlegacyExtension *legacy;
const __DRIswrastExtension *swrast;
+ const __DRIdri2Extension *dri2;
__glxHashTable *drawHash;
Display *dpy;
int scr, fd;
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c
index cd9605cdff..bdcbd25310 100644
--- a/src/glx/x11/glxcmds.c
+++ b/src/glx/x11/glxcmds.c
@@ -854,7 +854,8 @@ PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
if (pdraw != NULL) {
- (*pdraw->psc->core->swapBuffers)(pdraw->driDrawable);
+ glFlush();
+ (*pdraw->psc->driScreen->swapBuffers)(pdraw);
return;
}
#endif
diff --git a/src/mesa/Makefile.mgw b/src/mesa/Makefile.mgw
index 6244ded876..886b344ec9 100644
--- a/src/mesa/Makefile.mgw
+++ b/src/mesa/Makefile.mgw
@@ -154,7 +154,7 @@ DRIVER_SOURCES = \
endif
endif
-SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
+SOURCES = $(MESA_SOURCES) $(GLAPI_SOURCES) $(X86_SOURCES) $(DRIVER_SOURCES)
OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
diff --git a/src/mesa/drivers/dri/Makefile b/src/mesa/drivers/dri/Makefile
index 3b3fcf11df..eef68825bc 100644
--- a/src/mesa/drivers/dri/Makefile
+++ b/src/mesa/drivers/dri/Makefile
@@ -40,8 +40,6 @@ install: dri.pc
$(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL/internal
$(INSTALL) -m 0644 $(TOP)/include/GL/internal/dri_interface.h \
$(DESTDIR)$(INSTALL_INC_DIR)/GL/internal
- $(INSTALL) -m 0644 $(TOP)/include/GL/internal/dri_sarea.h \
- $(DESTDIR)$(INSTALL_INC_DIR)/GL/internal
$(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
$(INSTALL) -m 0644 dri.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index e68faa3f0a..66b3d619fa 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -221,7 +221,6 @@ static int driUnbindContext(__DRIcontext *pcp)
return GL_TRUE;
}
-
/**
* This function takes both a read buffer and a draw buffer. This is needed
* for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent
@@ -255,10 +254,7 @@ static int driBindContext(__DRIcontext *pcp,
** initialize the drawable information if has not been done before.
*/
- if (psp->dri2.enabled) {
- __driParseEvents(pcp, pdp);
- __driParseEvents(pcp, prp);
- } else {
+ if (!psp->dri2.enabled) {
if (!pdp->pStamp || *pdp->pStamp != pdp->lastStamp) {
DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
__driUtilUpdateDrawableInfo(pdp);
@@ -348,139 +344,6 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
}
-
-int
-__driParseEvents(__DRIcontextPrivate *pcp, __DRIdrawablePrivate *pdp)
-{
- __DRIscreenPrivate *psp = pdp->driScreenPriv;
- __DRIDrawableConfigEvent *dc, *last_dc;
- __DRIBufferAttachEvent *ba, *last_ba;
- unsigned int tail, mask, *p, end, total, size, changed;
- unsigned char *data;
- size_t rect_size;
-
- /* Check for wraparound. */
- if (pcp && psp->dri2.buffer->prealloc - pdp->dri2.tail > psp->dri2.buffer->size) {
- /* If prealloc overlaps into what we just parsed, the
- * server overwrote it and we have to reset our tail
- * pointer. */
- DRM_UNLOCK(psp->fd, psp->lock, pcp->hHWContext);
- (*psp->dri2.loader->reemitDrawableInfo)(pdp, &pdp->dri2.tail,
- pdp->loaderPrivate);
- DRM_LIGHT_LOCK(psp->fd, psp->lock, pcp->hHWContext);
- }
-
- total = psp->dri2.buffer->head - pdp->dri2.tail;
- mask = psp->dri2.buffer->size - 1;
- end = psp->dri2.buffer->head;
- data = psp->dri2.buffer->data;
-
- changed = 0;
- last_dc = NULL;
- last_ba = NULL;
-
- for (tail = pdp->dri2.tail; tail != end; tail += size) {
- p = (unsigned int *) (data + (tail & mask));
- size = DRI2_EVENT_SIZE(*p);
- if (size > total || (tail & mask) + size > psp->dri2.buffer->size) {
- /* illegal data, bail out. */
- fprintf(stderr, "illegal event size\n");
- break;
- }
-
- switch (DRI2_EVENT_TYPE(*p)) {
- case DRI2_EVENT_DRAWABLE_CONFIG:
- dc = (__DRIDrawableConfigEvent *) p;
- if (dc->drawable == pdp->dri2.drawable_id)
- last_dc = dc;
- break;
-
- case DRI2_EVENT_BUFFER_ATTACH:
- ba = (__DRIBufferAttachEvent *) p;
- if (ba->drawable == pdp->dri2.drawable_id &&
- ba->buffer.attachment == DRI_DRAWABLE_BUFFER_FRONT_LEFT)
- last_ba = ba;
- break;
- }
- }
-
- if (last_dc) {
- if (pdp->w != last_dc->width || pdp->h != last_dc->height)
- changed = 1;
-
- pdp->x = last_dc->x;
- pdp->y = last_dc->y;
- pdp->w = last_dc->width;
- pdp->h = last_dc->height;
-
- pdp->backX = 0;
- pdp->backY = 0;
- pdp->numBackClipRects = 1;
- pdp->pBackClipRects[0].x1 = 0;
- pdp->pBackClipRects[0].y1 = 0;
- pdp->pBackClipRects[0].x2 = pdp->w;
- pdp->pBackClipRects[0].y2 = pdp->h;
-
- pdp->numClipRects = last_dc->num_rects;
- _mesa_free(pdp->pClipRects);
- rect_size = last_dc->num_rects * sizeof last_dc->rects[0];
- pdp->pClipRects = _mesa_malloc(rect_size);
- memcpy(pdp->pClipRects, last_dc->rects, rect_size);
- }
-
- /* We only care about the most recent drawable config. */
- if (last_dc && changed)
- (*psp->DriverAPI.HandleDrawableConfig)(pdp, pcp, last_dc);
-
- /* Front buffer attachments are special, they typically mean that
- * we're rendering to a redirected window (or a child window of a
- * redirected window) and that it got resized. Resizing the root
- * window on randr events is a special case of this. Other causes
- * may be a window transitioning between redirected and
- * non-redirected, or a window getting reparented between parents
- * with different window pixmaps (eg two redirected windows).
- * These events are special in that the X server allocates the
- * buffer and that the buffer may be shared by other child
- * windows. When our window share the window pixmap with its
- * parent, drawable config events doesn't affect the front buffer.
- * We only care about the last such event in the buffer; in fact,
- * older events will refer to invalid buffer objects.*/
- if (last_ba)
- (*psp->DriverAPI.HandleBufferAttach)(pdp, pcp, last_ba);
-
- /* If there was a drawable config event in the buffer and it
- * changed the size of the window, all buffer auxillary buffer
- * attachments prior to that are invalid (as opposed to the front
- * buffer case discussed above). In that case we can start
- * looking for buffer attachment after the last drawable config
- * event. If there is no drawable config event in this batch of
- * events, we have to assume that the last batch might have had
- * one and process all buffer attach events.*/
- if (last_dc && changed)
- tail = (unsigned char *) last_dc - data;
- else
- tail = pdp->dri2.tail;
-
- for ( ; tail != end; tail += size) {
- ba = (__DRIBufferAttachEvent *) (data + (tail & mask));
- size = DRI2_EVENT_SIZE(ba->event_header);
-
- if (DRI2_EVENT_TYPE(ba->event_header) != DRI2_EVENT_BUFFER_ATTACH)
- continue;
- if (ba->drawable != pdp->dri2.drawable_id)
- continue;
- if (last_ba == ba)
- continue;
-
- (*psp->DriverAPI.HandleBufferAttach)(pdp, pcp, ba);
- changed = 1;
- }
-
- pdp->dri2.tail = tail;
-
- return changed || last_ba;
-}
-
/*@}*/
/*****************************************************************/
@@ -494,12 +357,7 @@ static void driReportDamage(__DRIdrawable *pdp,
__DRIscreen *psp = pdp->driScreenPriv;
/* Check that we actually have the new damage report method */
- if (psp->dri2.enabled) {
- (*psp->dri2.loader->postDamage)(pdp,
- pClipRects,
- numClipRects,
- pdp->loaderPrivate);
- } else if (psp->damage) {
+ if (psp->damage) {
/* Report the damage. Currently, all our drivers draw
* directly to the front buffer, so we report the damage there
* rather than to the backing storein (if any).
@@ -529,9 +387,6 @@ static void driSwapBuffers(__DRIdrawable *dPriv)
if (!dPriv->numClipRects)
return;
- if (psp->dri2.enabled)
- __driParseEvents(NULL, dPriv);
-
psp->DriverAPI.SwapBuffers(dPriv);
driReportDamage(dPriv, dPriv->pClipRects, dPriv->numClipRects);
@@ -671,17 +526,17 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config,
static __DRIdrawable *
-dri2CreateNewDrawable(__DRIscreen *screen, const __DRIconfig *config,
- unsigned int drawable_id, unsigned int head, void *data)
+dri2CreateNewDrawable(__DRIscreen *screen,
+ const __DRIconfig *config,
+ void *loaderPrivate)
{
__DRIdrawable *pdraw;
- pdraw = driCreateNewDrawable(screen, config, 0, 0, NULL, data);
+ pdraw = driCreateNewDrawable(screen, config, 0, 0, NULL, loaderPrivate);
if (!pdraw)
return NULL;
- pdraw->dri2.drawable_id = drawable_id;
- pdraw->dri2.tail = head;
+ pdraw->pClipRects = _mesa_malloc(sizeof *pdraw->pBackClipRects);
pdraw->pBackClipRects = _mesa_malloc(sizeof *pdraw->pBackClipRects);
return pdraw;
@@ -792,18 +647,7 @@ static __DRIcontext *
dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
__DRIcontext *shared, void *data)
{
- drm_context_t hwContext;
- DRM_CAS_RESULT(ret);
-
- /* DRI2 doesn't use kernel with context IDs, we just need an ID that's
- * different from the kernel context ID to make drmLock() happy. */
-
- do {
- hwContext = screen->dri2.lock->next_id;
- DRM_CAS(&screen->dri2.lock->next_id, hwContext, hwContext + 1, ret);
- } while (ret);
-
- return driCreateNewContext(screen, config, 0, shared, hwContext, data);
+ return driCreateNewContext(screen, config, 0, shared, 0, data);
}
@@ -839,12 +683,7 @@ static void driDestroyScreen(__DRIscreen *psp)
if (psp->DriverAPI.DestroyScreen)
(*psp->DriverAPI.DestroyScreen)(psp);
- if (psp->dri2.enabled) {
-#ifdef TTM_API
- drmBOUnmap(psp->fd, &psp->dri2.sareaBO);
- drmBOUnreference(psp->fd, &psp->dri2.sareaBO);
-#endif
- } else {
+ if (!psp->dri2.enabled) {
(void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX);
(void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
(void)drmCloseOnce(psp->fd);
@@ -867,8 +706,8 @@ setupLoaderExtensions(__DRIscreen *psp,
psp->damage = (__DRIdamageExtension *) extensions[i];
if (strcmp(extensions[i]->name, __DRI_SYSTEM_TIME) == 0)
psp->systemTime = (__DRIsystemTimeExtension *) extensions[i];
- if (strcmp(extensions[i]->name, __DRI_LOADER) == 0)
- psp->dri2.loader = (__DRIloaderExtension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_DRI2_LOADER) == 0)
+ psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i];
}
}
@@ -964,19 +803,16 @@ driCreateNewScreen(int scrn,
return psp;
}
-
/**
* DRI2
*/
static __DRIscreen *
-dri2CreateNewScreen(int scrn, int fd, unsigned int sarea_handle,
+dri2CreateNewScreen(int scrn, int fd,
const __DRIextension **extensions,
const __DRIconfig ***driver_configs, void *data)
{
-#ifdef TTM_API
static const __DRIextension *emptyExtensionList[] = { NULL };
__DRIscreen *psp;
- unsigned int *p;
drmVersionPtr version;
if (driDriverAPI.InitScreen2 == NULL)
@@ -1001,39 +837,9 @@ dri2CreateNewScreen(int scrn, int fd, unsigned int sarea_handle,
psp->myNum = scrn;
psp->dri2.enabled = GL_TRUE;
- if (drmBOReference(psp->fd, sarea_handle, &psp->dri2.sareaBO)) {
- fprintf(stderr, "Failed to reference DRI2 sarea BO\n");
- _mesa_free(psp);
- return NULL;
- }
-
- if (drmBOMap(psp->fd, &psp->dri2.sareaBO,
- DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0, &psp->dri2.sarea)) {
- drmBOUnreference(psp->fd, &psp->dri2.sareaBO);
- _mesa_free(psp);
- return NULL;
- }
-
- p = psp->dri2.sarea;
- while (DRI2_SAREA_BLOCK_TYPE(*p)) {
- switch (DRI2_SAREA_BLOCK_TYPE(*p)) {
- case DRI2_SAREA_BLOCK_LOCK:
- psp->dri2.lock = (__DRILock *) p;
- break;
- case DRI2_SAREA_BLOCK_EVENT_BUFFER:
- psp->dri2.buffer = (__DRIEventBuffer *) p;
- break;
- }
- p = DRI2_SAREA_BLOCK_NEXT(p);
- }
-
- psp->lock = (drmLock *) &psp->dri2.lock->lock;
-
psp->DriverAPI = driDriverAPI;
*driver_configs = driDriverAPI.InitScreen2(psp);
if (*driver_configs == NULL) {
- drmBOUnmap(psp->fd, &psp->dri2.sareaBO);
- drmBOUnreference(psp->fd, &psp->dri2.sareaBO);
_mesa_free(psp);
return NULL;
}
@@ -1041,9 +847,6 @@ dri2CreateNewScreen(int scrn, int fd, unsigned int sarea_handle,
psp->DriverAPI = driDriverAPI;
return psp;
-#else
- return NULL;
-#endif
}
static const __DRIextension **driGetExtensions(__DRIscreen *psp)
@@ -1051,36 +854,45 @@ static const __DRIextension **driGetExtensions(__DRIscreen *psp)
return psp->extensions;
}
-/** Legacy DRI interface */
-const __DRIlegacyExtension driLegacyExtension = {
- { __DRI_LEGACY, __DRI_LEGACY_VERSION },
- driCreateNewScreen,
- driCreateNewDrawable,
- driCreateNewContext
-};
-
-/** DRI2 interface */
+/** Core interface */
const __DRIcoreExtension driCoreExtension = {
{ __DRI_CORE, __DRI_CORE_VERSION },
- dri2CreateNewScreen,
+ NULL,
driDestroyScreen,
driGetExtensions,
driGetConfigAttrib,
driIndexConfigAttrib,
- dri2CreateNewDrawable,
+ NULL,
driDestroyDrawable,
driSwapBuffers,
- dri2CreateNewContext,
+ NULL,
driCopyContext,
driDestroyContext,
driBindContext,
driUnbindContext
};
+/** Legacy DRI interface */
+const __DRIlegacyExtension driLegacyExtension = {
+ { __DRI_LEGACY, __DRI_LEGACY_VERSION },
+ driCreateNewScreen,
+ driCreateNewDrawable,
+ driCreateNewContext,
+};
+
+/** Legacy DRI interface */
+const __DRIdri2Extension driDRI2Extension = {
+ { __DRI_DRI2, __DRI_DRI2_VERSION },
+ dri2CreateNewScreen,
+ dri2CreateNewDrawable,
+ dri2CreateNewContext,
+};
+
/* This is the table of extensions that the loader will dlsym() for. */
PUBLIC const __DRIextension *__driDriverExtensions[] = {
&driCoreExtension.base,
&driLegacyExtension.base,
+ &driDRI2Extension.base,
NULL
};
diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h
index abd1482e91..1a8f020c77 100644
--- a/src/mesa/drivers/dri/common/dri_util.h
+++ b/src/mesa/drivers/dri/common/dri_util.h
@@ -54,7 +54,6 @@
#include "glheader.h"
#include "GL/internal/glcore.h"
#include "GL/internal/dri_interface.h"
-#include "GL/internal/dri_sarea.h"
#define GLX_BAD_CONTEXT 5
@@ -202,16 +201,8 @@ struct __DriverAPIRec {
- /* DRI2 Entry points */
+ /* DRI2 Entry point */
const __DRIconfig **(*InitScreen2) (__DRIscreen * priv);
- void (*HandleDrawableConfig)(__DRIdrawable *dPriv,
- __DRIcontext *pcp,
- __DRIDrawableConfigEvent *event);
-
- void (*HandleBufferAttach)(__DRIdrawable *dPriv,
- __DRIcontext *pcp,
- __DRIBufferAttachEvent *ba);
-
};
extern const struct __DriverAPIRec driDriverAPI;
@@ -367,10 +358,6 @@ struct __DRIdrawableRec {
* GLX_MESA_swap_control.
*/
unsigned int swap_interval;
- struct {
- unsigned int tail;
- unsigned int drawable_id;
- } dri2;
};
/**
@@ -522,13 +509,7 @@ struct __DRIscreenRec {
/* Flag to indicate that this is a DRI2 screen. Many of the above
* fields will not be valid or initializaed in that case. */
int enabled;
-#ifdef TTM_API
- drmBO sareaBO;
-#endif
- void *sarea;
- __DRIEventBuffer *buffer;
- __DRILock *lock;
- __DRIloaderExtension *loader;
+ __DRIdri2LoaderExtension *loader;
} dri2;
/* The lock actually in use, old sarea or DRI2 */
@@ -542,9 +523,6 @@ __driUtilMessage(const char *f, ...);
extern void
__driUtilUpdateDrawableInfo(__DRIdrawable *pdp);
-extern int
-__driParseEvents(__DRIcontext *psp, __DRIdrawable *pdp);
-
extern float
driCalculateSwapUsage( __DRIdrawable *dPriv,
int64_t last_swap_ust, int64_t current_ust );
diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile
index fd77980ebf..5858e0ee9f 100644
--- a/src/mesa/drivers/dri/i915/Makefile
+++ b/src/mesa/drivers/dri/i915/Makefile
@@ -46,7 +46,6 @@ DRIVER_SOURCES = \
i915_vtbl.c \
intel_context.c \
intel_decode.c \
- intel_ioctl.c \
intel_screen.c \
intel_span.c \
intel_state.c \
@@ -64,6 +63,8 @@ DRIVER_DEFINES = -I../intel -I../intel/server -DI915 \
$(shell pkg-config libdrm --atleast-version=2.3.1 \
&& echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
+DRI_LIB_DEPS += -ldrm_intel
+
include ../Makefile.template
intel_decode.o: ../intel/intel_decode.c
diff --git a/src/mesa/drivers/dri/i915/i830_metaops.c b/src/mesa/drivers/dri/i915/i830_metaops.c
index 13e4ab3aac..acfb3af910 100644
--- a/src/mesa/drivers/dri/i915/i830_metaops.c
+++ b/src/mesa/drivers/dri/i915/i830_metaops.c
@@ -33,7 +33,6 @@
#include "intel_screen.h"
#include "intel_batchbuffer.h"
-#include "intel_ioctl.h"
#include "intel_regions.h"
#include "i830_context.h"
diff --git a/src/mesa/drivers/dri/i915/i830_tex.c b/src/mesa/drivers/dri/i915/i830_tex.c
index 79b0fcf596..c0126ba19a 100644
--- a/src/mesa/drivers/dri/i915/i830_tex.c
+++ b/src/mesa/drivers/dri/i915/i830_tex.c
@@ -38,8 +38,6 @@
#include "mm.h"
-#include "intel_ioctl.h"
-
#include "i830_context.h"
#include "i830_reg.h"
diff --git a/src/mesa/drivers/dri/i915/i830_texblend.c b/src/mesa/drivers/dri/i915/i830_texblend.c
index 58f220eb7c..dca72adeca 100644
--- a/src/mesa/drivers/dri/i915/i830_texblend.c
+++ b/src/mesa/drivers/dri/i915/i830_texblend.c
@@ -36,7 +36,6 @@
#include "mm.h"
#include "intel_screen.h"
-#include "intel_ioctl.h"
#include "intel_tex.h"
#include "i830_context.h"
diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c
index 4e9b022eae..314bbe32b6 100644
--- a/src/mesa/drivers/dri/i915/i830_texstate.c
+++ b/src/mesa/drivers/dri/i915/i830_texstate.c
@@ -28,7 +28,6 @@
#include "mtypes.h"
#include "enums.h"
#include "texformat.h"
-#include "dri_bufmgr.h"
#include "intel_mipmap_tree.h"
#include "intel_tex.h"
diff --git a/src/mesa/drivers/dri/i915/i915_metaops.c b/src/mesa/drivers/dri/i915/i915_metaops.c
index 73aa63451e..bfe97f13e5 100644
--- a/src/mesa/drivers/dri/i915/i915_metaops.c
+++ b/src/mesa/drivers/dri/i915/i915_metaops.c
@@ -33,7 +33,6 @@
#include "intel_screen.h"
#include "intel_batchbuffer.h"
-#include "intel_ioctl.h"
#include "intel_regions.h"
#include "i915_context.h"
diff --git a/src/mesa/drivers/dri/i915/i915_tex.c b/src/mesa/drivers/dri/i915/i915_tex.c
index 386617a1ff..cb55bf6125 100644
--- a/src/mesa/drivers/dri/i915/i915_tex.c
+++ b/src/mesa/drivers/dri/i915/i915_tex.c
@@ -38,8 +38,6 @@
#include "mm.h"
-#include "intel_ioctl.h"
-
#include "i915_context.h"
#include "i915_reg.h"
diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c
index 69c1e0755e..48137f025f 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -28,7 +28,6 @@
#include "mtypes.h"
#include "enums.h"
#include "texformat.h"
-#include "dri_bufmgr.h"
#include "intel_mipmap_tree.h"
#include "intel_tex.h"
@@ -78,7 +77,7 @@ translate_texture_format(GLuint mesa_format, GLenum DepthMode)
return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
case MESA_FORMAT_RGBA_DXT5:
return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
- case MESA_FORMAT_Z24_S8:
+ case MESA_FORMAT_S8_Z24:
return (MAPSURF_32BIT | MT_32BIT_xI824);
default:
fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format);
diff --git a/src/mesa/drivers/dri/i915/intel_ioctl.c b/src/mesa/drivers/dri/i915/intel_ioctl.c
deleted file mode 100644
index aa7c6d106c..0000000000
--- a/src/mesa/drivers/dri/i915/intel_ioctl.c
+++ /dev/null
@@ -1,659 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sched.h>
-
-#include "mtypes.h"
-#include "context.h"
-#include "swrast/swrast.h"
-
-#include "intel_context.h"
-#include "intel_ioctl.h"
-#include "intel_batchbuffer.h"
-#include "drm.h"
-
-uint32_t intelGetLastFrame (intelContextPtr intel)
-{
- int ret;
- uint32_t frame;
- drm_i915_getparam_t gp;
-
- gp.param = I915_PARAM_LAST_DISPATCH;
- gp.value = (int *)&frame;
- ret = drmCommandWriteRead( intel->driFd, DRM_I915_GETPARAM,
- &gp, sizeof(gp) );
- return frame;
-}
-
-int intelEmitIrqLocked( intelContextPtr intel )
-{
- drmI830IrqEmit ie;
- int ret, seq;
-
- assert(((*(int *)intel->driHwLock) & ~DRM_LOCK_CONT) ==
- (DRM_LOCK_HELD|intel->hHWContext));
-
- ie.irq_seq = &seq;
-
- ret = drmCommandWriteRead( intel->driFd, DRM_I830_IRQ_EMIT,
- &ie, sizeof(ie) );
- if ( ret ) {
- fprintf( stderr, "%s: drmI830IrqEmit: %d\n", __FUNCTION__, ret );
- exit(1);
- }
-
- if (0)
- fprintf(stderr, "%s --> %d\n", __FUNCTION__, seq );
-
- return seq;
-}
-
-void intelWaitIrq( intelContextPtr intel, int seq )
-{
- int ret;
-
- if (0)
- fprintf(stderr, "%s %d\n", __FUNCTION__, seq );
-
- intel->iw.irq_seq = seq;
-
- do {
- ret = drmCommandWrite( intel->driFd, DRM_I830_IRQ_WAIT, &intel->iw, sizeof(intel->iw) );
- } while (ret == -EAGAIN || ret == -EINTR);
-
- if ( ret ) {
- fprintf( stderr, "%s: drmI830IrqWait: %d\n", __FUNCTION__, ret );
- if (0)
- intel_dump_batchbuffer( intel->alloc.offset,
- intel->alloc.ptr,
- intel->alloc.size );
- exit(1);
- }
-}
-
-
-
-static void age_intel( intelContextPtr intel, int age )
-{
- GLuint i;
-
- for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
- if (intel->CurrentTexObj[i])
- intel->CurrentTexObj[i]->age = age;
-}
-
-void intel_dump_batchbuffer( long offset,
- int *ptr,
- int count )
-{
- int i;
- fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", count);
- for (i = 0; i < count/4; i += 4)
- fprintf(stderr, "\t0x%x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
- (unsigned int)offset + i*4, ptr[i], ptr[i+1], ptr[i+2], ptr[i+3]);
- fprintf(stderr, "END BATCH\n\n\n");
-}
-
-void intelRefillBatchLocked( intelContextPtr intel, GLboolean allow_unlock )
-{
- GLuint last_irq = intel->alloc.irq_emitted;
- GLuint half = intel->alloc.size / 2;
- GLuint buf = (intel->alloc.active_buf ^= 1);
-
- intel->alloc.irq_emitted = intelEmitIrqLocked( intel );
-
- if (last_irq) {
- if (allow_unlock) UNLOCK_HARDWARE( intel );
- intelWaitIrq( intel, last_irq );
- if (allow_unlock) LOCK_HARDWARE( intel );
- }
-
- if (0)
- fprintf(stderr, "%s: now using half %d\n", __FUNCTION__, buf);
-
- intel->batch.start_offset = intel->alloc.offset + buf * half;
- intel->batch.ptr = (unsigned char *)intel->alloc.ptr + buf * half;
- intel->batch.size = half - 8;
- intel->batch.space = half - 8;
- assert(intel->batch.space >= 0);
-}
-
-#define MI_BATCH_BUFFER_END (0xA<<23)
-
-
-void intelFlushBatchLocked( intelContextPtr intel,
- GLboolean ignore_cliprects,
- GLboolean refill,
- GLboolean allow_unlock)
-{
- drmI830BatchBuffer batch;
-
- assert(intel->locked);
-
- if (0)
- fprintf(stderr, "%s used %d of %d offset %x..%x refill %d (started in %s)\n",
- __FUNCTION__,
- (intel->batch.size - intel->batch.space),
- intel->batch.size,
- intel->batch.start_offset,
- intel->batch.start_offset +
- (intel->batch.size - intel->batch.space),
- refill,
- intel->batch.func);
-
- /* Throw away non-effective packets. Won't work once we have
- * hardware contexts which would preserve statechanges beyond a
- * single buffer.
- */
- if (intel->numClipRects == 0 && !ignore_cliprects) {
-
- /* Without this yeild, an application with no cliprects can hog
- * the hardware. Without unlocking, the effect is much worse -
- * effectively a lock-out of other contexts.
- */
- if (allow_unlock) {
- UNLOCK_HARDWARE( intel );
- sched_yield();
- LOCK_HARDWARE( intel );
- }
-
- /* Note that any state thought to have been emitted actually
- * hasn't:
- */
- intel->batch.ptr -= (intel->batch.size - intel->batch.space);
- intel->batch.space = intel->batch.size;
- intel->vtbl.lost_hardware( intel );
- }
-
- if (intel->batch.space != intel->batch.size) {
-
- if (intel->sarea->ctxOwner != intel->hHWContext) {
- intel->perf_boxes |= I830_BOX_LOST_CONTEXT;
- intel->sarea->ctxOwner = intel->hHWContext;
- }
-
- batch.start = intel->batch.start_offset;
- batch.used = intel->batch.size - intel->batch.space;
- batch.cliprects = intel->pClipRects;
- batch.num_cliprects = ignore_cliprects ? 0 : intel->numClipRects;
- batch.DR1 = 0;
- batch.DR4 = ((((GLuint)intel->drawX) & 0xffff) |
- (((GLuint)intel->drawY) << 16));
-
- if (intel->alloc.offset) {
- if ((batch.used & 0x4) == 0) {
- ((int *)intel->batch.ptr)[0] = 0;
- ((int *)intel->batch.ptr)[1] = MI_BATCH_BUFFER_END;
- batch.used += 0x8;
- intel->batch.ptr += 0x8;
- }
- else {
- ((int *)intel->batch.ptr)[0] = MI_BATCH_BUFFER_END;
- batch.used += 0x4;
- intel->batch.ptr += 0x4;
- }
- }
-
- if (0)
- intel_dump_batchbuffer( batch.start,
- (int *)(intel->batch.ptr - batch.used),
- batch.used );
-
- intel->batch.start_offset += batch.used;
- intel->batch.size -= batch.used;
-
- if (intel->batch.size < 8) {
- refill = GL_TRUE;
- intel->batch.space = intel->batch.size = 0;
- }
- else {
- intel->batch.size -= 8;
- intel->batch.space = intel->batch.size;
- }
-
-
- assert(intel->batch.space >= 0);
- assert(batch.start >= intel->alloc.offset);
- assert(batch.start < intel->alloc.offset + intel->alloc.size);
- assert(batch.start + batch.used > intel->alloc.offset);
- assert(batch.start + batch.used <=
- intel->alloc.offset + intel->alloc.size);
-
-
- if (intel->alloc.offset) {
- if (drmCommandWrite (intel->driFd, DRM_I830_BATCHBUFFER, &batch,
- sizeof(batch))) {
- fprintf(stderr, "DRM_I830_BATCHBUFFER: %d\n", -errno);
- UNLOCK_HARDWARE(intel);
- exit(1);
- }
- } else {
- drmI830CmdBuffer cmd;
- cmd.buf = (char *)intel->alloc.ptr + batch.start;
- cmd.sz = batch.used;
- cmd.DR1 = batch.DR1;
- cmd.DR4 = batch.DR4;
- cmd.num_cliprects = batch.num_cliprects;
- cmd.cliprects = batch.cliprects;
-
- if (drmCommandWrite (intel->driFd, DRM_I830_CMDBUFFER, &cmd,
- sizeof(cmd))) {
- fprintf(stderr, "DRM_I830_CMDBUFFER: %d\n", -errno);
- UNLOCK_HARDWARE(intel);
- exit(1);
- }
- }
-
-
- age_intel(intel, intel->sarea->last_enqueue);
-
- /* FIXME: use hardware contexts to avoid 'losing' hardware after
- * each buffer flush.
- */
- if (intel->batch.contains_geometry)
- assert(intel->batch.last_emit_state == intel->batch.counter);
-
- intel->batch.counter++;
- intel->batch.contains_geometry = 0;
- intel->batch.func = 0;
- intel->vtbl.lost_hardware( intel );
- }
-
- if (refill)
- intelRefillBatchLocked( intel, allow_unlock );
-}
-
-void intelFlushBatch( intelContextPtr intel, GLboolean refill )
-{
- if (intel->locked) {
- intelFlushBatchLocked( intel, GL_FALSE, refill, GL_FALSE );
- }
- else {
- LOCK_HARDWARE(intel);
- intelFlushBatchLocked( intel, GL_FALSE, refill, GL_TRUE );
- UNLOCK_HARDWARE(intel);
- }
-}
-
-
-void intelWaitForIdle( intelContextPtr intel )
-{
- if (0)
- fprintf(stderr, "%s\n", __FUNCTION__);
-
- intel->vtbl.emit_flush( intel );
- intelFlushBatch( intel, GL_TRUE );
-
- /* Use an irq to wait for dma idle -- Need to track lost contexts
- * to shortcircuit consecutive calls to this function:
- */
- intelWaitIrq( intel, intel->alloc.irq_emitted );
- intel->alloc.irq_emitted = 0;
-}
-
-
-/**
- * Check if we need to rotate/warp the front color buffer to the
- * rotated screen. We generally need to do this when we get a glFlush
- * or glFinish after drawing to the front color buffer.
- */
-static void
-intelCheckFrontRotate(GLcontext *ctx)
-{
- intelContextPtr intel = INTEL_CONTEXT( ctx );
- if (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT) {
- intelScreenPrivate *screen = intel->intelScreen;
- if (screen->current_rotation != 0) {
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
- intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT);
- }
- }
-}
-
-
-/**
- * NOT directly called via glFlush.
- */
-void intelFlush( GLcontext *ctx )
-{
- intelContextPtr intel = INTEL_CONTEXT( ctx );
-
- if (intel->Fallback)
- _swrast_flush( ctx );
-
- INTEL_FIREVERTICES( intel );
-
- if (intel->batch.size != intel->batch.space)
- intelFlushBatch( intel, GL_FALSE );
-}
-
-
-/**
- * Called via glFlush.
- */
-void intelglFlush( GLcontext *ctx )
-{
- intelFlush(ctx);
- intelCheckFrontRotate(ctx);
-}
-
-
-void intelFinish( GLcontext *ctx )
-{
- intelContextPtr intel = INTEL_CONTEXT( ctx );
- intelFlush( ctx );
- intelWaitForIdle( intel );
- intelCheckFrontRotate(ctx);
-}
-
-
-void intelClear(GLcontext *ctx, GLbitfield mask)
-{
- intelContextPtr intel = INTEL_CONTEXT( ctx );
- const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
- GLbitfield tri_mask = 0;
- GLbitfield blit_mask = 0;
- GLbitfield swrast_mask = 0;
-
- if (0)
- fprintf(stderr, "%s\n", __FUNCTION__);
-
- /* Take care of cliprects, which are handled differently for
- * clears, etc.
- */
- intelFlush( &intel->ctx );
-
- if (mask & BUFFER_BIT_FRONT_LEFT) {
- if (colorMask == ~0) {
- blit_mask |= BUFFER_BIT_FRONT_LEFT;
- }
- else {
- tri_mask |= BUFFER_BIT_FRONT_LEFT;
- }
- }
-
- if (mask & BUFFER_BIT_BACK_LEFT) {
- if (colorMask == ~0) {
- blit_mask |= BUFFER_BIT_BACK_LEFT;
- }
- else {
- tri_mask |= BUFFER_BIT_BACK_LEFT;
- }
- }
-
- if (mask & BUFFER_BIT_DEPTH) {
- blit_mask |= BUFFER_BIT_DEPTH;
- }
-
- if (mask & BUFFER_BIT_STENCIL) {
- if (!intel->hw_stencil) {
- swrast_mask |= BUFFER_BIT_STENCIL;
- }
- else if ((ctx->Stencil.WriteMask[0] & 0xff) != 0xff) {
- tri_mask |= BUFFER_BIT_STENCIL;
- }
- else {
- blit_mask |= BUFFER_BIT_STENCIL;
- }
- }
-
- swrast_mask |= (mask & BUFFER_BIT_ACCUM);
-
- if (blit_mask)
- intelClearWithBlit( ctx, blit_mask, 0, 0, 0, 0, 0);
-
- if (tri_mask)
- intel->vtbl.clear_with_tris( intel, tri_mask, 0, 0, 0, 0, 0);
-
- if (swrast_mask)
- _swrast_Clear( ctx, swrast_mask );
-}
-
-
-void
-intelRotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
- GLuint srcBuffer)
-{
- if (intel->vtbl.rotate_window) {
- intel->vtbl.rotate_window(intel, dPriv, srcBuffer);
- }
-}
-
-
-void *intelAllocateAGP( intelContextPtr intel, GLsizei size )
-{
- int region_offset;
- drmI830MemAlloc alloc;
- int ret;
-
- if (0)
- fprintf(stderr, "%s: %d bytes\n", __FUNCTION__, size);
-
- alloc.region = I830_MEM_REGION_AGP;
- alloc.alignment = 0;
- alloc.size = size;
- alloc.region_offset = &region_offset;
-
- LOCK_HARDWARE(intel);
-
- /* Make sure the global heap is initialized
- */
- if (intel->texture_heaps[0])
- driAgeTextures( intel->texture_heaps[0] );
-
-
- ret = drmCommandWriteRead( intel->driFd,
- DRM_I830_ALLOC,
- &alloc, sizeof(alloc));
-
- if (ret) {
- fprintf(stderr, "%s: DRM_I830_ALLOC ret %d\n", __FUNCTION__, ret);
- UNLOCK_HARDWARE(intel);
- return NULL;
- }
-
- if (0)
- fprintf(stderr, "%s: allocated %d bytes\n", __FUNCTION__, size);
-
- /* Need to propogate this information (agp memory in use) to our
- * local texture lru. The kernel has already updated the global
- * lru. An alternative would have been to allocate memory the
- * usual way and then notify the kernel to pin the allocation.
- */
- if (intel->texture_heaps[0])
- driAgeTextures( intel->texture_heaps[0] );
-
- UNLOCK_HARDWARE(intel);
-
- return (void *)((char *)intel->intelScreen->tex.map + region_offset);
-}
-
-void intelFreeAGP( intelContextPtr intel, void *pointer )
-{
- int region_offset;
- drmI830MemFree memfree;
- int ret;
-
- region_offset = (char *)pointer - (char *)intel->intelScreen->tex.map;
-
- if (region_offset < 0 ||
- region_offset > intel->intelScreen->tex.size) {
- fprintf(stderr, "offset %d outside range 0..%d\n", region_offset,
- intel->intelScreen->tex.size);
- return;
- }
-
- memfree.region = I830_MEM_REGION_AGP;
- memfree.region_offset = region_offset;
-
- ret = drmCommandWrite( intel->driFd,
- DRM_I830_FREE,
- &memfree, sizeof(memfree));
-
- if (ret)
- fprintf(stderr, "%s: DRM_I830_FREE ret %d\n", __FUNCTION__, ret);
-}
-
-/* This version of AllocateMemoryMESA allocates only agp memory, and
- * only does so after the point at which the driver has been
- * initialized.
- *
- * Theoretically a valid context isn't required. However, in this
- * implementation, it is, as I'm using the hardware lock to protect
- * the kernel data structures, and the current context to get the
- * device fd.
- */
-void *intelAllocateMemoryMESA(__DRInativeDisplay *dpy, int scrn,
- GLsizei size, GLfloat readfreq,
- GLfloat writefreq, GLfloat priority)
-{
- GET_CURRENT_CONTEXT(ctx);
-
- if (INTEL_DEBUG & DEBUG_IOCTL)
- fprintf(stderr, "%s sz %d %f/%f/%f\n", __FUNCTION__, size, readfreq,
- writefreq, priority);
-
- if (getenv("INTEL_NO_ALLOC"))
- return NULL;
-
- if (!ctx || INTEL_CONTEXT(ctx) == 0)
- return NULL;
-
- return intelAllocateAGP( INTEL_CONTEXT(ctx), size );
-}
-
-
-/* Called via glXFreeMemoryMESA() */
-void intelFreeMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer)
-{
- GET_CURRENT_CONTEXT(ctx);
- if (INTEL_DEBUG & DEBUG_IOCTL)
- fprintf(stderr, "%s %p\n", __FUNCTION__, pointer);
-
- if (!ctx || INTEL_CONTEXT(ctx) == 0) {
- fprintf(stderr, "%s: no context\n", __FUNCTION__);
- return;
- }
-
- intelFreeAGP( INTEL_CONTEXT(ctx), pointer );
-}
-
-/* Called via glXGetMemoryOffsetMESA()
- *
- * Returns offset of pointer from the start of agp aperture.
- */
-GLuint intelGetMemoryOffsetMESA(__DRInativeDisplay *dpy, int scrn,
- const GLvoid *pointer)
-{
- GET_CURRENT_CONTEXT(ctx);
- intelContextPtr intel;
-
- if (!ctx || !(intel = INTEL_CONTEXT(ctx)) ) {
- fprintf(stderr, "%s: no context\n", __FUNCTION__);
- return ~0;
- }
-
- if (!intelIsAgpMemory( intel, pointer, 0 ))
- return ~0;
-
- return intelAgpOffsetFromVirtual( intel, pointer );
-}
-
-
-GLboolean intelIsAgpMemory( intelContextPtr intel, const GLvoid *pointer,
- GLint size )
-{
- int offset = (char *)pointer - (char *)intel->intelScreen->tex.map;
- int valid = (size >= 0 &&
- offset >= 0 &&
- offset + size < intel->intelScreen->tex.size);
-
- if (INTEL_DEBUG & DEBUG_IOCTL)
- fprintf(stderr, "intelIsAgpMemory( %p ) : %d\n", pointer, valid );
-
- return valid;
-}
-
-
-GLuint intelAgpOffsetFromVirtual( intelContextPtr intel, const GLvoid *pointer )
-{
- int offset = (char *)pointer - (char *)intel->intelScreen->tex.map;
-
- if (offset < 0 || offset > intel->intelScreen->tex.size)
- return ~0;
- else
- return intel->intelScreen->tex.offset + offset;
-}
-
-
-
-
-
-/* Flip the front & back buffes
- */
-void intelPageFlip( const __DRIdrawablePrivate *dPriv )
-{
-#if 0
- intelContextPtr intel;
- int tmp, ret;
-
- if (INTEL_DEBUG & DEBUG_IOCTL)
- fprintf(stderr, "%s\n", __FUNCTION__);
-
- assert(dPriv);
- assert(dPriv->driContextPriv);
- assert(dPriv->driContextPriv->driverPrivate);
-
- intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate;
-
- intelFlush( &intel->ctx );
- LOCK_HARDWARE( intel );
-
- if (dPriv->pClipRects) {
- *(drm_clip_rect_t *)intel->sarea->boxes = dPriv->pClipRects[0];
- intel->sarea->nbox = 1;
- }
-
- ret = drmCommandNone(intel->driFd, DRM_I830_FLIP);
- if (ret) {
- fprintf(stderr, "%s: %d\n", __FUNCTION__, ret);
- UNLOCK_HARDWARE( intel );
- exit(1);
- }
-
- tmp = intel->sarea->last_enqueue;
- intelRefillBatchLocked( intel );
- UNLOCK_HARDWARE( intel );
-
-
- intelSetDrawBuffer( &intel->ctx, intel->ctx.Color.DriverDrawBuffer );
-#endif
-}
diff --git a/src/mesa/drivers/dri/i915/intel_pixel_read.c b/src/mesa/drivers/dri/i915/intel_pixel_read.c
index d009590a4b..120c887abd 100644
--- a/src/mesa/drivers/dri/i915/intel_pixel_read.c
+++ b/src/mesa/drivers/dri/i915/intel_pixel_read.c
@@ -35,7 +35,6 @@
#include "intel_screen.h"
#include "intel_context.h"
-#include "intel_ioctl.h"
#include "intel_batchbuffer.h"
#include "intel_blit.h"
#include "intel_buffers.h"
diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile
index 8fa205e79f..c2d555cd0c 100644
--- a/src/mesa/drivers/dri/i965/Makefile
+++ b/src/mesa/drivers/dri/i965/Makefile
@@ -13,7 +13,6 @@ DRIVER_SOURCES = \
intel_decode.c \
intel_depthstencil.c \
intel_fbo.c \
- intel_ioctl.c \
intel_mipmap_tree.c \
intel_regions.c \
intel_screen.c \
@@ -91,6 +90,8 @@ ASM_SOURCES =
DRIVER_DEFINES = -I../intel -I../intel/server
+DRI_LIB_DEPS += -ldrm_intel
+
include ../Makefile.template
symlinks:
diff --git a/src/mesa/drivers/dri/i965/brw_cc.c b/src/mesa/drivers/dri/i965/brw_cc.c
index d662cf7521..0458bf5983 100644
--- a/src/mesa/drivers/dri/i965/brw_cc.c
+++ b/src/mesa/drivers/dri/i965/brw_cc.c
@@ -255,12 +255,12 @@ cc_unit_create_from_key(struct brw_context *brw, struct brw_cc_unit_key *key)
NULL, NULL);
/* Emit CC viewport relocation */
- intel_bo_emit_reloc(bo,
- I915_GEM_DOMAIN_INSTRUCTION,
- 0,
- 0,
- offsetof(struct brw_cc_unit_state, cc4),
- brw->cc.vp_bo);
+ dri_bo_emit_reloc(bo,
+ I915_GEM_DOMAIN_INSTRUCTION,
+ 0,
+ 0,
+ offsetof(struct brw_cc_unit_state, cc4),
+ brw->cc.vp_bo);
return bo;
}
diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c b/src/mesa/drivers/dri/i965/brw_clip_state.c
index ae904c6253..51045f9188 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_state.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_state.c
@@ -119,12 +119,12 @@ clip_unit_create_from_key(struct brw_context *brw,
/* Emit clip program relocation */
assert(brw->clip.prog_bo);
- intel_bo_emit_reloc(bo,
- I915_GEM_DOMAIN_INSTRUCTION,
- 0,
- clip.thread0.grf_reg_count << 1,
- offsetof(struct brw_clip_unit_state, thread0),
- brw->clip.prog_bo);
+ dri_bo_emit_reloc(bo,
+ I915_GEM_DOMAIN_INSTRUCTION,
+ 0,
+ clip.thread0.grf_reg_count << 1,
+ offsetof(struct brw_clip_unit_state, thread0),
+ brw->clip.prog_bo);
return bo;
}
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index d43b52c2c7..95d798238d 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -39,7 +39,6 @@
#include "brw_state.h"
#include "brw_fallback.h"
-#include "intel_ioctl.h"
#include "intel_batchbuffer.h"
#include "intel_buffer_objects.h"
diff --git a/src/mesa/drivers/dri/i965/brw_draw.h b/src/mesa/drivers/dri/i965/brw_draw.h
index 2a3e0c1c5b..e0bba589d5 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.h
+++ b/src/mesa/drivers/dri/i965/brw_draw.h
@@ -31,7 +31,6 @@
#include "mtypes.h" /* for GLcontext... */
#include "vbo/vbo.h"
-#include "dri_bufmgr.h"
struct brw_context;
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 0122d18f82..465239f195 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -39,7 +39,6 @@
#include "brw_state.h"
#include "brw_fallback.h"
-#include "intel_ioctl.h"
#include "intel_batchbuffer.h"
#include "intel_buffer_objects.h"
#include "intel_tex.h"
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 6b97f8b170..0bfbec9d14 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -513,6 +513,8 @@ struct brw_instruction *brw_IF(struct brw_compile *p, GLuint execute_size)
insn->header.compression_control = BRW_COMPRESSION_NONE;
insn->header.predicate_control = BRW_PREDICATE_NORMAL;
insn->header.mask_control = BRW_MASK_ENABLE;
+ if (!p->single_program_flow)
+ insn->header.thread_control = BRW_THREAD_SWITCH;
p->current->header.predicate_control = BRW_PREDICATE_NONE;
@@ -538,6 +540,8 @@ struct brw_instruction *brw_ELSE(struct brw_compile *p,
insn->header.compression_control = BRW_COMPRESSION_NONE;
insn->header.execution_size = if_insn->header.execution_size;
insn->header.mask_control = BRW_MASK_ENABLE;
+ if (!p->single_program_flow)
+ insn->header.thread_control = BRW_THREAD_SWITCH;
/* Patch the if instruction to point at this instruction.
*/
@@ -579,6 +583,7 @@ void brw_ENDIF(struct brw_compile *p,
insn->header.compression_control = BRW_COMPRESSION_NONE;
insn->header.execution_size = patch_insn->header.execution_size;
insn->header.mask_control = BRW_MASK_ENABLE;
+ insn->header.thread_control = BRW_THREAD_SWITCH;
assert(patch_insn->bits3.if_else.jump_count == 0);
@@ -617,7 +622,7 @@ struct brw_instruction *brw_BREAK(struct brw_compile *p)
brw_set_src1(insn, brw_imm_d(0x0));
insn->header.compression_control = BRW_COMPRESSION_NONE;
insn->header.execution_size = BRW_EXECUTE_8;
- insn->header.mask_control = BRW_MASK_DISABLE;
+ /* insn->header.mask_control = BRW_MASK_DISABLE; */
insn->bits3.if_else.pad0 = 0;
return insn;
}
@@ -631,7 +636,7 @@ struct brw_instruction *brw_CONT(struct brw_compile *p)
brw_set_src1(insn, brw_imm_d(0x0));
insn->header.compression_control = BRW_COMPRESSION_NONE;
insn->header.execution_size = BRW_EXECUTE_8;
- insn->header.mask_control = BRW_MASK_DISABLE;
+ /* insn->header.mask_control = BRW_MASK_DISABLE; */
insn->bits3.if_else.pad0 = 0;
return insn;
}
@@ -655,7 +660,7 @@ struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
insn->header.execution_size = execute_size;
insn->header.predicate_control = BRW_PREDICATE_NONE;
/* insn->header.mask_control = BRW_MASK_ENABLE; */
- insn->header.mask_control = BRW_MASK_DISABLE;
+ /* insn->header.mask_control = BRW_MASK_DISABLE; */
return insn;
}
@@ -694,7 +699,7 @@ struct brw_instruction *brw_WHILE(struct brw_compile *p,
/* insn->header.mask_control = BRW_MASK_ENABLE; */
- insn->header.mask_control = BRW_MASK_DISABLE;
+ /* insn->header.mask_control = BRW_MASK_DISABLE; */
p->current->header.predicate_control = BRW_PREDICATE_NONE;
return insn;
}
diff --git a/src/mesa/drivers/dri/i965/brw_gs_state.c b/src/mesa/drivers/dri/i965/brw_gs_state.c
index ff2e3ab059..633e17cc9d 100644
--- a/src/mesa/drivers/dri/i965/brw_gs_state.c
+++ b/src/mesa/drivers/dri/i965/brw_gs_state.c
@@ -106,11 +106,11 @@ gs_unit_create_from_key(struct brw_context *brw, struct brw_gs_unit_key *key)
if (key->prog_active) {
/* Emit GS program relocation */
- intel_bo_emit_reloc(bo,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- gs.thread0.grf_reg_count << 1,
- offsetof(struct brw_gs_unit_state, thread0),
- brw->gs.prog_bo);
+ dri_bo_emit_reloc(bo,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ gs.thread0.grf_reg_count << 1,
+ offsetof(struct brw_gs_unit_state, thread0),
+ brw->gs.prog_bo);
}
return bo;
diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c
index 2478872b82..07d0b4c798 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
@@ -251,18 +251,18 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key,
NULL, NULL);
/* Emit SF program relocation */
- intel_bo_emit_reloc(bo,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- sf.thread0.grf_reg_count << 1,
- offsetof(struct brw_sf_unit_state, thread0),
- brw->sf.prog_bo);
+ dri_bo_emit_reloc(bo,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ sf.thread0.grf_reg_count << 1,
+ offsetof(struct brw_sf_unit_state, thread0),
+ brw->sf.prog_bo);
/* Emit SF viewport relocation */
- intel_bo_emit_reloc(bo,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- sf.sf5.front_winding | (sf.sf5.viewport_transform << 1),
- offsetof(struct brw_sf_unit_state, sf5),
- brw->sf.vp_bo);
+ dri_bo_emit_reloc(bo,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ sf.sf5.front_winding | (sf.sf5.viewport_transform << 1),
+ offsetof(struct brw_sf_unit_state, sf5),
+ brw->sf.vp_bo);
return bo;
}
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index d1d319d92e..7d4fd467b1 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -33,7 +33,6 @@
#include "brw_context.h"
#include "brw_state.h"
-#include "dri_bufmgr.h"
#include "intel_batchbuffer.h"
/* This is used to initialize brw->state.atoms[]. We could use this
diff --git a/src/mesa/drivers/dri/i965/brw_tex.c b/src/mesa/drivers/dri/i965/brw_tex.c
index 258c6260fb..ab6393420a 100644
--- a/src/mesa/drivers/dri/i965/brw_tex.c
+++ b/src/mesa/drivers/dri/i965/brw_tex.c
@@ -42,7 +42,6 @@
#include "texmem.h"
#include "intel_context.h"
-#include "intel_ioctl.h"
#include "intel_regions.h"
#include "intel_tex.h"
#include "brw_context.h"
diff --git a/src/mesa/drivers/dri/i965/brw_vs_state.c b/src/mesa/drivers/dri/i965/brw_vs_state.c
index 909b942610..24bf5567bd 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_state.c
@@ -115,11 +115,11 @@ vs_unit_create_from_key(struct brw_context *brw, struct brw_vs_unit_key *key)
NULL, NULL);
/* Emit VS program relocation */
- intel_bo_emit_reloc(bo,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- vs.thread0.grf_reg_count << 1,
- offsetof(struct brw_vs_unit_state, thread0),
- brw->vs.prog_bo);
+ dri_bo_emit_reloc(bo,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ vs.thread0.grf_reg_count << 1,
+ offsetof(struct brw_vs_unit_state, thread0),
+ brw->vs.prog_bo);
return bo;
}
diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
index 305100f883..8dce40f25b 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
@@ -850,20 +850,20 @@ static void emit_sop(struct brw_wm_compile *c,
struct brw_reg dst, src0, src1;
int i;
- brw_push_insn_state(p);
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
dst = get_dst_reg(c, inst, i, 1);
src0 = get_src_reg(c, &inst->SrcReg[0], i, 1);
src1 = get_src_reg(c, &inst->SrcReg[1], i, 1);
+ brw_push_insn_state(p);
brw_CMP(p, brw_null_reg(), cond, src0, src1);
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
brw_MOV(p, dst, brw_imm_f(0.0));
brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
brw_MOV(p, dst, brw_imm_f(1.0));
+ brw_pop_insn_state(p);
}
}
- brw_pop_insn_state(p);
}
static void emit_slt(struct brw_wm_compile *c,
diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
index 08d01823de..e47dbe8b10 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -303,12 +303,12 @@ static void upload_wm_samplers( struct brw_context *brw )
if (!brw->attribs.Texture->Unit[i]._ReallyEnabled)
continue;
- intel_bo_emit_reloc(brw->wm.sampler_bo,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0,
- i * sizeof(struct brw_sampler_state) +
- offsetof(struct brw_sampler_state, ss2),
- brw->wm.sdc_bo[i]);
+ dri_bo_emit_reloc(brw->wm.sampler_bo,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0,
+ i * sizeof(struct brw_sampler_state) +
+ offsetof(struct brw_sampler_state, ss2),
+ brw->wm.sdc_bo[i]);
}
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c
index f97d0dc285..61fe97a463 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_state.c
@@ -34,7 +34,6 @@
#include "brw_context.h"
#include "brw_state.h"
#include "brw_defines.h"
-#include "dri_bufmgr.h"
#include "brw_wm.h"
/***********************************************************************
@@ -199,28 +198,28 @@ wm_unit_create_from_key(struct brw_context *brw, struct brw_wm_unit_key *key,
NULL, NULL);
/* Emit WM program relocation */
- intel_bo_emit_reloc(bo,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- wm.thread0.grf_reg_count << 1,
- offsetof(struct brw_wm_unit_state, thread0),
- brw->wm.prog_bo);
+ dri_bo_emit_reloc(bo,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ wm.thread0.grf_reg_count << 1,
+ offsetof(struct brw_wm_unit_state, thread0),
+ brw->wm.prog_bo);
/* Emit scratch space relocation */
if (key->total_scratch != 0) {
- intel_bo_emit_reloc(bo,
- 0, 0,
- wm.thread2.per_thread_scratch_space,
- offsetof(struct brw_wm_unit_state, thread2),
- brw->wm.scratch_buffer);
+ dri_bo_emit_reloc(bo,
+ 0, 0,
+ wm.thread2.per_thread_scratch_space,
+ offsetof(struct brw_wm_unit_state, thread2),
+ brw->wm.scratch_buffer);
}
/* Emit sampler state relocation */
if (key->sampler_count != 0) {
- intel_bo_emit_reloc(bo,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- wm.wm4.stats_enable | (wm.wm4.sampler_count << 2),
- offsetof(struct brw_wm_unit_state, wm4),
- brw->wm.sampler_bo);
+ dri_bo_emit_reloc(bo,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ wm.wm4.stats_enable | (wm.wm4.sampler_count << 2),
+ offsetof(struct brw_wm_unit_state, wm4),
+ brw->wm.sampler_bo);
}
return bo;
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index af1401b34b..8fcd50924f 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -138,7 +138,7 @@ static GLuint translate_tex_format( GLuint mesa_format, GLenum depth_mode )
case MESA_FORMAT_SRGB_DXT1:
return BRW_SURFACEFORMAT_BC1_UNORM_SRGB;
- case MESA_FORMAT_Z24_S8:
+ case MESA_FORMAT_S8_Z24:
return BRW_SURFACEFORMAT_I24X8_UNORM;
default:
@@ -234,11 +234,11 @@ brw_create_texture_surface( struct brw_context *brw,
if (key->bo) {
/* Emit relocation to surface contents */
- intel_bo_emit_reloc(bo,
- I915_GEM_DOMAIN_SAMPLER, 0,
- 0,
- offsetof(struct brw_surface_state, ss1),
- key->bo);
+ dri_bo_emit_reloc(bo,
+ I915_GEM_DOMAIN_SAMPLER, 0,
+ 0,
+ offsetof(struct brw_surface_state, ss1),
+ key->bo);
}
return bo;
}
@@ -374,13 +374,13 @@ brw_update_region_surface(struct brw_context *brw, struct intel_region *region,
* them both. We might be able to figure out from other state
* a more restrictive relocation to emit.
*/
- intel_bo_emit_reloc(brw->wm.surf_bo[unit],
- I915_GEM_DOMAIN_RENDER |
- I915_GEM_DOMAIN_SAMPLER,
- I915_GEM_DOMAIN_RENDER,
- 0,
- offsetof(struct brw_surface_state, ss1),
- region_bo);
+ dri_bo_emit_reloc(brw->wm.surf_bo[unit],
+ I915_GEM_DOMAIN_RENDER |
+ I915_GEM_DOMAIN_SAMPLER,
+ I915_GEM_DOMAIN_RENDER,
+ 0,
+ offsetof(struct brw_surface_state, ss1),
+ region_bo);
}
}
}
@@ -420,11 +420,11 @@ brw_wm_get_binding_table(struct brw_context *brw)
/* Emit binding table relocations to surface state */
for (i = 0; i < BRW_WM_MAX_SURF; i++) {
if (brw->wm.surf_bo[i] != NULL) {
- intel_bo_emit_reloc(bind_bo,
- I915_GEM_DOMAIN_INSTRUCTION, 0,
- 0,
- i * sizeof(GLuint),
- brw->wm.surf_bo[i]);
+ dri_bo_emit_reloc(bind_bo,
+ I915_GEM_DOMAIN_INSTRUCTION, 0,
+ 0,
+ i * sizeof(GLuint),
+ brw->wm.surf_bo[i]);
}
}
diff --git a/src/mesa/drivers/dri/i965/intel_ioctl.c b/src/mesa/drivers/dri/i965/intel_ioctl.c
deleted file mode 120000
index effd0f378d..0000000000
--- a/src/mesa/drivers/dri/i965/intel_ioctl.c
+++ /dev/null
@@ -1 +0,0 @@
-../intel/intel_ioctl.c \ No newline at end of file
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index 5afaad070c..7dbc646370 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -25,8 +25,8 @@
*
**************************************************************************/
+#include "intel_context.h"
#include "intel_batchbuffer.h"
-#include "intel_ioctl.h"
#include "intel_decode.h"
#include "intel_reg.h"
#include "intel_bufmgr.h"
@@ -148,28 +148,15 @@ do_flush_locked(struct intel_batchbuffer *batch,
*/
if (!(intel->numClipRects == 0 &&
- batch->cliprect_mode == LOOP_CLIPRECTS)) {
- if (intel->ttm == GL_TRUE) {
- struct drm_i915_gem_execbuffer *execbuf;
-
- execbuf = dri_process_relocs(batch->buf);
- ret = intel_exec_ioctl(batch->intel,
- used,
- batch->cliprect_mode != LOOP_CLIPRECTS,
- allow_unlock,
- execbuf);
- } else {
- dri_process_relocs(batch->buf);
- ret = intel_batch_ioctl(batch->intel,
- batch->buf->offset,
- used,
- batch->cliprect_mode != LOOP_CLIPRECTS,
- allow_unlock);
- }
+ batch->cliprect_mode == LOOP_CLIPRECTS) || intel->no_hw) {
+ dri_bo_exec(batch->buf, used,
+ intel->pClipRects,
+ batch->cliprect_mode != LOOP_CLIPRECTS ?
+ 0 : intel->numClipRects,
+ (((GLuint) intel->drawX) & 0xffff) |
+ (((GLuint) intel->drawY) << 16));
}
- dri_post_submit(batch->buf);
-
if (intel->numClipRects == 0 &&
batch->cliprect_mode == LOOP_CLIPRECTS) {
if (allow_unlock) {
@@ -261,13 +248,9 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file,
UNLOCK_HARDWARE(intel);
if (INTEL_DEBUG & DEBUG_SYNC) {
- int irq;
-
fprintf(stderr, "waiting for idle\n");
- LOCK_HARDWARE(intel);
- irq = intelEmitIrqLocked(intel);
- UNLOCK_HARDWARE(intel);
- intelWaitIrq(intel, irq);
+ dri_bo_map(batch->buf, GL_TRUE);
+ dri_bo_unmap(batch->buf);
}
/* Reset the buffer:
@@ -289,8 +272,8 @@ intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
if (batch->ptr - batch->map > batch->buf->size)
_mesa_printf ("bad relocation ptr %p map %p offset %d size %d\n",
batch->ptr, batch->map, batch->ptr - batch->map, batch->buf->size);
- ret = intel_bo_emit_reloc(batch->buf, read_domains, write_domain,
- delta, batch->ptr - batch->map, buffer);
+ ret = dri_bo_emit_reloc(batch->buf, read_domains, write_domain,
+ delta, batch->ptr - batch->map, buffer);
/*
* Using the old buffer offset, write in what the right data would be, in case
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
index 52d6ecc223..cf7d4a0633 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
@@ -3,11 +3,10 @@
#include "mtypes.h"
-#include "dri_bufmgr.h"
+#include "intel_context.h"
+#include "intel_bufmgr.h"
#include "intel_reg.h"
-struct intel_context;
-
#define BATCH_SZ 16384
#define BATCH_RESERVED 16
diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c
index 7129a4ba91..653f485dd0 100644
--- a/src/mesa/drivers/dri/intel/intel_blit.c
+++ b/src/mesa/drivers/dri/intel/intel_blit.c
@@ -33,13 +33,13 @@
#include "context.h"
#include "enums.h"
-#include "intel_batchbuffer.h"
#include "intel_blit.h"
#include "intel_buffers.h"
#include "intel_context.h"
#include "intel_fbo.h"
#include "intel_reg.h"
#include "intel_regions.h"
+#include "intel_batchbuffer.h"
#define FILE_DEBUG_FLAG DEBUG_BLIT
diff --git a/src/mesa/drivers/dri/intel/intel_blit.h b/src/mesa/drivers/dri/intel/intel_blit.h
index 0881cc4fdc..52065b13ed 100644
--- a/src/mesa/drivers/dri/intel/intel_blit.h
+++ b/src/mesa/drivers/dri/intel/intel_blit.h
@@ -29,8 +29,6 @@
#define INTEL_BLIT_H
#include "intel_context.h"
-#include "intel_ioctl.h"
-#include "dri_bufmgr.h"
extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv,
const drm_clip_rect_t * rect);
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index 1923a21516..88484a07af 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -34,7 +34,6 @@
#include "intel_buffer_objects.h"
#include "intel_batchbuffer.h"
#include "intel_regions.h"
-#include "dri_bufmgr.h"
static GLboolean intel_bufferobj_unmap(GLcontext * ctx,
GLenum target,
diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c
index 77352e6a53..3fe67462d5 100644
--- a/src/mesa/drivers/dri/intel/intel_buffers.c
+++ b/src/mesa/drivers/dri/intel/intel_buffers.c
@@ -618,6 +618,9 @@ intel_wait_flips(struct intel_context *intel)
BUFFER_FRONT_LEFT ? BUFFER_FRONT_LEFT :
BUFFER_BACK_LEFT);
+ if (intel->intelScreen->driScrnPriv->dri2.enabled)
+ return;
+
if (intel_fb->Base.Name == 0 && intel_rb &&
intel_rb->pf_pending == intel_fb->pf_seq) {
GLint pf_planes = intel_fb->pf_planes;
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 50c1964d87..4d1a742698 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -51,7 +51,6 @@
#include "intel_chipset.h"
#include "intel_buffers.h"
#include "intel_tex.h"
-#include "intel_ioctl.h"
#include "intel_batchbuffer.h"
#include "intel_blit.h"
#include "intel_pixel.h"
@@ -195,6 +194,142 @@ intelGetString(GLcontext * ctx, GLenum name)
}
}
+void
+intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
+{
+ struct intel_framebuffer *intel_fb = drawable->driverPrivate;
+ struct intel_renderbuffer *rb;
+ struct intel_region *region, *depth_region;
+ struct intel_context *intel = context->driverPrivate;
+ __DRIbuffer *buffers;
+ __DRIscreen *screen;
+ int i, count;
+ unsigned int attachments[10];
+ uint32_t name;
+ const char *region_name;
+
+ if (INTEL_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable);
+
+ screen = intel->intelScreen->driScrnPriv;
+
+ i = 0;
+ if (intel_fb->color_rb[0])
+ attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
+ if (intel_fb->color_rb[1])
+ attachments[i++] = __DRI_BUFFER_BACK_LEFT;
+ if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH))
+ attachments[i++] = __DRI_BUFFER_DEPTH;
+ if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL))
+ attachments[i++] = __DRI_BUFFER_STENCIL;
+
+ buffers = (*screen->dri2.loader->getBuffers)(drawable,
+ &drawable->w,
+ &drawable->h,
+ attachments, i,
+ &count,
+ drawable->loaderPrivate);
+
+ drawable->x = 0;
+ drawable->y = 0;
+ drawable->backX = 0;
+ drawable->backY = 0;
+ drawable->numClipRects = 1;
+ drawable->pClipRects[0].x1 = 0;
+ drawable->pClipRects[0].y1 = 0;
+ drawable->pClipRects[0].x2 = drawable->w;
+ drawable->pClipRects[0].y2 = drawable->h;
+ drawable->numBackClipRects = 1;
+ drawable->pBackClipRects[0].x1 = 0;
+ drawable->pBackClipRects[0].y1 = 0;
+ drawable->pBackClipRects[0].x2 = drawable->w;
+ drawable->pBackClipRects[0].y2 = drawable->h;
+
+ depth_region = NULL;
+ for (i = 0; i < count; i++) {
+ switch (buffers[i].attachment) {
+ case __DRI_BUFFER_FRONT_LEFT:
+ rb = intel_fb->color_rb[0];
+ region_name = "dri2 front buffer";
+ break;
+
+ case __DRI_BUFFER_BACK_LEFT:
+ rb = intel_fb->color_rb[1];
+ region_name = "dri2 back buffer";
+ break;
+
+ case __DRI_BUFFER_DEPTH:
+ rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+ region_name = "dri2 depth buffer";
+ break;
+
+ case __DRI_BUFFER_STENCIL:
+ rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+ region_name = "dri2 stencil buffer";
+ break;
+
+ case __DRI_BUFFER_ACCUM:
+ default:
+ fprintf(stderr,
+ "unhandled buffer attach event, attacment type %d\n",
+ buffers[i].attachment);
+ return;
+ }
+
+ if (rb->region) {
+ dri_bo_flink(rb->region->buffer, &name);
+ if (name == buffers[i].name)
+ continue;
+ }
+
+ if (INTEL_DEBUG & DEBUG_DRI)
+ fprintf(stderr,
+ "attaching buffer %d, at %d, cpp %d, pitch %d\n",
+ buffers[i].name, buffers[i].attachment,
+ buffers[i].cpp, buffers[i].pitch);
+
+ if (buffers[i].attachment == __DRI_BUFFER_STENCIL && depth_region) {
+ if (INTEL_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "(reusing depth buffer as stencil)\n");
+ intel_region_reference(&region, depth_region);
+ }
+ else
+ region = intel_region_alloc_for_handle(intel, buffers[i].cpp,
+ buffers[i].pitch / buffers[i].cpp,
+ drawable->h,
+ buffers[i].name,
+ region_name);
+
+ if (buffers[i].attachment == __DRI_BUFFER_DEPTH)
+ depth_region = region;
+
+ intel_renderbuffer_set_region(rb, region);
+ intel_region_release(&region);
+ }
+
+ driUpdateFramebufferSize(&intel->ctx, drawable);
+}
+
+static void
+intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ struct intel_context *intel = intel_context(ctx);
+ __DRIcontext *driContext = intel->driContext;
+
+ if (!driContext->driScreenPriv->dri2.enabled)
+ return;
+
+ intel_update_renderbuffers(driContext, driContext->driDrawablePriv);
+ if (driContext->driDrawablePriv != driContext->driReadablePriv)
+ intel_update_renderbuffers(driContext, driContext->driReadablePriv);
+
+ ctx->Driver.Viewport = NULL;
+ intel->driDrawable = driContext->driDrawablePriv;
+ intelWindowMoved(intel);
+ intel_draw_buffer(ctx, intel->ctx.DrawBuffer);
+ ctx->Driver.Viewport = intel_viewport;
+}
+
/**
* Extension strings exported by the intel driver.
*
@@ -273,10 +408,12 @@ static const struct dri_extension brw_extensions[] = {
{ NULL, NULL }
};
+#ifdef I915_MMIO_READ
static const struct dri_extension arb_oc_extensions[] = {
{"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions},
{NULL, NULL}
};
+#endif
static const struct dri_extension ttm_extensions[] = {
{"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
@@ -301,10 +438,12 @@ void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging)
if (intel == NULL || intel->ttm)
driInitExtensions(ctx, ttm_extensions, GL_FALSE);
+#ifdef I915_MMIO_READ
if (intel == NULL ||
(IS_965(intel->intelScreen->deviceID) &&
intel->intelScreen->drmMinor >= 8))
driInitExtensions(ctx, arb_oc_extensions, GL_FALSE);
+#endif
if (intel == NULL || IS_965(intel->intelScreen->deviceID))
driInitExtensions(ctx, brw_extensions, GL_FALSE);
@@ -402,6 +541,7 @@ intelFinish(GLcontext * ctx)
}
}
+#ifdef I915_MMIO_READ
static void
intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
{
@@ -432,105 +572,7 @@ intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
q->Ready = GL_TRUE;
intel->stats_wm--;
}
-
-/** Driver-specific fence emit implementation for the fake memory manager. */
-static unsigned int
-intel_fence_emit(void *private)
-{
- struct intel_context *intel = (struct intel_context *)private;
- unsigned int fence;
-
- /* XXX: Need to emit a flush, if we haven't already (at least with the
- * current batchbuffer implementation, we have).
- */
-
- fence = intelEmitIrqLocked(intel);
-
- return fence;
-}
-
-/** Driver-specific fence wait implementation for the fake memory manager. */
-static int
-intel_fence_wait(void *private, unsigned int cookie)
-{
- struct intel_context *intel = (struct intel_context *)private;
-
- intelWaitIrq(intel, cookie);
-
- return 0;
-}
-
-static GLboolean
-intel_init_bufmgr(struct intel_context *intel)
-{
- intelScreenPrivate *intelScreen = intel->intelScreen;
- GLboolean gem_disable = getenv("INTEL_NO_GEM") != NULL;
- int gem_kernel = 0;
- GLboolean gem_supported;
- struct drm_i915_getparam gp;
-
- gp.param = I915_PARAM_HAS_GEM;
- gp.value = &gem_kernel;
-
- (void) drmCommandWriteRead(intel->driFd, DRM_I915_GETPARAM, &gp, sizeof(gp));
-
- /* If we've got a new enough DDX that's initializing GEM and giving us
- * object handles for the shared buffers, use that.
- */
- intel->ttm = GL_FALSE;
- if (intel->intelScreen->driScrnPriv->dri2.enabled)
- gem_supported = GL_TRUE;
- else if (intel->intelScreen->driScrnPriv->ddx_version.minor >= 9 &&
- gem_kernel &&
- intel->intelScreen->front.bo_handle != -1)
- gem_supported = GL_TRUE;
- else
- gem_supported = GL_FALSE;
-
- if (!gem_disable && gem_supported) {
- int bo_reuse_mode;
- intel->bufmgr = intel_bufmgr_gem_init(intel->driFd,
- BATCH_SZ);
- if (intel->bufmgr != NULL)
- intel->ttm = GL_TRUE;
-
- bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
- switch (bo_reuse_mode) {
- case DRI_CONF_BO_REUSE_DISABLED:
- break;
- case DRI_CONF_BO_REUSE_ALL:
- intel_bufmgr_gem_enable_reuse(intel->bufmgr);
- break;
- }
- }
- /* Otherwise, use the classic buffer manager. */
- if (intel->bufmgr == NULL) {
- if (gem_disable) {
- fprintf(stderr, "GEM disabled. Using classic.\n");
- } else {
- fprintf(stderr, "Failed to initialize GEM. "
- "Falling back to classic.\n");
- }
-
- if (intelScreen->tex.size == 0) {
- fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
- __func__, __LINE__);
- return GL_FALSE;
- }
-
- intel->bufmgr = intel_bufmgr_fake_init(intelScreen->tex.offset,
- intelScreen->tex.map,
- intelScreen->tex.size,
- intel_fence_emit,
- intel_fence_wait,
- intel);
- }
-
- /* XXX bufmgr should be per-screen, not per-context */
- intelScreen->ttm = intel->ttm;
-
- return GL_TRUE;
-}
+#endif
void
intelInitDriverFunctions(struct dd_function_table *functions)
@@ -541,14 +583,17 @@ intelInitDriverFunctions(struct dd_function_table *functions)
functions->Finish = intelFinish;
functions->GetString = intelGetString;
functions->UpdateState = intelInvalidateState;
+ functions->Viewport = intel_viewport;
functions->CopyColorTable = _swrast_CopyColorTable;
functions->CopyColorSubTable = _swrast_CopyColorSubTable;
functions->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
functions->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+#ifdef I915_MMIO_READ
functions->BeginQuery = intelBeginQuery;
functions->EndQuery = intelEndQuery;
+#endif
intelInitTextureFuncs(functions);
intelInitStateFuncs(functions);
@@ -568,8 +613,6 @@ intelInitContext(struct intel_context *intel,
GLcontext *shareCtx = (GLcontext *) sharedContextPrivate;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
- volatile struct drm_i915_sarea *saPriv = (struct drm_i915_sarea *)
- (((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset);
int fthrottle_mode;
if (!_mesa_initialize_context(&intel->ctx, mesaVis, shareCtx,
@@ -581,7 +624,8 @@ intelInitContext(struct intel_context *intel,
driContextPriv->driverPrivate = intel;
intel->intelScreen = intelScreen;
intel->driScreen = sPriv;
- intel->sarea = saPriv;
+ intel->sarea = intelScreen->sarea;
+ intel->driContext = driContextPriv;
/* Dri stuff */
intel->hHWContext = driContextPriv->hHWContext;
@@ -599,8 +643,20 @@ intelInitContext(struct intel_context *intel,
else
intel->maxBatchSize = BATCH_SZ;
- if (!intel_init_bufmgr(intel))
- return GL_FALSE;
+ intel->bufmgr = intelScreen->bufmgr;
+ intel->ttm = intelScreen->ttm;
+ if (intel->ttm) {
+ int bo_reuse_mode;
+
+ bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
+ switch (bo_reuse_mode) {
+ case DRI_CONF_BO_REUSE_DISABLED:
+ break;
+ case DRI_CONF_BO_REUSE_ALL:
+ intel_bufmgr_gem_enable_reuse(intel->bufmgr);
+ break;
+ }
+ }
ctx->Const.MaxTextureMaxAnisotropy = 2.0;
@@ -783,11 +839,14 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
struct intel_framebuffer *intel_fb =
(struct intel_framebuffer *) driDrawPriv->driverPrivate;
GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate;
-
-
- /* XXX FBO temporary fix-ups! */
- /* if the renderbuffers don't have regions, init them from the context */
- if (!driContextPriv->driScreenPriv->dri2.enabled) {
+
+ if (driContextPriv->driScreenPriv->dri2.enabled) {
+ intel_update_renderbuffers(driContextPriv, driDrawPriv);
+ if (driDrawPriv != driReadPriv)
+ intel_update_renderbuffers(driContextPriv, driReadPriv);
+ } else {
+ /* XXX FBO temporary fix-ups! */
+ /* if the renderbuffers don't have regions, init them from the context */
struct intel_renderbuffer *irbDepth
= intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
struct intel_renderbuffer *irbStencil
@@ -989,18 +1048,12 @@ void LOCK_HARDWARE( struct intel_context *intel )
intel_fb->vbl_waited = vbl.reply.sequence;
}
- DRM_CAS(intel->driHwLock, intel->hHWContext,
- (DRM_LOCK_HELD|intel->hHWContext), __ret);
+ if (!sPriv->dri2.enabled) {
+ DRM_CAS(intel->driHwLock, intel->hHWContext,
+ (DRM_LOCK_HELD|intel->hHWContext), __ret);
- if (sPriv->dri2.enabled) {
if (__ret)
- drmGetLock(intel->driFd, intel->hHWContext, 0);
- if (__driParseEvents(dPriv->driContextPriv, dPriv)) {
- intelWindowMoved(intel);
- intel_draw_buffer(&intel->ctx, intel->ctx.DrawBuffer);
- }
- } else if (__ret) {
- intelContendedLock( intel, 0 );
+ intelContendedLock( intel, 0 );
}
@@ -1013,10 +1066,13 @@ void LOCK_HARDWARE( struct intel_context *intel )
*/
void UNLOCK_HARDWARE( struct intel_context *intel )
{
+ __DRIscreen *sPriv = intel->driScreen;
+
intel->vtbl.note_unlock( intel );
intel->locked = 0;
- DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
+ if (!sPriv->dri2.enabled)
+ DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
_glthread_UNLOCK_MUTEX(lockMutex);
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index f9a373cf74..8bd75753ea 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -34,7 +34,6 @@
#include "drm.h"
#include "mm.h"
#include "texmem.h"
-#include "dri_bufmgr.h"
#include "intel_bufmgr.h"
#include "intel_screen.h"
@@ -257,6 +256,7 @@ struct intel_context
drmLock *driHwLock;
int driFd;
+ __DRIcontextPrivate *driContext;
__DRIdrawablePrivate *driDrawable;
__DRIdrawablePrivate *driReadDrawable;
__DRIscreenPrivate *driScreen;
@@ -492,6 +492,8 @@ extern int intel_translate_stencil_op(GLenum op);
extern int intel_translate_blend_factor(GLenum factor);
extern int intel_translate_logic_op(GLenum opcode);
+void intel_update_renderbuffers(__DRIcontext *context,
+ __DRIdrawable *drawable);
/*======================================================================
* Inline conversion functions.
diff --git a/src/mesa/drivers/dri/intel/intel_ioctl.c b/src/mesa/drivers/dri/intel/intel_ioctl.c
deleted file mode 100644
index 58c81766cd..0000000000
--- a/src/mesa/drivers/dri/intel/intel_ioctl.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sched.h>
-#include <sys/types.h>
-#include <sys/ioctl.h>
-
-#include "mtypes.h"
-#include "context.h"
-#include "swrast/swrast.h"
-
-#include "intel_context.h"
-#include "intel_ioctl.h"
-#include "intel_batchbuffer.h"
-#include "intel_blit.h"
-#include "intel_regions.h"
-#include "drm.h"
-#include "i915_drm.h"
-
-#include "intel_bufmgr.h"
-
-#define FILE_DEBUG_FLAG DEBUG_IOCTL
-
-int
-intelEmitIrqLocked(struct intel_context *intel)
-{
- struct drm_i915_irq_emit ie;
- int ret, seq = 1;
-
- if (intel->no_hw)
- return 1;
-
- /*
- assert(((*(int *)intel->driHwLock) & ~DRM_LOCK_CONT) ==
- (DRM_LOCK_HELD|intel->hHWContext));
- */
-
- ie.irq_seq = &seq;
-
- ret = drmCommandWriteRead(intel->driFd, DRM_I915_IRQ_EMIT, &ie, sizeof(ie));
- if (ret) {
- fprintf(stderr, "%s: drm_i915_irq_emit: %d\n", __FUNCTION__, ret);
- exit(1);
- }
-
- DBG("%s --> %d\n", __FUNCTION__, seq);
-
- return seq;
-}
-
-void
-intelWaitIrq(struct intel_context *intel, int seq)
-{
- struct drm_i915_irq_wait iw;
- int ret, lastdispatch;
- volatile struct drm_i915_sarea *sarea = intel->sarea;
-
- if (intel->no_hw)
- return;
-
- DBG("%s %d\n", __FUNCTION__, seq);
-
- iw.irq_seq = seq;
-
- do {
- lastdispatch = sarea->last_dispatch;
- ret = drmCommandWrite(intel->driFd, DRM_I915_IRQ_WAIT, &iw, sizeof(iw));
- } while (ret == -EAGAIN ||
- ret == -EINTR ||
- (ret == -EBUSY && lastdispatch != sarea->last_dispatch) ||
- (ret == 0 && seq > sarea->last_dispatch) ||
- (ret == 0 && sarea->last_dispatch - seq >= (1 << 24)));
-
- if (ret) {
- fprintf(stderr, "%s: drm_i915_irq_wait: %d\n", __FUNCTION__, ret);
- exit(1);
- }
-}
-
-
-int
-intel_batch_ioctl(struct intel_context *intel,
- GLuint start_offset,
- GLuint used,
- GLboolean ignore_cliprects, GLboolean allow_unlock)
-{
- struct drm_i915_batchbuffer batch;
-
- if (intel->no_hw)
- return 0;
-
- assert(intel->locked);
- assert(used);
-
- DBG("%s used %d offset %x..%x ignore_cliprects %d\n",
- __FUNCTION__,
- used, start_offset, start_offset + used, ignore_cliprects);
-
- /* Throw away non-effective packets. Won't work once we have
- * hardware contexts which would preserve statechanges beyond a
- * single buffer.
- */
- batch.start = start_offset;
- batch.used = used;
- batch.cliprects = intel->pClipRects;
- batch.num_cliprects = ignore_cliprects ? 0 : intel->numClipRects;
- batch.DR1 = 0;
- batch.DR4 = ((((GLuint) intel->drawX) & 0xffff) |
- (((GLuint) intel->drawY) << 16));
-
- DBG("%s: 0x%x..0x%x DR4: %x cliprects: %d\n",
- __FUNCTION__,
- batch.start,
- batch.start + batch.used * 4, batch.DR4, batch.num_cliprects);
-
- if (drmCommandWrite(intel->driFd, DRM_I915_BATCHBUFFER, &batch,
- sizeof(batch))) {
- fprintf(stderr, "DRM_I915_BATCHBUFFER: %d\n", -errno);
- return -errno;
- }
-
- return 0;
-}
-
-int
-intel_exec_ioctl(struct intel_context *intel,
- GLuint used,
- GLboolean ignore_cliprects, GLboolean allow_unlock,
- struct drm_i915_gem_execbuffer *execbuf)
-{
- int ret;
-
- assert(intel->locked);
- assert(used);
-
- if (intel->no_hw)
- return 0;
-
- execbuf->batch_start_offset = 0;
- execbuf->batch_len = used;
- execbuf->cliprects_ptr = (uintptr_t)intel->pClipRects;
- execbuf->num_cliprects = ignore_cliprects ? 0 : intel->numClipRects;
- execbuf->DR1 = 0;
- execbuf->DR4 = ((((GLuint) intel->drawX) & 0xffff) |
- (((GLuint) intel->drawY) << 16));
-
- do {
- ret = ioctl(intel->driFd, DRM_IOCTL_I915_GEM_EXECBUFFER, execbuf);
- } while (ret == -EAGAIN);
-
- if (ret != 0) {
- fprintf(stderr, "DRM_I915_GEM_EXECBUFFER: %d\n", -errno);
- return -errno;
- }
-
- return 0;
-}
diff --git a/src/mesa/drivers/dri/intel/intel_ioctl.h b/src/mesa/drivers/dri/intel/intel_ioctl.h
deleted file mode 100644
index 526e38358c..0000000000
--- a/src/mesa/drivers/dri/intel/intel_ioctl.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_IOCTL_H
-#define INTEL_IOCTL_H
-
-#include "intel_context.h"
-
-void intelWaitIrq( struct intel_context *intel, int seq );
-int intelEmitIrqLocked( struct intel_context *intel );
-
-int intel_batch_ioctl(struct intel_context *intel,
- GLuint start_offset,
- GLuint used,
- GLboolean ignore_cliprects,
- GLboolean allow_unlock);
-int intel_exec_ioctl(struct intel_context *intel,
- GLuint used,
- GLboolean ignore_cliprects, GLboolean allow_unlock,
- struct drm_i915_gem_execbuffer *execbuf);
-
-#endif
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
index 7e0d20e681..daa6d4be17 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
@@ -36,7 +36,6 @@
#include "intel_screen.h"
#include "intel_context.h"
-#include "intel_ioctl.h"
#include "intel_batchbuffer.h"
#include "intel_blit.h"
#include "intel_regions.h"
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c
index 3093ccf7c6..1c72d6179d 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c
@@ -35,7 +35,6 @@
#include "intel_screen.h"
#include "intel_context.h"
-#include "intel_ioctl.h"
#include "intel_batchbuffer.h"
#include "intel_buffers.h"
#include "intel_blit.h"
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
index 5675084da5..47460da9aa 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
@@ -35,7 +35,6 @@
#include "intel_screen.h"
#include "intel_context.h"
-#include "intel_ioctl.h"
#include "intel_batchbuffer.h"
#include "intel_blit.h"
#include "intel_buffers.h"
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index ddfdce3835..1cfc8ddd64 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -46,7 +46,6 @@
#include "intel_regions.h"
#include "intel_blit.h"
#include "intel_buffer_objects.h"
-#include "dri_bufmgr.h"
#include "intel_bufmgr.h"
#include "intel_batchbuffer.h"
#include "intel_chipset.h"
@@ -145,12 +144,12 @@ intel_region_alloc(struct intel_context *intel,
struct intel_region *
intel_region_alloc_for_handle(struct intel_context *intel,
GLuint cpp, GLuint pitch, GLuint height,
- GLuint handle)
+ GLuint handle, const char *name)
{
struct intel_region *region;
dri_bo *buffer;
- buffer = intel_bo_gem_create_from_name(intel->bufmgr, "dri2 region", handle);
+ buffer = intel_bo_gem_create_from_name(intel->bufmgr, name, handle);
region = intel_region_alloc_internal(intel, cpp, pitch, height, buffer);
if (region == NULL)
@@ -164,6 +163,9 @@ intel_region_alloc_for_handle(struct intel_context *intel,
void
intel_region_reference(struct intel_region **dst, struct intel_region *src)
{
+ if (src)
+ DBG("%s %d\n", __FUNCTION__, src->refcount);
+
assert(*dst == NULL);
if (src) {
src->refcount++;
diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h
index e5f19fbb45..a561de485e 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.h
+++ b/src/mesa/drivers/dri/intel/intel_regions.h
@@ -34,8 +34,10 @@
* the basic structure for rectangular collections of pixels stored in a dri_bo.
*/
+#include <xf86drm.h>
+
#include "mtypes.h"
-#include "dri_bufmgr.h"
+#include "intel_bufmgr.h"
struct intel_context;
struct intel_buffer_object;
@@ -76,7 +78,7 @@ struct intel_region *intel_region_alloc(struct intel_context *intel,
struct intel_region *
intel_region_alloc_for_handle(struct intel_context *intel,
GLuint cpp, GLuint pitch, GLuint height,
- unsigned int handle);
+ unsigned int handle, const char *name);
void intel_region_reference(struct intel_region **dst,
struct intel_region *src);
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 9ed89906d5..1de1ac49ea 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -41,7 +41,6 @@
#include "intel_buffers.h"
#include "intel_tex.h"
#include "intel_span.h"
-#include "intel_ioctl.h"
#include "intel_fbo.h"
#include "intel_chipset.h"
@@ -211,102 +210,6 @@ intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
intelPrintSAREA(sarea);
}
-
-/**
- * DRI2 entrypoint
- */
-static void
-intelHandleDrawableConfig(__DRIdrawablePrivate *dPriv,
- __DRIcontextPrivate *pcp,
- __DRIDrawableConfigEvent *event)
-{
- struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
- struct intel_region *region = NULL;
- struct intel_renderbuffer *rb, *depth_rb, *stencil_rb;
- struct intel_context *intel = pcp->driverPrivate;
- int cpp, pitch;
-
- cpp = intel->ctx.Visual.rgbBits / 8;
- pitch = ((cpp * dPriv->w + 63) & ~63) / cpp;
-
- rb = intel_fb->color_rb[1];
- if (rb) {
- region = intel_region_alloc(intel, cpp, pitch, dPriv->h);
- intel_renderbuffer_set_region(rb, region);
- }
-
- rb = intel_fb->color_rb[2];
- if (rb) {
- region = intel_region_alloc(intel, cpp, pitch, dPriv->h);
- intel_renderbuffer_set_region(rb, region);
- }
-
- depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
- stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
- if (depth_rb || stencil_rb)
- region = intel_region_alloc(intel, cpp, pitch, dPriv->h);
- if (depth_rb)
- intel_renderbuffer_set_region(depth_rb, region);
- if (stencil_rb)
- intel_renderbuffer_set_region(stencil_rb, region);
-
- /* FIXME: Tell the X server about the regions we just allocated and
- * attached. */
-}
-
-/**
- * DRI2 entrypoint
- */
-static void
-intelHandleBufferAttach(__DRIdrawablePrivate *dPriv,
- __DRIcontextPrivate *pcp,
- __DRIBufferAttachEvent *ba)
-{
- struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
- struct intel_renderbuffer *rb;
- struct intel_region *region;
- struct intel_context *intel = pcp->driverPrivate;
-
- switch (ba->buffer.attachment) {
- case DRI_DRAWABLE_BUFFER_FRONT_LEFT:
- rb = intel_fb->color_rb[0];
- break;
-
- case DRI_DRAWABLE_BUFFER_BACK_LEFT:
- rb = intel_fb->color_rb[0];
- break;
-
- case DRI_DRAWABLE_BUFFER_DEPTH:
- rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
- break;
-
- case DRI_DRAWABLE_BUFFER_STENCIL:
- rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
- break;
-
- case DRI_DRAWABLE_BUFFER_ACCUM:
- default:
- fprintf(stderr, "unhandled buffer attach event, attacment type %d\n",
- ba->buffer.attachment);
- return;
- }
-
-#if 0
- /* FIXME: Add this so we can filter out when the X server sends us
- * attachment events for the buffers we just allocated. Need to
- * get the BO handle for a render buffer. */
- if (intel_renderbuffer_get_region_handle(rb) == ba->buffer.handle)
- return;
-#endif
-
- region = intel_region_alloc_for_handle(intel, ba->buffer.cpp,
- ba->buffer.pitch / ba->buffer.cpp,
- dPriv->h,
- ba->buffer.handle);
-
- intel_renderbuffer_set_region(rb, region);
-}
-
static const __DRItexOffsetExtension intelTexOffsetExtension = {
{ __DRI_TEX_OFFSET },
intelSetTexOffset,
@@ -370,9 +273,9 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
intelScreen->driScrnPriv = sPriv;
sPriv->private = (void *) intelScreen;
- intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
sarea = (struct drm_i915_sarea *)
- (((GLubyte *) sPriv->pSAREA) + intelScreen->sarea_priv_offset);
+ (((GLubyte *) sPriv->pSAREA) + gDRIPriv->sarea_priv_offset);
+ intelScreen->sarea = sarea;
intelScreen->deviceID = gDRIPriv->deviceID;
@@ -385,8 +288,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
return GL_FALSE;
}
- intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
-
if (0)
intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
@@ -647,6 +548,69 @@ intelFillInModes(__DRIscreenPrivate *psp,
return configs;
}
+static GLboolean
+intel_init_bufmgr(intelScreenPrivate *intelScreen)
+{
+ GLboolean gem_disable = getenv("INTEL_NO_GEM") != NULL;
+ int gem_kernel = 0;
+ GLboolean gem_supported;
+ struct drm_i915_getparam gp;
+ __DRIscreenPrivate *spriv = intelScreen->driScrnPriv;
+
+ intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL;
+
+ gp.param = I915_PARAM_HAS_GEM;
+ gp.value = &gem_kernel;
+
+ (void) drmCommandWriteRead(spriv->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
+
+ /* If we've got a new enough DDX that's initializing GEM and giving us
+ * object handles for the shared buffers, use that.
+ */
+ intelScreen->ttm = GL_FALSE;
+ if (intelScreen->driScrnPriv->dri2.enabled)
+ gem_supported = GL_TRUE;
+ else if (intelScreen->driScrnPriv->ddx_version.minor >= 9 &&
+ gem_kernel &&
+ intelScreen->front.bo_handle != -1)
+ gem_supported = GL_TRUE;
+ else
+ gem_supported = GL_FALSE;
+
+ if (!gem_disable && gem_supported) {
+ intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
+ if (intelScreen->bufmgr != NULL)
+ intelScreen->ttm = GL_TRUE;
+ }
+ /* Otherwise, use the classic buffer manager. */
+ if (intelScreen->bufmgr == NULL) {
+ if (gem_disable) {
+ fprintf(stderr, "GEM disabled. Using classic.\n");
+ } else {
+ fprintf(stderr, "Failed to initialize GEM. "
+ "Falling back to classic.\n");
+ }
+
+ if (intelScreen->tex.size == 0) {
+ fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
+ __func__, __LINE__);
+ return GL_FALSE;
+ }
+
+ intelScreen->bufmgr =
+ intel_bufmgr_fake_init(spriv->fd,
+ intelScreen->tex.offset,
+ intelScreen->tex.map,
+ intelScreen->tex.size,
+ (unsigned int * volatile)
+ &intelScreen->sarea->last_dispatch);
+ }
+
+ /* XXX bufmgr should be per-screen, not per-context */
+ intelScreen->ttm = intelScreen->ttm;
+
+ return GL_TRUE;
+}
/**
* This is the driver specific part of the createNewScreen entry point.
@@ -658,6 +622,7 @@ intelFillInModes(__DRIscreenPrivate *psp,
*/
static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
{
+ intelScreenPrivate *intelScreen;
#ifdef I915
static const __DRIversion ddx_expected = { 1, 5, 0 };
#else
@@ -691,6 +656,10 @@ static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
psp->extensions = intelScreenExtensions;
+ intelScreen = psp->private;
+ if (!intel_init_bufmgr(intelScreen))
+ return GL_FALSE;
+
return (const __DRIconfig **)
intelFillInModes(psp, dri_priv->cpp * 8,
(dri_priv->cpp == 2) ? 16 : 24,
@@ -750,26 +719,15 @@ __DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
intelScreen->drmMinor = psp->drm_version.minor;
- /* Determine chipset ID? */
+ /* Determine chipset ID */
if (!intel_get_param(psp, I915_PARAM_CHIPSET_ID,
&intelScreen->deviceID))
return GL_FALSE;
- /* Determine if IRQs are active? */
- if (!intel_get_param(psp, I915_PARAM_IRQ_ACTIVE,
- &intelScreen->irq_active))
- return GL_FALSE;
-
- /* Determine if batchbuffers are allowed */
- if (!intel_get_param(psp, I915_PARAM_ALLOW_BATCHBUFFER,
- &intelScreen->allow_batchbuffer))
- return GL_FALSE;
-
- if (!intelScreen->allow_batchbuffer) {
- fprintf(stderr, "batch buffer not allowed\n");
- return GL_FALSE;
- }
+ if (!intel_init_bufmgr(intelScreen))
+ return GL_FALSE;
+ intelScreen->irq_active = 1;
psp->extensions = intelScreenExtensions;
return driConcatConfigs(intelFillInModes(psp, 16, 16, 0, 1),
@@ -792,6 +750,4 @@ const struct __DriverAPIRec driDriverAPI = {
.CopySubBuffer = intelCopySubBuffer,
.InitScreen2 = intelInitScreen2,
- .HandleDrawableConfig = intelHandleDrawableConfig,
- .HandleBufferAttach = intelHandleBufferAttach,
};
diff --git a/src/mesa/drivers/dri/intel/intel_screen.h b/src/mesa/drivers/dri/intel/intel_screen.h
index 9a73b13951..daf2ab4c58 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.h
+++ b/src/mesa/drivers/dri/intel/intel_screen.h
@@ -30,6 +30,7 @@
#include <sys/time.h>
#include "dri_util.h"
+#include "intel_bufmgr.h"
#include "i915_drm.h"
#include "xmlconfig.h"
@@ -67,14 +68,18 @@ typedef struct
int logTextureGranularity;
__DRIscreenPrivate *driScrnPriv;
- unsigned int sarea_priv_offset;
+
+ volatile struct drm_i915_sarea *sarea;
int drmMinor;
int irq_active;
int allow_batchbuffer;
+ GLboolean no_hw;
+
int ttm;
+ dri_bufmgr *bufmgr;
/**
* Configuration cache with default values for all contexts
diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c
index edede3a74b..0ea8576a02 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -34,7 +34,6 @@
#include "intel_screen.h"
#include "intel_span.h"
#include "intel_regions.h"
-#include "intel_ioctl.h"
#include "intel_tex.h"
#include "swrast/swrast.h"
diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c b/src/mesa/drivers/dri/intel/intel_tex_format.c
index 349a29bd71..8ae80e1601 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_format.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_format.c
@@ -138,7 +138,7 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
- return &_mesa_texformat_z24_s8;
+ return &_mesa_texformat_s8_z24;
#ifndef I915
case GL_SRGB_EXT:
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index c11687a2cf..d1f540b0f1 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -21,7 +21,6 @@
#include "intel_buffer_objects.h"
#include "intel_batchbuffer.h"
#include "intel_tex.h"
-#include "intel_ioctl.h"
#include "intel_blit.h"
#include "intel_fbo.h"
@@ -731,7 +730,7 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
if (!intelObj)
return;
- __driParseEvents(pDRICtx, dPriv);
+ intel_update_renderbuffers(pDRICtx, dPriv);
rb = intel_fb->color_rb[0];
type = GL_BGRA;
diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c
index 1c179eb3bb..9dafb74723 100644
--- a/src/mesa/drivers/windows/gdi/wmesa.c
+++ b/src/mesa/drivers/windows/gdi/wmesa.c
@@ -118,6 +118,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC)
/* Only 16 and 32 bit targets are supported now */
assert(pwfb->cColorBits == 0 ||
pwfb->cColorBits == 16 ||
+ pwfb->cColorBits == 24 ||
pwfb->cColorBits == 32);
switch(pwfb->cColorBits){
@@ -127,6 +128,7 @@ static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC)
case 16:
pwfb->pixelformat = PF_5R6G5B;
break;
+ case 24:
case 32:
pwfb->pixelformat = PF_8R8G8B;
break;
@@ -856,6 +858,195 @@ static void read_rgba_pixels_32(const GLcontext *ctx,
/*********************************************************************/
+/* DOUBLE BUFFER 24-bit */
+
+#define WMSETPIXEL24(pwc, y, x, r, g, b) { \
+LPBYTE lpb = ((LPBYTE)((pwc)->pbPixels + (pwc)->ScanWidth * (y)) + (3 * x)); \
+lpb[0] = (b); \
+lpb[1] = (g); \
+lpb[2] = (r); }
+
+/* Write a horizontal span of RGBA color pixels with a boolean mask. */
+static void write_rgba_span_24(const GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgba[][4],
+ const GLubyte mask[] )
+{
+ WMesaContext pwc = wmesa_context(ctx);
+ WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+ GLuint i;
+ LPBYTE lpb;
+
+ (void) ctx;
+
+ y=FLIP(y);
+ lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x);
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i]) {
+ lpb[3*i] = rgba[i][BCOMP];
+ lpb[3*i+1] = rgba[i][GCOMP];
+ lpb[3*i+2] = rgba[i][RCOMP];
+ }
+ }
+ else {
+ for (i=0; i<n; i++) {
+ *lpb++ = rgba[i][BCOMP];
+ *lpb++ = rgba[i][GCOMP];
+ *lpb++ = rgba[i][RCOMP];
+ }
+ }
+}
+
+
+/* Write a horizontal span of RGB color pixels with a boolean mask. */
+static void write_rgb_span_24(const GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLubyte rgb[][3],
+ const GLubyte mask[] )
+{
+ WMesaContext pwc = wmesa_context(ctx);
+ WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+ GLuint i;
+ LPBYTE lpb;
+
+ (void) ctx;
+
+ y=FLIP(y);
+ lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x);
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i]) {
+ lpb[3*i] = rgb[i][BCOMP];
+ lpb[3*i+1] = rgb[i][GCOMP];
+ lpb[3*i+2] = rgb[i][RCOMP];
+ }
+ }
+ else {
+ for (i=0; i<n; i++) {
+ *lpb++ = rgb[i][BCOMP];
+ *lpb++ = rgb[i][GCOMP];
+ *lpb++ = rgb[i][RCOMP];
+ }
+ }
+}
+
+/*
+ * Write a horizontal span of pixels with a boolean mask. The current color
+ * is used for all pixels.
+ */
+static void write_mono_rgba_span_24(const GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLchan color[4],
+ const GLubyte mask[])
+{
+ LPBYTE lpb;
+ GLuint i;
+ WMesaContext pwc = wmesa_context(ctx);
+ WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+ lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x);
+ y=FLIP(y);
+ if (mask) {
+ for (i=0; i<n; i++)
+ if (mask[i]) {
+ lpb[3*i] = color[BCOMP];
+ lpb[3*i+1] = color[GCOMP];
+ lpb[3*i+2] = color[RCOMP];
+ }
+ }
+ else
+ for (i=0; i<n; i++) {
+ *lpb++ = color[BCOMP];
+ *lpb++ = color[GCOMP];
+ *lpb++ = color[RCOMP];
+ }
+}
+
+/* Write an array of RGBA pixels with a boolean mask. */
+static void write_rgba_pixels_24(const GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLubyte rgba[][4],
+ const GLubyte mask[])
+{
+ GLuint i;
+ WMesaContext pwc = wmesa_context(ctx);
+ WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+ for (i=0; i<n; i++)
+ if (mask[i])
+ WMSETPIXEL24(pwfb, FLIP(y[i]), x[i],
+ rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+}
+
+/*
+ * Write an array of pixels with a boolean mask. The current color
+ * is used for all pixels.
+ */
+static void write_mono_rgba_pixels_24(const GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const GLchan color[4],
+ const GLubyte mask[])
+{
+ GLuint i;
+ WMesaContext pwc = wmesa_context(ctx);
+ WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+ for (i=0; i<n; i++)
+ if (mask[i])
+ WMSETPIXEL24(pwfb, FLIP(y[i]),x[i],color[RCOMP],
+ color[GCOMP], color[BCOMP]);
+}
+
+/* Read a horizontal span of color pixels. */
+static void read_rgba_span_24(const GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4] )
+{
+ GLuint i;
+ LPBYTE lpb;
+ WMesaContext pwc = wmesa_context(ctx);
+ WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+
+ y = FLIP(y);
+ lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y)) + (3 * x);
+ for (i=0; i<n; i++) {
+ rgba[i][RCOMP] = lpb[3*i+2];
+ rgba[i][GCOMP] = lpb[3*i+1];
+ rgba[i][BCOMP] = lpb[3*i];
+ rgba[i][ACOMP] = 255;
+ }
+}
+
+
+/* Read an array of color pixels. */
+static void read_rgba_pixels_24(const GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ GLubyte rgba[][4])
+{
+ GLuint i;
+ LPBYTE lpb;
+ WMesaContext pwc = wmesa_context(ctx);
+ WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer);
+
+ for (i=0; i<n; i++) {
+ GLint y2 = FLIP(y[i]);
+ lpb = ((LPBYTE)(pwfb->pbPixels + pwfb->ScanWidth * y2)) + (3 * x[i]);
+ rgba[i][RCOMP] = lpb[3*i+2];
+ rgba[i][GCOMP] = lpb[3*i+1];
+ rgba[i][BCOMP] = lpb[3*i];
+ rgba[i][ACOMP] = 255;
+ }
+}
+
+
+/*********************************************************************/
+
/* DOUBLE BUFFER 16-bit */
#define WMSETPIXEL16(pwc, y, x, r, g, b) { \
@@ -1077,7 +1268,7 @@ wmesa_renderbuffer_storage(GLcontext *ctx,
* on if we're drawing to the front or back color buffer.
*/
void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat,
- int double_buffer)
+ BYTE cColorBits, int double_buffer)
{
if (double_buffer) {
/* back buffer */
@@ -1097,16 +1288,32 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat,
rb->BlueBits = 5;
break;
case PF_8R8G8B:
- rb->PutRow = write_rgba_span_32;
- rb->PutRowRGB = write_rgb_span_32;
- rb->PutMonoRow = write_mono_rgba_span_32;
- rb->PutValues = write_rgba_pixels_32;
- rb->PutMonoValues = write_mono_rgba_pixels_32;
- rb->GetRow = read_rgba_span_32;
- rb->GetValues = read_rgba_pixels_32;
+ if (cColorBits == 24)
+ {
+ rb->PutRow = write_rgba_span_24;
+ rb->PutRowRGB = write_rgb_span_24;
+ rb->PutMonoRow = write_mono_rgba_span_24;
+ rb->PutValues = write_rgba_pixels_24;
+ rb->PutMonoValues = write_mono_rgba_pixels_24;
+ rb->GetRow = read_rgba_span_24;
+ rb->GetValues = read_rgba_pixels_24;
+ rb->RedBits = 8;
+ rb->GreenBits = 8;
+ rb->BlueBits = 8;
+ }
+ else
+ {
+ rb->PutRow = write_rgba_span_32;
+ rb->PutRowRGB = write_rgb_span_32;
+ rb->PutMonoRow = write_mono_rgba_span_32;
+ rb->PutValues = write_rgba_pixels_32;
+ rb->PutMonoValues = write_mono_rgba_pixels_32;
+ rb->GetRow = read_rgba_span_32;
+ rb->GetValues = read_rgba_pixels_32;
rb->RedBits = 8;
rb->GreenBits = 8;
rb->BlueBits = 8;
+ }
break;
default:
break;
@@ -1413,11 +1620,11 @@ void WMesaMakeCurrent(WMesaContext c, HDC hdc)
if (visual->doubleBufferMode == 1) {
rb = wmesa_new_renderbuffer();
_mesa_add_renderbuffer(&pwfb->Base, BUFFER_BACK_LEFT, rb);
- wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, 1);
+ wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 1);
}
rb = wmesa_new_renderbuffer();
_mesa_add_renderbuffer(&pwfb->Base, BUFFER_FRONT_LEFT, rb);
- wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, 0);
+ wmesa_set_renderbuffer_funcs(rb, pwfb->pixelformat, pwfb->cColorBits, 0);
/* Let Mesa own the Depth, Stencil, and Accum buffers */
_mesa_add_soft_renderbuffers(&pwfb->Base,
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index d62661e2b5..1461239317 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 7.2
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* (C) Copyright IBM Corporation 2006
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -77,7 +77,7 @@ lookup_arrayobj(GLcontext *ctx, GLuint id)
struct gl_array_object *
_mesa_new_array_object( GLcontext *ctx, GLuint name )
{
- struct gl_array_object *obj = MALLOC_STRUCT(gl_array_object);
+ struct gl_array_object *obj = CALLOC_STRUCT(gl_array_object);
if (obj)
_mesa_initialize_array_object(ctx, obj, name);
return obj;
@@ -219,6 +219,15 @@ _mesa_remove_array_object( GLcontext *ctx, struct gl_array_object *obj )
}
+static void
+unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
+{
+ if (bufObj != ctx->Array.NullBufferObj) {
+ _mesa_reference_buffer_object(ctx, &bufObj, NULL);
+ }
+}
+
+
/**********************************************************************/
/* API Functions */
/**********************************************************************/
@@ -320,18 +329,18 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids)
/* Unbind any buffer objects that might be bound to arrays in
* this array object.
*/
- _mesa_unbind_buffer_object( ctx, obj->Vertex.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->Normal.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->Color.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->FogCoord.BufferObj );
- _mesa_unbind_buffer_object( ctx, obj->Index.BufferObj );
+ unbind_buffer_object( ctx, obj->Vertex.BufferObj );
+ unbind_buffer_object( ctx, obj->Normal.BufferObj );
+ unbind_buffer_object( ctx, obj->Color.BufferObj );
+ unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj );
+ unbind_buffer_object( ctx, obj->FogCoord.BufferObj );
+ unbind_buffer_object( ctx, obj->Index.BufferObj );
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- _mesa_unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj );
+ unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj );
}
- _mesa_unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj );
+ unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj );
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- _mesa_unbind_buffer_object( ctx, obj->VertexAttrib[i].BufferObj );
+ unbind_buffer_object( ctx, obj->VertexAttrib[i].BufferObj );
}
#endif
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index ce0733855c..1a2c34b710 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -1280,6 +1280,29 @@ adjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step)
}
+/**
+ * Copy gl_pixelstore_attrib from src to dst, updating buffer
+ * object refcounts.
+ */
+static void
+copy_pixelstore(GLcontext *ctx,
+ struct gl_pixelstore_attrib *dst,
+ const struct gl_pixelstore_attrib *src)
+{
+ dst->Alignment = src->Alignment;
+ dst->RowLength = src->RowLength;
+ dst->SkipPixels = src->SkipPixels;
+ dst->SkipRows = src->SkipRows;
+ dst->ImageHeight = src->ImageHeight;
+ dst->SkipImages = src->SkipImages;
+ dst->SwapBytes = src->SwapBytes;
+ dst->LsbFirst = src->LsbFirst;
+ dst->ClientStorage = src->ClientStorage;
+ dst->Invert = src->Invert;
+ _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
+}
+
+
#define GL_CLIENT_PACK_BIT (1<<20)
#define GL_CLIENT_UNPACK_BIT (1<<21)
@@ -1298,31 +1321,29 @@ _mesa_PushClientAttrib(GLbitfield mask)
return;
}
- /* Build linked list of attribute nodes which save all attribute */
- /* groups specified by the mask. */
+ /* Build linked list of attribute nodes which save all attribute
+ * groups specified by the mask.
+ */
head = NULL;
if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
struct gl_pixelstore_attrib *attr;
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Pack.BufferObj->RefCount++;
- ctx->Unpack.BufferObj->RefCount++;
-#endif
/* packing attribs */
- attr = MALLOC_STRUCT( gl_pixelstore_attrib );
- MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );
+ attr = CALLOC_STRUCT( gl_pixelstore_attrib );
+ copy_pixelstore(ctx, attr, &ctx->Pack);
newnode = new_attrib_node( GL_CLIENT_PACK_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
/* unpacking attribs */
- attr = MALLOC_STRUCT( gl_pixelstore_attrib );
- MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) );
+ attr = CALLOC_STRUCT( gl_pixelstore_attrib );
+ copy_pixelstore(ctx, attr, &ctx->Unpack);
newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT );
newnode->data = attr;
newnode->next = head;
head = newnode;
}
+
if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
struct gl_array_attrib *attr;
struct gl_array_object *obj;
@@ -1359,7 +1380,7 @@ _mesa_PushClientAttrib(GLbitfield mask)
void GLAPIENTRY
_mesa_PopClientAttrib(void)
{
- struct gl_attrib_node *attr, *next;
+ struct gl_attrib_node *node, *next;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
@@ -1370,37 +1391,31 @@ _mesa_PopClientAttrib(void)
}
ctx->ClientAttribStackDepth--;
- attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];
+ node = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];
- while (attr) {
- switch (attr->kind) {
+ while (node) {
+ switch (node->kind) {
case GL_CLIENT_PACK_BIT:
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Pack.BufferObj->RefCount--;
- if (ctx->Pack.BufferObj->RefCount <= 0) {
- _mesa_remove_buffer_object( ctx, ctx->Pack.BufferObj );
- (*ctx->Driver.DeleteBuffer)( ctx, ctx->Pack.BufferObj );
+ {
+ struct gl_pixelstore_attrib *store =
+ (struct gl_pixelstore_attrib *) node->data;
+ copy_pixelstore(ctx, &ctx->Pack, store);
+ _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL);
}
-#endif
- MEMCPY( &ctx->Pack, attr->data,
- sizeof(struct gl_pixelstore_attrib) );
ctx->NewState |= _NEW_PACKUNPACK;
break;
case GL_CLIENT_UNPACK_BIT:
-#if FEATURE_EXT_pixel_buffer_object
- ctx->Unpack.BufferObj->RefCount--;
- if (ctx->Unpack.BufferObj->RefCount <= 0) {
- _mesa_remove_buffer_object( ctx, ctx->Unpack.BufferObj );
- (*ctx->Driver.DeleteBuffer)( ctx, ctx->Unpack.BufferObj );
+ {
+ struct gl_pixelstore_attrib *store =
+ (struct gl_pixelstore_attrib *) node->data;
+ copy_pixelstore(ctx, &ctx->Unpack, store);
+ _mesa_reference_buffer_object(ctx, &store->BufferObj, NULL);
}
-#endif
- MEMCPY( &ctx->Unpack, attr->data,
- sizeof(struct gl_pixelstore_attrib) );
ctx->NewState |= _NEW_PACKUNPACK;
break;
case GL_CLIENT_VERTEX_ARRAY_BIT: {
struct gl_array_attrib * data =
- (struct gl_array_attrib *) attr->data;
+ (struct gl_array_attrib *) node->data;
adjust_buffer_object_ref_counts(&ctx->Array, -1);
@@ -1437,10 +1452,10 @@ _mesa_PopClientAttrib(void)
break;
}
- next = attr->next;
- FREE( attr->data );
- FREE( attr );
- attr = next;
+ next = node->next;
+ FREE( node->data );
+ FREE( node );
+ node = next;
}
}
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 8d3ddaf60f..11e1fd6b2b 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
@@ -166,22 +166,75 @@ _mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
if (bufObj->Data)
_mesa_free(bufObj->Data);
+
+ /* assign strange values here to help w/ debugging */
+ bufObj->RefCount = -1000;
+ bufObj->Name = ~0;
+
_mesa_free(bufObj);
}
+
+/**
+ * Set ptr to bufObj w/ reference counting.
+ */
void
-_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
+_mesa_reference_buffer_object(GLcontext *ctx,
+ struct gl_buffer_object **ptr,
+ struct gl_buffer_object *bufObj)
{
- if (bufObj != ctx->Array.NullBufferObj) {
- bufObj->RefCount--;
- if (bufObj->RefCount <= 0) {
+ if (*ptr == bufObj)
+ return;
+
+ if (*ptr) {
+ /* Unreference the old texture */
+ GLboolean deleteFlag = GL_FALSE;
+ struct gl_buffer_object *oldObj = *ptr;
+
+ /*_glthread_LOCK_MUTEX(oldObj->Mutex);*/
+ ASSERT(oldObj->RefCount > 0);
+ oldObj->RefCount--;
+#if 0
+ printf("BufferObj %p %d DECR to %d\n",
+ (void *) oldObj, oldObj->Name, oldObj->RefCount);
+#endif
+ deleteFlag = (oldObj->RefCount == 0);
+ /*_glthread_UNLOCK_MUTEX(oldObj->Mutex);*/
+
+ if (deleteFlag) {
+
+ /* some sanity checking: don't delete a buffer still in use */
ASSERT(ctx->Array.ArrayBufferObj != bufObj);
ASSERT(ctx->Array.ElementArrayBufferObj != bufObj);
ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj);
ASSERT(ctx->Driver.DeleteBuffer);
- ctx->Driver.DeleteBuffer(ctx, bufObj);
+
+ ctx->Driver.DeleteBuffer(ctx, oldObj);
}
+
+ *ptr = NULL;
+ }
+ ASSERT(!*ptr);
+
+ if (bufObj) {
+ /* reference new texture */
+ /*_glthread_LOCK_MUTEX(tex->Mutex);*/
+ if (bufObj->RefCount == 0) {
+ /* this buffer's being deleted (look just above) */
+ /* Not sure this can every really happen. Warn if it does. */
+ _mesa_problem(NULL, "referencing deleted buffer object");
+ *ptr = NULL;
+ }
+ else {
+ bufObj->RefCount++;
+#if 0
+ printf("BufferObj %p %d INCR to %d\n",
+ (void *) bufObj, bufObj->Name, bufObj->RefCount);
+#endif
+ *ptr = bufObj;
+ }
+ /*_glthread_UNLOCK_MUTEX(tex->Mutex);*/
}
}
@@ -204,33 +257,6 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
/**
- * Add the given buffer object to the buffer object pool.
- */
-void
-_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj )
-{
- if (obj->Name > 0) {
- /* insert into hash table */
- _mesa_HashInsert(ctx->Shared->BufferObjects, obj->Name, obj);
- }
-}
-
-
-/**
- * Remove the given buffer object from the buffer object pool.
- * Do not deallocate the buffer object though.
- */
-void
-_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
-{
- if (bufObj->Name > 0) {
- /* remove from hash table */
- _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name);
- }
-}
-
-
-/**
* Allocate space for and store data in a buffer object. Any data that was
* previously stored in the buffer object is lost. If \c data is \c NULL,
* memory will be allocated, but no copy will occur.
@@ -400,6 +426,7 @@ _mesa_init_buffer_objects( GLcontext *ctx )
{
/* Allocate the default buffer object and set refcount so high that
* it never gets deleted.
+ * XXX with recent/improved refcounting this may not longer be needed.
*/
ctx->Array.NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0);
if (ctx->Array.NullBufferObj)
@@ -462,28 +489,16 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB");
return;
}
- _mesa_save_buffer_object(ctx, newBufObj);
+ _mesa_HashInsert(ctx->Shared->BufferObjects, buffer, newBufObj);
}
}
- /* Make new binding */
- *bindTarget = newBufObj;
- newBufObj->RefCount++;
+ /* bind new buffer */
+ _mesa_reference_buffer_object(ctx, bindTarget, newBufObj);
/* Pass BindBuffer call to device driver */
if (ctx->Driver.BindBuffer && newBufObj)
ctx->Driver.BindBuffer( ctx, target, newBufObj );
-
- /* decr ref count on old buffer obj, delete if needed */
- if (oldBufObj) {
- oldBufObj->RefCount--;
- assert(oldBufObj->RefCount >= 0);
- if (oldBufObj->RefCount == 0) {
- assert(oldBufObj->Name != 0);
- ASSERT(ctx->Driver.DeleteBuffer);
- ctx->Driver.DeleteBuffer( ctx, oldBufObj );
- }
- }
}
@@ -716,6 +731,23 @@ _mesa_lookup_bufferobj(GLcontext *ctx, GLuint buffer)
}
+/**
+ * If *ptr points to obj, set ptr = the Null/default buffer object.
+ * This is a helper for buffer object deletion.
+ * The GL spec says that deleting a buffer object causes it to get
+ * unbound from all arrays in the current context.
+ */
+static void
+unbind(GLcontext *ctx,
+ struct gl_buffer_object **ptr,
+ struct gl_buffer_object *obj)
+{
+ if (*ptr == obj) {
+ _mesa_reference_buffer_object(ctx, ptr, ctx->Array.NullBufferObj);
+ }
+}
+
+
/**********************************************************************/
/* API Functions */
@@ -759,54 +791,18 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
ASSERT(bufObj->Name == ids[i]);
- if (ctx->Array.ArrayObj->Vertex.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Vertex.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->Normal.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Normal.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->Color.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Color.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->SecondaryColor.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->FogCoord.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->FogCoord.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->Index.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->Index.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
- if (ctx->Array.ArrayObj->EdgeFlag.BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
+ unbind(ctx, &ctx->Array.ArrayObj->Vertex.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->Normal.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->Color.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->SecondaryColor.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->FogCoord.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->Index.BufferObj, bufObj);
+ unbind(ctx, &ctx->Array.ArrayObj->EdgeFlag.BufferObj, bufObj);
for (j = 0; j < MAX_TEXTURE_UNITS; j++) {
- if (ctx->Array.ArrayObj->TexCoord[j].BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->TexCoord[j].BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
+ unbind(ctx, &ctx->Array.ArrayObj->TexCoord[j].BufferObj, bufObj);
}
for (j = 0; j < VERT_ATTRIB_MAX; j++) {
- if (ctx->Array.ArrayObj->VertexAttrib[j].BufferObj == bufObj) {
- bufObj->RefCount--;
- ctx->Array.ArrayObj->VertexAttrib[j].BufferObj = ctx->Array.NullBufferObj;
- ctx->Array.NullBufferObj->RefCount++;
- }
+ unbind(ctx, &ctx->Array.ArrayObj->VertexAttrib[j].BufferObj, bufObj);
}
if (ctx->Array.ArrayBufferObj == bufObj) {
@@ -824,8 +820,8 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
}
/* The ID is immediately freed for re-use */
- _mesa_remove_buffer_object(ctx, bufObj);
- _mesa_unbind_buffer_object(ctx, bufObj);
+ _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name);
+ _mesa_reference_buffer_object(ctx, &bufObj, NULL);
}
}
@@ -874,7 +870,7 @@ _mesa_GenBuffersARB(GLsizei n, GLuint *buffer)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenBuffersARB");
return;
}
- _mesa_save_buffer_object(ctx, bufObj);
+ _mesa_HashInsert(ctx->Shared->BufferObjects, first + i, bufObj);
buffer[i] = first + i;
}
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 537b240474..3c08f0083c 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
@@ -55,10 +55,9 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
GLuint name, GLenum target );
extern void
-_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj );
-
-extern void
-_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj );
+_mesa_reference_buffer_object(GLcontext *ctx,
+ struct gl_buffer_object **ptr,
+ struct gl_buffer_object *bufObj);
extern void
_mesa_buffer_data( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
@@ -117,8 +116,6 @@ _mesa_unmap_readpix_pbo(GLcontext *ctx,
const struct gl_pixelstore_attrib *pack);
-extern void
-_mesa_unbind_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj );
/*
* API functions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 40a2c1b0a8..8dfbfeb62e 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.1
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index aba887a796..af78363ad3 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -569,13 +569,13 @@ _mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
if (fb->Attachment[BUFFER_ACCUM].Renderbuffer) {
fb->Visual.haveAccumBuffer = GL_TRUE;
fb->Visual.accumRedBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->RedBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->RedBits;
fb->Visual.accumGreenBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->GreenBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->GreenBits;
fb->Visual.accumBlueBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->BlueBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->BlueBits;
fb->Visual.accumAlphaBits
- = fb->Attachment[BUFFER_DEPTH].Renderbuffer->AlphaBits;
+ = fb->Attachment[BUFFER_ACCUM].Renderbuffer->AlphaBits;
}
compute_depth_max(fb);
diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
index 48c815772d..1a82ccce59 100644
--- a/src/mesa/main/getstring.c
+++ b/src/mesa/main/getstring.c
@@ -85,7 +85,7 @@ compute_version(const GLcontext *ctx)
ctx->Extensions.ARB_texture_non_power_of_two &&
ctx->Extensions.EXT_blend_equation_separate);
const GLboolean ver_2_1 = (ver_2_0 &&
- ctx->Extensions.ARB_shading_language_120 &&
+ /*ctx->Extensions.ARB_shading_language_120 &&*/
ctx->Extensions.EXT_pixel_buffer_object &&
ctx->Extensions.EXT_texture_sRGB);
if (ver_2_1)
@@ -121,12 +121,6 @@ _mesa_GetString( GLenum name )
static const char *vendor = "Brian Paul";
static const char *renderer = "Mesa";
-#if FEATURE_ARB_shading_language_120_foo /* support not complete! */
- static const char *sl_version = "1.20";
-#elif FEATURE_ARB_shading_language_100
- static const char *sl_version = "1.10";
-#endif
-
if (!ctx)
return NULL;
@@ -154,8 +148,10 @@ _mesa_GetString( GLenum name )
return (const GLubyte *) ctx->Extensions.String;
#if FEATURE_ARB_shading_language_100
case GL_SHADING_LANGUAGE_VERSION_ARB:
- if (ctx->Extensions.ARB_shading_language_100)
- return (const GLubyte *) sl_version;
+ if (ctx->Extensions.ARB_shading_language_120)
+ return (const GLubyte *) "1.20";
+ else if (ctx->Extensions.ARB_shading_language_100)
+ return (const GLubyte *) "1.10";
goto error;
#endif
#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 1307bae0d6..6cfd7ccc72 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -559,7 +559,7 @@ _mesa_pow(double x, double y)
int
_mesa_ffs(int32_t i)
{
-#if (defined(_WIN32) && !defined(__MINGW32__) ) || defined(__IBMC__) || defined(__IBMCPP__)
+#if (defined(_WIN32) ) || defined(__IBMC__) || defined(__IBMCPP__)
register int bit = 0;
if (i != 0) {
if ((i & 0xffff) == 0) {
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 30e1908771..d4db960f1b 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -184,6 +184,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
GET_CURRENT_CONTEXT(ctx);
GLint i = (GLint) (light - GL_LIGHT0);
GLfloat temp[4];
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
if (i < 0 || i >= (GLint) ctx->Const.MaxLights) {
_mesa_error( ctx, GL_INVALID_ENUM, "glLight(light=0x%x)", light );
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 39f9d1ddb0..57419aa2f3 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -2507,8 +2507,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
dstRow += dstRowStride / sizeof(GLuint);
}
}
- }
- else {
+ } else {
for (img = 0; img < srcDepth; img++) {
GLuint *dstRow = (GLuint *) dstAddr
+ dstImageOffsets[dstZoffset + img]
@@ -2522,7 +2521,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
for (row = 0; row < srcHeight; row++) {
GLubyte stencil[MAX_WIDTH];
GLint i;
- /* the 24 depth bits will be in the high position: */
+ /* the 24 depth bits will be in the low position: */
_mesa_unpack_depth_span(ctx, srcWidth,
GL_UNSIGNED_INT, /* dst type */
dstRow, /* dst addr */
@@ -2536,7 +2535,7 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
ctx->_ImageTransferState);
/* merge stencil values into depth values */
for (i = 0; i < srcWidth; i++)
- dstRow[i] = stencil[i] << 24;
+ dstRow[i] |= stencil[i] << 24;
src += srcRowStride;
dstRow += dstRowStride / sizeof(GLuint);
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 234b712f7f..9d9b28b518 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -62,14 +62,9 @@ update_array(GLcontext *ctx, struct gl_client_array *array,
array->Normalized = normalized;
array->Ptr = (const GLubyte *) ptr;
#if FEATURE_ARB_vertex_buffer_object
- array->BufferObj->RefCount--;
- if (array->BufferObj->RefCount <= 0) {
- ASSERT(array->BufferObj->Name);
- _mesa_remove_buffer_object( ctx, array->BufferObj );
- (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj );
- }
- array->BufferObj = ctx->Array.ArrayBufferObj;
- array->BufferObj->RefCount++;
+ _mesa_reference_buffer_object(ctx, &array->BufferObj,
+ ctx->Array.ArrayBufferObj);
+
/* Compute the index of the last array element that's inside the buffer.
* Later in glDrawArrays we'll check if start + count > _MaxElement to
* be sure we won't go out of bounds.
diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c
index 5ef0f7e705..ca1df04868 100644
--- a/src/mesa/tnl/t_vp_build.c
+++ b/src/mesa/tnl/t_vp_build.c
@@ -35,6 +35,437 @@
#include "t_vp_build.h"
+struct state_key {
+ unsigned light_global_enabled:1;
+ unsigned light_local_viewer:1;
+ unsigned light_twoside:1;
+ unsigned light_color_material:1;
+ unsigned light_color_material_mask:12;
+ unsigned light_material_mask:12;
+
+ unsigned normalize:1;
+ unsigned rescale_normals:1;
+ unsigned fog_source_is_depth:1;
+ unsigned tnl_do_vertex_fog:1;
+ unsigned separate_specular:1;
+ unsigned fog_mode:2;
+ unsigned point_attenuated:1;
+ unsigned texture_enabled_global:1;
+ unsigned fragprog_inputs_read:12;
+
+ struct {
+ unsigned light_enabled:1;
+ unsigned light_eyepos3_is_zero:1;
+ unsigned light_spotcutoff_is_180:1;
+ unsigned light_attenuated:1;
+ unsigned texunit_really_enabled:1;
+ unsigned texmat_enabled:1;
+ unsigned texgen_enabled:4;
+ unsigned texgen_mode0:4;
+ unsigned texgen_mode1:4;
+ unsigned texgen_mode2:4;
+ unsigned texgen_mode3:4;
+ } unit[8];
+};
+
+
+
+#define FOG_NONE 0
+#define FOG_LINEAR 1
+#define FOG_EXP 2
+#define FOG_EXP2 3
+
+static GLuint translate_fog_mode( GLenum mode )
+{
+ switch (mode) {
+ case GL_LINEAR: return FOG_LINEAR;
+ case GL_EXP: return FOG_EXP;
+ case GL_EXP2: return FOG_EXP2;
+ default: return FOG_NONE;
+ }
+}
+
+#define TXG_NONE 0
+#define TXG_OBJ_LINEAR 1
+#define TXG_EYE_LINEAR 2
+#define TXG_SPHERE_MAP 3
+#define TXG_REFLECTION_MAP 4
+#define TXG_NORMAL_MAP 5
+
+static GLuint translate_texgen( GLboolean enabled, GLenum mode )
+{
+ if (!enabled)
+ return TXG_NONE;
+
+ switch (mode) {
+ case GL_OBJECT_LINEAR: return TXG_OBJ_LINEAR;
+ case GL_EYE_LINEAR: return TXG_EYE_LINEAR;
+ case GL_SPHERE_MAP: return TXG_SPHERE_MAP;
+ case GL_REFLECTION_MAP_NV: return TXG_REFLECTION_MAP;
+ case GL_NORMAL_MAP_NV: return TXG_NORMAL_MAP;
+ default: return TXG_NONE;
+ }
+}
+
+static struct state_key *make_state_key( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
+ struct state_key *key = CALLOC_STRUCT(state_key);
+ GLuint i;
+
+ /* This now relies on texenvprogram.c being active:
+ */
+ assert(fp);
+
+ key->fragprog_inputs_read = fp->Base.InputsRead;
+
+ key->separate_specular = (ctx->Light.Model.ColorControl ==
+ GL_SEPARATE_SPECULAR_COLOR);
+
+ if (ctx->Light.Enabled) {
+ key->light_global_enabled = 1;
+
+ if (ctx->Light.Model.LocalViewer)
+ key->light_local_viewer = 1;
+
+ if (ctx->Light.Model.TwoSide)
+ key->light_twoside = 1;
+
+ if (ctx->Light.ColorMaterialEnabled) {
+ key->light_color_material = 1;
+ key->light_color_material_mask = ctx->Light.ColorMaterialBitmask;
+ }
+
+ for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++)
+ if (VB->AttribPtr[i]->stride)
+ key->light_material_mask |= 1<<(i-_TNL_ATTRIB_MAT_FRONT_AMBIENT);
+
+ for (i = 0; i < MAX_LIGHTS; i++) {
+ struct gl_light *light = &ctx->Light.Light[i];
+
+ if (light->Enabled) {
+ key->unit[i].light_enabled = 1;
+
+ if (light->EyePosition[3] == 0.0)
+ key->unit[i].light_eyepos3_is_zero = 1;
+
+ if (light->SpotCutoff == 180.0)
+ key->unit[i].light_spotcutoff_is_180 = 1;
+
+ if (light->ConstantAttenuation != 1.0 ||
+ light->LinearAttenuation != 0.0 ||
+ light->QuadraticAttenuation != 0.0)
+ key->unit[i].light_attenuated = 1;
+ }
+ }
+ }
+
+ if (ctx->Transform.Normalize)
+ key->normalize = 1;
+
+ if (ctx->Transform.RescaleNormals)
+ key->rescale_normals = 1;
+
+ key->fog_mode = translate_fog_mode(fp->FogOption);
+
+ if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT)
+ key->fog_source_is_depth = 1;
+
+ if (tnl->_DoVertexFog)
+ key->tnl_do_vertex_fog = 1;
+
+ if (ctx->Point._Attenuated)
+ key->point_attenuated = 1;
+
+ if (ctx->Texture._TexGenEnabled ||
+ ctx->Texture._TexMatEnabled ||
+ ctx->Texture._EnabledUnits)
+ key->texture_enabled_global = 1;
+
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+
+ if (texUnit->_ReallyEnabled)
+ key->unit[i].texunit_really_enabled = 1;
+
+ if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i))
+ key->unit[i].texmat_enabled = 1;
+
+ if (texUnit->TexGenEnabled) {
+ key->unit[i].texgen_enabled = 1;
+
+ key->unit[i].texgen_mode0 =
+ translate_texgen( texUnit->TexGenEnabled & (1<<0),
+ texUnit->GenModeS );
+ key->unit[i].texgen_mode1 =
+ translate_texgen( texUnit->TexGenEnabled & (1<<1),
+ texUnit->GenModeT );
+ key->unit[i].texgen_mode2 =
+ translate_texgen( texUnit->TexGenEnabled & (1<<2),
+ texUnit->GenModeR );
+ key->unit[i].texgen_mode3 =
+ translate_texgen( texUnit->TexGenEnabled & (1<<3),
+ texUnit->GenModeQ );
+ }
+ }
+
+ return key;
+}
+
+
+
+/* Very useful debugging tool - produces annotated listing of
+ * generated program with line/function references for each
+ * instruction back into this file:
+ */
+#define DISASSEM (MESA_VERBOSE&VERBOSE_DISASSEM)
+
+/* Should be tunable by the driver - do we want to do matrix
+ * multiplications with DP4's or with MUL/MAD's? SSE works better
+ * with the latter, drivers may differ.
+ */
+#define PREFER_DP4 0
+
+#define MAX_INSN 350
+
+/* Use uregs to represent registers internally, translate to Mesa's
+ * expected formats on emit.
+ *
+ * NOTE: These are passed by value extensively in this file rather
+ * than as usual by pointer reference. If this disturbs you, try
+ * remembering they are just 32bits in size.
+ *
+ * GCC is smart enough to deal with these dword-sized structures in
+ * much the same way as if I had defined them as dwords and was using
+ * macros to access and set the fields. This is much nicer and easier
+ * to evolve.
+ */
+struct ureg {
+ GLuint file:4;
+ GLint idx:8; /* relative addressing may be negative */
+ GLuint negate:1;
+ GLuint swz:12;
+ GLuint pad:7;
+};
+
+
+struct tnl_program {
+ const struct state_key *state;
+ struct gl_vertex_program *program;
+
+ GLuint temp_in_use;
+ GLuint temp_reserved;
+
+ struct ureg eye_position;
+ struct ureg eye_position_normalized;
+ struct ureg eye_normal;
+ struct ureg identity;
+
+ GLuint materials;
+ GLuint color_materials;
+};
+
+
+static const struct ureg undef = {
+ PROGRAM_UNDEFINED,
+ ~0,
+ 0,
+ 0,
+ 0
+};
+
+/* Local shorthand:
+ */
+#define X SWIZZLE_X
+#define Y SWIZZLE_Y
+#define Z SWIZZLE_Z
+#define W SWIZZLE_W
+
+
+/* Construct a ureg:
+ */
+static struct ureg make_ureg(GLuint file, GLint idx)
+{
+ struct ureg reg;
+ reg.file = file;
+ reg.idx = idx;
+ reg.negate = 0;
+ reg.swz = SWIZZLE_NOOP;
+ reg.pad = 0;
+ return reg;
+}
+
+
+
+static struct ureg negate( struct ureg reg )
+{
+ reg.negate ^= 1;
+ return reg;
+}
+
+
+static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w )
+{
+ reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x),
+ GET_SWZ(reg.swz, y),
+ GET_SWZ(reg.swz, z),
+ GET_SWZ(reg.swz, w));
+
+ return reg;
+}
+
+static struct ureg swizzle1( struct ureg reg, int x )
+{
+ return swizzle(reg, x, x, x, x);
+}
+
+static struct ureg get_temp( struct tnl_program *p )
+{
+ int bit = _mesa_ffs( ~p->temp_in_use );
+ if (!bit) {
+ _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
+ _mesa_exit(1);
+ }
+
+ if ((GLuint) bit > p->program->Base.NumTemporaries)
+ p->program->Base.NumTemporaries = bit;
+
+ p->temp_in_use |= 1<<(bit-1);
+ return make_ureg(PROGRAM_TEMPORARY, bit-1);
+}
+
+static struct ureg reserve_temp( struct tnl_program *p )
+{
+ struct ureg temp = get_temp( p );
+ p->temp_reserved |= 1<<temp.idx;
+ return temp;
+}
+
+static void release_temp( struct tnl_program *p, struct ureg reg )
+{
+ if (reg.file == PROGRAM_TEMPORARY) {
+ p->temp_in_use &= ~(1<<reg.idx);
+ p->temp_in_use |= p->temp_reserved; /* can't release reserved temps */
+ }
+}
+
+static void release_temps( struct tnl_program *p )
+{
+ p->temp_in_use = p->temp_reserved;
+}
+
+
+
+static struct ureg register_input( struct tnl_program *p, GLuint input )
+{
+ p->program->Base.InputsRead |= (1<<input);
+ return make_ureg(PROGRAM_INPUT, input);
+}
+
+static struct ureg register_output( struct tnl_program *p, GLuint output )
+{
+ p->program->Base.OutputsWritten |= (1<<output);
+ return make_ureg(PROGRAM_OUTPUT, output);
+}
+
+static struct ureg register_const4f( struct tnl_program *p,
+ GLfloat s0,
+ GLfloat s1,
+ GLfloat s2,
+ GLfloat s3)
+{
+ GLfloat values[4];
+ GLint idx;
+ GLuint swizzle;
+ values[0] = s0;
+ values[1] = s1;
+ values[2] = s2;
+ values[3] = s3;
+ idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
+ &swizzle );
+ ASSERT(swizzle == SWIZZLE_NOOP);
+ return make_ureg(PROGRAM_STATE_VAR, idx);
+}
+
+#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1)
+#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0)
+#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1)
+#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1)
+
+static GLboolean is_undef( struct ureg reg )
+{
+ return reg.file == PROGRAM_UNDEFINED;
+}
+
+static struct ureg get_identity_param( struct tnl_program *p )
+{
+ if (is_undef(p->identity))
+ p->identity = register_const4f(p, 0,0,0,1);
+
+ return p->identity;
+}
+
+static struct ureg register_param5(struct tnl_program *p,
+ GLint s0,
+ GLint s1,
+ GLint s2,
+ GLint s3,
+ GLint s4)
+{
+ gl_state_index tokens[STATE_LENGTH];
+ GLint idx;
+ tokens[0] = s0;
+ tokens[1] = s1;
+ tokens[2] = s2;
+ tokens[3] = s3;
+ tokens[4] = s4;
+ idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens );
+ return make_ureg(PROGRAM_STATE_VAR, idx);
+}
+
+
+#define register_param1(p,s0) register_param5(p,s0,0,0,0,0)
+#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0)
+#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0)
+#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0)
+
+
+static void register_matrix_param5( struct tnl_program *p,
+ GLint s0, /* modelview, projection, etc */
+ GLint s1, /* texture matrix number */
+ GLint s2, /* first row */
+ GLint s3, /* last row */
+ GLint s4, /* inverse, transpose, etc */
+ struct ureg *matrix )
+{
+ GLint i;
+
+ /* This is a bit sad as the support is there to pull the whole
+ * matrix out in one go:
+ */
+ for (i = 0; i <= s3 - s2; i++)
+ matrix[i] = register_param5( p, s0, s1, i, i, s4 );
+}
+
+
+/**
+ * Convert a ureg source register to a prog_src_register.
+ */
+static void emit_arg( struct prog_src_register *src,
+ struct ureg reg )
+{
+ assert(reg.file != PROGRAM_OUTPUT);
+ src->File = reg.file;
+ src->Index = reg.idx;
+ src->Swizzle = reg.swz;
+ src->NegateBase = reg.negate ? NEGATE_XYZW : 0;
+ src->Abs = 0;
+ src->NegateAbs = 0;
+ src->RelAddr = 0;
+}
+
/**
* XXX This should go away someday, but still referenced by some drivers...
*/
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 579bbeb4f3..d70b4bb1a1 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -1,6 +1,6 @@
/**************************************************************************
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
+Copyright 2002-2008 Tungsten Graphics Inc., Cedar Park, Texas.
All Rights Reserved.
@@ -31,6 +31,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "main/glheader.h"
+#include "main/bufferobj.h"
#include "main/context.h"
#include "main/macros.h"
#include "main/vtxfmt.h"
@@ -695,7 +696,10 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
* continuously, unless vbo_use_buffer_objects() is called to enable
* use of real VBOs.
*/
- exec->vtx.bufferobj = ctx->Array.NullBufferObj;
+ _mesa_reference_buffer_object(ctx,
+ &exec->vtx.bufferobj,
+ ctx->Array.NullBufferObj);
+
exec->vtx.buffer_map = ALIGN_MALLOC(VBO_VERT_BUFFER_SIZE * sizeof(GLfloat), 64);
vbo_exec_vtxfmt_init( exec );
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 3609a7452a..1d095c772f 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -26,6 +26,7 @@
*/
#include "main/glheader.h"
+#include "main/bufferobj.h"
#include "main/context.h"
#include "main/enums.h"
#include "main/state.h"
@@ -155,8 +156,12 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
*/
switch (get_program_mode(exec->ctx)) {
case VP_NONE:
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->mat_currval, MAT_ATTRIB_MAX * sizeof(arrays[0]));
+ for (attr = 0; attr < 16; attr++) {
+ exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
+ }
+ for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
+ exec->vtx.inputs[attr + 16] = &vbo->mat_currval[attr];
+ }
map = vbo->map_vp_none;
break;
case VP_NV:
@@ -165,8 +170,10 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
* occurred. NV vertex programs cannot access material values,
* nor attributes greater than VERT_ATTRIB_TEX7.
*/
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
+ for (attr = 0; attr < 16; attr++) {
+ exec->vtx.inputs[attr] = &vbo->legacy_currval[attr];
+ exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr];
+ }
map = vbo->map_vp_arb;
break;
}
@@ -178,24 +185,18 @@ static void vbo_exec_bind_arrays( GLcontext *ctx )
const GLuint src = map[attr];
if (exec->vtx.attrsz[src]) {
- if (exec->vtx.bufferobj->Name) {
- /* a real buffer obj: Ptr is an offset, not a pointer*/
- int offset;
- assert(exec->vtx.bufferobj->Pointer); /* buf should be mapped */
- offset = (GLbyte *) data - (GLbyte *) exec->vtx.bufferobj->Pointer;
- assert(offset >= 0);
- arrays[attr].Ptr = (void *) offset;
- }
- else {
- /* Ptr into ordinary app memory */
- arrays[attr].Ptr = (void *) data;
- }
+ /* override the default array set above */
+ exec->vtx.inputs[attr] = &arrays[attr];
+
+ arrays[attr].Ptr = (void *)data;
arrays[attr].Size = exec->vtx.attrsz[src];
arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat);
arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat);
arrays[attr].Type = GL_FLOAT;
arrays[attr].Enabled = 1;
- arrays[attr].BufferObj = exec->vtx.bufferobj;
+ _mesa_reference_buffer_object(ctx,
+ &arrays[attr].BufferObj,
+ exec->vtx.bufferobj);
arrays[attr]._MaxElement = count; /* ??? */
data += exec->vtx.attrsz[src] * sizeof(GLfloat);
diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c
index 8dd87141c0..9757c3d9f6 100644
--- a/src/mesa/vbo/vbo_save.c
+++ b/src/mesa/vbo/vbo_save.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 7.2
*
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,6 +27,7 @@
#include "main/mtypes.h"
+#include "main/bufferobj.h"
#include "main/dlist.h"
#include "main/vtxfmt.h"
#include "main/imports.h"
@@ -71,19 +72,24 @@ void vbo_save_destroy( GLcontext *ctx )
{
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_save_context *save = &vbo->save;
+ GLuint i;
+
if (save->prim_store) {
if ( --save->prim_store->refcount == 0 ) {
FREE( save->prim_store );
save->prim_store = NULL;
}
if ( --save->vertex_store->refcount == 0 ) {
- if (save->vertex_store->bufferobj)
- ctx->Driver.DeleteBuffer( ctx, save->vertex_store->bufferobj );
-
+ _mesa_reference_buffer_object(ctx,
+ &save->vertex_store->bufferobj, NULL);
FREE( save->vertex_store );
save->vertex_store = NULL;
}
}
+
+ for (i = 0; i < VBO_ATTRIB_MAX; i++) {
+ _mesa_reference_buffer_object(ctx, &save->arrays[i].BufferObj, NULL);
+ }
}
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index f62be5c14c..88d573f128 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -1,6 +1,6 @@
/**************************************************************************
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
+Copyright 2002-2008 Tungsten Graphics Inc., Cedar Park, Texas.
All Rights Reserved.
@@ -68,6 +68,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "main/glheader.h"
+#include "main/bufferobj.h"
#include "main/context.h"
#include "main/dlist.h"
#include "main/enums.h"
@@ -85,6 +86,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
+/* An interesting VBO number/name to help with debugging */
+#define VBO_BUF_ID 12345
+
+
/*
* NOTE: Old 'parity' issue is gone, but copying can still be
* wrong-footed on replay.
@@ -170,7 +175,9 @@ static struct vbo_save_vertex_store *alloc_vertex_store( GLcontext *ctx )
* user. Perhaps there could be a special number for internal
* buffers:
*/
- vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB);
+ vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx,
+ VBO_BUF_ID,
+ GL_ARRAY_BUFFER_ARB);
ctx->Driver.BufferData( ctx,
GL_ARRAY_BUFFER_ARB,
@@ -190,8 +197,9 @@ static void free_vertex_store( GLcontext *ctx, struct vbo_save_vertex_store *ver
{
assert(!vertex_store->buffer);
- if (vertex_store->bufferobj)
- ctx->Driver.DeleteBuffer( ctx, vertex_store->bufferobj );
+ if (vertex_store->bufferobj) {
+ _mesa_reference_buffer_object(ctx, &vertex_store->bufferobj, NULL);
+ }
FREE( vertex_store );
}
@@ -1139,6 +1147,7 @@ void vbo_save_api_init( struct vbo_save_context *save )
_save_vtxfmt_init( ctx );
_save_current_init( ctx );
+ /* These will actually get set again when binding/drawing */
for (i = 0; i < VBO_ATTRIB_MAX; i++)
save->inputs[i] = &save->arrays[i];
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index bf5c6d4eef..ed82f09958 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 7.2
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,6 +27,7 @@
*/
#include "main/glheader.h"
+#include "main/bufferobj.h"
#include "main/context.h"
#include "main/imports.h"
#include "main/mtypes.h"
@@ -115,8 +116,12 @@ static void vbo_bind_vertex_list( GLcontext *ctx,
*/
switch (get_program_mode(ctx)) {
case VP_NONE:
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->mat_currval, MAT_ATTRIB_MAX * sizeof(arrays[0]));
+ for (attr = 0; attr < 16; attr++) {
+ save->inputs[attr] = &vbo->legacy_currval[attr];
+ }
+ for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
+ save->inputs[attr + 16] = &vbo->mat_currval[attr];
+ }
map = vbo->map_vp_none;
break;
case VP_NV:
@@ -125,8 +130,10 @@ static void vbo_bind_vertex_list( GLcontext *ctx,
* occurred. NV vertex programs cannot access material values,
* nor attributes greater than VERT_ATTRIB_TEX7.
*/
- memcpy(arrays, vbo->legacy_currval, 16 * sizeof(arrays[0]));
- memcpy(arrays + 16, vbo->generic_currval, 16 * sizeof(arrays[0]));
+ for (attr = 0; attr < 16; attr++) {
+ save->inputs[attr] = &vbo->legacy_currval[attr];
+ save->inputs[attr + 16] = &vbo->generic_currval[attr];
+ }
map = vbo->map_vp_arb;
break;
}
@@ -135,13 +142,18 @@ static void vbo_bind_vertex_list( GLcontext *ctx,
GLuint src = map[attr];
if (node->attrsz[src]) {
- arrays[attr].Ptr = (const GLubyte *)data;
+ /* override the default array set above */
+ save->inputs[attr] = &arrays[attr];
+
+ arrays[attr].Ptr = (const GLubyte *) data;
arrays[attr].Size = node->attrsz[src];
arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat);
arrays[attr].Stride = node->vertex_size * sizeof(GLfloat);
arrays[attr].Type = GL_FLOAT;
arrays[attr].Enabled = 1;
- arrays[attr].BufferObj = node->vertex_store->bufferobj;
+ _mesa_reference_buffer_object(ctx,
+ &arrays[attr].BufferObj,
+ node->vertex_store->bufferobj);
arrays[attr]._MaxElement = node->count; /* ??? */
assert(arrays[attr].BufferObj->Name);