diff --git a/mesa-6.5.2-hush-synthetic-visual-warning.patch b/mesa-6.5.2-hush-synthetic-visual-warning.patch deleted file mode 100644 index a9dd39d..0000000 --- a/mesa-6.5.2-hush-synthetic-visual-warning.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Mesa-6.5.2/src/glx/x11/glxext.c.jx 2006-11-15 09:55:47.000000000 -0500 -+++ Mesa-6.5.2/src/glx/x11/glxext.c 2007-01-16 10:48:15.000000000 -0500 -@@ -666,6 +666,8 @@ - if ( do_delete && (m->visualID != 0) ) { - do_delete = GL_FALSE; - -+ if (m->visualRating != GLX_NON_CONFORMANT_VISUAL_EXT || -+ getenv("LIBGL_DEBUG")) - fprintf(stderr, "libGL warning: 3D driver claims to not support " - "visual 0x%02x\n", m->visualID); - } diff --git a/mesa-7.0-i-already-defined-glapi-you-twit.patch b/mesa-7.0-i-already-defined-glapi-you-twit.patch deleted file mode 100644 index 62321fc..0000000 --- a/mesa-7.0-i-already-defined-glapi-you-twit.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff -up mesa-20070725/include/GL/glu.h.jx mesa-20070725/include/GL/glu.h ---- mesa-20070725/include/GL/glu.h.jx 2007-07-25 09:36:03.000000000 -0400 -+++ mesa-20070725/include/GL/glu.h 2007-07-25 10:27:49.000000000 -0400 -@@ -44,19 +44,6 @@ - #define GLAPIENTRYP GLAPIENTRY * - #endif - --#ifdef GLAPI --#undef GLAPI --#endif -- --# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32) --# define GLAPI __declspec(dllexport) --# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ --# define GLAPI __declspec(dllimport) --# else /* for use with static link lib build of Win32 edition only */ --# define GLAPI extern --# endif /* _STATIC_MESA support */ -- -- - #ifndef GLAPI - #define GLAPI - #endif diff --git a/mesa-7.0.1-965-sampler-crash.patch b/mesa-7.0.1-965-sampler-crash.patch deleted file mode 100644 index eb566d1..0000000 --- a/mesa-7.0.1-965-sampler-crash.patch +++ /dev/null @@ -1,19 +0,0 @@ -commit 410d8f7cdb40889e66f5c6794878ad9a5f572ee7 -Author: Xiang, Haihao -Date: Wed Aug 29 10:13:10 2007 -0400 - - i965: samplers group in fours in WM_STATE. fix bug#9415 - -diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c -index ff5cb31..5b4f2ab 100644 ---- a/src/mesa/drivers/dri/i965/brw_wm_state.c -+++ b/src/mesa/drivers/dri/i965/brw_wm_state.c -@@ -117,7 +117,7 @@ static void upload_wm_unit(struct brw_context *brw ) - wm.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754; - - /* CACHE_NEW_SAMPLER */ -- wm.wm4.sampler_count = brw->wm.sampler_count; -+ wm.wm4.sampler_count = (brw->wm.sampler_count + 1) / 4; - wm.wm4.sampler_state_pointer = brw->wm.sampler_gs_offset >> 5; - - /* BRW_NEW_FRAGMENT_PROGRAM */ diff --git a/mesa-7.0.1-stable-branch.patch b/mesa-7.0.1-stable-branch.patch index d419048..5c8ef35 100644 --- a/mesa-7.0.1-stable-branch.patch +++ b/mesa-7.0.1-stable-branch.patch @@ -1,4 +1,7 @@ -Brian (21): +Adam Jackson (1): + Unbreak Linux builds with -fvisibility=hidden. + +Brian (64): added md5 sums fix even-sized point positioning (bug 11874) Merge branch 'mesa_7_0_branch' of git+ssh://brianp@git.freedesktop.org/git/mesa/mesa into mesa_7_0_branch @@ -20,18 +23,101 @@ Brian (21): added some temporary texobj ref counting debug output more tex obj ref count debugging (temporary) Added _mesa_free_attrib_data() to free anything left in the attribute stack upon context destruction. + copy Target in _mesa_copy_texture_object() + Rewrite quite a bit of the code for glPush/PopAttrib() for texture state. + more debug output (context destroy, fb destroy) + log deleting/binding of FBOs + Remove recent texobj refcount debug/logging code. + don't map buffer in _mesa_validate_DrawElements() unless needed + refactor bounds checking code + remove unneeded CallStack array + remove CallDepth++/-- accidentally removed in prev commit + new __gluInvertMatrix() function (Mesa bug 6748) + Fixed bugs 6748, 12141 + s/movaps/movups/ (see bug 12216) + fix i965 bugs, x86-64 bugs + sync with trunk, fixing bug 12239 + Use temporary matrix in __gluInvertMatrixd() to fix aliasing problem (see bugs 12269, 6748) + updated VC7 project files + clean-up (see bug 12317) + fix comment + Update depth test state when binding new framebuffer object + In _mesa_make_current(), don't unbind FBOs from the old context. + fix indirect rendering crash + updated with pkg-config info + added DSTDIR, pkg-config items + added .pc.in files to tarballs + Fix state.texgen parsing error (bug 12313). + added program_error2() function for better error reporting + fix ARB fp/vp parsing bug 12313 + fix copypixels overlap test bug (#12417) + fix glCopyPixel/glPixelZoom bug 12417) + updated link + From trunk: mesa: bind VBO_ATTRIB_XXX to correct input array when executing a display list. fix #10604 + fix bug 10604 + Added bluegene-xlc-osmesa config (Alexander Neundorf) + fixes for bluegene-xlc-osmesa config + added bluegene-xlc-osmesa, fortran fixes + fix for __IBMC__ + fix -D_BSD_SOURC + fix DrawRangeElements error msg + Restore old _TriangleCaps code to fix Blender problem (bug 12164) + fix blend bug 12164 + bump versions to 7.0.2 + for Miniglx, use git sources + prep for 7.0.2 release + +Christoph Kubisch (1): + updated VC7 project files + +Colin McDonald (1): + fixed problem with big glDrawArrays (see bug 12141) + +Dan Nicholson (2): + DESTDIR support. + pkg-config support Dan Torop (1): fix spantmp2 READ_RGBA inline asm (#11931) -Michel Dänzer (1): +Dave Airlie (1): + i965: fix vblank on 965gm laptops by bringing in code from i915 + +Michel Dänzer (2): i915tex: Make sure pitch is aligned properly for render-to-texture. + i915tex: Unreference texture buffers on context destruction. + +Roland Bär (1): + [i965] Bug #11812: Fix fwrite return value checks in AUB file code. + +Roland Scheidegger (2): + suppress warning about ncon visuals (bug #6689) + fix another occurence of movaps which might not be aligned Wang Zhenyu (1): i915tex: Add support for 945GME +Xiang, Haihao (13): + i965: flush batch buffer when getting the maximum. This makes + i965: samplers group in fours in WM_STATE. fix bug#9415 + i965: check NULL pointer. fix bug#12193 + i965: store read drawable info in intel_context. Some OpenGL + i965: Take the upper limitation on LOD into account. + fix bug#11009 + i965: limit on LOD Bias, fix#11987 + i965: take the secondary color into account when drawing + i965: fix #11378 + i965: fix bug#11925 + i965: The cube map texture coordinates must be devided by the + i965: handle all unfilled mode in clip stage. fix bug #12453 + mesa: make sure the gotten value isn't greater than the + +Zou Nan hai (2): + fix a bug in 965 ARB_occlusion_query, + fix fd.o bug #12217, recalcuate urb when clip plane size change + diff --git a/Makefile b/Makefile -index 3cab262..56efa83 100644 +index 3cab262..e05e0e6 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ @@ -42,7 +128,15 @@ index 3cab262..56efa83 100644 TOP = . SUBDIRS = src progs -@@ -156,7 +154,7 @@ sunos5-v9 \ +@@ -70,6 +68,7 @@ aix-gcc \ + aix-static \ + beos \ + bluegene-osmesa \ ++bluegene-xlc-osmesa \ + darwin \ + darwin-static \ + darwin-static-x86ppc \ +@@ -156,7 +155,7 @@ sunos5-v9 \ sunos5-v9-static \ sunos5-v9-cc-g++ \ ultrix-gcc: @@ -51,12 +145,207 @@ index 3cab262..56efa83 100644 echo "Please run 'make realclean' before changing configs" ; \ exit 1 ; \ fi +@@ -166,10 +165,10 @@ ultrix-gcc: + + # Rules for making release tarballs + +-DIRECTORY = Mesa-7.0.1 +-LIB_NAME = MesaLib-7.0.1 +-DEMO_NAME = MesaDemos-7.0.1 +-GLUT_NAME = MesaGLUT-7.0.1 ++DIRECTORY = Mesa-7.0.2-rc1 ++LIB_NAME = MesaLib-7.0.2-rc1 ++DEMO_NAME = MesaDemos-7.0.2-rc1 ++GLUT_NAME = MesaGLUT-7.0.2-rc1 + + MAIN_FILES = \ + $(DIRECTORY)/Makefile* \ +@@ -213,6 +212,7 @@ MAIN_FILES = \ + $(DIRECTORY)/src/mesa/Makefile* \ + $(DIRECTORY)/src/mesa/sources \ + $(DIRECTORY)/src/mesa/descrip.mms \ ++ $(DIRECTORY)/src/mesa/gl.pc.in \ + $(DIRECTORY)/src/mesa/depend \ + $(DIRECTORY)/src/mesa/main/*.[chS] \ + $(DIRECTORY)/src/mesa/main/descrip.mms \ +@@ -320,6 +320,7 @@ DRI_FILES = \ + SGI_GLU_FILES = \ + $(DIRECTORY)/src/glu/Makefile \ + $(DIRECTORY)/src/glu/descrip.mms \ ++ $(DIRECTORY)/src/glu/glu.pc.in \ + $(DIRECTORY)/src/glu/sgi/Makefile \ + $(DIRECTORY)/src/glu/sgi/Makefile.mgw \ + $(DIRECTORY)/src/glu/sgi/Makefile.win \ +@@ -396,6 +397,7 @@ GLUT_FILES = \ + $(DIRECTORY)/include/GL/glutf90.h \ + $(DIRECTORY)/src/glut/glx/Makefile* \ + $(DIRECTORY)/src/glut/glx/depend \ ++ $(DIRECTORY)/src/glut/glx/glut.pc.in \ + $(DIRECTORY)/src/glut/glx/*def \ + $(DIRECTORY)/src/glut/glx/descrip.mms \ + $(DIRECTORY)/src/glut/glx/mms_depend \ +@@ -418,6 +420,7 @@ DEPEND_FILES = \ + $(TOP)/src/mesa/depend \ + $(TOP)/src/glx/x11/depend \ + $(TOP)/src/glw/depend \ ++ $(TOP)/src/glw/glw.pc.in \ + $(TOP)/src/glut/glx/depend \ + $(TOP)/src/glu/sgi/depend + +diff --git a/configs/bluegene-xlc-osmesa b/configs/bluegene-xlc-osmesa +new file mode 100644 +index 0000000..b0c762d +--- /dev/null ++++ b/configs/bluegene-xlc-osmesa +@@ -0,0 +1,29 @@ ++# Configuration for building only libOSMesa on BlueGene using the IBM xlc compiler ++# This doesn't really have a lot of dependencies, so it should be usable ++# on similar systems too. ++# It uses static linking and disables multithreading. ++ ++include $(TOP)/configs/default ++ ++CONFIG_NAME = bluegene-osmesa ++ ++# Compiler and flags ++CC = /opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlc ++CXX = /opt/ibmcmp/vacpp/bg/8.0/bin/blrts_xlC ++CFLAGS = -O3 -pedantic -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE ++CXXFLAGS = -O3 -pedantic -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE ++ ++MKLIB_OPTIONS = -static ++ ++OSMESA_LIB_NAME = libOSMesa.a ++ ++# Directories ++SRC_DIRS = mesa glu ++DRIVER_DIRS = osmesa ++PROGRAM_DIRS = osdemos ++ ++ ++# Dependencies ++OSMESA_LIB_DEPS = -lm ++GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB) ++APP_LIB_DEPS = -lOSMesa -lGLU -lm +diff --git a/configs/default b/configs/default +index 81f0338..275b060 100644 +--- a/configs/default ++++ b/configs/default +@@ -10,7 +10,7 @@ CONFIG_NAME = default + # Version info + MESA_MAJOR=7 + MESA_MINOR=0 +-MESA_TINY=1 ++MESA_TINY=2 + + # external projects. This should be useless now that we use libdrm. + DRM_SOURCE_PATH=$(TOP)/../drm +diff --git a/docs/download.html b/docs/download.html +index 5c3989e..84451b8 100644 +--- a/docs/download.html ++++ b/docs/download.html +@@ -9,7 +9,7 @@ +

Downloading

+ +

+-Last stable release: 7.0.1 ++Last stable release: 7.0.2 +

+ +

+diff --git a/docs/fbdev-dri.html b/docs/fbdev-dri.html +index c7f59bb..0d9e52c 100644 +--- a/docs/fbdev-dri.html ++++ b/docs/fbdev-dri.html +@@ -28,6 +28,12 @@ Xlib interfaces allowing some degree of application portability between + the X and X-less environments. +

+ ++

++Some of the files needed for building this configuration are not included ++in the normal Mesa releases so you'll need to get the latest sources ++sources from the git repository. ++

++ + +

2. Compilation

+ +diff --git a/docs/install.html b/docs/install.html +index 804dee5..041e27b 100644 +--- a/docs/install.html ++++ b/docs/install.html +@@ -287,7 +287,15 @@ already installed, you'll have to choose different directories, like + To install Mesa's headers and libraries, run make install. + But first, check the Mesa/configs/default file and examine the values + of the INSTALL_DIR and DRI_DRIVER_INSTALL_DIR variables. +-Change them if needed, then run make install ++Change them if needed, then run make install. ++

++ ++

++The variable ++DESTDIR may also be used to install the contents to a temporary ++staging directory. ++This can be useful for package management. ++For example: make install DESTDIR=/somepath/ +

+ +

+@@ -298,6 +306,26 @@ This is a handy way to compare multiple OpenGL implementations. +

+ + ++

1.5 pkg-config support

++ ++

++Running make install will install package configuration files ++for the pkg-config utility. ++

++ ++

++When compiling your OpenGL application you can use pkg-config to determine ++the proper compiler and linker flags. ++

++ ++

++For example, compiling and linking a GLUT application can be done with: ++

++
++   gcc `pkg-config --cflags --libs glut` mydemo.c -o mydemo
++
++ ++
+ + +

2. Windows Compilation and Installation

+diff --git a/docs/modelers.html b/docs/modelers.html +index b93f4d8..aae9686 100644 +--- a/docs/modelers.html ++++ b/docs/modelers.html +@@ -28,7 +28,7 @@ +
  • Innovation3D + - 3D modeling program +
  • KWRL - VRML browser +-
  • LibVRML97/Lookat ++
  • LibVRML97/Lookat + - VRML viewer +
  • Maverik + - VR graphics and interaction system diff --git a/docs/news.html b/docs/news.html -index 1f66d4e..e5f2adb 100644 +index 1f66d4e..8694ce4 100644 --- a/docs/news.html +++ b/docs/news.html -@@ -13,7 +13,7 @@ +@@ -11,9 +11,16 @@ +

    News

    + ++

    September ??, 2007

    ++

    ++Mesa 7.0.2 is released. ++This is a bug-fix release. ++

    ++ ++

    August 3, 2007

    -Mesa 7.0.1 is released. @@ -86,10 +375,10 @@ index 47ee162..02713ad 100644 diff --git a/docs/relnotes-7.0.2.html b/docs/relnotes-7.0.2.html new file mode 100644 -index 0000000..f1fd3d2 +index 0000000..46040e1 --- /dev/null +++ b/docs/relnotes-7.0.2.html -@@ -0,0 +1,70 @@ +@@ -0,0 +1,84 @@ + + +Mesa Release Notes @@ -114,6 +403,10 @@ index 0000000..f1fd3d2 + +

    New features

    + + +

    Bug fixes

    @@ -123,6 +416,16 @@ index 0000000..f1fd3d2 +
  • Added checking/support for additional chips in the i915/i945 family +(see 11978) +
  • Fixed a blending/banding issue (bug 11931) ++
  • Fixed a GLU matrix inversion bug (#6748) ++
  • Fixed problem with large glDrawArrays calls and indirect rendering (bug 12141) ++
  • Fixed an assortment of i965 driver bugs ++
  • Fixed and x86-64 vertex transformation bug (12216) ++
  • Fixed X server crash caused by multiple indirect rendering clients ++
  • Parsing of state.texgen in ARB vertex/fragment programs didn't work (bug 12313) ++
  • Fixed a glCopyPixels/glPixelZoom bug (12417) ++
  • Fixed a bug when using glMaterial in display lists (bug 10604) ++
  • Fixed a few GLUT/Fortran issues (Bill Mitchell) ++
  • Fixed Blender crash bug (12164) + + + @@ -172,6 +475,476 @@ index 9a978d9..7464f5c 100644
  • 7.0.1 release notes
  • 7.0 release notes
  • 6.5.3 release notes +diff --git a/include/GL/glu.h b/include/GL/glu.h +index d82103d..7db4b70 100644 +--- a/include/GL/glu.h ++++ b/include/GL/glu.h +@@ -44,22 +44,17 @@ + #define GLAPIENTRYP GLAPIENTRY * + #endif + +-#ifdef GLAPI +-#undef GLAPI +-#endif +- +-# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32) +-# define GLAPI __declspec(dllexport) +-# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +-# define GLAPI __declspec(dllimport) +-# else /* for use with static link lib build of Win32 edition only */ +-# define GLAPI extern +-# endif /* _STATIC_MESA support */ +- +- +-#ifndef GLAPI +-#define GLAPI +-#endif ++#if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GLU32) ++# undef GLAPI ++# define GLAPI __declspec(dllexport) ++#elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) ++/* tag specifying we're building for DLL runtime support */ ++# undef GLAPI ++# define GLAPI __declspec(dllimport) ++#elif !defined(GLAPI) ++/* for use with static link lib build of Win32 edition only */ ++# define GLAPI extern ++#endif /* _STATIC_MESA support */ + + #ifdef __cplusplus + extern "C" { +diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile +index ec85464..525d556 100644 +--- a/progs/xdemos/Makefile ++++ b/progs/xdemos/Makefile +@@ -37,7 +37,7 @@ PROGS = glthreads \ + .SUFFIXES: .c + + .c: $(LIB_DEP) +- $(CC) -I$(INCDIR) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ ++ $(CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $< $(APP_LIB_DEPS) -o $@ + + + ##### TARGETS ##### +@@ -52,32 +52,32 @@ clean: + + # special cases + pbinfo: pbinfo.o pbutil.o +- $(CC) -I$(INCDIR) $(CFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@ ++ $(CC) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@ + + pbdemo: pbdemo.o pbutil.o +- $(CC) -I$(INCDIR) $(CFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@ ++ $(CC) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@ + + pbinfo.o: pbinfo.c pbutil.h +- $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbinfo.c ++ $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbinfo.c + + pbdemo.o: pbdemo.c pbutil.h +- $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbdemo.c ++ $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbdemo.c + + pbutil.o: pbutil.c pbutil.h +- $(CC) -c -I. -I$(INCDIR) $(CFLAGS) pbutil.c ++ $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbutil.c + + glxgears_fbconfig: glxgears_fbconfig.o pbutil.o +- $(CC) -I$(INCDIR) $(CFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@ ++ $(CC) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@ + + glxgears_fbconfig.o: glxgears_fbconfig.c pbutil.h +- $(CC) -I$(INCDIR) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c ++ $(CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c + + xrotfontdemo: xrotfontdemo.o xuserotfont.o +- $(CC) -I$(INCDIR) $(CFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@ ++ $(CC) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@ + + xuserotfont.o: xuserotfont.c xuserotfont.h +- $(CC) -c -I. -I$(INCDIR) $(CFLAGS) xuserotfont.c ++ $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xuserotfont.c + + xrotfontdemo.o: xrotfontdemo.c xuserotfont.h +- $(CC) -c -I. -I$(INCDIR) $(CFLAGS) xrotfontdemo.c ++ $(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xrotfontdemo.c + +diff --git a/src/glu/Makefile b/src/glu/Makefile +index 5ddc509..836baa6 100644 +--- a/src/glu/Makefile ++++ b/src/glu/Makefile +@@ -13,9 +13,19 @@ default: $(TOP)/configs/current + (cd $$dir ; $(MAKE)) ; \ + done + +-install: +- $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) +- $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(INSTALL_DIR)/$(LIB_DIR) ++# GLU pkg-config file ++pcedit = sed \ ++ -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ ++ -e 's,@LIB_DIR@,$(LIB_DIR),' \ ++ -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' ++glu.pc: glu.pc.in ++ $(pcedit) $< > $@ ++ ++install: glu.pc ++ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) ++ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig ++ $(INSTALL) $(TOP)/$(LIB_DIR)/libGLU.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) ++ $(INSTALL) -m 644 glu.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig + + clean: + @for dir in $(SUBDIRS) ; do \ +diff --git a/src/glu/glu.pc.in b/src/glu/glu.pc.in +new file mode 100644 +index 0000000..5d6e52a +--- /dev/null ++++ b/src/glu/glu.pc.in +@@ -0,0 +1,11 @@ ++prefix=@INSTALL_DIR@ ++exec_prefix=${prefix} ++libdir=${exec_prefix}/@LIB_DIR@ ++includedir=${prefix}/include ++ ++Name: glu ++Description: Mesa OpenGL Utility library ++Requires: gl ++Version: @VERSION@ ++Libs: -L${libdir} -lGLU ++Cflags: -I${includedir} +diff --git a/src/glu/sgi/libutil/project.c b/src/glu/sgi/libutil/project.c +index 2b20ad4..356b46b 100644 +--- a/src/glu/sgi/libutil/project.c ++++ b/src/glu/sgi/libutil/project.c +@@ -168,74 +168,57 @@ static void __gluMultMatrixVecd(const GLdouble matrix[16], const GLdouble in[4], + } + + /* +-** inverse = invert(src) +-** New, faster implementation by Shan Hao Bo, April 2006. ++** Invert 4x4 matrix. ++** Contributed by David Moore (See Mesa bug #6748) + */ +-static int __gluInvertMatrixd(const GLdouble src[16], GLdouble inverse[16]) ++static int __gluInvertMatrixd(const GLdouble m[16], GLdouble invOut[16]) + { +- int i, j, k; +- double t; +- GLdouble temp[4][4]; +- +- for (i=0; i<4; i++) { +- for (j=0; j<4; j++) { +- temp[i][j] = src[i*4+j]; +- } +- } +- __gluMakeIdentityd(inverse); +- +- for (i = 0; i < 4; i++) { +- if (temp[i][i] == 0.0f) { +- /* +- ** Look for non-zero element in column +- */ +- for (j = i + 1; j < 4; j++) { +- if (temp[j][i] != 0.0f) { +- break; +- } +- } +- +- if (j != 4) { +- /* +- ** Swap rows. +- */ +- for (k = 0; k < 4; k++) { +- t = temp[i][k]; +- temp[i][k] = temp[j][k]; +- temp[j][k] = t; +- +- t = inverse[i*4+k]; +- inverse[i*4+k] = inverse[j*4+k]; +- inverse[j*4+k] = t; +- } +- } +- else { +- /* +- ** No non-zero pivot. The matrix is singular, +-which shouldn't +- ** happen. This means the user gave us a bad +-matrix. +- */ +- return GL_FALSE; +- } +- } +- +- t = 1.0f / temp[i][i]; +- for (k = 0; k < 4; k++) { +- temp[i][k] *= t; +- inverse[i*4+k] *= t; +- } +- for (j = 0; j < 4; j++) { +- if (j != i) { +- t = temp[j][i]; +- for (k = 0; k < 4; k++) { +- temp[j][k] -= temp[i][k]*t; +- inverse[j*4+k] -= inverse[i*4+k]*t; +- } +- } +- } +- } +- return GL_TRUE; ++ double inv[16], det; ++ int i; ++ ++ inv[0] = m[5]*m[10]*m[15] - m[5]*m[11]*m[14] - m[9]*m[6]*m[15] ++ + m[9]*m[7]*m[14] + m[13]*m[6]*m[11] - m[13]*m[7]*m[10]; ++ inv[4] = -m[4]*m[10]*m[15] + m[4]*m[11]*m[14] + m[8]*m[6]*m[15] ++ - m[8]*m[7]*m[14] - m[12]*m[6]*m[11] + m[12]*m[7]*m[10]; ++ inv[8] = m[4]*m[9]*m[15] - m[4]*m[11]*m[13] - m[8]*m[5]*m[15] ++ + m[8]*m[7]*m[13] + m[12]*m[5]*m[11] - m[12]*m[7]*m[9]; ++ inv[12] = -m[4]*m[9]*m[14] + m[4]*m[10]*m[13] + m[8]*m[5]*m[14] ++ - m[8]*m[6]*m[13] - m[12]*m[5]*m[10] + m[12]*m[6]*m[9]; ++ inv[1] = -m[1]*m[10]*m[15] + m[1]*m[11]*m[14] + m[9]*m[2]*m[15] ++ - m[9]*m[3]*m[14] - m[13]*m[2]*m[11] + m[13]*m[3]*m[10]; ++ inv[5] = m[0]*m[10]*m[15] - m[0]*m[11]*m[14] - m[8]*m[2]*m[15] ++ + m[8]*m[3]*m[14] + m[12]*m[2]*m[11] - m[12]*m[3]*m[10]; ++ inv[9] = -m[0]*m[9]*m[15] + m[0]*m[11]*m[13] + m[8]*m[1]*m[15] ++ - m[8]*m[3]*m[13] - m[12]*m[1]*m[11] + m[12]*m[3]*m[9]; ++ inv[13] = m[0]*m[9]*m[14] - m[0]*m[10]*m[13] - m[8]*m[1]*m[14] ++ + m[8]*m[2]*m[13] + m[12]*m[1]*m[10] - m[12]*m[2]*m[9]; ++ inv[2] = m[1]*m[6]*m[15] - m[1]*m[7]*m[14] - m[5]*m[2]*m[15] ++ + m[5]*m[3]*m[14] + m[13]*m[2]*m[7] - m[13]*m[3]*m[6]; ++ inv[6] = -m[0]*m[6]*m[15] + m[0]*m[7]*m[14] + m[4]*m[2]*m[15] ++ - m[4]*m[3]*m[14] - m[12]*m[2]*m[7] + m[12]*m[3]*m[6]; ++ inv[10] = m[0]*m[5]*m[15] - m[0]*m[7]*m[13] - m[4]*m[1]*m[15] ++ + m[4]*m[3]*m[13] + m[12]*m[1]*m[7] - m[12]*m[3]*m[5]; ++ inv[14] = -m[0]*m[5]*m[14] + m[0]*m[6]*m[13] + m[4]*m[1]*m[14] ++ - m[4]*m[2]*m[13] - m[12]*m[1]*m[6] + m[12]*m[2]*m[5]; ++ inv[3] = -m[1]*m[6]*m[11] + m[1]*m[7]*m[10] + m[5]*m[2]*m[11] ++ - m[5]*m[3]*m[10] - m[9]*m[2]*m[7] + m[9]*m[3]*m[6]; ++ inv[7] = m[0]*m[6]*m[11] - m[0]*m[7]*m[10] - m[4]*m[2]*m[11] ++ + m[4]*m[3]*m[10] + m[8]*m[2]*m[7] - m[8]*m[3]*m[6]; ++ inv[11] = -m[0]*m[5]*m[11] + m[0]*m[7]*m[9] + m[4]*m[1]*m[11] ++ - m[4]*m[3]*m[9] - m[8]*m[1]*m[7] + m[8]*m[3]*m[5]; ++ inv[15] = m[0]*m[5]*m[10] - m[0]*m[6]*m[9] - m[4]*m[1]*m[10] ++ + m[4]*m[2]*m[9] + m[8]*m[1]*m[6] - m[8]*m[2]*m[5]; ++ ++ det = m[0]*inv[0] + m[1]*inv[4] + m[2]*inv[8] + m[3]*inv[12]; ++ if (det == 0) ++ return GL_FALSE; ++ ++ det = 1.0 / det; ++ ++ for (i = 0; i < 16; i++) ++ invOut[i] = inv[i] * det; ++ ++ return GL_TRUE; + } + + static void __gluMultMatricesd(const GLdouble a[16], const GLdouble b[16], +diff --git a/src/glw/Makefile b/src/glw/Makefile +index 5228cbb..c32fc0c 100644 +--- a/src/glw/Makefile ++++ b/src/glw/Makefile +@@ -25,11 +25,21 @@ OBJECTS = $(GLW_SOURCES:.c=.o) + + default: $(TOP)/$(LIB_DIR)/$(GLW_LIB_NAME) + +-install: +- $(INSTALL) -d $(INSTALL_DIR)/include/GL +- $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) +- $(INSTALL) -m 644 *.h $(INSTALL_DIR)/include/GL +- $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(INSTALL_DIR)/$(LIB_DIR) ++# GLU pkg-config file ++pcedit = sed \ ++ -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ ++ -e 's,@LIB_DIR@,$(LIB_DIR),' \ ++ -e 's,@VERSION@,$(MAJOR).$(MINOR).$(TINY),' ++glw.pc: glw.pc.in ++ $(pcedit) $< > $@ ++ ++install: glw.pc ++ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL ++ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) ++ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig ++ $(INSTALL) -m 644 *.h $(DESTDIR)$(INSTALL_DIR)/include/GL ++ $(INSTALL) $(TOP)/$(LIB_DIR)/libGLw.* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) ++ $(INSTALL) -m 644 glw.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig + + clean: + -rm depend depend.bak +diff --git a/src/glw/glw.pc.in b/src/glw/glw.pc.in +new file mode 100644 +index 0000000..951e2dc +--- /dev/null ++++ b/src/glw/glw.pc.in +@@ -0,0 +1,11 @@ ++prefix=@INSTALL_DIR@ ++exec_prefix=${prefix} ++libdir=${exec_prefix}/@LIB_DIR@ ++includedir=${prefix}/include ++ ++Name: glw ++Description: Mesa OpenGL widget library ++Requires: gl ++Version: @VERSION@ ++Libs: -L${libdir} -lGLU ++Cflags: -I${includedir} +diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c +index af3a516..8fe1033 100644 +--- a/src/glx/x11/glxext.c ++++ b/src/glx/x11/glxext.c +@@ -672,8 +672,11 @@ filter_modes( __GLcontextModes ** server_modes, + if ( do_delete && (m->visualID != 0) ) { + do_delete = GL_FALSE; + +- fprintf(stderr, "libGL warning: 3D driver claims to not support " +- "visual 0x%02x\n", m->visualID); ++ /* don't warn for this visual (Novell #247471 / X.Org #6689) */ ++ if (m->visualRating != GLX_NON_CONFORMANT_CONFIG) { ++ fprintf(stderr, "libGL warning: 3D driver claims to not " ++ "support visual 0x%02x\n", m->visualID); ++ } + } + + if ( do_delete ) { +diff --git a/src/glx/x11/indirect_vertex_array.c b/src/glx/x11/indirect_vertex_array.c +index 90ec277..120fd82 100644 +--- a/src/glx/x11/indirect_vertex_array.c ++++ b/src/glx/x11/indirect_vertex_array.c +@@ -527,7 +527,7 @@ static GLubyte * + emit_DrawArrays_header_old( __GLXcontext * gc, + struct array_state_vector * arrays, + size_t * elements_per_request, +- size_t * total_requests, ++ unsigned int * total_requests, + GLenum mode, GLsizei count ) + { + size_t command_size; +@@ -640,7 +640,7 @@ emit_DrawArrays_old( GLenum mode, GLint first, GLsizei count ) + + GLubyte * pc; + size_t elements_per_request; +- size_t total_requests = 0; ++ unsigned total_requests = 0; + unsigned i; + size_t total_sent = 0; + +@@ -770,9 +770,10 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type, + + GLubyte * pc; + size_t elements_per_request; +- size_t total_requests = 0; ++ unsigned total_requests = 0; + unsigned i; + unsigned req; ++ unsigned req_element=0; + + + pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request, +@@ -790,7 +791,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type, + + switch( type ) { + case GL_UNSIGNED_INT: { +- const GLuint * ui_ptr = (const GLuint *) indices; ++ const GLuint * ui_ptr = (const GLuint *) indices + req_element; + + for ( i = 0 ; i < elements_per_request ; i++ ) { + const GLint index = (GLint) *(ui_ptr++); +@@ -799,7 +800,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type, + break; + } + case GL_UNSIGNED_SHORT: { +- const GLushort * us_ptr = (const GLushort *) indices; ++ const GLushort * us_ptr = (const GLushort *) indices + req_element; + + for ( i = 0 ; i < elements_per_request ; i++ ) { + const GLint index = (GLint) *(us_ptr++); +@@ -808,7 +809,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type, + break; + } + case GL_UNSIGNED_BYTE: { +- const GLubyte * ub_ptr = (const GLubyte *) indices; ++ const GLubyte * ub_ptr = (const GLubyte *) indices + req_element; + + for ( i = 0 ; i < elements_per_request ; i++ ) { + const GLint index = (GLint) *(ub_ptr++); +@@ -826,6 +827,7 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type, + } + + count -= elements_per_request; ++ req_element += elements_per_request; + } + + +diff --git a/src/mesa/Makefile b/src/mesa/Makefile +index eadd7f2..e31be41 100644 +--- a/src/mesa/Makefile ++++ b/src/mesa/Makefile +@@ -133,6 +133,15 @@ $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECT + + + ###################################################################### ++# libGL pkg-config file ++pcedit = sed \ ++ -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ ++ -e 's,@LIB_DIR@,$(LIB_DIR),' \ ++ -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' ++gl.pc: gl.pc.in ++ $(pcedit) $< > $@ ++ ++###################################################################### + # Generic stuff + + depend: $(ALL_SOURCES) +@@ -147,23 +156,25 @@ subdirs: + @ (cd x86-64 ; $(MAKE)) + + +-install: default +- $(INSTALL) -d $(INSTALL_DIR)/include/GL +- $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) +- $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL ++install: default gl.pc ++ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL ++ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) ++ $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig ++ $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(DESTDIR)$(INSTALL_DIR)/include/GL + @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \ +- $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \ ++ $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \ + fi ++ $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)/pkgconfig + @if [ -e $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME) ]; then \ +- $(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(INSTALL_DIR)/$(LIB_DIR); \ ++ $(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \ + fi + @if [ "${DRIVER_DIRS}" = "dri" ] ; then \ + cd drivers/dri ; $(MAKE) install ; \ + fi + + ## NOT INSTALLED YET: +-## $(INSTALL) -d $(INSTALL_DIR)/include/GLES +-## $(INSTALL) -m 644 include/GLES/*.h $(INSTALL_DIR)/include/GLES ++## $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GLES ++## $(INSTALL) -m 644 include/GLES/*.h $(DESTDIR)$(INSTALL_DIR)/include/GLES + + + # Emacs tags +diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template +index 6f2314e..b1d3cbc 100644 +--- a/src/mesa/drivers/dri/Makefile.template ++++ b/src/mesa/drivers/dri/Makefile.template +@@ -100,8 +100,8 @@ clean: + + + install: $(LIBNAME) +- $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR) +- $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR) ++ $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) ++ $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + + + include depend diff --git a/src/mesa/drivers/dri/common/spantmp2.h b/src/mesa/drivers/dri/common/spantmp2.h index 50f3cf5..53f5f84 100644 --- a/src/mesa/drivers/dri/common/spantmp2.h @@ -295,6 +1068,81 @@ index 98ddc79..5bd2806 100644 GLuint row_len = image->Width * image->TexFormat->TexelBytes; GLubyte *dst = (GLubyte *)(t->BufAddr + offset); GLubyte *src = (GLubyte *)image->Data; +diff --git a/src/mesa/drivers/dri/i915tex/i830_vtbl.c b/src/mesa/drivers/dri/i915tex/i830_vtbl.c +index e432648..5555b74 100644 +--- a/src/mesa/drivers/dri/i915tex/i830_vtbl.c ++++ b/src/mesa/drivers/dri/i915tex/i830_vtbl.c +@@ -519,6 +519,16 @@ i830_emit_state(struct intel_context *intel) + static void + i830_destroy_context(struct intel_context *intel) + { ++ GLuint i; ++ struct i830_context *i830 = i830_context(&intel->ctx); ++ ++ for (i = 0; i < I830_TEX_UNITS; i++) { ++ if (i830->state.tex_buffer[i] != NULL) { ++ driBOUnReference(i830->state.tex_buffer[i]); ++ i830->state.tex_buffer[i] = NULL; ++ } ++ } ++ + _tnl_free_vertices(&intel->ctx); + } + +diff --git a/src/mesa/drivers/dri/i915tex/i915_metaops.c b/src/mesa/drivers/dri/i915tex/i915_metaops.c +index 3ab62bc..397ff75 100644 +--- a/src/mesa/drivers/dri/i915tex/i915_metaops.c ++++ b/src/mesa/drivers/dri/i915tex/i915_metaops.c +@@ -95,7 +95,7 @@ meta_depth_replace(struct intel_context *intel) + i915->meta.Ctx[I915_CTXREG_LIS6] |= (S6_DEPTH_TEST_ENABLE | + S6_DEPTH_WRITE_ENABLE); + +- /* ctx->Driver.DepthFunc( ctx, GL_REPLACE ) ++ /* ctx->Driver.DepthFunc( ctx, GL_ALWAYS ) + */ + i915->meta.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_FUNC_MASK; + i915->meta.Ctx[I915_CTXREG_LIS6] |= +diff --git a/src/mesa/drivers/dri/i915tex/i915_vtbl.c b/src/mesa/drivers/dri/i915tex/i915_vtbl.c +index ad333b4..e911fc4 100644 +--- a/src/mesa/drivers/dri/i915tex/i915_vtbl.c ++++ b/src/mesa/drivers/dri/i915tex/i915_vtbl.c +@@ -430,6 +430,16 @@ i915_emit_state(struct intel_context *intel) + static void + i915_destroy_context(struct intel_context *intel) + { ++ GLuint i; ++ struct i915_context *i915 = i915_context(&intel->ctx); ++ ++ for (i = 0; i < I915_TEX_UNITS; i++) { ++ if (i915->state.tex_buffer[i] != NULL) { ++ driBOUnReference(i915->state.tex_buffer[i]); ++ i915->state.tex_buffer[i] = NULL; ++ } ++ } ++ + _tnl_free_vertices(&intel->ctx); + } + +diff --git a/src/mesa/drivers/dri/i915tex/intel_buffers.c b/src/mesa/drivers/dri/i915tex/intel_buffers.c +index 15d02f8..78fb720 100644 +--- a/src/mesa/drivers/dri/i915tex/intel_buffers.c ++++ b/src/mesa/drivers/dri/i915tex/intel_buffers.c +@@ -1124,6 +1124,15 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb) + ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled); + } + ++ /* ++ * Update depth test state ++ */ ++ if (ctx->Depth.Test && fb->Visual.depthBits > 0) { ++ ctx->Driver.Enable(ctx, GL_DEPTH_TEST, GL_TRUE); ++ } ++ else { ++ ctx->Driver.Enable(ctx, GL_DEPTH_TEST, GL_FALSE); ++ } + + /** + ** Release old regions, reference new regions diff --git a/src/mesa/drivers/dri/i915tex/intel_context.c b/src/mesa/drivers/dri/i915tex/intel_context.c index 093b3b4..40ea756 100644 --- a/src/mesa/drivers/dri/i915tex/intel_context.c @@ -384,6 +1232,522 @@ index 5e6df81..2acdead 100644 return i915CreateContext(mesaVis, driContextPriv, sharedContextPrivate); default: +diff --git a/src/mesa/drivers/dri/i965/brw_aub.c b/src/mesa/drivers/dri/i965/brw_aub.c +index f851a5b..c549f7a 100644 +--- a/src/mesa/drivers/dri/i965/brw_aub.c ++++ b/src/mesa/drivers/dri/i965/brw_aub.c +@@ -80,7 +80,7 @@ static void init_aubfile( FILE *aub_file ) + fh.hour = (nr>>16) & 0xff; + fh.comment_length = 0x0; + +- if (fwrite(&fh, sizeof(fh), 1, aub_file) < 0) ++ if (fwrite(&fh, sizeof(fh), 1, aub_file) < 1) + FAIL; + + /* Setup the GTT starting at main memory address zero (!): +@@ -96,12 +96,12 @@ static void init_aubfile( FILE *aub_file ) + bh.address = PGETBL_CTL; + bh.length = 0x4; + +- if (fwrite(&bh, sizeof(bh), 1, aub_file) < 0) ++ if (fwrite(&bh, sizeof(bh), 1, aub_file) < 1) + FAIL; + + data = 0x0 | PGETBL_ENABLED; + +- if (fwrite(&data, sizeof(data), 1, aub_file) < 0) ++ if (fwrite(&data, sizeof(data), 1, aub_file) < 1) + FAIL; + } + +@@ -128,7 +128,7 @@ static void init_aub_gtt( struct brw_context *brw, + bh.address = start_offset / 4096 * 4; + bh.length = size / 4096 * 4; + +- if (fwrite(&bh, sizeof(bh), 1, aub_file) < 0) ++ if (fwrite(&bh, sizeof(bh), 1, aub_file) < 1) + FAIL; + + for (i = 0; i < size / 4096; i++) { +@@ -136,7 +136,7 @@ static void init_aub_gtt( struct brw_context *brw, + + brw->next_free_page += 4096; + +- if (fwrite(&data, sizeof(data), 1, aub_file) < 0) ++ if (fwrite(&data, sizeof(data), 1, aub_file) < 1) + FAIL; + } + +@@ -149,10 +149,10 @@ static void write_block_header( FILE *aub_file, + { + sz = (sz + 3) & ~3; + +- if (fwrite(bh, sizeof(*bh), 1, aub_file) < 0) ++ if (fwrite(bh, sizeof(*bh), 1, aub_file) < 1) + FAIL; + +- if (fwrite(data, sz, 1, aub_file) < 0) ++ if (fwrite(data, sz, 1, aub_file) < 1) + FAIL; + + fflush(aub_file); +@@ -162,7 +162,7 @@ static void write_block_header( FILE *aub_file, + static void write_dump_bmp( FILE *aub_file, + struct aub_dump_bmp *db ) + { +- if (fwrite(db, sizeof(*db), 1, aub_file) < 0) ++ if (fwrite(db, sizeof(*db), 1, aub_file) < 1) + FAIL; + + fflush(aub_file); +diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c +index 3bec153..8287fd9 100644 +--- a/src/mesa/drivers/dri/i965/brw_clip.c ++++ b/src/mesa/drivers/dri/i965/brw_clip.c +@@ -212,6 +212,10 @@ static void upload_clip_prog( struct brw_context *brw ) + } + } + ++ if (brw->attribs.Polygon->BackMode != GL_FILL || ++ brw->attribs.Polygon->FrontMode != GL_FILL) ++ key.do_unfilled = 1; ++ + /* Most cases the fixed function units will handle. Cases where + * one or more polygon faces are unfilled will require help: + */ +diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c b/src/mesa/drivers/dri/i965/brw_curbe.c +index 3f0aaa1..5bf0ed5 100644 +--- a/src/mesa/drivers/dri/i965/brw_curbe.c ++++ b/src/mesa/drivers/dri/i965/brw_curbe.c +@@ -90,7 +90,7 @@ static void calculate_curbe_offsets( struct brw_context *brw ) + */ + if (nr_fp_regs > brw->curbe.wm_size || + nr_vp_regs > brw->curbe.vs_size || +- nr_clip_regs > brw->curbe.clip_size || ++ nr_clip_regs != brw->curbe.clip_size || + (total_regs < brw->curbe.total_size / 4 && + brw->curbe.total_size > 16)) { + +diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c +index c7798b1..f796472 100644 +--- a/src/mesa/drivers/dri/i965/brw_draw.c ++++ b/src/mesa/drivers/dri/i965/brw_draw.c +@@ -330,6 +330,7 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx, + else { + /* Otherwise, explicitly do the cliprects at this point: + */ ++ GLuint nprims = 0; + for (j = 0; j < brw->intel.numClipRects; j++) { + brw_emit_cliprect(brw, &brw->intel.pClipRects[j]); + +@@ -337,6 +338,11 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx, + */ + for (i = 0; i < nr_prims; i++) { + brw_emit_prim(brw, &prim[i]); ++ ++ if (++nprims == VBO_MAX_PRIM) { ++ intel_batchbuffer_flush(brw->intel.batch); ++ nprims = 0; ++ } + } + } + } +diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c +index cbaf018..2ea9816 100644 +--- a/src/mesa/drivers/dri/i965/brw_sf_emit.c ++++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c +@@ -582,7 +582,9 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c ) + (1<<_3DPRIM_TRIFAN_NOSTIPPLE))); + jmp = brw_JMPI(p, ip, ip, brw_imm_w(0)); + { ++ brw_push_insn_state(p); + brw_emit_tri_setup( c ); ++ brw_pop_insn_state(p); + /* note - thread killed in subroutine */ + } + brw_land_fwd_jump(p, jmp); +@@ -596,7 +598,9 @@ void brw_emit_anyprim_setup( struct brw_sf_compile *c ) + (1<<_3DPRIM_LINESTRIP_CONT_BF))); + jmp = brw_JMPI(p, ip, ip, brw_imm_w(0)); + { ++ brw_push_insn_state(p); + brw_emit_line_setup( c ); ++ brw_pop_insn_state(p); + /* note - thread killed in subroutine */ + } + brw_land_fwd_jump(p, jmp); +diff --git a/src/mesa/drivers/dri/i965/brw_vs_tnl.c b/src/mesa/drivers/dri/i965/brw_vs_tnl.c +index 35adc48..14483b3 100644 +--- a/src/mesa/drivers/dri/i965/brw_vs_tnl.c ++++ b/src/mesa/drivers/dri/i965/brw_vs_tnl.c +@@ -1000,13 +1000,19 @@ static void build_lighting( struct tnl_program *p ) + STATE_POSITION); + struct ureg V = get_eye_position(p); + struct ureg dist = get_temp(p); ++ struct ureg tmpPpli = get_temp(p); + + VPpli = get_temp(p); + half = get_temp(p); +- ++ ++ /* In homogeneous object coordinates ++ */ ++ emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W)); ++ emit_op2(p, OPCODE_MUL, tmpPpli, 0, Ppli, dist); ++ + /* Calulate VPpli vector + */ +- emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); ++ emit_op2(p, OPCODE_SUB, VPpli, 0, tmpPpli, V); + + /* Normalize VPpli. The dist value also used in + * attenuation below. +@@ -1038,6 +1044,7 @@ static void build_lighting( struct tnl_program *p ) + emit_normalize_vec3(p, half, half); + + release_temp(p, dist); ++ release_temp(p, tmpPpli); + } + + /* Calculate dot products: +diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c +index ff97d87..dc57fd2 100644 +--- a/src/mesa/drivers/dri/i965/brw_wm_fp.c ++++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c +@@ -525,7 +525,57 @@ static void precalc_tex( struct brw_wm_compile *c, + struct prog_src_register coord; + struct prog_dst_register tmpcoord; + +- if (inst->TexSrcTarget == TEXTURE_RECT_INDEX) { ++ if (inst->TexSrcTarget == TEXTURE_CUBE_INDEX) { ++ struct prog_instruction *out; ++ struct prog_dst_register tmp0 = get_temp(c); ++ struct prog_src_register tmp0src = src_reg_from_dst(tmp0); ++ struct prog_dst_register tmp1 = get_temp(c); ++ struct prog_src_register tmp1src = src_reg_from_dst(tmp1); ++ struct prog_src_register src0 = inst->SrcReg[0]; ++ ++ tmpcoord = get_temp(c); ++ coord = src_reg_from_dst(tmpcoord); ++ ++ out = emit_op(c, OPCODE_MOV, ++ tmpcoord, ++ 0, 0, 0, ++ src0, ++ src_undef(), ++ src_undef()); ++ out->SrcReg[0].NegateBase = 0; ++ out->SrcReg[0].Abs = 1; ++ ++ emit_op(c, OPCODE_MAX, ++ tmp0, ++ 0, 0, 0, ++ src_swizzle1(coord, X), ++ src_swizzle1(coord, Y), ++ src_undef()); ++ ++ emit_op(c, OPCODE_MAX, ++ tmp1, ++ 0, 0, 0, ++ tmp0src, ++ src_swizzle1(coord, Z), ++ src_undef()); ++ ++ emit_op(c, OPCODE_RCP, ++ tmp0, ++ 0, 0, 0, ++ tmp1src, ++ src_undef(), ++ src_undef()); ++ ++ emit_op(c, OPCODE_MUL, ++ tmpcoord, ++ 0, 0, 0, ++ src0, ++ tmp0src, ++ src_undef()); ++ ++ release_temp(c, tmp0); ++ release_temp(c, tmp1); ++ } else if (inst->TexSrcTarget == TEXTURE_RECT_INDEX) { + struct prog_src_register scale = + search_or_add_param5( c, + STATE_INTERNAL, +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 93d4cfc..794c7d9 100644 +--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c ++++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +@@ -173,12 +173,12 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit, + * message (sample_c). So need to recompile WM program when + * shadow comparison is enabled on each/any texture unit. + */ +- sampler->ss0.shadow_function = intel_translate_compare_func(texObj->CompareFunc); ++ sampler->ss0.shadow_function = intel_translate_shadow_compare_func(texObj->CompareFunc); + } + + /* Set LOD bias: + */ +- sampler->ss0.lod_bias = S_FIXED(texUnit->LodBias + texObj->LodBias, 6); ++ sampler->ss0.lod_bias = S_FIXED(CLAMP(texUnit->LodBias + texObj->LodBias, -16, 15), 6); + + sampler->ss0.lod_preclamp = 1; /* OpenGL mode */ + sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */ +@@ -192,8 +192,8 @@ static void brw_update_sampler_state( struct gl_texture_unit *texUnit, + */ + sampler->ss0.base_level = U_FIXED(0, 1); + +- sampler->ss1.max_lod = U_FIXED(MAX2(texObj->MaxLod, 0), 6); +- sampler->ss1.min_lod = U_FIXED(MAX2(texObj->MinLod, 0), 6); ++ sampler->ss1.max_lod = U_FIXED(MIN2(MAX2(texObj->MaxLod, 0), 13), 6); ++ sampler->ss1.min_lod = U_FIXED(MIN2(MAX2(texObj->MinLod, 0), 13), 6); + + sampler->ss2.default_color_pointer = sdc_gs_offset >> 5; + } +diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c +index ff5cb31..5b4f2ab 100644 +--- a/src/mesa/drivers/dri/i965/brw_wm_state.c ++++ b/src/mesa/drivers/dri/i965/brw_wm_state.c +@@ -117,7 +117,7 @@ static void upload_wm_unit(struct brw_context *brw ) + wm.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754; + + /* CACHE_NEW_SAMPLER */ +- wm.wm4.sampler_count = brw->wm.sampler_count; ++ wm.wm4.sampler_count = (brw->wm.sampler_count + 1) / 4; + wm.wm4.sampler_state_pointer = brw->wm.sampler_gs_offset >> 5; + + /* BRW_NEW_FRAGMENT_PROGRAM */ +diff --git a/src/mesa/drivers/dri/i965/intel_buffers.c b/src/mesa/drivers/dri/i965/intel_buffers.c +index d155c03..de6a867 100644 +--- a/src/mesa/drivers/dri/i965/intel_buffers.c ++++ b/src/mesa/drivers/dri/i965/intel_buffers.c +@@ -31,7 +31,9 @@ + #include "intel_regions.h" + #include "intel_batchbuffer.h" + #include "context.h" ++#include "utils.h" + #include "framebuffer.h" ++#include "vblank.h" + #include "macros.h" + #include "swrast/swrast.h" + +@@ -190,8 +192,40 @@ void intelWindowMoved( struct intel_context *intel ) + } + } + ++ { ++ if (intel->intelScreen->driScrnPriv->ddxMinor >= 7) { ++ volatile drmI830Sarea *sarea = intel->sarea; ++ drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w, ++ .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h ++ }; ++ drm_clip_rect_t pipeA_rect = { .x1 = sarea->pipeA_x, ++ .x2 = sarea->pipeA_x + sarea->pipeA_w, ++ .y1 = sarea->pipeA_y, ++ .y2 = sarea->pipeA_y + sarea->pipeA_h }; ++ drm_clip_rect_t pipeB_rect = { .x1 = sarea->pipeB_x, ++ .x2 = sarea->pipeB_x + sarea->pipeB_w, ++ .y1 = sarea->pipeB_y, ++ .y2 = sarea->pipeB_y + sarea->pipeB_h }; ++ GLint areaA = driIntersectArea( drw_rect, pipeA_rect ); ++ GLint areaB = driIntersectArea( drw_rect, pipeB_rect ); ++ GLuint flags = intel->vblank_flags; ++ ++ if (areaB > areaA || (areaA > 0 && areaB > 0)) { ++ flags = intel->vblank_flags | VBLANK_FLAG_SECONDARY; ++ } else { ++ flags = intel->vblank_flags & ~VBLANK_FLAG_SECONDARY; ++ } ++ ++ if (flags != intel->vblank_flags) { ++ intel->vblank_flags = flags; ++ driGetCurrentVBlank(dPriv, intel->vblank_flags, &intel->vbl_seq); ++ } ++ } else { ++ intel->vblank_flags &= ~VBLANK_FLAG_SECONDARY; ++ } ++ } + _mesa_resize_framebuffer(&intel->ctx, +- (GLframebuffer*)dPriv->driverPrivate, ++ (GLframebuffer*)dPriv->driverPrivate, + dPriv->w, dPriv->h); + + /* Set state we know depends on drawable parameters: +diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c +index 10eb9a2..8c304a9 100644 +--- a/src/mesa/drivers/dri/i965/intel_context.c ++++ b/src/mesa/drivers/dri/i965/intel_context.c +@@ -262,7 +262,7 @@ intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) + }; + intel->stats_wm++; + intelFinish(&intel->ctx); +- drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io)); ++ drmCommandWrite(intel->driFd, DRM_I830_MMIO, &io, sizeof(io)); + } + + static void +@@ -276,7 +276,7 @@ intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q) + .data = &tmp + }; + intelFinish(&intel->ctx); +- drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io)); ++ drmCommandWrite(intel->driFd, DRM_I830_MMIO, &io, sizeof(io)); + q->Result = tmp - q->Result; + q->Ready = GL_TRUE; + intel->stats_wm--; +@@ -567,6 +567,10 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv, + if (driContextPriv) { + struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate; + ++ if (intel->driReadDrawable != driReadPriv) { ++ intel->driReadDrawable = driReadPriv; ++ } ++ + if ( intel->driDrawable != driDrawPriv ) { + /* Shouldn't the readbuffer be stored also? */ + driDrawableInitVBlank( driDrawPriv, intel->vblank_flags, +diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h +index 808512f..9f69f23 100644 +--- a/src/mesa/drivers/dri/i965/intel_context.h ++++ b/src/mesa/drivers/dri/i965/intel_context.h +@@ -234,6 +234,7 @@ struct intel_context + int driFd; + + __DRIdrawablePrivate *driDrawable; ++ __DRIdrawablePrivate *driReadDrawable; + __DRIscreenPrivate *driScreen; + intelScreenPrivate *intelScreen; + volatile drmI830Sarea *sarea; +@@ -463,7 +464,7 @@ extern void intelInitStateFuncs( struct dd_function_table *functions ); + #define BLENDFACT_INV_CONST_ALPHA 0x0f + #define BLENDFACT_MASK 0x0f + +- ++extern int intel_translate_shadow_compare_func( GLenum func ); + extern int intel_translate_compare_func( GLenum func ); + extern int intel_translate_stencil_op( GLenum op ); + extern int intel_translate_blend_factor( GLenum factor ); +diff --git a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c +index 421fcc5..df9d688 100644 +--- a/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c ++++ b/src/mesa/drivers/dri/i965/intel_pixel_bitmap.c +@@ -168,12 +168,15 @@ do_blit_bitmap( GLcontext *ctx, + { + struct intel_context *intel = intel_context(ctx); + struct intel_region *dst = intel_drawbuf_region(intel); +- ++ GLfloat tmpColor[4]; ++ + union { + GLuint ui; + GLubyte ub[4]; + } color; + ++ if (!dst) ++ return GL_FALSE; + + if (unpack->BufferObj->Name) { + bitmap = map_pbo(ctx, width, height, unpack, bitmap); +@@ -181,10 +184,16 @@ do_blit_bitmap( GLcontext *ctx, + return GL_TRUE; /* even though this is an error, we're done */ + } + +- UNCLAMPED_FLOAT_TO_CHAN(color.ub[0], ctx->Current.RasterColor[2]); +- UNCLAMPED_FLOAT_TO_CHAN(color.ub[1], ctx->Current.RasterColor[1]); +- UNCLAMPED_FLOAT_TO_CHAN(color.ub[2], ctx->Current.RasterColor[0]); +- UNCLAMPED_FLOAT_TO_CHAN(color.ub[3], ctx->Current.RasterColor[3]); ++ COPY_4V(tmpColor, ctx->Current.RasterColor); ++ ++ if (NEED_SECONDARY_COLOR(ctx)) { ++ ADD_3V(tmpColor, tmpColor, ctx->Current.RasterSecondaryColor); ++ } ++ ++ UNCLAMPED_FLOAT_TO_CHAN(color.ub[0], tmpColor[2]); ++ UNCLAMPED_FLOAT_TO_CHAN(color.ub[1], tmpColor[1]); ++ UNCLAMPED_FLOAT_TO_CHAN(color.ub[2], tmpColor[0]); ++ UNCLAMPED_FLOAT_TO_CHAN(color.ub[3], tmpColor[3]); + + /* Does zoom apply to bitmaps? + */ +diff --git a/src/mesa/drivers/dri/i965/intel_pixel_copy.c b/src/mesa/drivers/dri/i965/intel_pixel_copy.c +index 58dc495..3bdf2fb 100644 +--- a/src/mesa/drivers/dri/i965/intel_pixel_copy.c ++++ b/src/mesa/drivers/dri/i965/intel_pixel_copy.c +@@ -231,6 +231,7 @@ do_blit_copypixels(GLcontext * ctx, + + if (intel->driDrawable->numClipRects) { + __DRIdrawablePrivate *dPriv = intel->driDrawable; ++ __DRIdrawablePrivate *dReadPriv = intel->driReadDrawable; + drm_clip_rect_t *box = dPriv->pClipRects; + drm_clip_rect_t dest_rect; + GLint nbox = dPriv->numClipRects; +@@ -262,8 +263,8 @@ do_blit_copypixels(GLcontext * ctx, + srcy = dPriv->h - srcy - height; + dstx += dPriv->x; + dsty += dPriv->y; +- srcx += dPriv->x; +- srcy += dPriv->y; ++ srcx += dReadPriv->x; ++ srcy += dReadPriv->y; + + /* Clip against the source region. This is the only source + * clipping we do. Dst is clipped with cliprects below. +diff --git a/src/mesa/drivers/dri/i965/intel_state.c b/src/mesa/drivers/dri/i965/intel_state.c +index ec6e046..701b30c 100644 +--- a/src/mesa/drivers/dri/i965/intel_state.c ++++ b/src/mesa/drivers/dri/i965/intel_state.c +@@ -38,6 +38,31 @@ + #include "intel_regions.h" + #include "swrast/swrast.h" + ++int intel_translate_shadow_compare_func( GLenum func ) ++{ ++ switch(func) { ++ case GL_NEVER: ++ return COMPAREFUNC_ALWAYS; ++ case GL_LESS: ++ return COMPAREFUNC_LEQUAL; ++ case GL_LEQUAL: ++ return COMPAREFUNC_LESS; ++ case GL_GREATER: ++ return COMPAREFUNC_GEQUAL; ++ case GL_GEQUAL: ++ return COMPAREFUNC_GREATER; ++ case GL_NOTEQUAL: ++ return COMPAREFUNC_EQUAL; ++ case GL_EQUAL: ++ return COMPAREFUNC_NOTEQUAL; ++ case GL_ALWAYS: ++ return COMPAREFUNC_NEVER; ++ } ++ ++ fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func); ++ return COMPAREFUNC_NEVER; ++} ++ + int intel_translate_compare_func( GLenum func ) + { + switch(func) { +diff --git a/src/mesa/drivers/dri/i965/server/i830_common.h b/src/mesa/drivers/dri/i965/server/i830_common.h +index f320378..fe2b8e8 100644 +--- a/src/mesa/drivers/dri/i965/server/i830_common.h ++++ b/src/mesa/drivers/dri/i965/server/i830_common.h +@@ -119,6 +119,16 @@ typedef struct { + unsigned int depth_tiled; + unsigned int rotated_tiled; + unsigned int rotated2_tiled; ++ ++ int pipeA_x; ++ int pipeA_y; ++ int pipeA_w; ++ int pipeA_h; ++ int pipeB_x; ++ int pipeB_y; ++ int pipeB_w; ++ int pipeB_h; ++ + } drmI830Sarea; + + /* Flags for perf_boxes diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c index 4d25d32..7c73877 100644 --- a/src/mesa/drivers/dri/unichrome/via_context.c @@ -408,86 +1772,506 @@ index 4d25d32..7c73877 100644 switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) { case BUFFER_BIT_BACK_LEFT: -diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c -index 0b821cf..df40b88 100644 ---- a/src/mesa/main/attrib.c -+++ b/src/mesa/main/attrib.c -@@ -342,6 +342,12 @@ _mesa_PushAttrib(GLbitfield mask) - /* Bump the texture object reference counts so that they don't - * inadvertantly get deleted. - */ -+#ifdef DEBUG -+ printf("%lu: MESA PUSH TEX ATTRIB, INCR REF COUNT BY %d\n", -+ _glthread_GetID(), -+ ctx->Const.MaxTextureUnits); -+#endif +diff --git a/src/mesa/gl.pc.in b/src/mesa/gl.pc.in +new file mode 100644 +index 0000000..4b144ff +--- /dev/null ++++ b/src/mesa/gl.pc.in +@@ -0,0 +1,11 @@ ++prefix=@INSTALL_DIR@ ++exec_prefix=${prefix} ++libdir=${exec_prefix}/@LIB_DIR@ ++includedir=${prefix}/include + - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - ctx->Texture.Unit[u].Current1D->RefCount++; - ctx->Texture.Unit[u].Current2D->RefCount++; -@@ -349,6 +355,7 @@ _mesa_PushAttrib(GLbitfield mask) - ctx->Texture.Unit[u].CurrentCubeMap->RefCount++; - ctx->Texture.Unit[u].CurrentRect->RefCount++; - } -+ - attr = MALLOC_STRUCT( gl_texture_attrib ); - MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) ); - /* copy state of the currently bound texture objects */ -@@ -792,6 +799,11 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib) - * wouldn't inadvertantly get deleted while they were still referenced - * inside the attribute state stack. - */ -+#ifdef DEBUG -+ printf("%lu: MESA POP TEX ATTRIB, DECR REF COUNT BY %d\n", -+ _glthread_GetID(), -+ ctx->Const.MaxTextureUnits); -+#endif - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - ctx->Texture.Unit[u].Current1D->RefCount--; - ctx->Texture.Unit[u].Current2D->RefCount--; -@@ -1401,6 +1413,84 @@ _mesa_PopClientAttrib(void) - } ++Name: gl ++Description: Mesa OpenGL library ++Requires: ++Version: @VERSION@ ++Libs: -L${libdir} -lGL ++Cflags: -I${includedir} +diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c +index 841c6a5..4544843 100644 +--- a/src/mesa/main/api_validate.c ++++ b/src/mesa/main/api_validate.c +@@ -1,6 +1,6 @@ + /* + * Mesa 3-D graphics library +- * Version: 7.0.1 ++ * Version: 7.0.2 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * +@@ -30,6 +30,55 @@ + #include "state.h" -+static struct gl_texture_object * -+get_texobj(GLcontext *ctx, GLenum target, GLuint name) ++/** ++ * Find the max index in the given element/index buffer ++ */ ++static GLuint ++max_buffer_index(GLcontext *ctx, GLuint count, GLenum type, ++ const void *indices, ++ struct gl_buffer_object *elementBuf) +{ -+ struct gl_texture_object *texObj; -+ if (name) { -+ texObj = _mesa_lookup_texture(ctx, name); ++ const GLubyte *map = NULL; ++ GLuint max = 0; ++ GLint i; ++ ++ if (elementBuf->Name) { ++ /* elements are in a user-defined buffer object. need to map it */ ++ map = ctx->Driver.MapBuffer(ctx, ++ GL_ELEMENT_ARRAY_BUFFER_ARB, ++ GL_READ_ONLY, ++ elementBuf); ++ /* Actual address is the sum of pointers */ ++ indices = (const GLvoid *) ADD_POINTERS(map, (const GLubyte *) indices); ++ } ++ ++ if (type == GL_UNSIGNED_INT) { ++ for (i = 0; i < count; i++) ++ if (((GLuint *) indices)[i] > max) ++ max = ((GLuint *) indices)[i]; ++ } ++ else if (type == GL_UNSIGNED_SHORT) { ++ for (i = 0; i < count; i++) ++ if (((GLushort *) indices)[i] > max) ++ max = ((GLushort *) indices)[i]; + } + else { -+ switch (target) { -+ case GL_TEXTURE_1D: -+ texObj = ctx->Shared->Default1D; -+ break; -+ case GL_TEXTURE_2D: -+ texObj = ctx->Shared->Default2D; -+ break; -+ case GL_TEXTURE_3D: -+ texObj = ctx->Shared->Default3D; -+ break; -+ case GL_TEXTURE_CUBE_MAP_ARB: -+ texObj = ctx->Shared->DefaultCubeMap; -+ break; -+ case GL_TEXTURE_RECTANGLE_NV: -+ texObj = ctx->Shared->DefaultRect; -+ break; -+ default: -+ abort(); -+ } ++ ASSERT(type == GL_UNSIGNED_BYTE); ++ for (i = 0; i < count; i++) ++ if (((GLubyte *) indices)[i] > max) ++ max = ((GLubyte *) indices)[i]; + } -+ return texObj; ++ ++ if (map) { ++ ctx->Driver.UnmapBuffer(ctx, ++ GL_ELEMENT_ARRAY_BUFFER_ARB, ++ ctx->Array.ElementArrayBufferObj); ++ } ++ ++ return max; +} + + + GLboolean + _mesa_validate_DrawElements(GLcontext *ctx, + GLenum mode, GLsizei count, GLenum type, +@@ -61,20 +110,15 @@ _mesa_validate_DrawElements(GLcontext *ctx, + + /* Always need vertex positions */ + if (!ctx->Array.ArrayObj->Vertex.Enabled +- && !(ctx->VertexProgram._Enabled && ctx->Array.ArrayObj->VertexAttrib[0].Enabled)) ++ && !(ctx->VertexProgram._Enabled ++ && ctx->Array.ArrayObj->VertexAttrib[0].Enabled)) + return GL_FALSE; + + /* Vertex buffer object tests */ + if (ctx->Array.ElementArrayBufferObj->Name) { +- GLuint indexBytes; +- + /* use indices in the buffer object */ +- if (!ctx->Array.ElementArrayBufferObj->Data) { +- _mesa_warning(ctx, "DrawElements with empty vertex elements buffer!"); +- return GL_FALSE; +- } ++ GLuint indexBytes; + +- /* make sure count doesn't go outside buffer bounds */ + if (type == GL_UNSIGNED_INT) { + indexBytes = count * sizeof(GLuint); + } +@@ -86,19 +130,11 @@ _mesa_validate_DrawElements(GLcontext *ctx, + indexBytes = count * sizeof(GLushort); + } + +- if ((GLubyte *) indices + indexBytes > +- ctx->Array.ElementArrayBufferObj->Data + +- ctx->Array.ElementArrayBufferObj->Size) { ++ /* make sure count doesn't go outside buffer bounds */ ++ if (indexBytes > ctx->Array.ElementArrayBufferObj->Size) { + _mesa_warning(ctx, "glDrawElements index out of buffer bounds"); + return GL_FALSE; + } +- +- /* Actual address is the sum of pointers. Indices may be used below. */ +- if (ctx->Const.CheckArrayBounds) { +- indices = (const GLvoid *) +- ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data, +- (const GLubyte *) indices); +- } + } + else { + /* not using a VBO */ +@@ -108,24 +144,8 @@ _mesa_validate_DrawElements(GLcontext *ctx, + + if (ctx->Const.CheckArrayBounds) { + /* find max array index */ +- GLuint max = 0; +- GLint i; +- if (type == GL_UNSIGNED_INT) { +- for (i = 0; i < count; i++) +- if (((GLuint *) indices)[i] > max) +- max = ((GLuint *) indices)[i]; +- } +- else if (type == GL_UNSIGNED_SHORT) { +- for (i = 0; i < count; i++) +- if (((GLushort *) indices)[i] > max) +- max = ((GLushort *) indices)[i]; +- } +- else { +- ASSERT(type == GL_UNSIGNED_BYTE); +- for (i = 0; i < count; i++) +- if (((GLubyte *) indices)[i] > max) +- max = ((GLubyte *) indices)[i]; +- } ++ GLuint max = max_buffer_index(ctx, count, type, indices, ++ ctx->Array.ElementArrayBufferObj); + if (max >= ctx->Array._MaxElement) { + /* the max element is out of bounds of one or more enabled arrays */ + return GL_FALSE; +@@ -172,41 +192,41 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, + + /* Always need vertex positions */ + if (!ctx->Array.ArrayObj->Vertex.Enabled +- && !(ctx->VertexProgram._Enabled && ctx->Array.ArrayObj->VertexAttrib[0].Enabled)) ++ && !(ctx->VertexProgram._Enabled ++ && ctx->Array.ArrayObj->VertexAttrib[0].Enabled)) + return GL_FALSE; + + /* Vertex buffer object tests */ + if (ctx->Array.ElementArrayBufferObj->Name) { +- /* XXX re-use code from above? */ ++ /* use indices in the buffer object */ ++ GLuint indexBytes; ++ ++ if (type == GL_UNSIGNED_INT) { ++ indexBytes = count * sizeof(GLuint); ++ } ++ else if (type == GL_UNSIGNED_BYTE) { ++ indexBytes = count * sizeof(GLubyte); ++ } ++ else { ++ ASSERT(type == GL_UNSIGNED_SHORT); ++ indexBytes = count * sizeof(GLushort); ++ } ++ ++ /* make sure count doesn't go outside buffer bounds */ ++ if (indexBytes > ctx->Array.ElementArrayBufferObj->Size) { ++ _mesa_warning(ctx, "glDrawRangeElements index out of buffer bounds"); ++ return GL_FALSE; ++ } + } + else { +- /* not using VBO */ ++ /* not using a VBO */ + if (!indices) + return GL_FALSE; + } + + if (ctx->Const.CheckArrayBounds) { +- /* Find max array index. +- * We don't trust the user's start and end values. +- */ +- GLuint max = 0; +- GLint i; +- if (type == GL_UNSIGNED_INT) { +- for (i = 0; i < count; i++) +- if (((GLuint *) indices)[i] > max) +- max = ((GLuint *) indices)[i]; +- } +- else if (type == GL_UNSIGNED_SHORT) { +- for (i = 0; i < count; i++) +- if (((GLushort *) indices)[i] > max) +- max = ((GLushort *) indices)[i]; +- } +- else { +- ASSERT(type == GL_UNSIGNED_BYTE); +- for (i = 0; i < count; i++) +- if (((GLubyte *) indices)[i] > max) +- max = ((GLubyte *) indices)[i]; +- } ++ GLuint max = max_buffer_index(ctx, count, type, indices, ++ ctx->Array.ElementArrayBufferObj); + if (max >= ctx->Array._MaxElement) { + /* the max element is out of bounds of one or more enabled arrays */ + return GL_FALSE; +@@ -241,7 +261,8 @@ _mesa_validate_DrawArrays(GLcontext *ctx, + _mesa_update_state(ctx); + + /* Always need vertex positions */ +- if (!ctx->Array.ArrayObj->Vertex.Enabled && !ctx->Array.ArrayObj->VertexAttrib[0].Enabled) ++ if (!ctx->Array.ArrayObj->Vertex.Enabled ++ && !ctx->Array.ArrayObj->VertexAttrib[0].Enabled) + return GL_FALSE; + + if (ctx->Const.CheckArrayBounds) { +diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c +index 0b821cf..427a6b0 100644 +--- a/src/mesa/main/attrib.c ++++ b/src/mesa/main/attrib.c +@@ -1,6 +1,6 @@ + /* + * Mesa 3-D graphics library +- * Version: 6.5.3 ++ * Version: 7.0.2 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * +@@ -52,6 +52,32 @@ + + + /** ++ * Special struct for saving/restoring texture state (GL_TEXTURE_BIT) ++ */ ++struct texture_state ++{ ++ struct gl_texture_attrib Texture; /**< The usual context state */ ++ ++ /** to save per texture object state (wrap modes, filters, etc): */ ++ struct gl_texture_object Saved1D[MAX_TEXTURE_UNITS]; ++ struct gl_texture_object Saved2D[MAX_TEXTURE_UNITS]; ++ struct gl_texture_object Saved3D[MAX_TEXTURE_UNITS]; ++ struct gl_texture_object SavedCube[MAX_TEXTURE_UNITS]; ++ struct gl_texture_object SavedRect[MAX_TEXTURE_UNITS]; ++ ++ /** ++ * To save references to texture objects (so they don't get accidentally ++ * deleted while saved in the attribute stack). ++ */ ++ struct gl_texture_object *SavedRef1D[MAX_TEXTURE_UNITS]; ++ struct gl_texture_object *SavedRef2D[MAX_TEXTURE_UNITS]; ++ struct gl_texture_object *SavedRef3D[MAX_TEXTURE_UNITS]; ++ struct gl_texture_object *SavedRefCube[MAX_TEXTURE_UNITS]; ++ struct gl_texture_object *SavedRefRect[MAX_TEXTURE_UNITS]; ++}; ++ ++ ++/** + * Allocate a new attribute state node. These nodes have a + * "kind" value and a pointer to a struct of state data. + */ +@@ -335,40 +361,48 @@ _mesa_PushAttrib(GLbitfield mask) + } + + if (mask & GL_TEXTURE_BIT) { +- struct gl_texture_attrib *attr; ++ struct texture_state *texstate = CALLOC_STRUCT( texture_state ); + GLuint u; + ++ if (!texstate) { ++ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glPushAttrib(GL_TEXTURE_BIT)"); ++ goto end; ++ } ++ + _mesa_lock_context_textures(ctx); +- /* Bump the texture object reference counts so that they don't +- * inadvertantly get deleted. ++ ++ /* copy/save the bulk of texture state here */ ++ _mesa_memcpy(&texstate->Texture, &ctx->Texture, sizeof(ctx->Texture)); ++ ++ /* Save references to the currently bound texture objects so they don't ++ * accidentally get deleted while referenced in the attribute stack. + */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { +- ctx->Texture.Unit[u].Current1D->RefCount++; +- ctx->Texture.Unit[u].Current2D->RefCount++; +- ctx->Texture.Unit[u].Current3D->RefCount++; +- ctx->Texture.Unit[u].CurrentCubeMap->RefCount++; +- ctx->Texture.Unit[u].CurrentRect->RefCount++; ++ _mesa_reference_texobj(&texstate->SavedRef1D[u], ctx->Texture.Unit[u].Current1D); ++ _mesa_reference_texobj(&texstate->SavedRef2D[u], ctx->Texture.Unit[u].Current2D); ++ _mesa_reference_texobj(&texstate->SavedRef3D[u], ctx->Texture.Unit[u].Current3D); ++ _mesa_reference_texobj(&texstate->SavedRefCube[u], ctx->Texture.Unit[u].CurrentCubeMap); ++ _mesa_reference_texobj(&texstate->SavedRefRect[u], ctx->Texture.Unit[u].CurrentRect); + } +- attr = MALLOC_STRUCT( gl_texture_attrib ); +- MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) ); +- /* copy state of the currently bound texture objects */ ++ ++ /* copy state/contents of the currently bound texture objects */ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { +- _mesa_copy_texture_object(&attr->Unit[u].Saved1D, +- attr->Unit[u].Current1D); +- _mesa_copy_texture_object(&attr->Unit[u].Saved2D, +- attr->Unit[u].Current2D); +- _mesa_copy_texture_object(&attr->Unit[u].Saved3D, +- attr->Unit[u].Current3D); +- _mesa_copy_texture_object(&attr->Unit[u].SavedCubeMap, +- attr->Unit[u].CurrentCubeMap); +- _mesa_copy_texture_object(&attr->Unit[u].SavedRect, +- attr->Unit[u].CurrentRect); ++ _mesa_copy_texture_object(&texstate->Saved1D[u], ++ ctx->Texture.Unit[u].Current1D); ++ _mesa_copy_texture_object(&texstate->Saved2D[u], ++ ctx->Texture.Unit[u].Current2D); ++ _mesa_copy_texture_object(&texstate->Saved3D[u], ++ ctx->Texture.Unit[u].Current3D); ++ _mesa_copy_texture_object(&texstate->SavedCube[u], ++ ctx->Texture.Unit[u].CurrentCubeMap); ++ _mesa_copy_texture_object(&texstate->SavedRect[u], ++ ctx->Texture.Unit[u].CurrentRect); + } + + _mesa_unlock_context_textures(ctx); + + newnode = new_attrib_node( GL_TEXTURE_BIT ); +- newnode->data = attr; ++ newnode->data = texstate; + newnode->next = head; + head = newnode; + } +@@ -404,6 +438,7 @@ _mesa_PushAttrib(GLbitfield mask) + head = newnode; + } + ++end: + ctx->AttribStack[ctx->AttribStackDepth] = head; + ctx->AttribStackDepth++; + } +@@ -613,14 +648,19 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable) + } + + ++/** ++ * Pop/restore texture attribute/group state. ++ */ + static void +-pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib) ++pop_texture_group(GLcontext *ctx, struct texture_state *texstate) + { + GLuint u; + ++ _mesa_lock_context_textures(ctx); ++ + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { +- const struct gl_texture_unit *unit = &texAttrib->Unit[u]; +- GLuint i; ++ const struct gl_texture_unit *unit = &texstate->Texture.Unit[u]; ++ GLuint tgt; + + _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u); + _mesa_set_enable(ctx, GL_TEXTURE_1D, +@@ -713,41 +753,44 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib) + 1 << unit->Combine.ScaleShiftA); + } + +- /* Restore texture object state */ +- for (i = 0; i < NUM_TEXTURE_TARGETS; i++) { +- GLenum target = 0; ++ /* Restore texture object state for each target */ ++ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { + const struct gl_texture_object *obj = NULL; + GLfloat bordColor[4]; ++ GLenum target; + +- switch (i) { +- case 0: +- target = GL_TEXTURE_1D; +- obj = &unit->Saved1D; ++ switch (tgt) { ++ case TEXTURE_1D_INDEX: ++ obj = &texstate->Saved1D[u]; ++ ASSERT(obj->Target == GL_TEXTURE_1D); + break; +- case 1: +- target = GL_TEXTURE_2D; +- obj = &unit->Saved2D; ++ case TEXTURE_2D_INDEX: ++ obj = &texstate->Saved2D[u]; ++ ASSERT(obj->Target == GL_TEXTURE_2D); + break; +- case 2: +- target = GL_TEXTURE_3D; +- obj = &unit->Saved3D; ++ case TEXTURE_3D_INDEX: ++ obj = &texstate->Saved3D[u]; ++ ASSERT(obj->Target == GL_TEXTURE_3D); + break; +- case 3: ++ case TEXTURE_CUBE_INDEX: + if (!ctx->Extensions.ARB_texture_cube_map) + continue; +- target = GL_TEXTURE_CUBE_MAP_ARB; +- obj = &unit->SavedCubeMap; ++ obj = &texstate->SavedCube[u]; ++ ASSERT(obj->Target == GL_TEXTURE_CUBE_MAP_ARB); + break; +- case 4: ++ case TEXTURE_RECT_INDEX: + if (!ctx->Extensions.NV_texture_rectangle) + continue; +- target = GL_TEXTURE_RECTANGLE_NV; +- obj = &unit->SavedRect; ++ obj = &texstate->SavedRect[u]; ++ ASSERT(obj->Target == GL_TEXTURE_RECTANGLE_NV); + break; + default: +- ; /* silence warnings */ ++ _mesa_problem(ctx, "bad texture index in pop_texture_group"); ++ continue; + } + ++ target = obj->Target; ++ + _mesa_BindTexture(target, obj->Name); + + bordColor[0] = CHAN_TO_FLOAT(obj->BorderColor[0]); +@@ -782,23 +825,19 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib) + _mesa_TexParameterf(target, GL_SHADOW_AMBIENT_SGIX, + obj->ShadowAmbient); + } +- + } +- } +- _mesa_ActiveTextureARB(GL_TEXTURE0_ARB +- + texAttrib->CurrentUnit); + +- /* "un-bump" the texture object reference counts. We did that so they +- * wouldn't inadvertantly get deleted while they were still referenced +- * inside the attribute state stack. +- */ +- for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { +- ctx->Texture.Unit[u].Current1D->RefCount--; +- ctx->Texture.Unit[u].Current2D->RefCount--; +- ctx->Texture.Unit[u].Current3D->RefCount--; +- ctx->Texture.Unit[u].CurrentCubeMap->RefCount--; +- ctx->Texture.Unit[u].CurrentRect->RefCount--; ++ /* remove saved references to the texture objects */ ++ _mesa_reference_texobj(&texstate->SavedRef1D[u], NULL); ++ _mesa_reference_texobj(&texstate->SavedRef2D[u], NULL); ++ _mesa_reference_texobj(&texstate->SavedRef3D[u], NULL); ++ _mesa_reference_texobj(&texstate->SavedRefCube[u], NULL); ++ _mesa_reference_texobj(&texstate->SavedRefRect[u], NULL); + } ++ ++ _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + texstate->Texture.CurrentUnit); ++ ++ _mesa_unlock_context_textures(ctx); + } + + +@@ -1177,9 +1216,9 @@ _mesa_PopAttrib(void) + case GL_TEXTURE_BIT: + /* Take care of texture object reference counters */ + { +- const struct gl_texture_attrib *texture; +- texture = (const struct gl_texture_attrib *) attr->data; +- pop_texture_group(ctx, texture); ++ struct texture_state *texstate ++ = (struct texture_state *) attr->data; ++ pop_texture_group(ctx, texstate); + ctx->NewState |= _NEW_TEXTURE; + } + break; +@@ -1401,6 +1440,41 @@ _mesa_PopClientAttrib(void) + } + + +void +_mesa_free_attrib_data(GLcontext *ctx) +{ -+#ifdef DEBUG -+ printf("%lu: MESA FREEING ATTRIB STACK DATA\n", -+ _glthread_GetID()); -+#endif + while (ctx->AttribStackDepth > 0) { + struct gl_attrib_node *attr, *next; + @@ -495,23 +2279,20 @@ index 0b821cf..df40b88 100644 + attr = ctx->AttribStack[ctx->AttribStackDepth]; + + while (attr) { -+ struct gl_texture_attrib *texAttrib -+ = (struct gl_texture_attrib *) attr->data; -+ GLuint u; -+ -+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { -+ struct gl_texture_unit *unit = &texAttrib->Unit[u]; -+ struct gl_texture_object *texObj; -+ texObj = get_texobj(ctx, GL_TEXTURE_1D, unit->Saved1D.Name); -+ MESA_REF_TEXOBJ(&texObj, NULL); -+ texObj = get_texobj(ctx, GL_TEXTURE_2D, unit->Saved2D.Name); -+ MESA_REF_TEXOBJ(&texObj, NULL); -+ texObj = get_texobj(ctx, GL_TEXTURE_3D, unit->Saved3D.Name); -+ MESA_REF_TEXOBJ(&texObj, NULL); -+ texObj = get_texobj(ctx, GL_TEXTURE_CUBE_MAP, unit->SavedCubeMap.Name); -+ MESA_REF_TEXOBJ(&texObj, NULL); -+ texObj = get_texobj(ctx, GL_TEXTURE_RECTANGLE_NV, unit->SavedRect.Name); -+ MESA_REF_TEXOBJ(&texObj, NULL); ++ if (attr->kind == GL_TEXTURE_BIT) { ++ struct texture_state *texstate = (struct texture_state*)attr->data; ++ GLuint u; ++ /* clear references to the saved texture objects */ ++ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { ++ _mesa_reference_texobj(&texstate->SavedRef1D[u], NULL); ++ _mesa_reference_texobj(&texstate->SavedRef2D[u], NULL); ++ _mesa_reference_texobj(&texstate->SavedRef3D[u], NULL); ++ _mesa_reference_texobj(&texstate->SavedRefCube[u], NULL); ++ _mesa_reference_texobj(&texstate->SavedRefRect[u], NULL); ++ } ++ } ++ else { ++ /* any other chunks of state that requires special handling? */ + } + + next = attr->next; @@ -520,10 +2301,6 @@ index 0b821cf..df40b88 100644 + attr = next; + } + } -+#ifdef DEBUG -+ printf("%lu: MESA DONE FREEING ATTRIB STACK DATA\n", -+ _glthread_GetID()); -+#endif +} + + @@ -550,9 +2327,18 @@ index 09d7519..ea28859 100644 #endif diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c -index e067840..64f3a7f 100644 +index e067840..754b1a7 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c +@@ -6,7 +6,7 @@ + + /* + * Mesa 3-D graphics library +- * Version: 7.0 ++ * Version: 7.0.2 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * @@ -467,17 +467,12 @@ alloc_shared_state( GLcontext *ctx ) if (!ss->DefaultRect) goto cleanup; @@ -585,18 +2371,7 @@ index e067840..64f3a7f 100644 /* Ran out of memory at some point. Free everything and return NULL */ if (ss->DisplayList) _mesa_DeleteHashTable(ss->DisplayList); -@@ -567,6 +561,10 @@ delete_texture_cb(GLuint id, void *data, void *userData) - { - struct gl_texture_object *texObj = (struct gl_texture_object *) data; - GLcontext *ctx = (GLcontext *) userData; -+#ifdef DEBUG -+ printf("MESA TEX DELETE %p (%u) from DestroyContext\n", -+ (void *) texObj, texObj->Name); -+#endif - ctx->Driver.DeleteTexture(ctx, texObj); - } - -@@ -634,6 +632,33 @@ delete_shader_cb(GLuint id, void *data, void *userData) +@@ -634,6 +628,33 @@ delete_shader_cb(GLuint id, void *data, void *userData) } } @@ -630,7 +2405,7 @@ index e067840..64f3a7f 100644 /** * Deallocate a shared state object and all children structures. -@@ -656,20 +681,6 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) +@@ -656,20 +677,6 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) _mesa_HashDeleteAll(ss->DisplayList, delete_displaylist_cb, ctx); _mesa_DeleteHashTable(ss->DisplayList); @@ -651,7 +2426,7 @@ index e067840..64f3a7f 100644 #if defined(FEATURE_NV_vertex_program) || defined(FEATURE_NV_fragment_program) _mesa_HashDeleteAll(ss->Programs, delete_program_cb, ctx); _mesa_DeleteHashTable(ss->Programs); -@@ -701,10 +712,27 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) +@@ -701,10 +708,27 @@ free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) #endif #if FEATURE_EXT_framebuffer_object @@ -679,31 +2454,25 @@ index e067840..64f3a7f 100644 _glthread_DESTROY_MUTEX(ss->Mutex); _mesa_free(ss); -@@ -1157,18 +1185,27 @@ _mesa_create_context(const GLvisual *visual, +@@ -1157,18 +1181,20 @@ _mesa_create_context(const GLvisual *visual, void _mesa_free_context_data( GLcontext *ctx ) { - /* if we're destroying the current context, unbind it first */ - if (ctx == _mesa_get_current_context()) { - _mesa_make_current(NULL, NULL, NULL); -+ if (!_mesa_get_current_context()){ -+ /* No current context, but we may need one in order to delete -+ * texture objs, etc. So temporarily bind the context now. -+ */ -+ _mesa_make_current(ctx, NULL, NULL); - } +- } - else { - /* unreference WinSysDraw/Read buffers */ - _mesa_unreference_framebuffer(&ctx->WinSysDrawBuffer); - _mesa_unreference_framebuffer(&ctx->WinSysReadBuffer); - _mesa_unreference_framebuffer(&ctx->DrawBuffer); - _mesa_unreference_framebuffer(&ctx->ReadBuffer); -+ -+ if (ctx->AttribStackDepth > 0) { -+#ifdef DEBUG -+ printf("%lu: MESA: DESTROY CONTEXT WITH NON-EMPTRY ATTRIB STACK!\n", -+ _glthread_GetID()); -+#endif ++ if (!_mesa_get_current_context()){ ++ /* No current context, but we may need one in order to delete ++ * texture objs, etc. So temporarily bind the context now. ++ */ ++ _mesa_make_current(ctx, NULL, NULL); } + /* unreference WinSysDraw/Read buffers */ @@ -716,7 +2485,7 @@ index e067840..64f3a7f 100644 _mesa_free_lighting_data( ctx ); _mesa_free_eval_data( ctx ); _mesa_free_texture_data( ctx ); -@@ -1200,6 +1237,11 @@ _mesa_free_context_data( GLcontext *ctx ) +@@ -1200,6 +1226,11 @@ _mesa_free_context_data( GLcontext *ctx ) if (ctx->Extensions.String) _mesa_free((void *) ctx->Extensions.String); @@ -728,8 +2497,124 @@ index e067840..64f3a7f 100644 } +@@ -1431,8 +1462,6 @@ void + _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, + GLframebuffer *readBuffer ) + { +- GET_CURRENT_CONTEXT(oldCtx); +- + if (MESA_VERBOSE & VERBOSE_API) + _mesa_debug(newCtx, "_mesa_make_current()\n"); + +@@ -1457,13 +1486,6 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer, + _glapi_set_context((void *) newCtx); + ASSERT(_mesa_get_current_context() == newCtx); + +- if (oldCtx) { +- _mesa_unreference_framebuffer(&oldCtx->WinSysDrawBuffer); +- _mesa_unreference_framebuffer(&oldCtx->WinSysReadBuffer); +- _mesa_unreference_framebuffer(&oldCtx->DrawBuffer); +- _mesa_unreference_framebuffer(&oldCtx->ReadBuffer); +- } +- + if (!newCtx) { + _glapi_set_dispatch(NULL); /* none current */ + } +diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c +index 7813c7a..844db6b 100644 +--- a/src/mesa/main/dlist.c ++++ b/src/mesa/main/dlist.c +@@ -1,6 +1,6 @@ + /* + * Mesa 3-D graphics library +- * Version: 7.0.1 ++ * Version: 7.0.2 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * +@@ -5737,7 +5737,7 @@ execute_list(GLcontext *ctx, GLuint list) + if (!dlist) + return; + +- ctx->ListState.CallStack[ctx->ListState.CallDepth++] = dlist; ++ ctx->ListState.CallDepth++; + + if (ctx->Driver.BeginCallList) + ctx->Driver.BeginCallList(ctx, dlist); +@@ -6629,7 +6629,7 @@ execute_list(GLcontext *ctx, GLuint list) + if (ctx->Driver.EndCallList) + ctx->Driver.EndCallList(ctx); + +- ctx->ListState.CallStack[ctx->ListState.CallDepth--] = NULL; ++ ctx->ListState.CallDepth--; + } + + +diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c +index 0e14345..1c6167b 100644 +--- a/src/mesa/main/enable.c ++++ b/src/mesa/main/enable.c +@@ -364,6 +364,10 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) + case GL_LIGHTING: + if (ctx->Light.Enabled == state) + return; ++ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) ++ ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; ++ else ++ ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.Enabled = state; + break; +@@ -372,12 +376,14 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) + return; + FLUSH_VERTICES(ctx, _NEW_LINE); + ctx->Line.SmoothFlag = state; ++ ctx->_TriangleCaps ^= DD_LINE_SMOOTH; + break; + case GL_LINE_STIPPLE: + if (ctx->Line.StippleFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_LINE); + ctx->Line.StippleFlag = state; ++ ctx->_TriangleCaps ^= DD_LINE_STIPPLE; + break; + case GL_INDEX_LOGIC_OP: + if (ctx->Color.IndexLogicOpEnabled == state) +@@ -516,18 +522,21 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + ctx->Point.SmoothFlag = state; ++ ctx->_TriangleCaps ^= DD_POINT_SMOOTH; + break; + case GL_POLYGON_SMOOTH: + if (ctx->Polygon.SmoothFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.SmoothFlag = state; ++ ctx->_TriangleCaps ^= DD_TRI_SMOOTH; + break; + case GL_POLYGON_STIPPLE: + if (ctx->Polygon.StippleFlag == state) + return; + FLUSH_VERTICES(ctx, _NEW_POLYGON); + ctx->Polygon.StippleFlag = state; ++ ctx->_TriangleCaps ^= DD_TRI_STIPPLE; + break; + case GL_POLYGON_OFFSET_POINT: + if (ctx->Polygon.OffsetPoint == state) +@@ -877,6 +886,10 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) + return; + FLUSH_VERTICES(ctx, _NEW_STENCIL); + ctx->Stencil.TestTwoSide = state; ++ if (state) ++ ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; ++ else ++ ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL; + break; + + #if FEATURE_ARB_fragment_program diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c -index eac2f78..f0e413b 100644 +index eac2f78..8e7d66c 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -150,22 +150,18 @@ _mesa_remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att) @@ -750,7 +2635,7 @@ index eac2f78..f0e413b 100644 - } - } - att->Texture = NULL; -+ MESA_REF_TEXOBJ(&att->Texture, NULL); /* unbind */ ++ _mesa_reference_texobj(&att->Texture, NULL); /* unbind */ + ASSERT(!att->Texture); } if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) { @@ -769,12 +2654,32 @@ index eac2f78..f0e413b 100644 - att->Texture = texObj; - texObj->RefCount++; + assert(!att->Texture); -+ MESA_REF_TEXOBJ(&att->Texture, texObj); ++ _mesa_reference_texobj(&att->Texture, texObj); } /* always update these fields */ +@@ -983,6 +979,7 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) + return; + } + _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb); ++ ASSERT(newFb->RefCount == 1); + } + } + else { +@@ -1006,8 +1003,10 @@ _mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer) + if (bindDrawBuf) { + /* check if old FB had any texture attachments */ + check_end_texture_render(ctx, ctx->DrawBuffer); +- /* check if time to delete this framebuffer */ ++ ++ /* bind new drawing buffer */ + _mesa_reference_framebuffer(&ctx->DrawBuffer, newFb); ++ + if (newFb->Name != 0) { + /* check if newly bound framebuffer has any texture attachments */ + check_begin_texture_render(ctx, newFb); diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c -index 1fd31a5..09f0994 100644 +index 1fd31a5..8aeb369 100644 --- a/src/mesa/main/framebuffer.c +++ b/src/mesa/main/framebuffer.c @@ -38,6 +38,7 @@ @@ -797,7 +2702,7 @@ index 1fd31a5..09f0994 100644 - ctx->Driver.DeleteTexture(ctx, att->Texture); - } - } -+ MESA_REF_TEXOBJ(&att->Texture, NULL); ++ _mesa_reference_texobj(&att->Texture, NULL); } + ASSERT(!att->Renderbuffer); + ASSERT(!att->Texture); @@ -806,6 +2711,19 @@ index 1fd31a5..09f0994 100644 } /* unbind _Depth/_StencilBuffer to decr ref counts */ +diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h +index fd41275..2d2da49 100644 +--- a/src/mesa/main/glheader.h ++++ b/src/mesa/main/glheader.h +@@ -237,7 +237,7 @@ + #endif + + +-#if !defined __GNUC__ || __GNUC__ < 3 ++#if (!defined(__GNUC__) || __GNUC__ < 3) && !defined(__IBMC__) + # define __builtin_expect(x, y) x + #endif + diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c index 803f478..d7a96f7 100644 --- a/src/mesa/main/image.c @@ -819,19 +2737,212 @@ index 803f478..d7a96f7 100644 } if (dstPacking->SwapBytes) { _mesa_swap4( (GLuint *) dst, n ); +diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c +index 6e05761..6dd334e 100644 +--- a/src/mesa/main/light.c ++++ b/src/mesa/main/light.c +@@ -53,6 +53,11 @@ _mesa_ShadeModel( GLenum mode ) + + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.ShadeModel = mode; ++ if (mode == GL_FLAT) ++ ctx->_TriangleCaps |= DD_FLATSHADE; ++ else ++ ctx->_TriangleCaps &= ~DD_FLATSHADE; ++ + if (ctx->Driver.ShadeModel) + ctx->Driver.ShadeModel( ctx, mode ); + } +@@ -441,6 +446,10 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params ) + return; + FLUSH_VERTICES(ctx, _NEW_LIGHT); + ctx->Light.Model.TwoSide = newbool; ++ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) ++ ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; ++ else ++ ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; + break; + case GL_LIGHT_MODEL_COLOR_CONTROL: + if (params[0] == (GLfloat) GL_SINGLE_COLOR) +diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c +index dc7195d..b464c4f 100644 +--- a/src/mesa/main/lines.c ++++ b/src/mesa/main/lines.c +@@ -59,6 +59,11 @@ _mesa_LineWidth( GLfloat width ) + ctx->Const.MinLineWidth, + ctx->Const.MaxLineWidth); + ++ if (width != 1.0F) ++ ctx->_TriangleCaps |= DD_LINE_WIDTH; ++ else ++ ctx->_TriangleCaps &= ~DD_LINE_WIDTH; ++ + if (ctx->Driver.LineWidth) + ctx->Driver.LineWidth(ctx, width); + } +diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h +index 71215d5..d00f2ef 100644 +--- a/src/mesa/main/mtypes.h ++++ b/src/mesa/main/mtypes.h +@@ -1523,12 +1523,6 @@ struct gl_texture_unit + + struct gl_texture_object *_Current; /**< Points to really enabled tex obj */ + +- struct gl_texture_object Saved1D; /**< only used by glPush/PopAttrib */ +- struct gl_texture_object Saved2D; +- struct gl_texture_object Saved3D; +- struct gl_texture_object SavedCubeMap; +- struct gl_texture_object SavedRect; +- + /* GL_SGI_texture_color_table */ + struct gl_color_table ColorTable; + struct gl_color_table ProxyColorTable; +@@ -2848,7 +2842,6 @@ struct mesa_display_list + */ + struct gl_dlist_state + { +- struct mesa_display_list *CallStack[MAX_LIST_NESTING]; + GLuint CallDepth; /**< Current recursion calling depth */ + + struct mesa_display_list *CurrentList; +diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c +index 408b68a..8825bb1 100644 +--- a/src/mesa/main/points.c ++++ b/src/mesa/main/points.c +@@ -123,9 +123,15 @@ _mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params) + return; + FLUSH_VERTICES(ctx, _NEW_POINT); + COPY_3V(ctx->Point.Params, params); ++ + ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 || + ctx->Point.Params[1] != 0.0 || + ctx->Point.Params[2] != 0.0); ++ ++ if (ctx->Point._Attenuated) ++ ctx->_TriangleCaps |= DD_POINT_ATTEN; ++ else ++ ctx->_TriangleCaps &= ~DD_POINT_ATTEN; + } + else { + _mesa_error(ctx, GL_INVALID_ENUM, +diff --git a/src/mesa/main/polygon.c b/src/mesa/main/polygon.c +index fd02e5a..564250b 100644 +--- a/src/mesa/main/polygon.c ++++ b/src/mesa/main/polygon.c +@@ -167,6 +167,11 @@ _mesa_PolygonMode( GLenum face, GLenum mode ) + return; + } + ++ if (ctx->Polygon.FrontMode == GL_FILL && ctx->Polygon.BackMode == GL_FILL) ++ ctx->_TriangleCaps &= ~DD_TRI_UNFILLED; ++ else ++ ctx->_TriangleCaps |= DD_TRI_UNFILLED; ++ + if (ctx->Driver.PolygonMode) + ctx->Driver.PolygonMode(ctx, face, mode); + } +diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c +index 96ee512..767161f 100644 +--- a/src/mesa/main/state.c ++++ b/src/mesa/main/state.c +@@ -821,6 +821,16 @@ _mesa_init_exec_table(struct _glapi_table *exec) + /*@{*/ + + ++static void ++update_separate_specular( GLcontext *ctx ) ++{ ++ if (NEED_SECONDARY_COLOR(ctx)) ++ ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR; ++ else ++ ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR; ++} ++ ++ + /** + * Update state dependent on vertex arrays. + */ +@@ -1045,6 +1055,26 @@ update_color(GLcontext *ctx) + } + + ++/* ++ * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET ++ * in ctx->_TriangleCaps if needed. ++ */ ++static void ++update_polygon( GLcontext *ctx ) ++{ ++ ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET); ++ ++ if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) ++ ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK; ++ ++ /* Any Polygon offsets enabled? */ ++ if (ctx->Polygon.OffsetPoint || ++ ctx->Polygon.OffsetLine || ++ ctx->Polygon.OffsetFill) { ++ ctx->_TriangleCaps |= DD_TRI_OFFSET; ++ } ++} ++ + + /** + * Update the ctx->_TriangleCaps bitfield. +@@ -1052,6 +1082,7 @@ update_color(GLcontext *ctx) + * This function must be called after other update_*() functions since + * there are dependencies on some other derived values. + */ ++#if 0 + static void + update_tricaps(GLcontext *ctx, GLbitfield new_state) + { +@@ -1117,6 +1148,7 @@ update_tricaps(GLcontext *ctx, GLbitfield new_state) + if (ctx->Stencil._TestTwoSide) + ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; + } ++#endif + + + /** +@@ -1154,6 +1186,9 @@ _mesa_update_state_locked( GLcontext *ctx ) + if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT)) + _mesa_update_draw_buffer_bounds( ctx ); + ++ if (new_state & _NEW_POLYGON) ++ update_polygon( ctx ); ++ + if (new_state & _NEW_LIGHT) + _mesa_update_lighting( ctx ); + +@@ -1163,6 +1198,9 @@ _mesa_update_state_locked( GLcontext *ctx ) + if (new_state & _IMAGE_NEW_TRANSFER_STATE) + _mesa_update_pixel( ctx, new_state ); + ++ if (new_state & _DD_NEW_SEPARATE_SPECULAR) ++ update_separate_specular( ctx ); ++ + if (new_state & (_NEW_ARRAY | _NEW_PROGRAM)) + update_arrays( ctx ); + +@@ -1172,9 +1210,11 @@ _mesa_update_state_locked( GLcontext *ctx ) + if (new_state & _NEW_COLOR) + update_color( ctx ); + ++#if 0 + if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT + | _NEW_STENCIL | _DD_NEW_SEPARATE_SPECULAR)) + update_tricaps( ctx, new_state ); ++#endif + + if (ctx->FragmentProgram._MaintainTexEnvProgram) { + if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG)) diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c -index 56d816e..fa14d91 100644 +index 56d816e..7b36154 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c -@@ -154,8 +154,18 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj ) - { - GLuint i, face; +@@ -156,6 +156,11 @@ _mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj ) -+#ifdef DEBUG -+ printf("%lu: MESA TEX DELETE %p (%u) REF COUNT = %d\n", -+ _glthread_GetID(), -+ (void*) texObj, texObj->Name, texObj->RefCount); -+#endif (void) ctx; + /* Set Target to an invalid value. With some assertions elsewhere @@ -842,7 +2953,15 @@ index 56d816e..fa14d91 100644 _mesa_free_colortable_data(&texObj->Palette); /* free the texture images */ -@@ -220,6 +230,106 @@ _mesa_copy_texture_object( struct gl_texture_object *dest, +@@ -188,6 +193,7 @@ void + _mesa_copy_texture_object( struct gl_texture_object *dest, + const struct gl_texture_object *src ) + { ++ dest->Target = src->Target; + dest->Name = src->Name; + dest->Priority = src->Priority; + dest->BorderColor[0] = src->BorderColor[0]; +@@ -220,6 +226,92 @@ _mesa_copy_texture_object( struct gl_texture_object *dest, /** @@ -877,8 +2996,7 @@ index 56d816e..fa14d91 100644 + */ +void +_mesa_reference_texobj(struct gl_texture_object **ptr, -+ struct gl_texture_object *tex, -+ const char *where) ++ struct gl_texture_object *tex) +{ + assert(ptr); + if (*ptr == tex) { @@ -897,12 +3015,6 @@ index 56d816e..fa14d91 100644 + ASSERT(oldTex->RefCount > 0); + oldTex->RefCount--; + -+#ifdef DEBUG -+ printf("%lu: MESA TEX REF DECR %p (%u) to %d from %s\n", -+ _glthread_GetID(), -+ (void*) oldTex, oldTex->Name, oldTex->RefCount, where); -+#endif -+ + deleteFlag = (oldTex->RefCount == 0); + _glthread_UNLOCK_MUTEX(oldTex->Mutex); + @@ -930,13 +3042,6 @@ index 56d816e..fa14d91 100644 + } + else { + tex->RefCount++; -+ -+#ifdef DEBUG -+ printf("%lu: MESA TEX REF INCR %p (%u) to %d from %s\n", -+ _glthread_GetID(), -+ (void*) tex, tex->Name, tex->RefCount, where); -+#endif -+ + *ptr = tex; + } + _glthread_UNLOCK_MUTEX(tex->Mutex); @@ -949,7 +3054,7 @@ index 56d816e..fa14d91 100644 * Report why a texture object is incomplete. * * \param t texture object. -@@ -620,8 +730,7 @@ unbind_texobj_from_fbo(GLcontext *ctx, struct gl_texture_object *texObj) +@@ -620,8 +712,7 @@ unbind_texobj_from_fbo(GLcontext *ctx, struct gl_texture_object *texObj) /** * Check if the given texture object is bound to any texture image units and @@ -959,7 +3064,7 @@ index 56d816e..fa14d91 100644 */ static void unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj) -@@ -630,34 +739,20 @@ unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj) +@@ -630,34 +721,20 @@ unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj) for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) { struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; @@ -968,22 +3073,22 @@ index 56d816e..fa14d91 100644 if (texObj == unit->Current1D) { - curr = &unit->Current1D; - unit->Current1D = ctx->Shared->Default1D; -+ MESA_REF_TEXOBJ(&unit->Current1D, ctx->Shared->Default1D); ++ _mesa_reference_texobj(&unit->Current1D, ctx->Shared->Default1D); } else if (texObj == unit->Current2D) { - curr = &unit->Current2D; - unit->Current2D = ctx->Shared->Default2D; -+ MESA_REF_TEXOBJ(&unit->Current2D, ctx->Shared->Default2D); ++ _mesa_reference_texobj(&unit->Current2D, ctx->Shared->Default2D); } else if (texObj == unit->Current3D) { - curr = &unit->Current3D; - unit->Current3D = ctx->Shared->Default3D; -+ MESA_REF_TEXOBJ(&unit->Current3D, ctx->Shared->Default3D); ++ _mesa_reference_texobj(&unit->Current3D, ctx->Shared->Default3D); } else if (texObj == unit->CurrentCubeMap) { - curr = &unit->CurrentCubeMap; - unit->CurrentCubeMap = ctx->Shared->DefaultCubeMap; -+ MESA_REF_TEXOBJ(&unit->CurrentCubeMap, ctx->Shared->DefaultCubeMap); ++ _mesa_reference_texobj(&unit->CurrentCubeMap, ctx->Shared->DefaultCubeMap); } else if (texObj == unit->CurrentRect) { - curr = &unit->CurrentRect; @@ -995,11 +3100,11 @@ index 56d816e..fa14d91 100644 - texObj->RefCount--; - if (texObj == unit->_Current) - unit->_Current = *curr; -+ MESA_REF_TEXOBJ(&unit->CurrentRect, ctx->Shared->DefaultRect); ++ _mesa_reference_texobj(&unit->CurrentRect, ctx->Shared->DefaultRect); } } } -@@ -693,8 +788,6 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) +@@ -693,8 +770,6 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) = _mesa_lookup_texture(ctx, textures[i]); if (delObj) { @@ -1008,7 +3113,7 @@ index 56d816e..fa14d91 100644 _mesa_lock_texture(ctx, delObj); /* Check if texture is bound to any framebuffer objects. -@@ -704,10 +797,12 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) +@@ -704,10 +779,12 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) unbind_texobj_from_fbo(ctx, delObj); /* Check if this texture is currently bound to any texture units. @@ -1022,7 +3127,7 @@ index 56d816e..fa14d91 100644 ctx->NewState |= _NEW_TEXTURE; /* The texture _name_ is now free for re-use. -@@ -717,23 +812,10 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) +@@ -717,23 +794,10 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures) _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name); _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); @@ -1045,11 +3150,11 @@ index 56d816e..fa14d91 100644 - ASSERT(ctx->Driver.DeleteTexture); - (*ctx->Driver.DeleteTexture)(ctx, delObj); - } -+ MESA_REF_TEXOBJ(&delObj, NULL); ++ _mesa_reference_texobj(&delObj, NULL); } } } -@@ -761,7 +843,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) +@@ -761,7 +825,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) GET_CURRENT_CONTEXT(ctx); const GLuint unit = ctx->Texture.CurrentUnit; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; @@ -1057,7 +3162,7 @@ index 56d816e..fa14d91 100644 struct gl_texture_object *newTexObj = NULL; ASSERT_OUTSIDE_BEGIN_END(ctx); -@@ -770,48 +851,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) +@@ -770,48 +833,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) _mesa_lookup_enum_by_nr(target), (GLint) texName); /* @@ -1106,7 +3211,7 @@ index 56d816e..fa14d91 100644 * Get pointer to new texture object (newTexObj) */ if (texName == 0) { -@@ -879,28 +918,30 @@ _mesa_BindTexture( GLenum target, GLuint texName ) +@@ -879,28 +900,30 @@ _mesa_BindTexture( GLenum target, GLuint texName ) newTexObj->Target = target; } @@ -1126,27 +3231,27 @@ index 56d816e..fa14d91 100644 switch (target) { case GL_TEXTURE_1D: - texUnit->Current1D = newTexObj; -+ MESA_REF_TEXOBJ(&texUnit->Current1D, newTexObj); ++ _mesa_reference_texobj(&texUnit->Current1D, newTexObj); break; case GL_TEXTURE_2D: - texUnit->Current2D = newTexObj; -+ MESA_REF_TEXOBJ(&texUnit->Current2D, newTexObj); ++ _mesa_reference_texobj(&texUnit->Current2D, newTexObj); break; case GL_TEXTURE_3D: - texUnit->Current3D = newTexObj; -+ MESA_REF_TEXOBJ(&texUnit->Current3D, newTexObj); ++ _mesa_reference_texobj(&texUnit->Current3D, newTexObj); break; case GL_TEXTURE_CUBE_MAP_ARB: - texUnit->CurrentCubeMap = newTexObj; -+ MESA_REF_TEXOBJ(&texUnit->CurrentCubeMap, newTexObj); ++ _mesa_reference_texobj(&texUnit->CurrentCubeMap, newTexObj); break; case GL_TEXTURE_RECTANGLE_NV: - texUnit->CurrentRect = newTexObj; -+ MESA_REF_TEXOBJ(&texUnit->CurrentRect, newTexObj); ++ _mesa_reference_texobj(&texUnit->CurrentRect, newTexObj); break; default: _mesa_problem(ctx, "bad target in BindTexture"); -@@ -910,18 +951,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) +@@ -910,18 +933,6 @@ _mesa_BindTexture( GLenum target, GLuint texName ) /* Pass BindTexture call to device driver */ if (ctx->Driver.BindTexture) (*ctx->Driver.BindTexture)( ctx, target, newTexObj ); @@ -1166,26 +3271,22 @@ index 56d816e..fa14d91 100644 diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h -index ec7cf8c..78e7933 100644 +index ec7cf8c..9577e5e 100644 --- a/src/mesa/main/texobj.h +++ b/src/mesa/main/texobj.h -@@ -57,6 +57,14 @@ extern void - _mesa_copy_texture_object( struct gl_texture_object *dest, +@@ -58,6 +58,10 @@ _mesa_copy_texture_object( struct gl_texture_object *dest, const struct gl_texture_object *src ); -+#define MESA_REF_TEXOBJ(PTR, TEX) \ -+ _mesa_reference_texobj(PTR, TEX, __FUNCTION__) + extern void ++_mesa_reference_texobj(struct gl_texture_object **ptr, ++ struct gl_texture_object *tex); + +extern void -+_mesa_reference_texobj(struct gl_texture_object **ptr, -+ struct gl_texture_object *tex, -+ const char *where); -+ - extern void _mesa_test_texobj_completeness( const GLcontext *ctx, struct gl_texture_object *obj ); + diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c -index 1b45eae..c4b678b 100644 +index 1b45eae..a5966e7 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -63,31 +63,6 @@ static const struct gl_tex_env_combine_state default_combine_state = { @@ -1234,15 +3335,15 @@ index 1b45eae..c4b678b 100644 - src->Texture.Unit[i].CurrentCubeMap); - copy_texture_binding(src, &dst->Texture.Unit[i].CurrentRect, - src->Texture.Unit[i].CurrentRect); -+ MESA_REF_TEXOBJ(&dst->Texture.Unit[i].Current1D, ++ _mesa_reference_texobj(&dst->Texture.Unit[i].Current1D, + src->Texture.Unit[i].Current1D); -+ MESA_REF_TEXOBJ(&dst->Texture.Unit[i].Current2D, ++ _mesa_reference_texobj(&dst->Texture.Unit[i].Current2D, + src->Texture.Unit[i].Current2D); -+ MESA_REF_TEXOBJ(&dst->Texture.Unit[i].Current3D, ++ _mesa_reference_texobj(&dst->Texture.Unit[i].Current3D, + src->Texture.Unit[i].Current3D); -+ MESA_REF_TEXOBJ(&dst->Texture.Unit[i].CurrentCubeMap, ++ _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentCubeMap, + src->Texture.Unit[i].CurrentCubeMap); -+ MESA_REF_TEXOBJ(&dst->Texture.Unit[i].CurrentRect, ++ _mesa_reference_texobj(&dst->Texture.Unit[i].CurrentRect, + src->Texture.Unit[i].CurrentRect); _mesa_unlock_context_textures(dst); @@ -1266,11 +3367,11 @@ index 1b45eae..c4b678b 100644 - texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap; - texUnit->CurrentRect = ctx->Shared->DefaultRect; + /* initialize current texture object ptrs to the shared default objects */ -+ MESA_REF_TEXOBJ(&texUnit->Current1D, ctx->Shared->Default1D); -+ MESA_REF_TEXOBJ(&texUnit->Current2D, ctx->Shared->Default2D); -+ MESA_REF_TEXOBJ(&texUnit->Current3D, ctx->Shared->Default3D); -+ MESA_REF_TEXOBJ(&texUnit->CurrentCubeMap, ctx->Shared->DefaultCubeMap); -+ MESA_REF_TEXOBJ(&texUnit->CurrentRect, ctx->Shared->DefaultRect); ++ _mesa_reference_texobj(&texUnit->Current1D, ctx->Shared->Default1D); ++ _mesa_reference_texobj(&texUnit->Current2D, ctx->Shared->Default2D); ++ _mesa_reference_texobj(&texUnit->Current3D, ctx->Shared->Default3D); ++ _mesa_reference_texobj(&texUnit->CurrentCubeMap, ctx->Shared->DefaultCubeMap); ++ _mesa_reference_texobj(&texUnit->CurrentRect, ctx->Shared->DefaultRect); } @@ -1320,11 +3421,11 @@ index 1b45eae..c4b678b 100644 + /* unreference current textures */ + for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) { + struct gl_texture_unit *unit = ctx->Texture.Unit + u; -+ MESA_REF_TEXOBJ(&unit->Current1D, NULL); -+ MESA_REF_TEXOBJ(&unit->Current2D, NULL); -+ MESA_REF_TEXOBJ(&unit->Current3D, NULL); -+ MESA_REF_TEXOBJ(&unit->CurrentCubeMap, NULL); -+ MESA_REF_TEXOBJ(&unit->CurrentRect, NULL); ++ _mesa_reference_texobj(&unit->Current1D, NULL); ++ _mesa_reference_texobj(&unit->Current2D, NULL); ++ _mesa_reference_texobj(&unit->Current3D, NULL); ++ _mesa_reference_texobj(&unit->CurrentCubeMap, NULL); ++ _mesa_reference_texobj(&unit->CurrentRect, NULL); + } /* Free proxy texture objects */ @@ -1340,6 +3441,247 @@ index 1b45eae..c4b678b 100644 _mesa_TexEnvProgramCacheDestroy( ctx ); } +diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h +index 2c84579..2d3c68b 100644 +--- a/src/mesa/main/version.h ++++ b/src/mesa/main/version.h +@@ -1,6 +1,6 @@ + /* + * Mesa 3-D graphics library +- * Version: 7.0.1 ++ * Version: 7.0.2 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * +@@ -30,8 +30,8 @@ + /* Mesa version */ + #define MESA_MAJOR 7 + #define MESA_MINOR 0 +-#define MESA_PATCH 1 +-#define MESA_VERSION_STRING "7.0.1" ++#define MESA_PATCH 2 ++#define MESA_VERSION_STRING "7.0.2" + + /* To make version comparison easy */ + #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c +index 5027264..6a87a17 100644 +--- a/src/mesa/shader/arbprogparse.c ++++ b/src/mesa/shader/arbprogparse.c +@@ -624,6 +624,41 @@ program_error(GLcontext *ctx, GLint position, const char *descrip) + } + + ++/** ++ * As above, but with an extra string parameter for more info. ++ */ ++static void ++program_error2(GLcontext *ctx, GLint position, const char *descrip, ++ const char *var) ++{ ++ if (descrip) { ++ const char *prefix = "glProgramString(", *suffix = ")"; ++ char *str = (char *) _mesa_malloc(_mesa_strlen(descrip) + ++ _mesa_strlen(": ") + ++ _mesa_strlen(var) + ++ _mesa_strlen(prefix) + ++ _mesa_strlen(suffix) + 1); ++ if (str) { ++ _mesa_sprintf(str, "%s%s: %s%s", prefix, descrip, var, suffix); ++ _mesa_error(ctx, GL_INVALID_OPERATION, str); ++ _mesa_free(str); ++ } ++ } ++ { ++ char *str = (char *) _mesa_malloc(_mesa_strlen(descrip) + ++ _mesa_strlen(": ") + ++ _mesa_strlen(var) + 1); ++ if (str) { ++ _mesa_sprintf(str, "%s: %s", descrip, var); ++ } ++ _mesa_set_program_error(ctx, position, str); ++ if (str) { ++ _mesa_free(str); ++ } ++ } ++} ++ ++ + + /** + * constructs an integer from 4 GLubytes in LE format +@@ -1217,10 +1252,10 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, + state_tokens[1] = coord; + + /* EYE or OBJECT */ +- type = *(*inst++); ++ type = *(*inst)++; + + /* 0 - s, 1 - t, 2 - r, 3 - q */ +- coord = *(*inst++); ++ coord = *(*inst)++; + + if (type == TEX_GEN_EYE) { + switch (coord) { +@@ -1236,6 +1271,9 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, + case COMPONENT_W: + state_tokens[2] = STATE_TEXGEN_EYE_Q; + break; ++ default: ++ _mesa_problem(ctx, "bad texgen component in " ++ "parse_state_single_item()"); + } + } + else { +@@ -1252,6 +1290,9 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, + case COMPONENT_W: + state_tokens[2] = STATE_TEXGEN_OBJECT_Q; + break; ++ default: ++ _mesa_problem(ctx, "bad texgen component in " ++ "parse_state_single_item()"); + } + } + } +@@ -1274,7 +1315,7 @@ parse_state_single_item (GLcontext * ctx, const GLubyte ** inst, + break; + + case STATE_POINT: +- switch (*(*inst++)) { ++ switch (*(*inst)++) { + case POINT_SIZE: + state_tokens[0] = STATE_POINT_SIZE; + break; +@@ -1678,18 +1719,14 @@ parse_attrib (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head + struct arb_program *Program) + { + GLuint found; +- char *error_msg; + struct var_cache *attrib_var; + + attrib_var = parse_string (inst, vc_head, Program, &found); + Program->Position = parse_position (inst); + if (found) { +- error_msg = (char *) +- _mesa_malloc (_mesa_strlen ((char *) attrib_var->name) + 40); +- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", +- attrib_var->name); +- program_error(ctx, Program->Position, error_msg); +- _mesa_free (error_msg); ++ program_error2(ctx, Program->Position, ++ "Duplicate variable declaration", ++ (char *) attrib_var->name); + return 1; + } + +@@ -1867,12 +1904,9 @@ parse_param (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, + Program->Position = parse_position (inst); + + if (found) { +- char *error_msg = (char *) +- _mesa_malloc (_mesa_strlen ((char *) param_var->name) + 40); +- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", +- param_var->name); +- program_error (ctx, Program->Position, error_msg); +- _mesa_free (error_msg); ++ program_error2(ctx, Program->Position, ++ "Duplicate variable declaration", ++ (char *) param_var->name); + return 1; + } + +@@ -1967,12 +2001,9 @@ parse_temp (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, + temp_var = parse_string (inst, vc_head, Program, &found); + Program->Position = parse_position (inst); + if (found) { +- char *error_msg = (char *) +- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); +- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", +- temp_var->name); +- program_error(ctx, Program->Position, error_msg); +- _mesa_free (error_msg); ++ program_error2(ctx, Program->Position, ++ "Duplicate variable declaration", ++ (char *) temp_var->name); + return 1; + } + +@@ -2013,12 +2044,9 @@ parse_output (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head + output_var = parse_string (inst, vc_head, Program, &found); + Program->Position = parse_position (inst); + if (found) { +- char *error_msg = (char *) +- _mesa_malloc (_mesa_strlen ((char *) output_var->name) + 40); +- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", +- output_var->name); +- program_error (ctx, Program->Position, error_msg); +- _mesa_free (error_msg); ++ program_error2(ctx, Program->Position, ++ "Duplicate variable declaration", ++ (char *) output_var->name); + return 1; + } + +@@ -2044,12 +2072,9 @@ parse_alias (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, + Program->Position = parse_position (inst); + + if (found) { +- char *error_msg = (char *) +- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); +- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", +- temp_var->name); +- program_error(ctx, Program->Position, error_msg); +- _mesa_free (error_msg); ++ program_error2(ctx, Program->Position, ++ "Duplicate variable declaration", ++ (char *) temp_var->name); + return 1; + } + +@@ -2059,12 +2084,9 @@ parse_alias (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head, + + if (!found) + { +- char *error_msg = (char *) +- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); +- _mesa_sprintf (error_msg, "Alias value %s is not defined", +- temp_var->alias_binding->name); +- program_error (ctx, Program->Position, error_msg); +- _mesa_free (error_msg); ++ program_error2(ctx, Program->Position, ++ "Undefined alias value", ++ (char *) temp_var->alias_binding->name); + return 1; + } + +@@ -2087,12 +2109,9 @@ parse_address (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_hea + temp_var = parse_string (inst, vc_head, Program, &found); + Program->Position = parse_position (inst); + if (found) { +- char *error_msg = (char *) +- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40); +- _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s", +- temp_var->name); +- program_error (ctx, Program->Position, error_msg); +- _mesa_free (error_msg); ++ program_error2(ctx, Program->Position, ++ "Duplicate variable declaration", ++ (char *) temp_var->name); + return 1; + } + +@@ -2445,8 +2464,9 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst, + Program->Position = parse_position (inst); + + if (!found) { +- program_error(ctx, Program->Position, +- "2: Undefined variable"); /* src->name */ ++ program_error2(ctx, Program->Position, ++ "Undefined variable", ++ (char *) src->name); + return 1; + } + diff --git a/src/mesa/shader/atifragshader.c b/src/mesa/shader/atifragshader.c index 4727c1a..854c911 100644 --- a/src/mesa/shader/atifragshader.c @@ -1402,6 +3744,40 @@ index b794e30..06d24b4 100644 for (i = 0; i < n; i++) { if (shProg->Shaders[i]->Name == shader) { /* found it */ +diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c +index 012839c..ac7fa21 100644 +--- a/src/mesa/swrast/s_copypix.c ++++ b/src/mesa/swrast/s_copypix.c +@@ -1,6 +1,6 @@ + /* + * Mesa 3-D graphics library +- * Version: 6.5.3 ++ * Version: 7.0.2 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * +@@ -71,13 +71,20 @@ regions_overlap(GLint srcx, GLint srcy, + } + else { + /* add one pixel of slop when zooming, just to be safe */ +- if ((srcx > dstx + (width * zoomX) + 1) || (srcx + width + 1 < dstx)) { ++ if (srcx > (dstx + ((zoomX > 0.0F) ? (width * zoomX + 1.0F) : 0.0F))) { ++ /* src is completely right of dest */ ++ return GL_FALSE; ++ } ++ else if (srcx + width + 1.0F < dstx + ((zoomX > 0.0F) ? 0.0F : (width * zoomX))) { ++ /* src is completely left of dest */ + return GL_FALSE; + } + else if ((srcy < dsty) && (srcy + height < dsty + (height * zoomY))) { ++ /* src is completely below dest */ + return GL_FALSE; + } + else if ((srcy > dsty) && (srcy + height > dsty + (height * zoomY))) { ++ /* src is completely above dest */ + return GL_FALSE; + } + else { diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h index dddc2f7..9436464 100644 --- a/src/mesa/swrast/s_pointtemp.h @@ -1418,6 +3794,200 @@ index dddc2f7..9436464 100644 ymax = ymin + iSize - 1; } #endif /*SMOOTH*/ +diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c +index 097d2c7..5814400 100644 +--- a/src/mesa/swrast/s_span.c ++++ b/src/mesa/swrast/s_span.c +@@ -61,8 +61,11 @@ _swrast_span_default_z( GLcontext *ctx, SWspan *span ) + const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF; + if (ctx->DrawBuffer->Visual.depthBits <= 16) + span->z = FloatToFixed(ctx->Current.RasterPos[2] * depthMax + 0.5F); +- else +- span->z = (GLint) (ctx->Current.RasterPos[2] * depthMax + 0.5F); ++ else { ++ GLfloat tmpf = ctx->Current.RasterPos[2] * depthMax; ++ tmpf = MIN2(tmpf, depthMax); ++ span->z = (GLint) tmpf; ++ } + span->zStep = 0; + span->interpMask |= SPAN_Z; + } +diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c +index dff062a..63f7890 100644 +--- a/src/mesa/tnl/t_vp_build.c ++++ b/src/mesa/tnl/t_vp_build.c +@@ -1,8 +1,8 @@ + /* + * Mesa 3-D graphics library +- * Version: 6.5 ++ * Version: 7.1 + * +- * Copyright (C) 2006 Tungsten Graphics All Rights Reserved. ++ * Copyright (C) 2007 Tungsten Graphics 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"), +@@ -33,11 +33,11 @@ + #include "glheader.h" + #include "macros.h" + #include "enums.h" +-#include "program.h" +-#include "prog_instruction.h" +-#include "prog_parameter.h" +-#include "prog_print.h" +-#include "prog_statevars.h" ++#include "shader/program.h" ++#include "shader/prog_instruction.h" ++#include "shader/prog_parameter.h" ++#include "shader/prog_print.h" ++#include "shader/prog_statevars.h" + #include "t_context.h" /* NOTE: very light dependency on this */ + #include "t_vp_build.h" + +@@ -457,9 +457,13 @@ static void register_matrix_param5( struct tnl_program *p, + } + + ++/** ++ * 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; +@@ -469,9 +473,18 @@ static void emit_arg( struct prog_src_register *src, + src->RelAddr = 0; + } + ++/** ++ * Convert a ureg dest register to a prog_dst_register. ++ */ + static void emit_dst( struct prog_dst_register *dst, + struct ureg reg, GLuint mask ) + { ++ /* Check for legal output register type. UNDEFINED will occur in ++ * instruction that don't produce a result (like END). ++ */ ++ assert(reg.file == PROGRAM_TEMPORARY || ++ reg.file == PROGRAM_OUTPUT || ++ reg.file == PROGRAM_UNDEFINED); + dst->File = reg.file; + dst->Index = reg.idx; + /* allow zero as a shorthand for xyzw */ +@@ -956,13 +969,19 @@ static void build_lighting( struct tnl_program *p ) + STATE_POSITION); + struct ureg V = get_eye_position(p); + struct ureg dist = get_temp(p); ++ struct ureg tmpPpli = get_temp(p); + + VPpli = get_temp(p); + half = get_temp(p); + +- /* Calulate VPpli vector ++ /* In homogeneous object coordinates ++ */ ++ emit_op1(p, OPCODE_RCP, dist, 0, swizzle1(Ppli, W)); ++ emit_op2(p, OPCODE_MUL, tmpPpli, 0, Ppli, dist); ++ ++ /* Calculate VPpli vector + */ +- emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); ++ emit_op2(p, OPCODE_SUB, VPpli, 0, tmpPpli, V); + + /* Normalize VPpli. The dist value also used in + * attenuation below. +@@ -994,6 +1013,7 @@ static void build_lighting( struct tnl_program *p ) + emit_normalize_vec3(p, half, half); + + release_temp(p, dist); ++ release_temp(p, tmpPpli); + } + + /* Calculate dot products: +@@ -1103,7 +1123,9 @@ static void build_fog( struct tnl_program *p ) + { + struct ureg fog = register_output(p, VERT_RESULT_FOGC); + struct ureg input; +- ++ GLuint useabs = p->state->fog_source_is_depth && p->state->fog_mode && ++ (p->state->fog_mode != FOG_EXP2); ++ + if (p->state->fog_source_is_depth) { + input = swizzle1(get_eye_position(p), Z); + } +@@ -1111,31 +1133,36 @@ static void build_fog( struct tnl_program *p ) + input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); + } + +- if (p->state->tnl_do_vertex_fog) { ++ if (p->state->fog_mode && p->state->tnl_do_vertex_fog) { + struct ureg params = register_param2(p, STATE_INTERNAL, + STATE_FOG_PARAMS_OPTIMIZED); + struct ureg tmp = get_temp(p); + ++ if (useabs) { ++ emit_op1(p, OPCODE_ABS, tmp, 0, input); ++ } ++ + switch (p->state->fog_mode) { + case FOG_LINEAR: { + struct ureg id = get_identity_param(p); +- emit_op3(p, OPCODE_MAD, tmp, 0, input, swizzle1(params,X), swizzle1(params,Y)); ++ emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input, ++ swizzle1(params,X), swizzle1(params,Y)); + emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */ + emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W)); + break; + } + case FOG_EXP: +- emit_op1(p, OPCODE_ABS, tmp, 0, input); +- emit_op2(p, OPCODE_MUL, tmp, 0, tmp, swizzle1(params,Z)); ++ emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input, ++ swizzle1(params,Z)); + emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp)); + break; + case FOG_EXP2: + emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W)); +- emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp); ++ emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp); + emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp)); + break; + } +- ++ + release_temp(p, tmp); + } + else { +@@ -1143,7 +1170,7 @@ static void build_fog( struct tnl_program *p ) + * + * KW: Is it really necessary to do anything in this case? + */ +- emit_op1(p, OPCODE_MOV, fog, WRITEMASK_X, input); ++ emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, WRITEMASK_X, input); + } + } + +diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c +index 8940551..697d00e 100644 +--- a/src/mesa/vbo/vbo_save_draw.c ++++ b/src/mesa/vbo/vbo_save_draw.c +@@ -132,9 +132,11 @@ static void vbo_bind_vertex_list( GLcontext *ctx, + } + + for (attr = 0; attr < VBO_ATTRIB_MAX; attr++) { +- if (node->attrsz[attr]) { ++ GLuint src = map[attr]; ++ ++ if (node->attrsz[src]) { + arrays[attr].Ptr = (const GLubyte *)data; +- arrays[attr].Size = node->attrsz[attr]; ++ 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; diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c index e142dde..b71a935 100644 --- a/src/mesa/vbo/vbo_split_copy.c @@ -1445,3 +4015,38 @@ index e142dde..b71a935 100644 dst->BufferObj = ctx->Array.NullBufferObj; dst->_MaxElement = copy->dstbuf_size; /* may be less! */ +diff --git a/src/mesa/x86-64/xform4.S b/src/mesa/x86-64/xform4.S +index 65328f6..f512b3a 100644 +--- a/src/mesa/x86-64/xform4.S ++++ b/src/mesa/x86-64/xform4.S +@@ -1,10 +1,8 @@ +-/* $Id: xform4.S,v 1.2 2006/04/17 18:58:24 krh Exp $ */ +- + /* + * Mesa 3-D graphics library +- * Version: 3.5 ++ * Version: 7.0.1 + * +- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. ++ * Copyright (C) 1999-2007 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"), +@@ -64,7 +62,7 @@ _mesa_x86_64_transform_points4_general: + + p4_general_loop: + +- movaps (%rdx), %xmm8 /* ox | oy | oz | ow */ ++ movups (%rdx), %xmm8 /* ox | oy | oz | ow */ + prefetchw 16(%rdi) + + pshufd $0x00, %xmm8, %xmm0 /* ox | ox | ox | ox */ +@@ -149,7 +147,7 @@ _mesa_x86_64_transform_points4_3d: + + p4_3d_loop: + +- movaps (%rdx), %xmm8 /* ox | oy | oz | ow */ ++ movups (%rdx), %xmm8 /* ox | oy | oz | ow */ + prefetchw 16(%rdi) + + pshufd $0x00, %xmm8, %xmm0 /* ox | ox | ox | ox */ diff --git a/mesa.spec b/mesa.spec index 82b07dd..9ca1063 100644 --- a/mesa.spec +++ b/mesa.spec @@ -32,7 +32,7 @@ Summary: Mesa graphics libraries Name: mesa Version: 7.0.1 -Release: 5%{?dist} +Release: 6%{?dist} License: MIT Group: System Environment/Libraries URL: http://www.mesa3d.org @@ -46,13 +46,10 @@ Patch0: mesa-7.0-build-config.patch Patch4: mesa-6.5-dont-libglut-me-harder-ok-thx-bye.patch Patch5: mesa-6.5.2-xserver-1.1-source-compat.patch Patch18: mesa-7.0-selinux-awareness.patch -Patch22: mesa-6.5.2-hush-synthetic-visual-warning.patch Patch23: mesa-6.5.2-bindcontext-paranoia.patch -Patch24: mesa-7.0-i-already-defined-glapi-you-twit.patch Patch25: mesa-7.0-symlinks-before-depend.patch Patch26: mesa-7.0.1-stable-branch.patch Patch27: mesa-7.0-use_master-r300.patch -Patch28: mesa-7.0.1-965-sampler-crash.patch BuildRequires: pkgconfig %if %{with_dri} @@ -178,13 +175,10 @@ chmod a-x progs/demos/glslnoise.c %patch4 -p0 -b .dont-libglut-me-harder-ok-thx-bye %patch5 -p1 -b .xserver-1.1-compat %patch18 -p1 -b .selinux-awareness -%patch22 -p1 -b .visual-warning %patch23 -p1 -b .bindcontext -%patch24 -p1 -b .glapi %patch25 -p1 -b .makej %patch26 -p1 -b .stable %patch27 -p1 -b .r300 -%patch28 -p1 -b .965-sampler # WARNING: The following files are copyright "Mark J. Kilgard" under the GLUT # license and are not open source/free software, so we remove them. @@ -414,6 +408,15 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/mesa-demos-data %changelog +* Fri Sep 28 2007 Dave Airlie 7.0.1-6 +- mesa-7.0.1-stable-branch.patch - Updated to close to 7.0.2-rc1 +- This contains the fixes made to the upstream Mesa stable branch + including fixes for 965 vblank interrupt issues along with a fix + in the kernel - remove patches that already upstream. +- mesa-6.5.2-hush-synthetic-visual-warning.patch - dropped +- mesa-7.0-i-already-defined-glapi-you-twit.patch - dropped +- mesa-7.0.1-965-sampler-crash.patch - dropped + * Thu Sep 06 2007 Adam Jackson 7.0.1-5 - mesa-7.0.1-965-sampler-crash.patch: Fix a crash with 965 in Torcs. (#262941)