Index: trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu.c
===================================================================
--- trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu.c	(revision 21292)
+++ trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu.c	(revision 21308)
@@ -478,4 +478,6 @@
     }
 #endif
+    //crDebug("arrayspu_DrawElements mode:0x%x, count:%d, type:0x%x", mode, count, type);
+    
 
     array_spu.self.Begin(mode);
@@ -521,65 +523,77 @@
 static void ARRAYSPU_APIENTRY arrayspu_ColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
 {
-    crStateColorPointer( size, type, stride, pointer );
+    crStateColorPointer(size, type, stride, pointer);
+    array_spu.child.ColorPointer(size, type, stride, pointer);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_SecondaryColorPointerEXT( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
 {
-    crStateSecondaryColorPointerEXT( size, type, stride, pointer );
+    crStateSecondaryColorPointerEXT(size, type, stride, pointer);
+    array_spu.child.SecondaryColorPointerEXT(size, type, stride, pointer);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_VertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
 {
-    crStateVertexPointer( size, type, stride, pointer );
+    crStateVertexPointer(size, type, stride, pointer);
+    array_spu.child.VertexPointer(size, type, stride, pointer);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_TexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
 {
-    crStateTexCoordPointer( size, type, stride, pointer );
+    crStateTexCoordPointer(size, type, stride, pointer);
+    array_spu.child.TexCoordPointer(size, type, stride, pointer);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_NormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
 {
-    crStateNormalPointer( type, stride, pointer );
+    crStateNormalPointer(type, stride, pointer);
+    array_spu.child.NormalPointer(type, stride, pointer);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_IndexPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
 {
-    crStateIndexPointer( type, stride, pointer );
+    crStateIndexPointer(type, stride, pointer);
+    array_spu.child.IndexPointer(type, stride, pointer);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_EdgeFlagPointer( GLsizei stride, const GLvoid *pointer )
 {
-    crStateEdgeFlagPointer( stride, pointer );
+    crStateEdgeFlagPointer(stride, pointer);
+    array_spu.child.EdgeFlagPointer(stride, pointer);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_VertexAttribPointerNV( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer )
 {
-    crStateVertexAttribPointerNV( index, size, type, stride, pointer );
+    crStateVertexAttribPointerNV(index, size, type, stride, pointer);
+    array_spu.child.VertexAttribPointerNV(index, size, type, stride, pointer);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_FogCoordPointerEXT( GLenum type, GLsizei stride, const GLvoid *pointer )
 {
-    crStateFogCoordPointerEXT( type, stride, pointer );
+    crStateFogCoordPointerEXT(type, stride, pointer);
+    array_spu.child.FogCoordPointerEXT(type, stride, pointer);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_GetPointerv( GLenum pname, GLvoid **params )
 {
-    crStateGetPointerv( pname, params );
+    crStateGetPointerv(pname, params);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_EnableClientState( GLenum array )
 {
-    crStateEnableClientState( array );
+    crStateEnableClientState(array);
+    array_spu.child.EnableClientState(array);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_DisableClientState( GLenum array )
 {
-    crStateDisableClientState( array );
+    crStateDisableClientState(array);
+    array_spu.child.DisableClientState(array);
 }
 
 static void ARRAYSPU_APIENTRY arrayspu_ClientActiveTextureARB( GLenum texture )
 {
-    crStateClientActiveTextureARB( texture );
+    crStateClientActiveTextureARB(texture);
+    array_spu.child.ClientActiveTextureARB(texture);
 }
 
@@ -662,5 +676,6 @@
                                 const GLvoid *pointer)
 {
-    crStateVertexAttribPointerARB( index, size, type, normalized, stride, pointer );
+    crStateVertexAttribPointerARB(index, size, type, normalized, stride, pointer);
+    array_spu.child.VertexAttribPointerARB(index, size, type, normalized, stride, pointer);
 }
 
@@ -703,5 +718,5 @@
 arrayspu_GenBuffersARB( GLsizei n, GLuint * buffers )
 {
-    crStateGenBuffersARB(n, buffers);
+    array_spu.child.GenBuffersARB(n, buffers);
 }
 
@@ -710,4 +725,5 @@
 {
     crStateDeleteBuffersARB(n, buffers);
+    array_spu.child.DeleteBuffersARB(n, buffers);
 }
 
@@ -716,4 +732,5 @@
 {
     crStateBindBufferARB(target, buffer);
+    array_spu.child.BindBufferARB(target, buffer);
 }
 
@@ -721,5 +738,5 @@
 arrayspu_IsBufferARB (GLuint buffer)
 {
-    return crStateIsBufferARB(buffer);
+    return array_spu.child.IsBufferARB(buffer);
 }
 
@@ -728,4 +745,5 @@
 {
     crStateBufferDataARB(target, size, data, usage);
+    array_spu.child.BufferDataARB(target, size, data, usage);
 }
 
@@ -735,4 +753,5 @@
 {
     crStateBufferSubDataARB(target, offset, size, data);
+    array_spu.child.BufferSubDataARB(target, offset, size, data);
 }
 
@@ -752,5 +771,6 @@
 arrayspu_UnmapBufferARB(GLenum target)
 {
-    return crStateUnmapBufferARB(target);
+    crStateUnmapBufferARB(target);
+    return array_spu.child.UnmapBufferARB(target);
 }
 
Index: trunk/src/VBox/Additions/common/crOpenGL/load.c
===================================================================
--- trunk/src/VBox/Additions/common/crOpenGL/load.c	(revision 21292)
+++ trunk/src/VBox/Additions/common/crOpenGL/load.c	(revision 21308)
@@ -589,5 +589,5 @@
 #endif
 
-    strcpy(response, "3 0 array 1 feedback 2 pack");
+    strcpy(response, "2 0 feedback 1 pack");
     spuchain = crStrSplit( response, " " );
     num_spus = crStrToInt( spuchain[0] );
Index: trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c
===================================================================
--- trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c	(revision 21292)
+++ trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c	(revision 21308)
@@ -15,8 +15,9 @@
 packspu_MapBufferARB( GLenum target, GLenum access )
 {
-    GLint size = -1;
     GET_CONTEXT(ctx);
     void *buffer;
+#if 0
     CRBufferObject *bufObj;
+    GLint size = -1;
 
     (void) crStateMapBufferARB( target, access );
@@ -52,6 +53,15 @@
      */
     packspu_GetBufferSubDataARB(target, 0, bufObj->size, buffer);
+#else
+    CRASSERT(GL_TRUE == ctx->clientState->bufferobject.retainBufferData);
+    buffer = crStateMapBufferARB(target, access); 
+#endif
 
     return buffer;
+}
+
+void PACKSPU_APIENTRY packspu_GetBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data )
+{
+    crStateGetBufferSubDataARB(target, offset, size, data);
 }
 
@@ -60,6 +70,8 @@
 packspu_UnmapBufferARB( GLenum target )
 {
+    GET_CONTEXT(ctx);
+
+#if 0
     CRBufferObject *bufObj;
-    GET_CONTEXT(ctx);
 
     if (target == GL_ARRAY_BUFFER_ARB) {
@@ -76,4 +88,5 @@
     /* free the buffer / unmap it */
     crFree(bufObj->pointer);
+#endif
 
     crStateUnmapBufferARB( target );
@@ -84,9 +97,17 @@
 
 void PACKSPU_APIENTRY
-packspu_BufferDataARB( GLenum target, GLsizeiptrARB size,
-                                             const GLvoid * data, GLenum usage )
+packspu_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage)
 {
+    /*crDebug("packspu_BufferDataARB size:%d", size);*/
     crStateBufferDataARB(target, size, data, usage);
     crPackBufferDataARB(target, size, data, usage);
+}
+
+void PACKSPU_APIENTRY
+packspu_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data)
+{
+    /*crDebug("packspu_BufferSubDataARB size:%d", size);*/
+    crStateBufferSubDataARB(target, offset, size, data);
+    crPackBufferSubDataARB(target, offset, size, data);
 }
 
Index: trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_client.c
===================================================================
--- trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_client.c	(revision 21292)
+++ trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_client.c	(revision 21308)
@@ -153,4 +153,7 @@
     }
 #endif
+
+    /*crDebug("packspu_InterleavedArrays");*/
+
     crStateInterleavedArrays( format, stride, pointer );
 }
@@ -160,8 +163,10 @@
 packspu_ArrayElement( GLint index )
 {
+#if 0
     GLboolean serverArrays = GL_FALSE;
 
 #if CR_ARB_vertex_buffer_object
     GET_CONTEXT(ctx);
+    /*crDebug("packspu_ArrayElement index:%i", index);*/
     if (ctx->clientState->extensions.ARB_vertex_buffer_object)
         serverArrays = crStateUseServerArrays();
@@ -184,4 +189,9 @@
             crPackExpandArrayElement( index, clientState );
     }
+#else
+    GET_CONTEXT(ctx);
+    CRClientState *clientState = &(ctx->clientState->client);
+    crPackExpandArrayElement(index, clientState);
+#endif
 }
 
@@ -194,4 +204,5 @@
 #if CR_ARB_vertex_buffer_object
     GET_CONTEXT(ctx);
+    /*crDebug("DrawElements count=%d, indices=%p", count, indices);*/
     if (ctx->clientState->extensions.ARB_vertex_buffer_object)
         serverArrays = crStateUseServerArrays();
@@ -212,5 +223,9 @@
             crPackExpandDrawElementsSWAP( mode, count, type, indices, clientState );
         else
+        {
+            //packspu_Begin(mode);
             crPackExpandDrawElements( mode, count, type, indices, clientState );
+            //packspu_End();
+        }
     }
 }
@@ -224,4 +239,5 @@
 #if CR_ARB_vertex_buffer_object
     GET_CONTEXT(ctx);
+    /*crDebug("DrawRangeElements count=%d", count);*/
     if (ctx->clientState->extensions.ARB_vertex_buffer_object)
          serverArrays = crStateUseServerArrays();
@@ -242,5 +258,7 @@
             crPackExpandDrawRangeElementsSWAP( mode, start, end, count, type, indices, clientState );
         else
+        {
             crPackExpandDrawRangeElements( mode, start, end, count, type, indices, clientState );
+        }
     }
 }
@@ -254,4 +272,5 @@
 #if CR_ARB_vertex_buffer_object
     GET_CONTEXT(ctx);
+    /*crDebug("DrawArrays count=%d", count);*/
     if (ctx->clientState->extensions.ARB_vertex_buffer_object)
          serverArrays = crStateUseServerArrays();
@@ -302,53 +321,36 @@
 void PACKSPU_APIENTRY packspu_EnableClientState( GLenum array )
 {
-    crStateEnableClientState( array );
+    crStateEnableClientState(array);
+    crPackEnableClientState(array);
 }
 
 void PACKSPU_APIENTRY packspu_DisableClientState( GLenum array )
 {
-    crStateDisableClientState( array );
+    crStateDisableClientState(array);
+    crPackDisableClientState(array);
 }
 
 void PACKSPU_APIENTRY packspu_ClientActiveTextureARB( GLenum texUnit )
 {
-    crStateClientActiveTextureARB( texUnit );
-    /* XXX also send to server for texcoord arrays? */
-}
-
+    crStateClientActiveTextureARB(texUnit);
+    crPackClientActiveTextureARB(texUnit);
+}
+
+void PACKSPU_APIENTRY packspu_EnableVertexAttribArrayARB(GLuint index)
+{
+    crStateEnableVertexAttribArrayARB(index);
+    crPackEnableVertexAttribArrayARB(index);
+}
+
+
+void PACKSPU_APIENTRY packspu_DisableVertexAttribArrayARB(GLuint index)
+{
+    crStateDisableVertexAttribArrayARB(index);
+    crPackDisableVertexAttribArrayARB(index);
+}
 
 void PACKSPU_APIENTRY packspu_Enable( GLenum cap )
 {
-    switch (cap) {
-    case GL_VERTEX_ARRAY:
-    case GL_NORMAL_ARRAY:
-    case GL_COLOR_ARRAY:
-    case GL_INDEX_ARRAY:
-    case GL_TEXTURE_COORD_ARRAY:
-    case GL_EDGE_FLAG_ARRAY:
-    case GL_FOG_COORDINATE_ARRAY_EXT:
-    case GL_SECONDARY_COLOR_ARRAY_EXT:
-#if CR_NV_vertex_program
-    case GL_VERTEX_ATTRIB_ARRAY0_NV:
-    case GL_VERTEX_ATTRIB_ARRAY1_NV:
-    case GL_VERTEX_ATTRIB_ARRAY2_NV:
-    case GL_VERTEX_ATTRIB_ARRAY3_NV:
-    case GL_VERTEX_ATTRIB_ARRAY4_NV:
-    case GL_VERTEX_ATTRIB_ARRAY5_NV:
-    case GL_VERTEX_ATTRIB_ARRAY6_NV:
-    case GL_VERTEX_ATTRIB_ARRAY7_NV:
-    case GL_VERTEX_ATTRIB_ARRAY8_NV:
-    case GL_VERTEX_ATTRIB_ARRAY9_NV:
-    case GL_VERTEX_ATTRIB_ARRAY10_NV:
-    case GL_VERTEX_ATTRIB_ARRAY11_NV:
-    case GL_VERTEX_ATTRIB_ARRAY12_NV:
-    case GL_VERTEX_ATTRIB_ARRAY13_NV:
-    case GL_VERTEX_ATTRIB_ARRAY14_NV:
-    case GL_VERTEX_ATTRIB_ARRAY15_NV:
-#endif /* CR_NV_vertex_program */
-        crStateEnableClientState(cap);
-        break;
-    default:
-        ;
-    }
+    crStateEnable(cap);
 
     if (pack_spu.swap)
@@ -361,36 +363,5 @@
 void PACKSPU_APIENTRY packspu_Disable( GLenum cap )
 {
-    switch (cap) {
-    case GL_VERTEX_ARRAY:
-    case GL_NORMAL_ARRAY:
-    case GL_COLOR_ARRAY:
-    case GL_INDEX_ARRAY:
-    case GL_TEXTURE_COORD_ARRAY:
-    case GL_EDGE_FLAG_ARRAY:
-    case GL_FOG_COORDINATE_ARRAY_EXT:
-    case GL_SECONDARY_COLOR_ARRAY_EXT:
-#if CR_NV_vertex_program
-    case GL_VERTEX_ATTRIB_ARRAY0_NV:
-    case GL_VERTEX_ATTRIB_ARRAY1_NV:
-    case GL_VERTEX_ATTRIB_ARRAY2_NV:
-    case GL_VERTEX_ATTRIB_ARRAY3_NV:
-    case GL_VERTEX_ATTRIB_ARRAY4_NV:
-    case GL_VERTEX_ATTRIB_ARRAY5_NV:
-    case GL_VERTEX_ATTRIB_ARRAY6_NV:
-    case GL_VERTEX_ATTRIB_ARRAY7_NV:
-    case GL_VERTEX_ATTRIB_ARRAY8_NV:
-    case GL_VERTEX_ATTRIB_ARRAY9_NV:
-    case GL_VERTEX_ATTRIB_ARRAY10_NV:
-    case GL_VERTEX_ATTRIB_ARRAY11_NV:
-    case GL_VERTEX_ATTRIB_ARRAY12_NV:
-    case GL_VERTEX_ATTRIB_ARRAY13_NV:
-    case GL_VERTEX_ATTRIB_ARRAY14_NV:
-    case GL_VERTEX_ATTRIB_ARRAY15_NV:
-#endif /* CR_NV_vertex_program */
-        crStateDisableClientState(cap);
-        break;
-    default:
-        ;
-    }
+    crStateDisable(cap);
 
     if (pack_spu.swap)
@@ -400,8 +371,27 @@
 }
 
+GLboolean PACKSPU_APIENTRY packspu_IsEnabled(GLenum cap)
+{
+    GLboolean res = crStateIsEnabled(cap);
+#ifdef DEBUG
+    {    
+    	GET_THREAD(thread);
+	    int writeback = 1;
+	    GLboolean return_val = (GLboolean) 0;
+        crPackIsEnabled(cap, &return_val, &writeback);
+	    packspuFlush( (void *) thread );
+	    while (writeback)
+		  crNetRecv();
+        CRASSERT(return_val==res);
+    }
+#endif
+
+    return res;
+}
 
 void PACKSPU_APIENTRY packspu_PushClientAttrib( GLbitfield mask )
 {
     crStatePushClientAttrib(mask);
+    crPackPushClientAttrib(mask);
 }
 
@@ -409,3 +399,4 @@
 {
     crStatePopClientAttrib();
-}
+    crPackPopClientAttrib();
+}
Index: trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c
===================================================================
--- trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c	(revision 21292)
+++ trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c	(revision 21308)
@@ -163,4 +163,5 @@
     /* XXX fix-up sharedCtx param here */
     pack_spu.context[slot].clientState = crStateCreateContext(NULL, visual, NULL);
+    pack_spu.context[slot].clientState->bufferobject.retainBufferData = GL_TRUE;
     pack_spu.context[slot].serverCtx = serverCtx;
 
@@ -227,4 +228,5 @@
         crPackSetContext( thread->packer );
         crStateMakeCurrent( newCtx->clientState );
+        //crStateSetCurrentPointers(newCtx->clientState, &thread->packer->current);
         serverCtx = pack_spu.context[slot].serverCtx;
     }
Index: trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py
===================================================================
--- trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py	(revision 21292)
+++ trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py	(revision 21308)
@@ -69,33 +69,36 @@
         print '\t}'
         if func_name in simple_funcs:
-            print '\tif (pname == GL_UNPACK_ALIGNMENT ||'
-            print '\t\tpname == GL_UNPACK_ROW_LENGTH ||'
-            print '\t\tpname == GL_UNPACK_SKIP_PIXELS ||'
-            print '\t\tpname == GL_UNPACK_LSB_FIRST ||'
-            print '\t\tpname == GL_UNPACK_SWAP_BYTES ||'
-            print '#ifdef CR_OPENGL_VERSION_1_2'
-            print '\t\tpname == GL_UNPACK_IMAGE_HEIGHT ||'
-            print '#endif'
-            print '\t\tpname == GL_UNPACK_SKIP_ROWS ||'
-            print '\t\tpname == GL_PACK_ALIGNMENT ||'
-            print '\t\tpname == GL_PACK_ROW_LENGTH ||'
-            print '\t\tpname == GL_PACK_SKIP_PIXELS ||'
-            print '\t\tpname == GL_PACK_LSB_FIRST ||'
-            print '\t\tpname == GL_PACK_SWAP_BYTES ||'
-            print '#ifdef CR_OPENGL_VERSION_1_2'
-            print '\t\tpname == GL_PACK_IMAGE_HEIGHT ||'
-            print '#endif'
-            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;'
-            print '\t}'
+            print """
+    if (pname == GL_UNPACK_ALIGNMENT
+        || pname == GL_UNPACK_ROW_LENGTH
+        || pname == GL_UNPACK_SKIP_PIXELS
+        || pname == GL_UNPACK_LSB_FIRST
+        || pname == GL_UNPACK_SWAP_BYTES
+#ifdef CR_OPENGL_VERSION_1_2
+        || pname == GL_UNPACK_IMAGE_HEIGHT
+#endif
+        || pname == GL_UNPACK_SKIP_ROWS
+        || pname == GL_PACK_ALIGNMENT
+        || pname == GL_PACK_ROW_LENGTH
+        || pname == GL_PACK_SKIP_PIXELS
+        || pname == GL_PACK_LSB_FIRST
+        || pname == GL_PACK_SWAP_BYTES
+#ifdef CR_OPENGL_VERSION_1_2
+        || pname == GL_PACK_IMAGE_HEIGHT
+#endif
+        || pname == GL_PACK_SKIP_ROWS
+        || pname == GL_DRAW_BUFFER
+#ifdef CR_OPENGL_VERSION_1_3
+        || pname == GL_ACTIVE_TEXTURE
+#endif
+#ifdef CR_ARB_multitexture
+        || pname == GL_ACTIVE_TEXTURE_ARB
+#endif
+        )
+        {
+            crState%s( pname, params );
+            return;
+        }
+            """ % func_name
         params.append( ("&writeback", "foo", 0) )
         print '\tif (pack_spu.swap)'
Index: trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_special
===================================================================
--- trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_special	(revision 21292)
+++ trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_special	(revision 21308)
@@ -72,2 +72,7 @@
 GetAttachedObjectsARB
 GetInfoLogARB
+BufferSubDataARB
+EnableVertexAttribArrayARB
+DisableVertexAttribArrayARB
+GetBufferSubDataARB
+IsEnabled
