Index: /trunk/src/VBox/Additions/common/crOpenGL/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/Makefile.kmk	(revision 20083)
+++ /trunk/src/VBox/Additions/common/crOpenGL/Makefile.kmk	(revision 20084)
@@ -351,4 +351,5 @@
 	pack/packspu_swapbuf.c \
 	pack/packspu_pixel.c \
+	pack/packspu_texture.c \
 	$(VBOX_PATH_CROGL_GENFILES)/packspu.c \
 	$(VBOX_PATH_CROGL_GENFILES)/packspu_get.c \
Index: /trunk/src/VBox/Additions/common/crOpenGL/load.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/load.c	(revision 20083)
+++ /trunk/src/VBox/Additions/common/crOpenGL/load.c	(revision 20084)
@@ -544,5 +544,5 @@
     if (stub_initialized)
         return true;
-    
+
     stubInitVars();
 
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu.h
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu.h	(revision 20083)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu.h	(revision 20084)
@@ -83,4 +83,6 @@
 extern void packspuHuge( CROpcode opcode, void *buf );
 
+extern GLboolean packspuSyncOnFlushes();
+
 extern ThreadInfo *packspuNewThread( unsigned long id );
 
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_flush_special
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_flush_special	(revision 20083)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_flush_special	(revision 20084)
@@ -3,5 +3,4 @@
 #
 # See the file LICENSE.txt for information on redistributing this software.
-Flush
 BarrierCreateCR
 BarrierExecCR
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py	(revision 20083)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py	(revision 20084)
@@ -86,5 +86,13 @@
             print '\t\tpname == GL_PACK_IMAGE_HEIGHT ||'
             print '#endif'
-            print '\t\tpname == GL_PACK_SKIP_ROWS) {'
+            print '\t\tpname == GL_PACK_SKIP_ROWS'
+            print '\t\t|| pname == GL_DRAW_BUFFER'
+            print '#ifdef CR_OPENGL_VERSION_1_3'
+            print '\t\t|| pname == GL_ACTIVE_TEXTURE'
+            print '#endif'
+            print '#ifdef CR_ARB_multitexture'
+            print '\t\t|| pname == GL_ACTIVE_TEXTURE_ARB'
+            print '#endif'
+            print ') {'
             print '\t\t\tcrState%s( pname, params );' % func_name
             print '\t\t\treturn;'
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c	(revision 20083)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c	(revision 20084)
@@ -41,25 +41,70 @@
 }
 
+GLboolean packspuSyncOnFlushes()
+{
+    GLint buffer;
+    crStateGetIntegerv(GL_DRAW_BUFFER, &buffer);
+    /*Usually buffer==GL_BACK, so put this extra check to simplify boolean eval on runtime*/
+    return  (buffer != GL_BACK)
+            && (buffer == GL_FRONT_LEFT 
+                || buffer == GL_FRONT_RIGHT
+                || buffer == GL_FRONT
+                || buffer == GL_FRONT_AND_BACK
+                || buffer == GL_LEFT
+                || buffer == GL_RIGHT);
+}
+
+void PACKSPU_APIENTRY packspu_DrawBuffer(GLenum mode)
+{
+    crStateDrawBuffer(mode);
+    crPackDrawBuffer(mode);
+}
+
 void PACKSPU_APIENTRY packspu_Finish( void )
 {
     GET_THREAD(thread);
     GLint writeback = pack_spu.thread[0].netServer.conn->actual_network;
-    if (pack_spu.swap)
-    {
-        crPackFinishSWAP(  );
+
+    if (pack_spu.swap)
+    {
+        crPackFinishSWAP();
+    }
+    else
+    {
+        crPackFinish();
+    }
+
+    if (packspuSyncOnFlushes())
+    {
+        packspuFlush( (void *) thread );
+
         if (writeback)
-            crPackWritebackSWAP( &writeback );
-    }
-    else
-    {
-        crPackFinish(  );
-        if (writeback)
-            crPackWriteback( &writeback );
-    }
-    packspuFlush( (void *) thread );
-    while (writeback)
-        crNetRecv();
-}
-
+            if (pack_spu.swap)
+                crPackWritebackSWAP(&writeback);
+            else
+                crPackWriteback(&writeback);
+
+        while (writeback)
+            crNetRecv();
+    }
+}
+
+void PACKSPU_APIENTRY packspu_Flush( void )
+{
+    GET_THREAD(thread);
+    if (pack_spu.swap)
+    {
+        crPackFlushSWAP();
+    }
+    else
+    {
+        crPackFlush();
+    }
+
+    if (packspuSyncOnFlushes())
+    {
+        packspuFlush( (void *) thread );
+    }
+}
 
 GLint PACKSPU_APIENTRY packspu_WindowCreate( const char *dpyName, GLint visBits )
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_net.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_net.c	(revision 20083)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_net.c	(revision 20084)
@@ -151,7 +151,13 @@
 
     if ( buf->holds_BeginEnd )
+    {
+        /*crDebug("crNetBarf %d, (%d)", len, buf->size);*/
         crNetBarf( thread->netServer.conn, &(buf->pack), hdr, len );
+    }
     else
+    {
+        /*crDebug("crNetSend %d, (%d)", len, buf->size);*/
         crNetSend( thread->netServer.conn, &(buf->pack), hdr, len );
+    }
 
     buf->pack = crNetAlloc( thread->netServer.conn );
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_special
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_special	(revision 20083)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_special	(revision 20084)
@@ -61,2 +61,5 @@
 BufferDataARB
 ZPixCR
+ActiveTextureARB
+DrawBuffer
+Flush
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c	(revision 20084)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c	(revision 20084)
@@ -0,0 +1,23 @@
+/* $Id$ */
+
+/** @file
+ * VBox OpenGL DRI driver functions
+ */
+
+/*
+ * Copyright (C) 2009 Sun Microsystems, Inc.
+ *
+ * Sun Microsystems, Inc. confidential
+ * All rights reserved
+ */
+
+#include "packspu.h"
+#include "cr_packfunctions.h"
+#include "cr_glstate.h"
+#include "packspu_proto.h"
+
+void PACKSPU_APIENTRY packspu_ActiveTextureARB(GLenum texture)
+{
+    crStateActiveTextureARB(texture);
+    crPackActiveTextureARB(texture);
+}
Index: /trunk/src/VBox/Additions/common/crOpenGL/stub.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/stub.c	(revision 20083)
+++ /trunk/src/VBox/Additions/common/crOpenGL/stub.c	(revision 20084)
@@ -14,4 +14,13 @@
 #include <X11/extensions/Xfixes.h>
 #endif
+
+static void crForcedFlush()
+{
+    GLint buffer;
+    stub.spu->dispatch_table.GetIntegerv(GL_DRAW_BUFFER, &buffer);
+    stub.spu->dispatch_table.DrawBuffer(GL_FRONT);
+    stub.spu->dispatch_table.Flush();
+    stub.spu->dispatch_table.DrawBuffer(buffer);
+}
 
 /**
@@ -100,5 +109,5 @@
         }
 #endif
-        stub.spu->dispatch_table.Flush();
+        crForcedFlush();
 
         crHashtableDelete(stub.windowTable, window, crFree);
@@ -303,5 +312,5 @@
                 if (stubUpdateWindowGeometry(winInfo, GL_FALSE) || changed)
                 {
-                    stub.spuDispatch.Flush();
+                    crForcedFlush();
                 }
                 break;
@@ -317,5 +326,5 @@
                 if (stub.trackWindowVisibleRgn && stubUpdateWindowVisibileRegions(winInfo))
                 {
-                    stub.spuDispatch.Flush();
+                    crForcedFlush();
                 }
                 break;
@@ -327,5 +336,5 @@
                 {
                     crDebug("Visibility info updated due to unknown hooked message (%d)", pMsgInfo->message);
-                    stub.spuDispatch.Flush();
+                    crForcedFlush();
                 }
                 break;
