Index: /trunk/Config.kmk
===================================================================
--- /trunk/Config.kmk	(revision 78189)
+++ /trunk/Config.kmk	(revision 78190)
@@ -2503,8 +2503,4 @@
  ifdef VBOX_WITH_WDDM
   VBOX_WITH_CRHGSMI = 1
- endif
-
- if1of ($(KBUILD_TARGET),darwin)
-  #VBOX_WITH_CR_DISPLAY_LISTS = 1
  endif
 
@@ -7337,5 +7333,5 @@
 TEMPLATE_VBOXCROGLR3HOSTDLL_DEFS.linux       = Linux=1 _GNU_SOURCE
 TEMPLATE_VBOXCROGLR3HOSTDLL_DEFS.solaris     = SunOS=1 _GNU_SOURCE #GLEXT_64_TYPES_DEFINED
-TEMPLATE_VBOXCROGLR3HOSTDLL_DEFS.darwin      = DARWIN=1 GL_GLEXT_LEGACY _GNU_SOURCE VBOX_WITH_COCOA_QT
+TEMPLATE_VBOXCROGLR3HOSTDLL_DEFS.darwin      = DARWIN=1 GL_GLEXT_LEGACY _GNU_SOURCE
 TEMPLATE_VBOXCROGLR3HOSTDLL_DEFS.freebsd     = FreeBSD=1 _GNU_SOURCE
 TEMPLATE_VBOXCROGLR3HOSTDLL_INCS             = $(VBOX_PATH_CROGL_INCLUDE) $(VBOX_PATH_CROGL_GENFILES)
@@ -7384,14 +7380,15 @@
 #
 TEMPLATE_VBOXCROGLR3GUESTDLL                  = VBox OpenGL Guest DLLs
-if "$(KBUILD_TARGET)" == "win" || defined(VBOX_WITH_MASOCHISTIC_WARNINGS) || defined(VBOX_WITH_NO_GCC_WARNING_POLICY) ## @todo use VBoxGuestR3Dll everywhere
-TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS          = VBoxGuestR3DllMinW2K
-else
+# @todo Temporarily disabled, causes linker errors on Windows because VBoxOGLcrutil and VBoxOGLspupacker both drag in RuntimeGuestR3Shared.lib
+#if "$(KBUILD_TARGET)" == "win" || defined(VBOX_WITH_MASOCHISTIC_WARNINGS) || defined(VBOX_WITH_NO_GCC_WARNING_POLICY) ## @todo use VBoxGuestR3Dll everywhere
+#TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS          = VBoxGuestR3DllMinW2K
+#else
 TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS          = VBOXGUESTR3NPDLL
-endif
+#endif
 TEMPLATE_VBOXCROGLR3GUESTDLL_DEFS             = $(TEMPLATE_$(TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS)_DEFS) CHROMIUM_THREADSAFE VBOX_WITH_HGCM
 TEMPLATE_VBOXCROGLR3GUESTDLL_DEFS.win         = $(TEMPLATE_$(TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS)_DEFS.win) WINDOWS=1
 TEMPLATE_VBOXCROGLR3GUESTDLL_DEFS.linux       = $(TEMPLATE_$(TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS)_DEFS.linux) Linux=1 _GNU_SOURCE
 TEMPLATE_VBOXCROGLR3GUESTDLL_DEFS.solaris     = $(TEMPLATE_$(TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS)_DEFS.solaris) SunOS=1 _GNU_SOURCE #GLEXT_64_TYPES_DEFINED
-TEMPLATE_VBOXCROGLR3GUESTDLL_DEFS.darwin      = $(TEMPLATE_$(TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS)_DEFS.darwin) DARWIN=1 GL_GLEXT_LEGACY _GNU_SOURCE VBOX_WITH_COCOA_QT
+TEMPLATE_VBOXCROGLR3GUESTDLL_DEFS.darwin      = $(TEMPLATE_$(TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS)_DEFS.darwin) DARWIN=1 GL_GLEXT_LEGACY _GNU_SOURCE
 TEMPLATE_VBOXCROGLR3GUESTDLL_DEFS.freebsd     = $(TEMPLATE_$(TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS)_DEFS.freebsd) FreeBSD=1 _GNU_SOURCE
 TEMPLATE_VBOXCROGLR3GUESTDLL_INCS             = $(VBOX_PATH_CROGL_INCLUDE) $(VBOX_PATH_CROGL_GENFILES) $(TEMPLATE_$(TEMPLATE_VBOXCROGLR3GUESTDLL_EXTENDS)_INCS)
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/Makefile.kmk	(revision 78189)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/Makefile.kmk	(revision 78190)
@@ -119,4 +119,5 @@
  	wddm/VBoxMPCm.cpp \
  	wddm/VBoxMPCr.cpp \
+ 	wddm/VBoxMPSa.cpp \
  	wddm/VBoxMPMisc.cpp \
  	wddm/VBoxWddm.rc \
@@ -132,7 +133,4 @@
  	$(PATH_ROOT)/src/VBox/Additions/common/VBoxVideo/Modesetting.cpp
 
- VBoxWddm_SOURCES         += \
-	$(PATH_ROOT)/src/VBox/GuestHost/OpenGL/util/sortarray.cpp
-
  if defined(VBOX_WITH_CROGL)
    VBoxWddm_SOURCES       += \
@@ -142,5 +140,4 @@
  	$(PATH_ROOT)/src/VBox/GuestHost/OpenGL/packer/pack_visibleregion.c \
  	$(PATH_ROOT)/src/VBox/GuestHost/OpenGL/packer/pack_misc.c \
- 	$(VBOX_PATH_CROGL_GENFILES)/pack_bounds_swap.c \
  	$(VBOX_PATH_CROGL_GENFILES)/packer.c \
  	wddm/VBoxMPCrUtil.cpp
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPSa.cpp
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPSa.cpp	(revision 78190)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPSa.cpp	(revision 78190)
@@ -0,0 +1,415 @@
+/* $Id$ */
+
+/** @file
+ * Sorted array impl
+ */
+
+/*
+ * Copyright (C) 2014-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include <cr_error.h>
+#include <iprt/err.h>
+#include <iprt/mem.h>
+
+#include <memory.h>
+
+#include "VBoxMPSa.h"
+
+VBOXSADECL(int) CrSaInit(CR_SORTARRAY *pArray, uint32_t cInitBuffer)
+{
+    pArray->cBufferSize = cInitBuffer;
+    pArray->cSize = 0;
+    if (cInitBuffer)
+    {
+        pArray->pElements = (uint64_t*)RTMemAlloc(cInitBuffer * sizeof (pArray->pElements[0]));
+        if (!pArray->pElements)
+        {
+            WARN(("no memory"));
+            /* sanity */
+            pArray->cBufferSize = 0;
+            return VERR_NO_MEMORY;
+        }
+    }
+    else
+        pArray->pElements = NULL;
+
+    return VINF_SUCCESS;
+}
+
+VBOXSADECL(void) CrSaCleanup(CR_SORTARRAY *pArray)
+{
+    if (pArray->pElements)
+        RTMemFree(pArray->pElements);
+
+    CrSaInit(pArray, 0);
+}
+
+static int crSaSearch(const CR_SORTARRAY *pArray, uint64_t element)
+{
+    int iMin = 0;
+    int iMax = pArray->cSize;
+    int i = 0;
+
+    while (iMin < iMax)
+    {
+        i = (iMax + iMin) / 2;
+
+        uint64_t el = pArray->pElements[i];
+        if (el == element)
+            return i;
+        else if (el < element)
+            iMin = i + 1;
+        else
+            iMax = i;
+    }
+
+    return -1;
+}
+
+static void crSaDbgValidate(const CR_SORTARRAY *pArray)
+{
+    Assert(pArray->cSize <= pArray->cBufferSize);
+    Assert(!pArray->pElements == !pArray->cBufferSize);
+    if (!pArray->cSize)
+        return;
+    uint64_t cur = pArray->pElements[0];
+    for (uint32_t i = 1; i < pArray->cSize; ++i)
+    {
+        Assert(pArray->pElements[i] > cur);
+        cur = pArray->pElements[i];
+    }
+}
+
+#ifdef DEBUG
+# define crSaValidate crSaDbgValidate
+#else
+# define crSaValidate(_a) do {} while (0)
+#endif
+
+static int crSaInsAt(CR_SORTARRAY *pArray, uint32_t iPos, uint64_t element)
+{
+    if (pArray->cSize == pArray->cBufferSize)
+    {
+        uint32_t cNewBufferSize = pArray->cBufferSize + 16;
+        uint64_t *pNew;
+        if (pArray->pElements)
+            pNew = (uint64_t*)RTMemRealloc(pArray->pElements, cNewBufferSize * sizeof (pArray->pElements[0]));
+        else
+            pNew = (uint64_t*)RTMemAlloc(cNewBufferSize * sizeof (pArray->pElements[0]));
+        if (!pNew)
+        {
+            WARN(("no memory"));
+            return VERR_NO_MEMORY;
+        }
+
+        pArray->pElements = pNew;
+        pArray->cBufferSize = cNewBufferSize;
+        crSaValidate(pArray);
+    }
+
+    for (int32_t i = (int32_t)pArray->cSize - 1; i >= (int32_t)iPos; --i)
+    {
+        pArray->pElements[i+1] = pArray->pElements[i];
+    }
+
+    pArray->pElements[iPos] = element;
+    ++pArray->cSize;
+
+    crSaValidate(pArray);
+
+    return VINF_SUCCESS;
+}
+
+static void crSaDelAt(CR_SORTARRAY *pArray, uint32_t iPos)
+{
+    Assert(pArray->cSize > iPos);
+
+    for (uint32_t i = iPos; i < pArray->cSize - 1; ++i)
+    {
+        pArray->pElements[i] = pArray->pElements[i+1];
+    }
+
+    --pArray->cSize;
+}
+
+static int crSaAdd(CR_SORTARRAY *pArray, uint64_t element)
+{
+    int iMin = 0;
+    int iMax = pArray->cSize;
+    int i = 0;
+    uint64_t el;
+
+    if (!iMax)
+        return crSaInsAt(pArray, 0, element);
+
+    el = element; /* Shup up MSC. */
+    while (iMin < iMax)
+    {
+        i = (iMax + iMin) / 2;
+
+        el = pArray->pElements[i];
+        if (el == element)
+            return VINF_ALREADY_INITIALIZED;
+        else if (el < element)
+            iMin = i + 1;
+        else
+            iMax = i;
+    }
+
+    if (el < element)
+        return crSaInsAt(pArray, i+1, element);
+    return crSaInsAt(pArray, i, element);
+}
+
+static int crSaRemove(CR_SORTARRAY *pArray, uint64_t element)
+{
+    int i = crSaSearch(pArray, element);
+    if (i >= 0)
+    {
+        crSaDelAt(pArray, i);
+        return VINF_SUCCESS;
+    }
+    return VINF_ALREADY_INITIALIZED;
+}
+
+/*
+ *  * @return true if element is found */
+VBOXSADECL(bool) CrSaContains(const CR_SORTARRAY *pArray, uint64_t element)
+{
+    return crSaSearch(pArray, element) >= 0;
+}
+
+VBOXSADECL(int) CrSaAdd(CR_SORTARRAY *pArray, uint64_t element)
+{
+    return crSaAdd(pArray, element);
+}
+
+VBOXSADECL(int) CrSaRemove(CR_SORTARRAY *pArray, uint64_t element)
+{
+    return crSaRemove(pArray, element);
+}
+
+static int crSaIntersected(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
+{
+    int rc = VINF_SUCCESS;
+    CrSaClear(pResult);
+
+    for (uint32_t i = 0, j = 0; i < pArray1->cSize && j < pArray2->cSize; )
+    {
+        if (pArray1->pElements[i] == pArray2->pElements[j])
+        {
+            rc = CrSaAdd(pResult, pArray1->pElements[i]);
+            if (rc < 0)
+            {
+                WARN(("CrSaAdd failed"));
+                return rc;
+            }
+
+            ++i;
+            ++j;
+        }
+        else if (pArray1->pElements[i] < pArray2->pElements[j])
+        {
+            ++i;
+        }
+        else
+        {
+            ++j;
+        }
+    }
+
+    return VINF_SUCCESS;
+}
+
+static void crSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
+{
+    for (uint32_t i = 0, j = 0; i < pArray1->cSize && j < pArray2->cSize; )
+    {
+        if (pArray1->pElements[i] == pArray2->pElements[j])
+        {
+            ++i;
+            ++j;
+        }
+        else if (pArray1->pElements[i] < pArray2->pElements[j])
+            crSaDelAt(pArray1, i);
+        else
+            ++j;
+    }
+}
+
+/*
+ * @return >= 0 success
+ * < 0 - no memory
+ *  */
+VBOXSADECL(void) CrSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
+{
+    crSaIntersect(pArray1, pArray2);
+}
+
+VBOXSADECL(int) CrSaIntersected(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
+{
+    return crSaIntersected(pArray1, pArray2, pResult);
+}
+
+static int crSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
+{
+    int rc = VINF_SUCCESS;
+    CrSaClear(pResult);
+
+    uint32_t i = 0, j = 0;
+    uint32_t cResult = 0;
+    while (i < pArray1->cSize && j < pArray2->cSize)
+    {
+        uint64_t element;
+        if (pArray1->pElements[i] == pArray2->pElements[j])
+        {
+            element = pArray1->pElements[i];
+            ++i;
+            ++j;
+        }
+        else if (pArray1->pElements[i] < pArray2->pElements[j])
+        {
+            element = pArray1->pElements[i];
+            ++i;
+        }
+        else
+        {
+            element = pArray1->pElements[j];
+            ++j;
+        }
+
+        rc = crSaInsAt(pResult, cResult++, element);
+        if (rc < 0)
+        {
+            WARN(("crSaInsAt failed"));
+            return rc;
+        }
+    }
+
+    uint32_t iTail;
+    const CR_SORTARRAY *pTail;
+
+    if (i < pArray1->cSize)
+    {
+        iTail = i;
+        pTail = pArray1;
+    }
+    else if (j < pArray2->cSize)
+    {
+        iTail = j;
+        pTail = pArray2;
+    }
+    else
+    {
+        iTail = 0;
+        pTail = 0;
+    }
+
+    if (pTail)
+    {
+        for (;iTail < pTail->cSize; ++iTail)
+        {
+            rc = crSaInsAt(pResult, cResult++, pTail->pElements[iTail]);
+            if (rc < 0)
+            {
+                WARN(("crSaInsAt failed"));
+                return rc;
+            }
+        }
+    }
+
+    return VINF_SUCCESS;
+}
+
+VBOXSADECL(int) CrSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
+{
+    return crSaUnited(pArray1, pArray2, pResult);
+}
+
+static int crSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult)
+{
+    CrSaClear(pResult);
+
+    if (pArray1->cSize > pResult->cBufferSize)
+    {
+        CrSaCleanup(pResult);
+        uint32_t cNewBufferSize = pArray1->cSize;
+        uint64_t *pNew = (uint64_t*)RTMemAlloc(cNewBufferSize * sizeof (pResult->pElements[0]));
+        if (!pNew)
+        {
+            WARN(("no memory"));
+            return VERR_NO_MEMORY;
+        }
+
+        pResult->pElements = pNew;
+        pResult->cBufferSize = cNewBufferSize;
+        crSaValidate(pResult);
+    }
+
+    pResult->cSize = pArray1->cSize;
+    memcpy(pResult->pElements, pArray1->pElements, pArray1->cSize * sizeof (pArray1->pElements[0]));
+    return VINF_SUCCESS;
+}
+
+/*
+ * @return VINF_SUCCESS on success
+ * VERR_NO_MEMORY - no memory
+ *  */
+VBOXSADECL(int) CrSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult)
+{
+    return crSaClone(pArray1, pResult);
+}
+
+static int crSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
+{
+    int diff = CrSaGetSize(pArray1) - CrSaGetSize(pArray2);
+    if (diff)
+        return diff;
+
+    return memcmp(pArray1->pElements, pArray2->pElements, pArray1->cSize * sizeof (pArray1->pElements[0]));
+}
+
+VBOXSADECL(int) CrSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
+{
+    return crSaCmp(pArray1, pArray2);
+}
+
+static bool crSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
+{
+    if (CrSaGetSize(pArray1) < CrSaGetSize(pArray2))
+        return false;
+
+    uint32_t i = 0, j = 0;
+    while (j < pArray2->cSize)
+    {
+        if (i == pArray1->cSize)
+            return false;
+
+        if (pArray1->pElements[i] == pArray2->pElements[j])
+        {
+            ++i;
+            ++j;
+        }
+        else if (pArray1->pElements[i] < pArray2->pElements[j])
+            ++i;
+        else
+            return false;
+    }
+
+    return true;
+}
+
+VBOXSADECL(bool) CrSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
+{
+    return crSaCovers(pArray1, pArray2);
+}
+
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPSa.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPSa.h	(revision 78190)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPSa.h	(revision 78190)
@@ -0,0 +1,102 @@
+/* $Id$ */
+
+/** @file
+ * Sorted array API
+ */
+
+/*
+ * Copyright (C) 2014-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#ifndef ___cr_sortarray_h_
+#define ___cr_sortarray_h_
+
+#include <iprt/types.h>
+#include <iprt/assert.h>
+
+typedef struct CR_SORTARRAY
+{
+    uint32_t cBufferSize;
+    uint32_t cSize;
+    uint64_t *pElements;
+} CR_SORTARRAY;
+
+
+#ifndef IN_RING0
+# define VBOXSADECL(_type) DECLEXPORT(_type)
+#else
+# define VBOXSADECL(_type) RTDECL(_type)
+#endif
+
+
+DECLINLINE(uint32_t) CrSaGetSize(const CR_SORTARRAY *pArray)
+{
+    return pArray->cSize;
+}
+
+DECLINLINE(uint64_t) CrSaGetVal(const CR_SORTARRAY *pArray, uint32_t i)
+{
+    Assert(i < pArray->cSize);
+    return pArray->pElements[i];
+}
+
+DECLINLINE(const uint64_t*) CrSaGetElements(const CR_SORTARRAY *pArray)
+{
+    return pArray->pElements;
+}
+
+DECLINLINE(void) CrSaClear(CR_SORTARRAY *pArray)
+{
+    pArray->cSize = 0;
+}
+
+VBOXSADECL(int) CrSaInit(CR_SORTARRAY *pArray, uint32_t cInitBuffer);
+VBOXSADECL(void) CrSaCleanup(CR_SORTARRAY *pArray);
+/*
+ * @return true if element is found */
+VBOXSADECL(bool) CrSaContains(const CR_SORTARRAY *pArray, uint64_t element);
+
+/*
+ * @return VINF_SUCCESS  if element is added
+ * VINF_ALREADY_INITIALIZED if element was in array already
+ * VERR_NO_MEMORY - no memory
+ *  */
+VBOXSADECL(int) CrSaAdd(CR_SORTARRAY *pArray, uint64_t element);
+
+/*
+ * @return VINF_SUCCESS  if element is removed
+ * VINF_ALREADY_INITIALIZED if element was NOT in array
+ *  */
+VBOXSADECL(int) CrSaRemove(CR_SORTARRAY *pArray, uint64_t element);
+
+/*
+ * @return VINF_SUCCESS on success
+ * VERR_NO_MEMORY - no memory
+ *  */
+VBOXSADECL(void) CrSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2);
+VBOXSADECL(int) CrSaIntersected(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult);
+
+/*
+ * @return VINF_SUCCESS on success
+ * VERR_NO_MEMORY - no memory
+ *  */
+VBOXSADECL(int) CrSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult);
+
+/*
+ * @return VINF_SUCCESS on success
+ * VERR_NO_MEMORY - no memory
+ *  */
+VBOXSADECL(int) CrSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult);
+
+VBOXSADECL(int) CrSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2);
+
+VBOXSADECL(bool) CrSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2);
+
+#endif /* ___cr_sortarray_h_ */
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h	(revision 78189)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h	(revision 78190)
@@ -36,4 +36,5 @@
 #include "VBoxMPVbva.h"
 #include "VBoxMPCr.h"
+#include "VBoxMPSa.h"
 #include "VBoxMPVModes.h"
 
@@ -41,6 +42,4 @@
 #include <cr_vreg.h>
 #endif
-
-#include <cr_sortarray.h>
 
 #if 0
Index: /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVModes.h
===================================================================
--- /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVModes.h	(revision 78189)
+++ /trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVModes.h	(revision 78190)
@@ -24,6 +24,5 @@
 //#include "../../common/VBoxVideoTools.h"
 
-#include <cr_sortarray.h>
-
+#include "VBoxMPSa.h"
 
 #define _CR_TYPECAST(_Type, _pVal) ((_Type*)((void*)(_pVal)))
Index: /trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu_config.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu_config.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu_config.c	(revision 78190)
@@ -15,11 +15,4 @@
 }
 
-/* No SPU options yet.
- */
-SPUOptions arraySPUOptions[] = {
-   { NULL, CR_BOOL, 0, NULL, NULL, NULL, NULL, NULL },
-};
-
-
 void arrayspuSetVBoxConfiguration( void )
 {
Index: /trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu_init.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu_init.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/array/arrayspu_init.c	(revision 78190)
@@ -11,6 +11,4 @@
 
 extern SPUNamedFunctionTable _cr_array_table[];
-
-extern SPUOptions arraySPUOptions[];
 
 static SPUFunctions array_functions = {
@@ -73,5 +71,5 @@
 int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
          SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
-         SPUOptionsPtr *options, int *flags )
+         int *flags )
 {
     *name = "array";
@@ -80,5 +78,4 @@
     *self = arraySPUSelfDispatch;
     *cleanup = arraySPUCleanup;
-    *options = arraySPUOptions;
     *flags = (SPU_NO_PACKER|SPU_NOT_TERMINAL|SPU_MAX_SERVERS_ZERO);
 
Index: /trunk/src/VBox/Additions/common/crOpenGL/context.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/context.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/context.c	(revision 78190)
@@ -29,5 +29,4 @@
 #include "cr_mem.h"
 #include "cr_string.h"
-#include "cr_environment.h"
 #include "stub.h"
 
Index: /trunk/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu.h
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu.h	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu.h	(revision 78190)
@@ -18,5 +18,4 @@
 
 #include "cr_spu.h"
-#include "cr_timer.h"
 #include "cr_glstate.h"
 
@@ -52,6 +51,4 @@
 extern SPUNamedFunctionTable _cr_feedback_table[];
 
-extern SPUOptions feedbackSPUOptions[];
-
 extern void feedbackspuGatherConfiguration( void );
 
Index: /trunk/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_config.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_config.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_config.c	(revision 78190)
@@ -6,5 +6,4 @@
 
 #include "cr_string.h"
-#include "cr_environment.h"
 #include "cr_error.h"
 #include "cr_mem.h"
@@ -21,21 +20,4 @@
 }
 
-static void set_default_viewport( void *foo, const char *response )
-{
-   (void) foo;
-   sscanf( response, "%d", &(feedback_spu.default_viewport) );
-}
-
-/* option, type, nr, default, min, max, title, callback
- */
-SPUOptions feedbackSPUOptions[] = {
-
-   { "default_viewport", CR_BOOL, 1, "0", "0", "1",
-     "Return default viewport parameters", (SPUOptionCB)set_default_viewport },
-
-   { NULL, CR_BOOL, 0, NULL, NULL, NULL, NULL, NULL },
-
-};
-
 
 void feedbackspuGatherConfiguration( void )
Index: /trunk/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_init.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_init.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/feedback/feedbackspu_init.c	(revision 78190)
@@ -6,5 +6,4 @@
 
 #include "cr_spu.h"
-#include "cr_environment.h"
 #include "cr_string.h"
 #include "cr_error.h"
@@ -73,5 +72,5 @@
 int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
 	     SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
-	     SPUOptionsPtr *options, int *flags )
+	     int *flags )
 {
 	*name = "feedback";
@@ -80,5 +79,4 @@
 	*self = feedbackSPUSelfDispatch;
 	*cleanup = feedbackSPUCleanup;
-	*options = feedbackSPUOptions;
 	*flags = (SPU_NO_PACKER|SPU_NOT_TERMINAL|SPU_MAX_SERVERS_ZERO);
 
Index: /trunk/src/VBox/Additions/common/crOpenGL/icd_drv.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/icd_drv.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/icd_drv.c	(revision 78190)
@@ -28,4 +28,6 @@
 
 #include <iprt/win/windows.h>
+
+#include <stdio.h> /*sprintf*/
 
 /// @todo consider
Index: /trunk/src/VBox/Additions/common/crOpenGL/load.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/load.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/load.c	(revision 78190)
@@ -11,7 +11,5 @@
 #include "cr_string.h"
 #include "cr_net.h"
-#include "cr_environment.h"
 #include "cr_process.h"
-#include "cr_rand.h"
 #include "cr_netserver.h"
 #include "stub.h"
@@ -19,8 +17,10 @@
 #include <string.h>
 #include <signal.h>
+#include <stdio.h> /*swprintf*/
 #include <iprt/initterm.h>
 #include <iprt/thread.h>
 #include <iprt/errcore.h>
 #include <iprt/asm.h>
+#include <iprt/env.h>
 #ifndef WINDOWS
 # include <sys/types.h>
@@ -601,140 +601,6 @@
 
 
-#if 0 /* unused */
-
-/**
- * Return a free port number for the mothership to use, or -1 if we
- * can't find one.
- */
-static int
-GenerateMothershipPort(void)
-{
-    const int MAX_PORT = 10100;
-    unsigned short port;
-
-    /* generate initial port number randomly */
-    crRandAutoSeed();
-    port = (unsigned short) crRandInt(10001, MAX_PORT);
-
-#ifdef WINDOWS
-    /* XXX should implement a free port check here */
-    return port;
-#else
-    /*
-     * See if this port number really is free, try another if needed.
-     */
-    {
-        struct sockaddr_in servaddr;
-        int so_reuseaddr = 1;
-        int sock, k;
-
-        /* create socket */
-        sock = socket(AF_INET, SOCK_STREAM, 0);
-        CRASSERT(sock > 2);
-
-        /* deallocate socket/port when we exit */
-        k = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
-                                     (char *) &so_reuseaddr, sizeof(so_reuseaddr));
-        CRASSERT(k == 0);
-
-        /* initialize the servaddr struct */
-        crMemset(&servaddr, 0, sizeof(servaddr) );
-        servaddr.sin_family = AF_INET;
-        servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
-
-        while (port < MAX_PORT) {
-            /* Bind to the given port number, return -1 if we fail */
-            servaddr.sin_port = htons((unsigned short) port);
-            k = bind(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
-            if (k) {
-                /* failed to create port. try next one. */
-                port++;
-            }
-            else {
-                /* free the socket/port now so mothership can make it */
-                close(sock);
-                return port;
-            }
-        }
-    }
-#endif /* WINDOWS */
-    return -1;
-}
-
-
-/**
- * Try to determine which mothership configuration to use for this program.
- */
-static char **
-LookupMothershipConfig(const char *procName)
-{
-    const int procNameLen = crStrlen(procName);
-    FILE *f;
-    const char *home;
-    char configPath[1000];
-
-    /* first, check if the CR_CONFIG env var is set */
-    {
-        const char *conf = crGetenv("CR_CONFIG");
-        if (conf && crStrlen(conf) > 0)
-            return crStrSplit(conf, " ");
-    }
-
-    /* second, look up config name from config file */
-    home = crGetenv("HOME");
-    if (home)
-        sprintf(configPath, "%s/%s", home, CONFIG_LOOKUP_FILE);
-    else
-        crStrcpy(configPath, CONFIG_LOOKUP_FILE); /* from current dir */
-    /* Check if the CR_CONFIG_PATH env var is set. */
-    {
-        const char *conf = crGetenv("CR_CONFIG_PATH");
-        if (conf)
-            crStrcpy(configPath, conf); /* from env var */
-    }
-
-    f = fopen(configPath, "r");
-    if (!f) {
-        return NULL;
-    }
-
-    while (!feof(f)) {
-        char line[1000];
-        char **args;
-        fgets(line, 999, f);
-        line[crStrlen(line) - 1] = 0; /* remove trailing newline */
-        if (crStrncmp(line, procName, procNameLen) == 0 &&
-            (line[procNameLen] == ' ' || line[procNameLen] == '\t'))
-        {
-            crWarning("Using Chromium configuration for %s from %s",
-                                procName, configPath);
-            args = crStrSplit(line + procNameLen + 1, " ");
-            return args;
-        }
-    }
-    fclose(f);
-    return NULL;
-}
-
-
-static int Mothership_Awake = 0;
-
-
-/**
- * Signal handler to determine when mothership is ready.
- */
-static void
-MothershipPhoneHome(int signo)
-{
-    crDebug("Got signal %d: mothership is awake!", signo);
-    Mothership_Awake = 1;
-}
-
-#endif /* 0 */
-
 static void stubSetDefaultConfigurationOptions(void)
 {
-    unsigned char key[16]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-
     stub.appDrawCursor = 0;
     stub.minChromiumWindowWidth = 0;
@@ -752,8 +618,4 @@
     stub.matchChromiumWindowCount = 0;
     stub.spu_dir = NULL;
-    crNetSetRank(0);
-    crNetSetContextRange(32, 35);
-    crNetSetNodeRange("iam0", "iamvis20");
-    crNetSetKey(key,sizeof(key));
     stub.force_pbuffers = 0;
 
@@ -963,5 +825,5 @@
 
     /** @todo check if it'd be of any use on other than guests, no use for windows */
-    app_id = crGetenv( "CR_APPLICATION_ID_NUMBER" );
+    app_id = RTEnvGet( "CR_APPLICATION_ID_NUMBER" );
 
     crNetInit( NULL, NULL );
@@ -1347,5 +1209,5 @@
 
 #ifdef VDBG_VEHANDLER
-        env = crGetenv("CR_DBG_VEH_ENABLE");
+        env = RTEnvGet("CR_DBG_VEH_ENABLE");
         g_VBoxVehEnable = crStrParseI32(env,
 # ifdef DEBUG_misha
@@ -1362,5 +1224,5 @@
             size_t cChars;
 
-            env = crGetenv("CR_DBG_VEH_FLAGS");
+            env = RTEnvGet("CR_DBG_VEH_FLAGS");
             g_VBoxVehFlags = crStrParseI32(env,
                     0
@@ -1372,5 +1234,5 @@
                     );
 
-            env = crGetenv("CR_DBG_VEH_DUMP_DIR");
+            env = RTEnvGet("CR_DBG_VEH_DUMP_DIR");
             if (!env)
                 env = VBOXMD_DUMP_DIR_DEFAULT;
@@ -1410,5 +1272,5 @@
             g_aszwVBoxMdFilePrefix[g_cVBoxMdFilePrefixLen] = L'\0';
 
-            env = crGetenv("CR_DBG_VEH_DUMP_TYPE");
+            env = RTEnvGet("CR_DBG_VEH_DUMP_TYPE");
 
             g_enmVBoxMdDumpType = crStrParseI32(env,
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/pack.py
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/pack.py	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/pack.py	(revision 78190)
@@ -53,5 +53,5 @@
         print('\t__fillin(%3d, "%s", (SPUGenericFunction) packspu_%s);' % (index, func_name, func_name ))
     else:
-        print('\t__fillin(%3d, "%s", (SPUGenericFunction) (pack_spu.swap ? crPack%sSWAP : crPack%s));' % (index, func_name, func_name, func_name ))
+        print('\t__fillin(%3d, "%s", (SPUGenericFunction) (crPack%s));' % (index, func_name, func_name ))
 print('\t__fillin(%3d, NULL, NULL);' % num_funcs)
 print('}')
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu.h
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu.h	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu.h	(revision 78190)
@@ -82,5 +82,4 @@
 typedef struct {
     int id;
-    int swap;
 
     /* config options */
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_beginend.py
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_beginend.py	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_beginend.py	(revision 78190)
@@ -48,13 +48,5 @@
 #endif
 
-    if (pack_spu.swap)
-    {
-        crPackBeginSWAP( mode );
-    }
-    else
-    {
-        crPackBegin( mode );
-    }
-
+    crPackBegin( mode );
     if ( thread->netServer.conn->Barf ) {
         thread->BeginEndMode = mode;
@@ -99,12 +91,5 @@
     }
 
-    if (pack_spu.swap)
-    {
-        crPackEndSWAP();
-    }
-    else
-    {
-        crPackEnd();
-    }
+    crPackEnd();
 }
 
@@ -166,12 +151,5 @@
     print('void PACKSPU_APIENTRY packspu_%s(%s)' % ( func_name, apiutil.MakeDeclarationString(params) ))
     print('{')
-    print('\tif (pack_spu.swap)')
-    print('\t{')
-    print('\t\tcrPack%sSWAP(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
-    print('\t}')
-    print('\telse')
-    print('\t{')
-    print('\t\tcrPack%s(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
-    print('\t}')
+    print('\tcrPack%s(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
     print('\tRunState();')
     print('}')
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_bufferobject.c	(revision 78190)
@@ -140,12 +140,6 @@
         crError( "packspu_GenBuffersARB doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
     }
-    if (pack_spu.swap)
-    {
-        crPackGenBuffersARBSWAP( n, buffer, &writeback );
-    }
-    else
-    {
-        crPackGenBuffersARB( n, buffer, &writeback );
-    }
+
+    crPackGenBuffersARB( n, buffer, &writeback );
     packspuFlush( (void *) thread );
     CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_client.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_client.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_client.c	(revision 78190)
@@ -15,9 +15,6 @@
 #if CR_ARB_vertex_buffer_object
     GET_CONTEXT(ctx);
-    if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackFogCoordPointerEXTSWAP( type, stride, pointer );
-        else
-            crPackFogCoordPointerEXT( type, stride, pointer );
+   if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
+        crPackFogCoordPointerEXT( type, stride, pointer );
     }
 #endif
@@ -30,8 +27,5 @@
     GET_CONTEXT(ctx);
     if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackColorPointerSWAP( size, type, stride, pointer );
-        else
-            crPackColorPointer( size, type, stride, pointer );
+        crPackColorPointer( size, type, stride, pointer );
     }
 #endif
@@ -44,8 +38,5 @@
     GET_CONTEXT(ctx);
     if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackSecondaryColorPointerEXTSWAP( size, type, stride, pointer );
-        else
-            crPackSecondaryColorPointerEXT( size, type, stride, pointer );
+        crPackSecondaryColorPointerEXT( size, type, stride, pointer );
     }
 #endif
@@ -59,8 +50,5 @@
     CRASSERT(ctx->clientState->extensions.ARB_vertex_buffer_object);
     if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackVertexPointerSWAP( size, type, stride, pointer );
-        else
-            crPackVertexPointer( size, type, stride, pointer );
+        crPackVertexPointer( size, type, stride, pointer );
     }
 #endif
@@ -73,8 +61,5 @@
     GET_CONTEXT(ctx);
     if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackTexCoordPointerSWAP( size, type, stride, pointer );
-        else
-            crPackTexCoordPointer( size, type, stride, pointer );
+        crPackTexCoordPointer( size, type, stride, pointer );
     }
 #endif
@@ -87,8 +72,5 @@
     GET_CONTEXT(ctx);
     if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackNormalPointerSWAP( type, stride, pointer );
-        else
-            crPackNormalPointer( type, stride, pointer );
+        crPackNormalPointer( type, stride, pointer );
     }
 #endif
@@ -101,8 +83,5 @@
     GET_CONTEXT(ctx);
     if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackEdgeFlagPointerSWAP( stride, pointer );
-        else
-            crPackEdgeFlagPointer( stride, pointer );
+        crPackEdgeFlagPointer( stride, pointer );
     }
 #endif
@@ -115,8 +94,5 @@
     GET_CONTEXT(ctx);
     if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackVertexAttribPointerARBSWAP( index, size, type, normalized, stride, pointer );
-        else
-            crPackVertexAttribPointerARB( index, size, type, normalized, stride, pointer );
+        crPackVertexAttribPointerARB( index, size, type, normalized, stride, pointer );
     }
 #endif
@@ -129,8 +105,5 @@
     GET_CONTEXT(ctx);
     if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackVertexAttribPointerNVSWAP( index, size, type, stride, pointer );
-        else
-            crPackVertexAttribPointerNV( index, size, type, stride, pointer );
+        crPackVertexAttribPointerNV( index, size, type, stride, pointer );
     }
 #endif
@@ -143,8 +116,5 @@
     GET_CONTEXT(ctx);
     if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackIndexPointerSWAP( type, stride, pointer );
-        else
-            crPackIndexPointer( type, stride, pointer );
+        crPackIndexPointer( type, stride, pointer );
     }
 #endif
@@ -162,8 +132,5 @@
     GET_CONTEXT(ctx);
     if (ctx->clientState->extensions.ARB_vertex_buffer_object) {
-        if (pack_spu.swap)
-            crPackInterleavedArraysSWAP( format, stride, pointer );
-        else
-            crPackInterleavedArrays( format, stride, pointer );
+        crPackInterleavedArrays( format, stride, pointer );
     }
 #endif
@@ -380,8 +347,5 @@
 
         /* Send the DrawArrays command over the wire */
-        if (pack_spu.swap)
-            crPackArrayElementSWAP( index );
-        else
-            crPackArrayElement( index );
+        crPackArrayElement( index );
 
         if (cZvaValues)
@@ -400,8 +364,5 @@
 #endif
 
-        if (pack_spu.swap)
-            crPackExpandArrayElementSWAP( index, clientState, cZvaValues ? aAttrib : NULL );
-        else
-            crPackExpandArrayElement( index, clientState, cZvaValues ? aAttrib : NULL );
+        crPackExpandArrayElement( index, clientState, cZvaValues ? aAttrib : NULL );
 
 #ifdef CR_FORCE_ZVA_SERVER_ARRAY
@@ -529,8 +490,5 @@
 
         /* Send the DrawArrays command over the wire */
-        if (pack_spu.swap)
-            crPackDrawElementsSWAP( mode, count, type, indices );
-        else
-            crPackDrawElements( mode, count, type, indices );
+        crPackDrawElements( mode, count, type, indices );
 
         if (cZvaValues)
@@ -549,12 +507,7 @@
 #endif
 
-        if (pack_spu.swap)
-            crPackExpandDrawElementsSWAP( mode, count, type, indices, clientState, cZvaValues ? aAttrib : NULL );
-        else
-        {
-            //packspu_Begin(mode);
-            crPackExpandDrawElements( mode, count, type, indices, clientState, cZvaValues ? aAttrib : NULL );
-            //packspu_End();
-        }
+        //packspu_Begin(mode);
+        crPackExpandDrawElements( mode, count, type, indices, clientState, cZvaValues ? aAttrib : NULL );
+        //packspu_End();
 
 #ifdef CR_FORCE_ZVA_SERVER_ARRAY
@@ -615,8 +568,5 @@
 
         /* Send the DrawRangeElements command over the wire */
-        if (pack_spu.swap)
-            crPackDrawRangeElementsSWAP( mode, start, end, count, type, indices );
-        else
-            crPackDrawRangeElements( mode, start, end, count, type, indices );
+        crPackDrawRangeElements( mode, start, end, count, type, indices );
 
         if (cZvaValues)
@@ -634,10 +584,5 @@
 #endif
 
-        if (pack_spu.swap)
-            crPackExpandDrawRangeElementsSWAP( mode, start, end, count, type, indices, clientState, cZvaValues ? aAttrib : NULL );
-        else
-        {
-            crPackExpandDrawRangeElements( mode, start, end, count, type, indices, clientState, cZvaValues ? aAttrib : NULL );
-        }
+        crPackExpandDrawRangeElements( mode, start, end, count, type, indices, clientState, cZvaValues ? aAttrib : NULL );
 
 #ifdef CR_FORCE_ZVA_SERVER_ARRAY
@@ -709,8 +654,5 @@
 
         /* Send the DrawArrays command over the wire */
-        if (pack_spu.swap)
-            crPackDrawArraysSWAP( mode, first, count );
-        else
-            crPackDrawArrays( mode, first, count );
+        crPackDrawArrays( mode, first, count );
 
         if (cZvaValues)
@@ -729,8 +671,5 @@
 #endif
 
-        if (pack_spu.swap)
-            crPackExpandDrawArraysSWAP( mode, first, count, clientState, cZvaValues ? aAttrib : NULL );
-        else
-            crPackExpandDrawArrays( mode, first, count, clientState, cZvaValues ? aAttrib : NULL );
+        crPackExpandDrawArrays( mode, first, count, clientState, cZvaValues ? aAttrib : NULL );
 
 #ifdef CR_FORCE_ZVA_SERVER_ARRAY
@@ -809,9 +748,5 @@
     {
         crStateEnable(cap);
-
-        if (pack_spu.swap)
-            crPackEnableSWAP(cap);
-        else
-            crPackEnable(cap);
+        crPackEnable(cap);
     }
     else
@@ -834,9 +769,5 @@
     {
         crStateDisable(cap);
-
-        if (pack_spu.swap)
-            crPackDisableSWAP(cap);
-        else
-            crPackDisable(cap);
+        crPackDisable(cap);
     }
     else
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_config.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_config.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_config.c	(revision 78190)
@@ -23,31 +23,4 @@
 
 
-static void set_emit( void *foo, const char *response )
-{
-    RT_NOREF(foo);
-    sscanf( response, "%d", &(pack_spu.emit_GATHER_POST_SWAPBUFFERS) );
-}
-
-static void set_swapbuffer_sync( void *foo, const char *response )
-{
-    RT_NOREF(foo);
-    sscanf( response, "%d", &(pack_spu.swapbuffer_sync) );
-}
-
-
-
-/* No SPU options yet. Well.. not really..
- */
-SPUOptions packSPUOptions[] = {
-    { "emit_GATHER_POST_SWAPBUFFERS", CR_BOOL, 1, "0", NULL, NULL,
-      "Emit a parameter after SwapBuffers", (SPUOptionCB)set_emit },
-
-    { "swapbuffer_sync", CR_BOOL, 1, "1", NULL, NULL,
-        "Sync on SwapBuffers", (SPUOptionCB) set_swapbuffer_sync },
-
-    { NULL, CR_BOOL, 0, NULL, NULL, NULL, NULL, NULL },
-};
-
-
 void packspuSetVBoxConfiguration( const SPU *child_spu )
 {
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_context.c	(revision 78190)
@@ -69,5 +69,5 @@
     /* packer setup */
     CRASSERT(thread->packer == NULL);
-    thread->packer = crPackNewContext( pack_spu.swap );
+    thread->packer = crPackNewContext();
     CRASSERT(thread->packer);
     crPackInitBuffer( &(thread->buffer), crNetAlloc(thread->netServer.conn),
@@ -357,8 +357,5 @@
 
     /* Pack the command */
-    if (pack_spu.swap)
-        crPackCreateContextSWAP( dpyName, visual, shareCtx, &serverCtx, &writeback );
-    else
-        crPackCreateContext( dpyName, visual, shareCtx, &serverCtx, &writeback );
+    crPackCreateContext( dpyName, visual, shareCtx, &serverCtx, &writeback );
 
     /* Flush buffer and get return value */
@@ -385,7 +382,4 @@
         CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
 
-        if (pack_spu.swap) {
-            serverCtx = (GLint) SWAP32(serverCtx);
-        }
         if (serverCtx < 0) {
 #ifdef CHROMIUM_THREADSAFE
@@ -472,9 +466,5 @@
         }
 
-        if (pack_spu.swap)
-            crPackDestroyContextSWAP( context->serverCtx );
-        else
-            crPackDestroyContext( context->serverCtx );
-
+        crPackDestroyContext( context->serverCtx );
         crStateDestroyContext( context->clientState );
 
@@ -600,9 +590,5 @@
     }
 
-    if (pack_spu.swap)
-        crPackMakeCurrentSWAP( window, nativeWindow, serverCtx );
-    else
-        crPackMakeCurrent( window, nativeWindow, serverCtx );
-
+    crPackMakeCurrent( window, nativeWindow, serverCtx );
     if (serverCtx)
     {
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_flush.py
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_flush.py	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_flush.py	(revision 78190)
@@ -31,12 +31,5 @@
     print('{')
     print('\tGET_THREAD(thread);')
-    print('\tif (pack_spu.swap)')
-    print('\t{')
-    print('\t\tcrPack%sSWAP(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
-    print('\t}')
-    print('\telse')
-    print('\t{')
-    print('\t\tcrPack%s(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
-    print('\t}')
+    print('\tcrPack%s(%s);' % ( func_name, apiutil.MakeCallString( params ) ))
     print('\tpackspuFlush( (void *) thread );')
     print('}\n')
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_framebuffer.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_framebuffer.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_framebuffer.c	(revision 78190)
@@ -107,12 +107,6 @@
         crError( "packspu_GenFramebuffersEXT doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
     }
-    if (pack_spu.swap)
-    {
-        crPackGenFramebuffersEXTSWAP( n, framebuffers, &writeback );
-    }
-    else
-    {
-        crPackGenFramebuffersEXT( n, framebuffers, &writeback );
-    }
+
+    crPackGenFramebuffersEXT( n, framebuffers, &writeback );
     packspuFlush( (void *) thread );
     CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
@@ -129,12 +123,6 @@
         crError( "packspu_GenRenderbuffersEXT doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
     }
-    if (pack_spu.swap)
-    {
-        crPackGenRenderbuffersEXTSWAP( n, renderbuffers, &writeback );
-    }
-    else
-    {
-        crPackGenRenderbuffersEXT( n, renderbuffers, &writeback );
-    }
+
+    crPackGenRenderbuffersEXT( n, renderbuffers, &writeback );
     packspuFlush( (void *) thread );
     CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_get.py	(revision 78190)
@@ -49,31 +49,10 @@
 """)
 
+print('#ifdef DEBUG');
 from get_sizes import *
-
-easy_swaps = {
-    'GenTextures': '(unsigned int) n',
-    'GetClipPlane': '4',
-    'GetPolygonStipple': '0'
-}
+print('#endif');
 
 simple_funcs = [ 'GetIntegerv', 'GetFloatv', 'GetDoublev', 'GetBooleanv' ]
-simple_swaps = [ 'SWAP32', 'SWAPFLOAT', 'SWAPDOUBLE', '(GLboolean) SWAP32' ]
-
 vertattr_get_funcs = [ 'GetVertexAttribdv' 'GetVertexAttribfv' 'GetVertexAttribiv' ]
-
-hard_funcs = {
-    'GetLightfv': 'SWAPFLOAT',
-    'GetLightiv': 'SWAP32',
-    'GetMaterialfv': 'SWAPFLOAT',
-    'GetMaterialiv': 'SWAP32',
-    'GetTexEnvfv': 'SWAPFLOAT',
-    'GetTexEnviv': 'SWAP32',
-    'GetTexGendv': 'SWAPDOUBLE',
-    'GetTexGenfv': 'SWAPFLOAT',
-    'GetTexGeniv': 'SWAP32',
-    'GetTexLevelParameterfv': 'SWAPFLOAT',
-    'GetTexLevelParameteriv': 'SWAP32',
-    'GetTexParameterfv': 'SWAPFLOAT',
-    'GetTexParameteriv': 'SWAP32' }
 
 keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
@@ -93,6 +72,4 @@
             print('\t%s return_val = (%s) 0;' % (return_type, return_type))
             params.append( ("&return_val", "foo", 0) )
-        if (func_name in easy_swaps and easy_swaps[func_name] != '0') or func_name in simple_funcs or func_name in hard_funcs:
-            print('\tunsigned int i;')
         print('\tif (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))')
         print('\t{')
@@ -138,4 +115,5 @@
                )
             {
+                unsigned int i = 0;
                 %s localparams;
                 localparams = (%s) crAlloc(__numValues(pname) * sizeof(*localparams));
@@ -193,12 +171,5 @@
 
         params.append( ("&writeback", "foo", 0) )
-        print('\tif (pack_spu.swap)')
-        print('\t{')
-        print('\t\tcrPack%sSWAP(%s);' % (func_name, apiutil.MakeCallString( params ) ))
-        print('\t}')
-        print('\telse')
-        print('\t{')
-        print('\t\tcrPack%s(%s);' % (func_name, apiutil.MakeCallString( params ) ))
-        print('\t}')
+        print('\tcrPack%s(%s);' % (func_name, apiutil.MakeCallString( params ) ))
         print('\tpackspuFlush( (void *) thread );')
         print('\tCRPACKSPU_WRITEBACK_WAIT(thread, writeback);')
@@ -208,43 +179,4 @@
         lastParamName = params[-2][0]
         if return_type != 'void':
-            print('\tif (pack_spu.swap)')
-            print('\t{')
-            print('\t\treturn_val = (%s) SWAP32(return_val);' % return_type)
-            print('\t}')
             print('\treturn return_val;')
-        if func_name in easy_swaps and easy_swaps[func_name] != '0':
-            limit = easy_swaps[func_name]
-            print('\tif (pack_spu.swap)')
-            print('\t{')
-            print('\t\tfor (i = 0; i < %s; i++)' % limit)
-            print('\t\t{')
-            if params[-2][1].find( "double" ) > -1:
-                print('\t\t\t%s[i] = SWAPDOUBLE(%s[i]);' % (lastParamName, lastParamName))
-            else:
-                print('\t\t\t%s[i] = SWAP32(%s[i]);' % (lastParamName, lastParamName))
-            print('\t\t}')
-            print('\t}')
-        for index in range(len(simple_funcs)):
-            if simple_funcs[index] == func_name:
-                print('\tif (pack_spu.swap)')
-                print('\t{')
-                print('\t\tfor (i = 0; i < __numValues(pname); i++)')
-                print('\t\t{')
-                if simple_swaps[index] == 'SWAPDOUBLE':
-                    print('\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName))
-                else:
-                    print('\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, simple_swaps[index], lastParamName))
-                print('\t\t}')
-                print('\t}')
-        if func_name in hard_funcs:
-            print('\tif (pack_spu.swap)')
-            print('\t{')
-            print('\t\tfor (i = 0; i < crStateHlpComponentsCount(pname); i++)')
-            print('\t\t{')
-            if hard_funcs[func_name] == 'SWAPDOUBLE':
-                print('\t\t\t%s[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName))
-            else:
-                print('\t\t\t((GLuint *) %s)[i] = %s(%s[i]);' % (lastParamName, hard_funcs[func_name], lastParamName))
-            print('\t\t}')
-            print('\t}')
         print('}\n')
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_getstring.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_getstring.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_getstring.c	(revision 78190)
@@ -17,4 +17,7 @@
 static GLubyte gpszShadingVersion[255]="";
 #endif
+static uint32_t g_uOpenGlVersMaj = 0;
+static uint32_t g_uOpenGlVersMin = 0;
+
 
 static void GetString(GLenum name, GLubyte *pszStr)
@@ -23,8 +26,5 @@
     int writeback = 1;
 
-    if (pack_spu.swap)
-        crPackGetStringSWAP(name, pszStr, &writeback);
-    else
-        crPackGetString(name, pszStr, &writeback);
+    crPackGetString(name, pszStr, &writeback);
     packspuFlush( (void *) thread );
 
@@ -32,5 +32,5 @@
 }
 
-static GLfloat
+static void
 GetVersionString(void)
 {
@@ -40,4 +40,5 @@
     if (!fInitialized)
     {
+        int iGlVersion = 0;
         GLubyte return_value[100];
 
@@ -45,11 +46,11 @@
         CRASSERT(crStrlen((char *)return_value) < 100);
 
-        version = crStrToFloat((char *) return_value);
-        version = crStateComputeVersion(version);
+        iGlVersion = crStrParseGlVersion((const char *) return_value);
+        g_uOpenGlVersMaj = CR_GLVERSION_GET_MAJOR(iGlVersion);
+        g_uOpenGlVersMin = CR_GLVERSION_GET_MINOR(iGlVersion);
+        crStateComputeVersion(&g_uOpenGlVersMaj, &g_uOpenGlVersMin);
 
         fInitialized = GL_TRUE;
     }
-
-    return version;
 }
 
@@ -65,12 +66,5 @@
         int writeback = 1;
 
-        if (pack_spu.swap)
-        {
-            crPackGetStringSWAP( GL_EXTENSIONS, return_value, &writeback );
-        }
-        else
-        {
-            crPackGetString( GL_EXTENSIONS, return_value, &writeback );
-        }
+        crPackGetString( GL_EXTENSIONS, return_value, &writeback );
         packspuFlush( (void *) thread );
 
@@ -129,5 +123,4 @@
             {
                 char *oldlocale;
-                float version;
 
                 oldlocale = setlocale(LC_NUMERIC, NULL);
@@ -135,6 +128,6 @@
                 setlocale(LC_NUMERIC, "C");
 
-                version = GetVersionString();
-                sprintf((char*)ctx->glVersion, "%.1f Chromium %s", version, CR_VERSION_STRING);
+                GetVersionString();
+                sprintf((char*)ctx->glVersion, "%u.%u Chromium %s", g_uOpenGlVersMaj, g_uOpenGlVersMin, CR_VERSION_STRING);
 
                 if (oldlocale)
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_glsl.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_glsl.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_glsl.c	(revision 78190)
@@ -33,19 +33,7 @@
         crError("packspu_CreateProgram doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!");
     }
-    if (pack_spu.swap)
-    {
-        crPackCreateProgramSWAP(&return_val, &writeback);
-    }
-    else
-    {
-        crPackCreateProgram(&return_val, &writeback);
-    }
+    crPackCreateProgram(&return_val, &writeback);
     packspuFlush((void *) thread);
     CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
-    if (pack_spu.swap)
-    {
-        return_val = (GLuint) SWAP32(return_val);
-    }
-
     crStateCreateProgram(return_val);
 
@@ -62,18 +50,8 @@
         crError("packspu_GetUniformLocation doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!");
     }
-    if (pack_spu.swap)
-    {
-        crPackGetUniformLocationSWAP(program, name, &return_val, &writeback);
-    }
-    else
-    {
-        crPackGetUniformLocation(program, name, &return_val, &writeback);
-    }
+
+    crPackGetUniformLocation(program, name, &return_val, &writeback);
     packspuFlush((void *) thread);
     CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
-    if (pack_spu.swap)
-    {
-        return_val = (GLint) SWAP32(return_val);
-    }
     return return_val;
 }
@@ -124,18 +102,8 @@
         crError( "packspu_GetAttribLocation doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
     }
-    if (pack_spu.swap)
-    {
-        crPackGetAttribLocationSWAP( program, name, &return_val, &writeback );
-    }
-    else
-    {
-        crPackGetAttribLocation( program, name, &return_val, &writeback );
-    }
+
+    crPackGetAttribLocation( program, name, &return_val, &writeback );
     packspuFlush( (void *) thread );
     CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
-    if (pack_spu.swap)
-    {
-        return_val = (GLint) SWAP32(return_val);
-    }
     return return_val;
 }
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_init.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_init.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_init.c	(revision 78190)
@@ -135,9 +135,7 @@
 }
 
-extern SPUOptions packSPUOptions[];
-
 int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
          SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
-         SPUOptionsPtr *options, int *flags )
+         int *flags )
 {
     *name = "pack";
@@ -146,5 +144,4 @@
     *self = packSPUSelfDispatch;
     *cleanup = packSPUCleanup;
-    *options = packSPUOptions;
     *flags = (SPU_HAS_PACKER|SPU_IS_TERMINAL|SPU_MAX_SERVERS_ONE);
 
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_misc.c	(revision 78190)
@@ -85,8 +85,5 @@
     }
 
-    if (pack_spu.swap)
-        crPackChromiumParametervCRSWAP(target, type, count, values);
-    else
-        crPackChromiumParametervCR(target, type, count, values);
+    crPackChromiumParametervCR(target, type, count, values);
 
     if (fFlush)
@@ -131,21 +128,10 @@
     GLint writeback = CRPACKSPU_IS_WDDM_CRHGSMI() ? 1 : pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network;
 
-    if (pack_spu.swap)
-    {
-        crPackFinishSWAP();
-    }
-    else
-    {
-        crPackFinish();
-    }
-
+    crPackFinish();
     if (packspuSyncOnFlushes())
     {
         if (writeback)
         {
-            if (pack_spu.swap)
-                crPackWritebackSWAP(&writeback);
-            else
-                crPackWriteback(&writeback);
+            crPackWriteback(&writeback);
 
             packspuFlush( (void *) thread );
@@ -277,13 +263,5 @@
 
     crPackSetContext(thread->packer);
-
-    if (pack_spu.swap)
-    {
-        crPackWindowCreateSWAP( dpyName, visBits, &return_val, &writeback );
-    }
-    else
-    {
-        crPackWindowCreate( dpyName, visBits, &return_val, &writeback );
-    }
+    crPackWindowCreate( dpyName, visBits, &return_val, &writeback );
     packspuFlush(thread);
     if (!(thread->netServer.conn->actual_network))
@@ -294,8 +272,4 @@
     {
         CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
-        if (pack_spu.swap)
-        {
-            return_val = (GLint) SWAP32(return_val);
-        }
         retVal = return_val;
     }
@@ -334,12 +308,5 @@
     }
 
-    if (pack_spu.swap)
-    {
-        crPackAreTexturesResidentSWAP( n, textures, residences, &return_val, &writeback );
-    }
-    else
-    {
-        crPackAreTexturesResident( n, textures, residences, &return_val, &writeback );
-    }
+    crPackAreTexturesResident( n, textures, residences, &return_val, &writeback );
     packspuFlush( (void *) thread );
 
@@ -373,12 +340,6 @@
         crError( "packspu_AreProgramsResidentNV doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
     }
-    if (pack_spu.swap)
-    {
-        crPackAreProgramsResidentNVSWAP( n, ids, residences, &return_val, &writeback );
-    }
-    else
-    {
-        crPackAreProgramsResidentNV( n, ids, residences, &return_val, &writeback );
-    }
+
+    crPackAreProgramsResidentNV( n, ids, residences, &return_val, &writeback );
     packspuFlush( (void *) thread );
 
@@ -403,13 +364,5 @@
     int writeback = 1;
 
-    if (pack_spu.swap)
-    {
-        crPackGetPolygonStippleSWAP( mask, &writeback );
-    }
-    else
-    {
-        crPackGetPolygonStipple( mask, &writeback );
-    }
-
+    crPackGetPolygonStipple( mask, &writeback );
 #ifdef CR_ARB_pixel_buffer_object
     if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
@@ -426,13 +379,5 @@
     int writeback = 1;
 
-    if (pack_spu.swap)
-    {
-        crPackGetPixelMapfvSWAP( map, values, &writeback );
-    }
-    else
-    {
-        crPackGetPixelMapfv( map, values, &writeback );
-    }
-
+    crPackGetPixelMapfv( map, values, &writeback );
 #ifdef CR_ARB_pixel_buffer_object
     if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
@@ -449,12 +394,5 @@
     int writeback = 1;
 
-    if (pack_spu.swap)
-    {
-        crPackGetPixelMapuivSWAP( map, values, &writeback );
-    }
-    else
-    {
-        crPackGetPixelMapuiv( map, values, &writeback );
-    }
+    crPackGetPixelMapuiv( map, values, &writeback );
 
 #ifdef CR_ARB_pixel_buffer_object
@@ -472,13 +410,5 @@
     int writeback = 1;
 
-    if (pack_spu.swap)
-    {
-        crPackGetPixelMapusvSWAP( map, values, &writeback );
-    }
-    else
-    {
-        crPackGetPixelMapusv( map, values, &writeback );
-    }
-
+    crPackGetPixelMapusv( map, values, &writeback );
 #ifdef CR_ARB_pixel_buffer_object
     if (!crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
@@ -558,21 +488,8 @@
         crError( "packspu_GetError doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
     }
-    if (pack_spu.swap)
-    {
-        crPackGetErrorSWAP( &return_val, &writeback );
-    }
-    else
-    {
-        crPackGetError( &return_val, &writeback );
-    }
-
+
+    crPackGetError( &return_val, &writeback );
     packspuFlush( (void *) thread );
     CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
-
-    if (pack_spu.swap)
-    {
-        return_val = (GLenum) SWAP32(return_val);
-    }
-
     return return_val;
 }
@@ -619,5 +536,5 @@
 
         CRASSERT(thread->packer == NULL);
-        thread->packer = crPackNewContext( pack_spu.swap );
+        thread->packer = crPackNewContext();
         CRASSERT(thread->packer);
         crPackInitBuffer(&(thread->buffer), crNetAlloc(thread->netServer.conn),
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_net.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_net.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_net.c	(revision 78190)
@@ -95,14 +95,6 @@
     CRASSERT( (void *) hdr >= buf->pack );
 
-    if (pack_spu.swap)
-    {
-        hdr->header.type = (CRMessageType) SWAP32(CR_MESSAGE_OPCODES);
-        hdr->numOpcodes  = SWAP32(num_opcodes);
-    }
-    else
-    {
-        hdr->header.type = CR_MESSAGE_OPCODES;
-        hdr->numOpcodes  = num_opcodes;
-    }
+    hdr->header.type = CR_MESSAGE_OPCODES;
+    hdr->numOpcodes  = num_opcodes;
 
     *len = buf->data_current - (unsigned char *) hdr;
@@ -206,9 +198,4 @@
        a header */
     len = ((unsigned int *) buf)[-1];
-    if (pack_spu.swap)
-    {
-        /* It's already been swapped, swap it back. */
-        len = SWAP32(len);
-    }
     len += 4 + sizeof(CRMessageOpcodes);
 
@@ -221,15 +208,6 @@
 
     msg = (CRMessageOpcodes *) src;
-
-    if (pack_spu.swap)
-    {
-        msg->header.type = (CRMessageType) SWAP32(CR_MESSAGE_OPCODES);
-        msg->numOpcodes  = SWAP32(1);
-    }
-    else
-    {
-        msg->header.type = CR_MESSAGE_OPCODES;
-        msg->numOpcodes  = 1;
-    }
+    msg->header.type = CR_MESSAGE_OPCODES;
+    msg->numOpcodes  = 1;
 
     CRASSERT( thread->netServer.conn );
@@ -272,5 +250,4 @@
             return;
         }
-        pack_spu.swap = server->conn->swap;
     }
     else {
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_pixel.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_pixel.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_pixel.c	(revision 78190)
@@ -330,8 +330,5 @@
 {
     GET_THREAD(thread);
-    if (pack_spu.swap)
-        crPackCopyPixelsSWAP( x, y, width, height, type );
-    else
-        crPackCopyPixels( x, y, width, height, type );
+    crPackCopyPixels( x, y, width, height, type );
     /* XXX why flush here? */
     packspuFlush( (void *) thread );
@@ -378,9 +375,5 @@
     }
 
-    if (pack_spu.swap)
-        crPackTexImage1DSWAP( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) );
-    else
-        crPackTexImage1D( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) );
-
+    crPackTexImage1D( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) );
     if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
     {
@@ -411,9 +404,5 @@
     }
 
-    if (pack_spu.swap)
-        crPackTexImage2DSWAP( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) );
-    else
-        crPackTexImage2D( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) );
-
+    crPackTexImage2D( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) );
     if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
     {
@@ -433,9 +422,5 @@
     }
 
-    if (pack_spu.swap)
-        crPackTexImage3DEXTSWAP( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
-    else
-        crPackTexImage3DEXT( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
-
+    crPackTexImage3DEXT( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
     if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
     {
@@ -456,9 +441,5 @@
     }
 
-    if (pack_spu.swap)
-        crPackTexImage3DSWAP( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
-    else
-        crPackTexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
-
+    crPackTexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) );
     if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
     {
@@ -484,9 +465,5 @@
     }
 
-    if (pack_spu.swap)
-        crPackTexSubImage1DSWAP( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) );
-    else
-        crPackTexSubImage1D( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) );
-
+    crPackTexSubImage1D( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) );
     if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
     {
@@ -511,9 +488,5 @@
     }
 
-    if (pack_spu.swap)
-        crPackTexSubImage2DSWAP( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) );
-    else
-        crPackTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) );
-
+    crPackTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) );
     if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
     {
@@ -533,9 +506,5 @@
     }
 
-    if (pack_spu.swap)
-        crPackTexSubImage3DSWAP( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, &(clientState->unpack) );
-    else
-        crPackTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, &(clientState->unpack) );
-
+    crPackTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, &(clientState->unpack) );
     if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
     {
@@ -549,8 +518,5 @@
     GET_CONTEXT(ctx);
     CRClientState *clientState = &(ctx->clientState->client);
-    if (pack_spu.swap)
-        crPackZPixCRSWAP( width, height, format, type, ztype, zparm, length, pixels, &(clientState->unpack) );
-    else
-        crPackZPixCR( width, height, format, type, ztype, zparm, length, pixels, &(clientState->unpack) );
+    crPackZPixCR( width, height, format, type, ztype, zparm, length, pixels, &(clientState->unpack) );
 }
 
@@ -572,9 +538,5 @@
     }
 
-    if (pack_spu.swap)
-        crPackGetTexImageSWAP( target, level, format, type, pixels, &(clientState->pack), &writeback );
-    else
-        crPackGetTexImage( target, level, format, type, pixels, &(clientState->pack), &writeback );
-
+    crPackGetTexImage( target, level, format, type, pixels, &(clientState->pack), &writeback );
     if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
     {
@@ -601,13 +563,5 @@
     }
 
-    if (pack_spu.swap)
-    {
-        crPackGetCompressedTexImageARBSWAP( target, level, img, &writeback );
-    }
-    else
-    {
-        crPackGetCompressedTexImageARB( target, level, img, &writeback );
-    }
-
+    crPackGetCompressedTexImageARB( target, level, img, &writeback );
     if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
     {
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_swapbuf.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_swapbuf.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_swapbuf.c	(revision 78190)
@@ -11,22 +11,4 @@
 #include "packspu_proto.h"
 
-#if 0
-
-void PACKSPU_APIENTRY packspu_SwapBuffers( GLint window, GLint flags )
-{
-    GET_THREAD(thread);
-    if (pack_spu.swap)
-    {
-        crPackSwapBuffersSWAP( window, flags );
-    }
-    else
-    {
-        crPackSwapBuffers( window, flags );
-    }
-    packspuFlush( (void *) thread );
-}
-
-
-#else
 
 void PACKSPU_APIENTRY packspu_SwapBuffers( GLint window, GLint flags )
@@ -34,12 +16,5 @@
     GET_THREAD(thread);
 
-    if (pack_spu.swap)
-    {
-        crPackSwapBuffersSWAP( window, flags );
-    }
-    else
-    {
-        crPackSwapBuffers( window, flags );
-    }
+    crPackSwapBuffers( window, flags );
     packspuFlush( (void *) thread );
 
@@ -73,12 +48,5 @@
              */
             thread->writeback = 1;
-            if (pack_spu.swap)
-            {
-                crPackWritebackSWAP( (GLint *) &thread->writeback );
-            }
-            else
-            {
-                crPackWriteback( (GLint *) &thread->writeback );
-            }
+            crPackWriteback( (GLint *) &thread->writeback );
             break;
         case 1:
@@ -92,11 +60,5 @@
     /* want to emit a parameter here */
     if (pack_spu.emit_GATHER_POST_SWAPBUFFERS)
-    {
-        if (pack_spu.swap)
-            crPackChromiumParameteriCRSWAP(GL_GATHER_POST_SWAPBUFFERS_CR, 1);
-        else
-            crPackChromiumParameteriCR(GL_GATHER_POST_SWAPBUFFERS_CR, 1);
-    }
+        crPackChromiumParameteriCR(GL_GATHER_POST_SWAPBUFFERS_CR, 1);
 }
 
-#endif
Index: /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_texture.c	(revision 78190)
@@ -44,27 +44,12 @@
     GET_THREAD(thread);
     int writeback = 1;
-    unsigned int i;
     if (!CRPACKSPU_IS_WDDM_CRHGSMI() && !(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))
     {
         crError( "packspu_GenTextures doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!" );
     }
-    if (pack_spu.swap)
-    {
-        crPackGenTexturesSWAP( n, textures, &writeback );
-    }
-    else
-    {
-        crPackGenTextures( n, textures, &writeback );
-    }
+
+    crPackGenTextures( n, textures, &writeback );
     packspuFlush( (void *) thread );
     CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
-    if (pack_spu.swap)
-    {
-        for (i = 0 ; i < (unsigned int) n ; i++)
-        {
-            textures[i] = SWAP32(textures[i]);
-        }
-    }
-
     crStateRegTextures(n, textures);
 }
Index: /trunk/src/VBox/Additions/common/crOpenGL/passthrough/passthroughspu_init.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/passthrough/passthroughspu_init.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/passthrough/passthroughspu_init.c	(revision 78190)
@@ -44,12 +44,8 @@
 }
 
-static SPUOptions passthroughSPUOptions[] = {
-   { NULL, CR_BOOL, 0, NULL, NULL, NULL, NULL, NULL },
-};
-
 
 int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
 	     SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
-	     SPUOptionsPtr *options, int *flags )
+	     int *flags )
 {
 	*name = "passthrough";
@@ -58,5 +54,4 @@
 	*self = passthroughSPUSelfDispatch;
 	*cleanup = passthroughSPUCleanup;
-	*options = passthroughSPUOptions;
 	*flags = (SPU_NO_PACKER|SPU_NOT_TERMINAL|SPU_MAX_SERVERS_ZERO);
 
Index: /trunk/src/VBox/Additions/common/crOpenGL/wgl.c
===================================================================
--- /trunk/src/VBox/Additions/common/crOpenGL/wgl.c	(revision 78189)
+++ /trunk/src/VBox/Additions/common/crOpenGL/wgl.c	(revision 78190)
@@ -7,5 +7,4 @@
 #include "cr_error.h"
 #include "cr_spu.h"
-#include "cr_environment.h"
 #include "cr_mem.h"
 #include "stub.h"
@@ -19,4 +18,5 @@
 
 #include <iprt/cdefs.h>
+#include <iprt/env.h>
 
 /* Currently host part will misbehave re-creating context with proper visual bits
@@ -83,5 +83,5 @@
      * There are subtle differences in the use of these calls.
      */
-    crSetenv("CR_WGL_DO_NOT_USE_GDI", "yes");
+    RTEnvSet("CR_WGL_DO_NOT_USE_GDI", "yes");
 
     if ( pfd->nSize != sizeof(*pfd) || pfd->nVersion != 1 ) {
Index: /trunk/src/VBox/GuestHost/OpenGL/Makefile.kmk
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/Makefile.kmk	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/Makefile.kmk	(revision 78190)
@@ -60,16 +60,8 @@
 endif
 VBoxOGLcrutil_SOURCES       = \
-	util/bbox.c \
 	util/bufpool.c \
-	util/calllists.c \
-	util/devnull.c \
 	util/dll.c \
-	util/endian.c \
-	util/environment.c \
 	util/error.c \
-	util/filenet.c \
 	util/hash.c \
-	util/hull.c \
-	util/list.c \
 	util/matrix.c \
 	util/mem.c \
@@ -77,12 +69,6 @@
 	util/pixel.c \
 	util/process.c \
-	util/rand.c \
 	util/string.c \
 	util/threads.c \
-	util/tcpip.c \
-	util/udptcpip.c \
-	util/timer.c \
-	util/url.c \
-	util/warp.c \
 	util/vreg.cpp \
 	util/blitter.cpp \
@@ -90,6 +76,5 @@
 	util/htable.cpp \
 	util/bmpscale.cpp \
-	util/vboxhgcm.c \
-	$(VBOX_PATH_CROGL_GENFILES)/debug_opcodes.c
+	util/vboxhgcm.c
 VBoxOGLcrutil_SOURCES.win = \
 	util/VBoxOGLcrutil.rc
@@ -123,6 +108,4 @@
 VBoxOGLcrutil_LIBS.win    += $(VBOX_PATH_ADDITIONS_LIB)/VBoxDispMpLogger$(VBOX_SUFF_LIB)
 endif
-VBoxOGLcrutil_CLEAN = \
-	$(VBOX_PATH_CROGL_GENFILES)/debug_opcodes.c
 if1of ($(KBUILD_TARGET), linux)
 VBoxOGLcrutil_LDFLAGS += -Wl,-z,nodelete
@@ -191,8 +174,4 @@
 # Generate files for VBoxOGLcrutil and VBoxOGLhostcrutil.
 #
-$(VBOX_PATH_CROGL_GENFILES)/debug_opcodes.c: $(PATH_SUB_CURRENT)/util/debug_opcodes.py $(VBOX_CROGL_API_FILES) | $$(dir $$@)
-	$(call MSG_GENERATE,python,$@,$<)
-	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI)
-
 ifdef VBOX_WITH_CRDUMPER
 $(VBOX_PATH_CROGL_GENFILES)/dump_gen.cpp: $(PATH_SUB_CURRENT)/state_tracker/dump_gen.py $(PATH_ROOT)/src/VBox/HostServices/SharedOpenGL/crserverlib/get_sizes.py $(addprefix $(PATH_SUB_CURRENT)/state_tracker/, state_isenabled.txt state_extensions_isenabled.txt) $(VBOX_CROGL_API_FILES) | $$(dir $$@)
@@ -235,8 +214,6 @@
 	packer/pack_lights.c \
 	packer/pack_lists.c \
-	packer/pack_swap_lists.c \
 	packer/pack_map.c \
 	packer/pack_point.c \
-	packer/pack_swap_map.c \
 	packer/pack_misc.c \
 	packer/pack_materials.c \
@@ -244,47 +221,15 @@
 	packer/pack_pixels.c \
 	packer/pack_pixelmap.c \
-	packer/pack_swap_pixelmap.c \
 	packer/pack_program.c \
 	packer/pack_regcombiner.c \
 	packer/pack_stipple.c \
 	packer/pack_texture.c \
-	packer/pack_swap_texture.c \
 	packer/pack_visibleregion.c \
 	packer/pack_shaders.c \
 	packer/pack_framebuffer.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_arrays_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_bounds_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_bufferobject_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_client_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_clipplane_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_fog_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_lights_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_materials_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_matrices_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_misc_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_pixels_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_point_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_program_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_regcombiner_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_stipple_swap.c \
 	$(VBOX_PATH_CROGL_GENFILES)/pack_bbox.c \
 	$(VBOX_PATH_CROGL_GENFILES)/pack_current.c \
 	$(VBOX_PATH_CROGL_GENFILES)/packer.c
 VBoxOGLcrpacker_CLEAN = \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_arrays_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_bounds_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_bufferobject_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_client_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_clipplane_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_fog_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_lights_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_materials_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_matrices_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_misc_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_pixels_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_point_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_program_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_regcombiner_swap.c \
-	$(VBOX_PATH_CROGL_GENFILES)/pack_stipple_swap.c \
 	$(VBOX_PATH_CROGL_GENFILES)/pack_bbox.c \
 	$(VBOX_PATH_CROGL_GENFILES)/pack_current.c \
@@ -347,9 +292,4 @@
 	$(call MSG_GENERATE,python,$@,$<)
 	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $<
-
-$(VBOX_PATH_CROGL_GENFILES)/%_swap.c: $(PATH_SUB_CURRENT)/packer/%.c $(PATH_SUB_CURRENT)/packer/pack_swap.py | $$(dir $$@)
-	$(call MSG_GENERATE,python,$@,$<)
-	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $(<D)/pack_swap.py $<
-
 
 #
Index: /trunk/src/VBox/GuestHost/OpenGL/error/errorspu_init.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/error/errorspu_init.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/error/errorspu_init.c	(revision 78190)
@@ -38,12 +38,8 @@
 }
 
-static SPUOptions errorSPUOptions[] = {
-   { NULL, CR_BOOL, 0, NULL, NULL, NULL, NULL, NULL },
-};
-
 
 int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
              SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
-             SPUOptionsPtr *options, int *flags )
+             int *flags )
 {
 #ifdef IN_GUEST
@@ -56,5 +52,4 @@
         *self = errorSPUSelfDispatch;
         *cleanup = errorSPUCleanup;
-        *options = errorSPUOptions;
         *flags = (SPU_NO_PACKER|SPU_NOT_TERMINAL|SPU_MAX_SERVERS_ZERO);
         
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_bbox.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_bbox.h	(revision 78189)
+++ 	(revision )
@@ -1,39 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved.
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifndef CR_BBOX_H
-#define CR_BBOX_H
-
-#include "state/cr_statetypes.h"
-
-#include <iprt/cdefs.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern DECLEXPORT(void)
-crTransformBBox(float xmin, float ymin, float zmin,
-								float xmax, float ymax, float zmax,
-								const CRmatrix *m,
-								float *out_xmin, float *out_ymin, float *out_zmin,
-								float *out_xmax, float *out_ymax, float *out_zmax);
-
-extern DECLEXPORT(void)
-crProjectBBox(const GLfloat modl[16], const GLfloat proj[16], 
-							GLfloat *x1, GLfloat *y1, GLfloat *z1,
-							GLfloat *x2, GLfloat *y2, GLfloat *z2);
-
-
-extern DECLEXPORT(void)
-crRectiUnion(CRrecti *result, const CRrecti *a, const CRrecti *b);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CR_BBOX_H */
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_calllists.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_calllists.h	(revision 78189)
+++ 	(revision )
@@ -1,28 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifndef CR_CALLLISTS_H
-#define CR_CALLLISTS_H
-
-#include <iprt/cdefs.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern DECLEXPORT(int)
-crExpandCallLists(GLsizei n, GLenum type, const GLvoid *lists, 
-    GLuint base, void (*callListFunc)(GLuint list));
-
-extern DECLEXPORT(int)
-crExpandCallListsWithData(GLsizei n, GLenum type, const GLvoid *lists, 
-    GLuint base, void (*callListFunc)(GLuint list, GLuint index, GLvoid *data), GLvoid *data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CR_CALLLISTS_H */
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_debugopcodes.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_debugopcodes.h	(revision 78189)
+++ 	(revision )
@@ -1,23 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved.
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifndef CR_DEBUG_OPCODES_H
-#define CR_DEBUG_OPCODES_H
-
-#include "cr_opcodes.h"
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void crDebugOpcodes( FILE *fp, unsigned char *ptr, unsigned int num_opcodes );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CR_DEBUG_OPCODES_H */
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_dmx.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_dmx.h	(revision 78189)
+++ 	(revision )
@@ -1,55 +1,0 @@
-/**
- * DMX utility functions.
- */
-
-#ifndef CR_DMX_H
-#define CR_DMX_H
-
-#include <X11/Xlib.h>
-#include <X11/extensions/dmxext.h>
-
-#include "cr_spu.h"
-#include "state/cr_statetypes.h"
-
-
-typedef struct {
-    GLXDrawable xwin;     /**< backend server's X window */
-    GLXDrawable xsubwin;  /**< child of xwin, clipped to screen bounds */
-    Display *dpy;         /**< DMX back-end server display */
-    CRrecti visrect;      /**< visible rect, in front-end screen coords */
-} CRDMXBackendWindowInfo;
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-extern int
-crDMXSupported(Display *dpy);
-
-extern CRDMXBackendWindowInfo *
-crDMXAllocBackendWindowInfo(unsigned int numBackendWindows);
-
-extern void
-crDMXFreeBackendWindowInfo(unsigned int numBackendWindows,
-													 CRDMXBackendWindowInfo *backendWindows);
-
-/* Given the DMX front-end display "dpy" and window "xwin", update the
- * backend window information in "backendWindows".  If new subwindows are
- * needed, and an OpenGL interface pointer is provided, use that interface
- * and the subwindowVisBits to create new subwindows.
- */
-extern GLboolean
-crDMXGetBackendWindowInfo(Display *dpy, GLXDrawable xwin, 
-													unsigned int numBackendWindows,
-													CRDMXBackendWindowInfo *backendWindows,
-													const crOpenGLInterface *openGlInterface,
-													GLint subwindowVisBits);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CR_DLM_H */
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_endian.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_endian.h	(revision 78189)
+++ 	(revision )
@@ -1,90 +1,0 @@
-#ifndef CR_ENDIAN_H
-#define CR_ENDIAN_H
-
-#define CR_LITTLE_ENDIAN 0
-#define CR_BIG_ENDIAN 1
-
-#include <iprt/cdefs.h>
-
-#ifdef __cplusplus 
-extern "C" {
-#endif
-
-extern DECLEXPORT(char) crDetermineEndianness( void );
-
-#ifdef WINDOWS
-typedef __int64 CR64BitType;
-#else
-#ifndef __STDC__
-typedef long long CR64BitType;
-#else
-typedef struct  _CR64BitType
-{
-    unsigned int  lo;
-    unsigned int  hi;
-
-} CR64BitType;
-#endif
-#endif
-
-#define SWAP8(x) x
-#define SWAP16(x) (short) ((((x) & 0x00FF) << 8) | (((x) & 0xFF00) >> 8))
-#define SWAP32(x) ((((x) & 0x000000FF) << 24) | \
-		   (((x) & 0x0000FF00) << 8)  | \
-		   (((x) & 0x00FF0000) >> 8)  | \
-		   (((x) & 0xFF000000) >> 24))
-#ifdef WINDOWS
-#define SWAP64(x) \
-	 ((((x) & 0xFF00000000000000L) >> 56) | \
-		(((x) & 0x00FF000000000000L) >> 40) | \
-		(((x) & 0x0000FF0000000000L) >> 24) | \
-		(((x) & 0x000000FF00000000L) >> 8)  | \
-		(((x) & 0x00000000FF000000L) << 8)  | \
-		(((x) & 0x0000000000FF0000L) << 24) | \
-		(((x) & 0x000000000000FF00L) << 40) | \
-		(((x) & 0x00000000000000FFL) << 56))
-#else
-#ifndef __STDC__
-#define SWAP64(x) \
-	  x = ((((x) & 0xFF00000000000000LL) >> 56) | \
-		(((x) & 0x00FF000000000000LL) >> 40) | \
-		(((x) & 0x0000FF0000000000LL) >> 24) | \
-		(((x) & 0x000000FF00000000LL) >> 8)  | \
-		(((x) & 0x00000000FF000000LL) << 8)  | \
-		(((x) & 0x0000000000FF0000LL) << 24) | \
-		(((x) & 0x000000000000FF00LL) << 40) | \
-		(((x) & 0x00000000000000FFLL) << 56))
-#else
-#define SWAP64(x) \
-   {                                            \
-      GLubyte *bytes = (GLubyte *) &(x);    \
-      GLubyte tmp = bytes[0];                   \
-      bytes[0] = bytes[7];                      \
-      bytes[7] = tmp;                           \
-      tmp = bytes[1];                           \
-      bytes[1] = bytes[6];                      \
-      bytes[6] = tmp;                           \
-      tmp = bytes[2];                           \
-      bytes[2] = bytes[5];                      \
-      bytes[5] = tmp;                           \
-      tmp = bytes[4];                           \
-      bytes[4] = bytes[3];                      \
-      bytes[3] = tmp;                           \
-   }
-#endif
-#endif
-
-DECLEXPORT(double) SWAPDOUBLE( double d );
-
-#define SWAPFLOAT(x) ( ((*((int *) &(x)) & 0x000000FF) << 24) | \
-                       ((*((int *) &(x)) & 0x0000FF00) << 8) | \
-                       ((*((int *) &(x)) & 0x00FF0000) >> 8) | \
-                       ((*((int *) &(x)) & 0xFF000000) >> 24))
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
- 
-
-#endif /* CR_ENDIAN_H */
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_environment.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_environment.h	(revision 78189)
+++ 	(revision )
@@ -1,23 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved.
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifndef CR_ENVIRONMENT_H
-#define CR_ENVIRONMENT_H
-
-#include <iprt/cdefs.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern DECLEXPORT(void) crSetenv( const char *var, const char *value );
-extern DECLEXPORT(const char *) crGetenv( const char *var );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CR_ENVIRONMENT_H */
Index: /trunk/src/VBox/GuestHost/OpenGL/include/cr_htable.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_htable.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/cr_htable.h	(revision 78190)
@@ -45,11 +45,4 @@
 } CRHTABLE, *PCRHTABLE;
 
-typedef struct CRHTABLE_ITERATOR
-{
-    PCRHTABLE pTbl;
-    uint32_t iCur;
-    uint32_t cLeft;
-} VCRHTABLE_ITERATOR, *PCRHTABLE_ITERATOR;
-
 /*private stuff, not to be used directly */
 DECLINLINE(CRHTABLE_HANDLE) crHTableIndex2Handle(uint32_t iIndex)
@@ -61,41 +54,4 @@
 {
     return hHandle-1;
-}
-
-/* public API */
-DECLINLINE(void) CrHTableIterInit(PCRHTABLE pTbl, PCRHTABLE_ITERATOR pIter)
-{
-    pIter->pTbl = pTbl;
-    pIter->iCur = 0;
-    pIter->cLeft = pTbl->cData;
-}
-
-DECLINLINE(void*) CrHTableIterNext(PCRHTABLE_ITERATOR pIter, CRHTABLE_HANDLE *phHandle)
-{
-    PCRHTABLE pTbl;
-    uint32_t i;
-    if (!pIter->cLeft)
-    {
-        if (phHandle)
-            *phHandle = 0;
-        return NULL;
-    }
-
-    pTbl = pIter->pTbl;
-
-    for (i = pIter->iCur; i < pTbl->cSize; ++i)
-    {
-        if (pTbl->paData[i])
-        {
-            pIter->iCur = i+1;
-            --(pIter->cLeft);
-            if (phHandle)
-                *phHandle = crHTableIndex2Handle(i);
-            return pTbl->paData[i];
-        }
-    }
-
-    crWarning("interator concurent modification!");
-    return NULL;
 }
 
@@ -111,6 +67,4 @@
 VBOXHTABLEDECL(CRHTABLE_HANDLE) CrHTablePut(PCRHTABLE pTbl, void *pvData);
 VBOXHTABLEDECL(int) CrHTablePutToSlot(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle, void* pvData);
-
-/* note: can be called for the element returned with CrHTableIterNext w/o corrupting the iterator */
 VBOXHTABLEDECL(void*) CrHTableRemove(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle);
 VBOXHTABLEDECL(void*) CrHTableGet(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle);
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_hull.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_hull.h	(revision 78189)
+++ 	(revision )
@@ -1,24 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved.
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifndef CR_HULL_H
-#define CR_HULL_H
-
-#include "state/cr_statetypes.h"
-
-#include <iprt/cdefs.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-DECLEXPORT(void) crHullInteriorBox(const double *pnts, int npnts, double *bbox);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CR_BBOX_H */
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_list.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_list.h	(revision 78189)
+++ 	(revision )
@@ -1,48 +1,0 @@
-#ifndef CR_LIST_H
-#define CR_LIST_H
-
-#include <iprt/cdefs.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct CRList CRList;
-typedef struct CRListIterator CRListIterator;
-typedef int ( *CRListCompareFunc ) ( const void *element1, const void *element2 );
-typedef void ( *CRListApplyFunc ) ( void *element, void *arg );
-
-DECLEXPORT(CRList *) crAllocList( void );
-DECLEXPORT(void) crFreeList( CRList *l );
-
-DECLEXPORT(unsigned) crListSize( const CRList *l );
-DECLEXPORT(int) crListIsEmpty( const CRList *l );
-
-DECLEXPORT(void) crListInsert( CRList *l, CRListIterator *iter, void *elem );
-DECLEXPORT(void) crListErase( CRList *l, CRListIterator *iter );
-DECLEXPORT(void) crListClear( CRList *l );
-
-DECLEXPORT(void) crListPushBack( CRList *l, void *elem );
-DECLEXPORT(void) crListPushFront( CRList *l, void *elem );
-
-DECLEXPORT(void) crListPopBack( CRList *l );
-DECLEXPORT(void) crListPopFront( CRList *l );
-
-DECLEXPORT(void *) crListFront( CRList *l );
-DECLEXPORT(void *) crListBack( CRList *l );
-
-DECLEXPORT(CRListIterator *) crListBegin( CRList *l );
-DECLEXPORT(CRListIterator *) crListEnd( CRList *l );
-
-DECLEXPORT(CRListIterator *) crListNext( CRListIterator *iter );
-DECLEXPORT(CRListIterator *) crListPrev( CRListIterator *iter );
-DECLEXPORT(void *) crListElement( CRListIterator *iter );
-
-DECLEXPORT(CRListIterator *) crListFind( CRList *l, void *element, CRListCompareFunc compare );
-DECLEXPORT(void) crListApply( CRList *l, CRListApplyFunc apply, void *arg );
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* CR_LIST_H */
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_logo.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_logo.h	(revision 78189)
+++ 	(revision )
@@ -1,2746 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved.
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifndef CR_LOGO_H
-#define CR_LOGO_H
-
-#define CR_LOGO_H_WIDTH 128
-#define CR_LOGO_H_HEIGHT 64
-
-static unsigned char raw_bytes[] = {
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x03, 0x03, 0x03, 0x00, 0x11, 0x11, 0x11, 0x00, 0x14, 0x14, 0x14, 0x00,
-0x13, 0x13, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x00, 0x2f, 0x2f, 0x2f, 0x00,
-0x1d, 0x1d, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x0e, 0x0e, 0x0e, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x09, 0x09, 0x09, 0x00, 0x0b, 0x0b, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x00, 0x04, 0x04, 0x04, 0x00,
-0x11, 0x11, 0x11, 0x00, 0x14, 0x14, 0x14, 0x00, 0x14, 0x14, 0x14, 0x00,
-0x14, 0x14, 0x14, 0x00, 0x06, 0x06, 0x06, 0x00, 0x09, 0x09, 0x09, 0x00,
-0x13, 0x13, 0x13, 0x00, 0x14, 0x14, 0x14, 0x00, 0x0e, 0x0e, 0x0e, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00,
-0x13, 0x13, 0x13, 0x00, 0x14, 0x14, 0x14, 0x00, 0x14, 0x14, 0x14, 0x00,
-0x0e, 0x0e, 0x0e, 0x00, 0x03, 0x03, 0x03, 0x00, 0x11, 0x11, 0x11, 0x00,
-0x14, 0x14, 0x14, 0x00, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x03, 0x03, 0x03, 0x00, 0x11, 0x11, 0x11, 0x00, 0x14, 0x14, 0x14, 0x00,
-0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x0b, 0x0b, 0x0b, 0x00, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x15, 0x15, 0x00,
-0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x59, 0x59, 0x38,
-0xed, 0xed, 0xed, 0x80, 0xe0, 0xe0, 0xe0, 0x83, 0xe6, 0xe6, 0xe6, 0x82,
-0xa4, 0xa4, 0xa4, 0x58, 0x00, 0x00, 0x00, 0x00, 0x32, 0x32, 0x32, 0x03,
-0xcd, 0xcd, 0xcd, 0x6e, 0xd3, 0xd3, 0xd3, 0xb1, 0xe8, 0xe8, 0xe8, 0x9a,
-0x74, 0x74, 0x74, 0x38, 0x0b, 0x0b, 0x0b, 0x05, 0xdc, 0xdc, 0xdc, 0x78,
-0x29, 0x29, 0x29, 0x2a, 0x08, 0x08, 0x08, 0x00, 0xdc, 0xdc, 0xdc, 0x76,
-0x99, 0x99, 0x99, 0x62, 0x00, 0x00, 0x00, 0x00, 0x85, 0x85, 0x85, 0x3f,
-0xa8, 0xa8, 0xa8, 0x74, 0x57, 0x57, 0x57, 0x45, 0xec, 0xec, 0xec, 0x80,
-0xdf, 0xdf, 0xdf, 0x83, 0xdf, 0xdf, 0xdf, 0x83, 0xd7, 0xd7, 0xd7, 0x83,
-0x2b, 0x2b, 0x2b, 0x39, 0xbd, 0xbd, 0xbd, 0x6b, 0xe5, 0xe5, 0xe5, 0x82,
-0xe0, 0xe0, 0xe0, 0x83, 0xde, 0xde, 0xde, 0x81, 0x5c, 0x5c, 0x5c, 0x2f,
-0x00, 0x00, 0x00, 0x01, 0xc3, 0xc3, 0xc3, 0x70, 0xe4, 0xe4, 0xe4, 0x82,
-0xdf, 0xdf, 0xdf, 0x83, 0xdf, 0xdf, 0xdf, 0x83, 0x7d, 0x7d, 0x7d, 0x61,
-0x51, 0x51, 0x51, 0x40, 0xed, 0xed, 0xed, 0x80, 0xe0, 0xe0, 0xe0, 0x83,
-0xda, 0xda, 0xda, 0x7c, 0x55, 0x55, 0x55, 0x26, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x59, 0x59, 0x38,
-0xed, 0xed, 0xed, 0x80, 0xe0, 0xe0, 0xe0, 0x83, 0xdf, 0xdf, 0xdf, 0x81,
-0x88, 0x88, 0x88, 0x47, 0x01, 0x01, 0x01, 0x00, 0x4b, 0x4b, 0x4b, 0x40,
-0xd5, 0xd5, 0xd5, 0x7a, 0x0e, 0x0e, 0x0e, 0x0c, 0x00, 0x00, 0x00, 0x00,
-0xa4, 0xa4, 0xa4, 0x4b, 0xaf, 0xaf, 0xaf, 0x7e, 0x00, 0x00, 0x00, 0x15,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x9f, 0x9f, 0x9f, 0x8f, 0xa4, 0xa4, 0xa4, 0xff,
-0x09, 0x09, 0x09, 0xfb, 0x2f, 0x2f, 0x2f, 0xff, 0xf9, 0xf9, 0xf9, 0xff,
-0x3e, 0x3e, 0x3e, 0x5b, 0xd8, 0xd8, 0xd8, 0xa4, 0x8d, 0x8d, 0x8d, 0xff,
-0x0d, 0x0d, 0x0d, 0xf2, 0x44, 0x44, 0x44, 0xff, 0xec, 0xec, 0xec, 0xeb,
-0x3a, 0x3a, 0x3a, 0x5d, 0xd6, 0xd6, 0xd6, 0xff, 0x27, 0x27, 0x27, 0x8d,
-0x71, 0x71, 0x71, 0x61, 0xff, 0xff, 0xff, 0xff, 0x9a, 0x9a, 0x9a, 0xeb,
-0x0a, 0x0a, 0x0a, 0x48, 0xe8, 0xe8, 0xe8, 0xda, 0x42, 0x42, 0x42, 0xe2,
-0x93, 0x93, 0x93, 0xc2, 0xa7, 0xa7, 0xa7, 0xff, 0x0b, 0x0b, 0x0b, 0xf9,
-0x0c, 0x0c, 0x0c, 0xf8, 0x0e, 0x0e, 0x0e, 0xf3, 0x24, 0x24, 0x24, 0x98,
-0xeb, 0xeb, 0xeb, 0xfd, 0x28, 0x28, 0x28, 0xff, 0x04, 0x04, 0x04, 0xf9,
-0x92, 0x92, 0x92, 0xff, 0xc3, 0xc3, 0xc3, 0xd0, 0x1f, 0x1f, 0x1f, 0x42,
-0xeb, 0xeb, 0xeb, 0xfc, 0x2f, 0x2f, 0x2f, 0xff, 0x0c, 0x0c, 0x0c, 0xf8,
-0x0c, 0x0c, 0x0c, 0xf8, 0x07, 0x07, 0x07, 0xc1, 0x9e, 0x9e, 0x9e, 0xb9,
-0xac, 0xac, 0xac, 0xff, 0x14, 0x14, 0x14, 0xfd, 0x61, 0x61, 0x61, 0xff,
-0xe7, 0xe7, 0xe7, 0xd9, 0x15, 0x15, 0x15, 0x2b, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x9f, 0x9f, 0x9f, 0x8f, 0xa1, 0xa1, 0xa1, 0xff,
-0x02, 0x02, 0x02, 0xfa, 0x50, 0x50, 0x50, 0xff, 0xfb, 0xfb, 0xfb, 0xf7,
-0x0e, 0x0e, 0x0e, 0x3b, 0x06, 0x06, 0x06, 0x5a, 0xdd, 0xdd, 0xdd, 0xff,
-0x6c, 0x6c, 0x6c, 0x7a, 0x69, 0x69, 0x69, 0x40, 0xea, 0xea, 0xea, 0xf9,
-0x20, 0x20, 0x20, 0xe2, 0x41, 0x41, 0x41, 0x56, 0x44, 0x44, 0x44, 0x0f,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x06,
-0xc6, 0xc6, 0xc6, 0xca, 0xa2, 0xa2, 0xa2, 0xfc, 0x4b, 0x4b, 0x4b, 0xc5,
-0xa1, 0xa1, 0xa1, 0xcd, 0xbf, 0xbf, 0xbf, 0xff, 0x69, 0x69, 0x69, 0xdc,
-0xd1, 0xd1, 0xd1, 0xff, 0x01, 0x01, 0x01, 0xe2, 0x00, 0x00, 0x00, 0xba,
-0x00, 0x00, 0x00, 0xb7, 0xd2, 0xd2, 0xd2, 0xff, 0x59, 0x59, 0x59, 0xc9,
-0xb7, 0xb7, 0xb7, 0xf2, 0x50, 0x50, 0x50, 0xc8, 0xd1, 0xd1, 0xd1, 0xe1,
-0xaf, 0xaf, 0xaf, 0xff, 0xa2, 0xa2, 0xa2, 0xf2, 0x79, 0x79, 0x79, 0xb7,
-0xc2, 0xc2, 0xc2, 0xfd, 0x00, 0x00, 0x00, 0xd5, 0xc1, 0xc1, 0xc1, 0xed,
-0xd7, 0xd7, 0xd7, 0xf9, 0x9c, 0x9c, 0x9c, 0xdb, 0xa5, 0xa5, 0xa5, 0xcd,
-0x5a, 0x5a, 0x5a, 0xb7, 0x4a, 0x4a, 0x4a, 0xaf, 0xf0, 0xf0, 0xf0, 0xfd,
-0x72, 0x72, 0x72, 0xe0, 0x6b, 0x6b, 0x6b, 0xbb, 0xd2, 0xd2, 0xd2, 0xec,
-0x70, 0x70, 0x70, 0xf7, 0x44, 0x44, 0x44, 0xb7, 0xfa, 0xfa, 0xfa, 0xfc,
-0xa8, 0xa8, 0xa8, 0xe9, 0xa1, 0xa1, 0xa1, 0xd1, 0x9c, 0x9c, 0x9c, 0xcb,
-0x20, 0x20, 0x20, 0xa1, 0xc1, 0xc1, 0xc1, 0xe0, 0x6c, 0x6c, 0x6c, 0xf8,
-0x00, 0x00, 0x00, 0xc6, 0x09, 0x09, 0x09, 0xc3, 0xed, 0xed, 0xed, 0xff,
-0x34, 0x34, 0x34, 0x94, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03,
-0xc5, 0xc5, 0xc5, 0xca, 0xcb, 0xcb, 0xcb, 0xfc, 0x8d, 0x8d, 0x8d, 0xca,
-0xc4, 0xc4, 0xc4, 0xdf, 0x8f, 0x8f, 0x8f, 0xff, 0x02, 0x02, 0x02, 0x94,
-0x00, 0x00, 0x00, 0x34, 0x68, 0x68, 0x68, 0xdd, 0xee, 0xee, 0xee, 0xe9,
-0xf2, 0xf2, 0xf2, 0xe3, 0x41, 0x41, 0x41, 0xf9, 0x00, 0x00, 0x00, 0xbe,
-0x85, 0x85, 0x85, 0xdb, 0x67, 0x67, 0x67, 0xa1, 0x00, 0x00, 0x00, 0x0e,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x14, 0xe8, 0xe8, 0xe8, 0xed,
-0xc1, 0xc1, 0xc1, 0xff, 0xb3, 0xb3, 0xb3, 0xef, 0xa8, 0xa8, 0xa8, 0xf8,
-0x20, 0x20, 0x20, 0xf2, 0x8a, 0x8a, 0x8a, 0xf1, 0xab, 0xab, 0xab, 0xfd,
-0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x43, 0x25, 0x25, 0x25, 0x3c,
-0xed, 0xed, 0xed, 0xf8, 0x33, 0x33, 0x33, 0xe3, 0xb9, 0xb9, 0xb9, 0xf4,
-0xc0, 0xc0, 0xc0, 0xed, 0xa4, 0xa4, 0xa4, 0xfb, 0x57, 0x57, 0x57, 0xf5,
-0xcc, 0xcc, 0xcc, 0xf9, 0xe2, 0xe2, 0xe2, 0xf6, 0x46, 0x46, 0x46, 0xf2,
-0x08, 0x08, 0x08, 0xb9, 0xe4, 0xe4, 0xe4, 0xf2, 0x83, 0x83, 0x83, 0xff,
-0x6b, 0x6b, 0x6b, 0xfc, 0x70, 0x70, 0x70, 0xfb, 0x35, 0x35, 0x35, 0xbe,
-0x7d, 0x7d, 0x7d, 0xa7, 0xd5, 0xd5, 0xd5, 0xff, 0x98, 0x98, 0x98, 0xfb,
-0xff, 0xff, 0xff, 0xf5, 0x6f, 0x6f, 0x6f, 0xf6, 0x00, 0x00, 0x00, 0xdc,
-0x83, 0x83, 0x83, 0xd3, 0xd0, 0xd0, 0xd0, 0xff, 0x69, 0x69, 0x69, 0xfe,
-0x6c, 0x6c, 0x6c, 0xfa, 0x65, 0x65, 0x65, 0xf4, 0x21, 0x21, 0x21, 0x8e,
-0xe3, 0xe3, 0xe3, 0xed, 0x37, 0x37, 0x37, 0xeb, 0x00, 0x00, 0x00, 0x67,
-0x3a, 0x3a, 0x3a, 0x55, 0xec, 0xec, 0xec, 0xff, 0x18, 0x18, 0x18, 0xc4,
-0x00, 0x00, 0x00, 0x1f, 0x12, 0x12, 0x12, 0x0f, 0xe5, 0xe5, 0xe5, 0xed,
-0x9b, 0x9b, 0x9b, 0xff, 0x8d, 0x8d, 0x8d, 0xf8, 0xc0, 0xc0, 0xc0, 0xfc,
-0x9e, 0x9e, 0x9e, 0xf5, 0x02, 0x02, 0x02, 0x94, 0x00, 0x00, 0x00, 0x15,
-0x10, 0x10, 0x10, 0x8b, 0xf3, 0xf3, 0xf3, 0xff, 0x80, 0x80, 0x80, 0xff,
-0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x8e,
-0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x3f, 0x3f, 0x3f, 0x3d, 0xe7, 0xe7, 0xe7, 0xfc, 0x10, 0x10, 0x10, 0xf9,
-0x00, 0x00, 0x00, 0xec, 0x00, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, 0xc2,
-0x66, 0x66, 0x66, 0xd8, 0xe2, 0xe2, 0xe2, 0xff, 0x1d, 0x1d, 0x1d, 0x87,
-0x16, 0x16, 0x16, 0x00, 0xc2, 0xc2, 0xc2, 0x73, 0xaa, 0xaa, 0xaa, 0xff,
-0x03, 0x03, 0x03, 0xd5, 0xc4, 0xc4, 0xc4, 0xf5, 0xff, 0xff, 0xff, 0xff,
-0x3a, 0x3a, 0x3a, 0xee, 0x37, 0x37, 0x37, 0xe5, 0xff, 0xff, 0xff, 0xff,
-0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00, 0xd5, 0x3d, 0x3d, 0x3d, 0x9b,
-0xea, 0xea, 0xea, 0xf8, 0x18, 0x18, 0x18, 0xee, 0x06, 0x06, 0x06, 0xca,
-0x05, 0x05, 0x05, 0xbb, 0x03, 0x03, 0x03, 0x9e, 0xbb, 0xbb, 0xbb, 0xd1,
-0x7e, 0x7e, 0x7e, 0xfe, 0x00, 0x00, 0x00, 0xed, 0xa9, 0xa9, 0xa9, 0xff,
-0x94, 0x94, 0x94, 0xed, 0x00, 0x00, 0x00, 0xa2, 0xbb, 0xbb, 0xbb, 0xcc,
-0x8c, 0x8c, 0x8c, 0xfd, 0x06, 0x06, 0x06, 0xdc, 0x05, 0x05, 0x05, 0xbf,
-0x05, 0x05, 0x05, 0xb1, 0x3e, 0x3e, 0x3e, 0xa5, 0xea, 0xea, 0xea, 0xfd,
-0x1f, 0x1f, 0x1f, 0xcb, 0x30, 0x30, 0x30, 0x33, 0xd9, 0xd9, 0xd9, 0x8b,
-0x9a, 0x9a, 0x9a, 0xff, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x1d,
-0x3f, 0x3f, 0x3f, 0x38, 0xea, 0xea, 0xea, 0xfc, 0x15, 0x15, 0x15, 0xf1,
-0x02, 0x02, 0x02, 0xd2, 0x87, 0x87, 0x87, 0xec, 0xd2, 0xd2, 0xd2, 0xff,
-0x04, 0x04, 0x04, 0x7c, 0x00, 0x00, 0x00, 0x01, 0x21, 0x21, 0x21, 0x41,
-0xec, 0xec, 0xec, 0xfc, 0x21, 0x21, 0x21, 0xfa, 0x00, 0x00, 0x00, 0xa0,
-0x0f, 0x0f, 0x0f, 0x1d, 0x26, 0x26, 0x26, 0x26, 0x00, 0x00, 0x00, 0x59,
-0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x6a, 0x6a, 0x7c,
-0xb6, 0xb6, 0xb6, 0xff, 0x00, 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, 0x94,
-0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x4b, 0x0a, 0x0a, 0x0a, 0x84,
-0xac, 0xac, 0xac, 0xff, 0xe0, 0xe0, 0xe0, 0xc7, 0xda, 0xda, 0xda, 0x95,
-0xaf, 0xaf, 0xaf, 0xf8, 0x11, 0x11, 0x11, 0xed, 0x00, 0x00, 0x00, 0xb3,
-0xb1, 0xb1, 0xb1, 0xef, 0xbb, 0xbb, 0xbb, 0xff, 0x00, 0x00, 0x00, 0xdb,
-0x3f, 0x3f, 0x3f, 0xc7, 0xed, 0xed, 0xed, 0xff, 0x47, 0x47, 0x47, 0xff,
-0x00, 0x00, 0x00, 0xa5, 0x60, 0x60, 0x60, 0x9c, 0xec, 0xec, 0xec, 0xff,
-0xe0, 0xe0, 0xe0, 0xed, 0xe0, 0xe0, 0xe0, 0xcb, 0xe0, 0xe0, 0xe0, 0xc0,
-0x5f, 0x5f, 0x5f, 0x90, 0xbd, 0xbd, 0xbd, 0xea, 0x4a, 0x4a, 0x4a, 0xf4,
-0x00, 0x00, 0x00, 0xa4, 0x3a, 0x3a, 0x3a, 0xd1, 0xdc, 0xdc, 0xdc, 0xff,
-0x26, 0x26, 0x26, 0x81, 0xc3, 0xc3, 0xc3, 0xe6, 0xe5, 0xe5, 0xe5, 0xfd,
-0xe0, 0xe0, 0xe0, 0xdb, 0xe0, 0xe0, 0xe0, 0xc2, 0xac, 0xac, 0xac, 0xad,
-0x66, 0x66, 0x66, 0xa8, 0xec, 0xec, 0xec, 0xff, 0xdf, 0xdf, 0xdf, 0xdc,
-0xde, 0xde, 0xde, 0xc3, 0x9a, 0x9a, 0x9a, 0xfe, 0x0f, 0x0f, 0x0f, 0xf0,
-0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x05, 0x60, 0x60, 0x60, 0x78,
-0xec, 0xec, 0xec, 0xff, 0xe0, 0xe0, 0xe0, 0xef, 0xe0, 0xe0, 0xe0, 0xd5,
-0xc9, 0xc9, 0xc9, 0xf5, 0x40, 0x40, 0x40, 0xfb, 0x00, 0x00, 0x00, 0x8b,
-0x00, 0x00, 0x00, 0x00, 0x4e, 0x4e, 0x4e, 0x5f, 0xc9, 0xc9, 0xc9, 0xff,
-0x07, 0x07, 0x07, 0xd7, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x53,
-0xae, 0xae, 0xae, 0xad, 0x01, 0x01, 0x01, 0x1d, 0x00, 0x00, 0x00, 0x01,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x06, 0x05, 0x05, 0x69, 0x05, 0x05, 0x05, 0xe4,
-0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x04,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0xc4,
-0x27, 0x27, 0x27, 0xff, 0x25, 0x24, 0x24, 0xff, 0x00, 0x00, 0x00, 0xe7,
-0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x5e, 0x08, 0x08, 0x08, 0xb3,
-0x02, 0x02, 0x02, 0xf9, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, 0x78,
-0x0a, 0x0a, 0x0a, 0xe6, 0x00, 0x00, 0x00, 0xed, 0x00, 0x00, 0x00, 0x61,
-0x04, 0x04, 0x04, 0x6a, 0x0c, 0x0c, 0x0c, 0xec, 0x0f, 0x0f, 0x0f, 0xfd,
-0x0f, 0x0f, 0x0f, 0xf5, 0x0f, 0x0f, 0x0f, 0xf3, 0x02, 0x02, 0x02, 0xb8,
-0x0a, 0x0a, 0x0a, 0xd3, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x4b,
-0x00, 0x00, 0x00, 0x62, 0x0c, 0x0c, 0x0c, 0xe5, 0x03, 0x03, 0x03, 0xab,
-0x0a, 0x0a, 0x0a, 0xca, 0x0d, 0x0d, 0x0d, 0xfa, 0x0f, 0x0f, 0x0f, 0xf8,
-0x0f, 0x0f, 0x0f, 0xf5, 0x08, 0x08, 0x08, 0xdd, 0x04, 0x04, 0x04, 0xb0,
-0x0c, 0x0c, 0x0c, 0xec, 0x10, 0x10, 0x0f, 0xfd, 0x0c, 0x0c, 0x0b, 0xf7,
-0x00, 0x00, 0x00, 0xe7, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x47,
-0x00, 0x00, 0x00, 0x00, 0x05, 0x04, 0x04, 0x65, 0x0c, 0x0c, 0x0c, 0xeb,
-0x10, 0x0f, 0x0f, 0xfb, 0x10, 0x10, 0x10, 0xf2, 0x01, 0x01, 0x01, 0xee,
-0x00, 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00,
-0x03, 0x03, 0x03, 0x56, 0x06, 0x06, 0x06, 0xe0, 0x00, 0x00, 0x00, 0xac,
-0x00, 0x00, 0x00, 0x11, 0x06, 0x06, 0x06, 0x61, 0x09, 0x09, 0x08, 0xd2,
-0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x10, 0x0f, 0x10, 0x00, 0x10, 0x10, 0x0f, 0x00,
-0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00,
-0x0e, 0x0e, 0x0e, 0x21, 0x0e, 0x0d, 0x0d, 0x73, 0x11, 0x10, 0x10, 0x4a,
-0x11, 0x10, 0x10, 0x00, 0x11, 0x10, 0x10, 0x00, 0x12, 0x11, 0x10, 0x00,
-0x12, 0x11, 0x10, 0x03, 0x10, 0x0f, 0x0e, 0x49, 0x0b, 0x09, 0x08, 0x9d,
-0x0b, 0x09, 0x09, 0xb0, 0x10, 0x0f, 0x0e, 0x97, 0x12, 0x11, 0x10, 0x4d,
-0x12, 0x10, 0x10, 0x0b, 0x0e, 0x0d, 0x0d, 0x45, 0x0e, 0x0e, 0x0d, 0x8f,
-0x11, 0x10, 0x10, 0x4b, 0x10, 0x0f, 0x0f, 0x1a, 0x0c, 0x0c, 0x0c, 0x76,
-0x10, 0x0f, 0x0f, 0x7c, 0x10, 0x10, 0x10, 0x1a, 0x0e, 0x0e, 0x0e, 0x1f,
-0x0b, 0x0b, 0x0b, 0x8b, 0x0b, 0x0b, 0x0b, 0xb1, 0x0b, 0x0b, 0x0b, 0xaa,
-0x0b, 0x0b, 0x0b, 0xa7, 0x0e, 0x0e, 0x0e, 0x87, 0x0c, 0x0c, 0x0c, 0x76,
-0x0e, 0x0e, 0x0e, 0x75, 0x0f, 0x0f, 0x0f, 0x1e, 0x0f, 0x0f, 0x0f, 0x18,
-0x0b, 0x0b, 0x0b, 0x74, 0x0e, 0x0e, 0x0e, 0x73, 0x0c, 0x0c, 0x0c, 0x6a,
-0x0b, 0x0b, 0x0b, 0xa9, 0x0b, 0x0b, 0x0b, 0xad, 0x0b, 0x0b, 0x0b, 0xa9,
-0x0c, 0x0c, 0x0c, 0x99, 0x0e, 0x0e, 0x0e, 0x70, 0x0c, 0x0c, 0x0b, 0x8b,
-0x0d, 0x0c, 0x0b, 0xaa, 0x0d, 0x0c, 0x0c, 0xa2, 0x10, 0x0f, 0x0f, 0x8a,
-0x12, 0x11, 0x10, 0x45, 0x12, 0x11, 0x10, 0x05, 0x11, 0x10, 0x10, 0x00,
-0x10, 0x0f, 0x0e, 0x22, 0x0d, 0x0c, 0x0c, 0x87, 0x0d, 0x0c, 0x0c, 0xab,
-0x0d, 0x0c, 0x0b, 0xa3, 0x0e, 0x0d, 0x0d, 0x9a, 0x11, 0x10, 0x10, 0x69,
-0x11, 0x10, 0x10, 0x17, 0x11, 0x10, 0x10, 0x00, 0x0f, 0x0f, 0x0e, 0x17,
-0x0d, 0x0d, 0x0c, 0x6d, 0x11, 0x10, 0x10, 0x54, 0x11, 0x10, 0x10, 0x00,
-0x0e, 0x0e, 0x0e, 0x1b, 0x0d, 0x0d, 0x0d, 0x68, 0x11, 0x10, 0x10, 0x44,
-0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00,
-0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00,
-0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x0f, 0x00,
-0x10, 0x10, 0x0f, 0x00, 0x10, 0x10, 0x0f, 0x00, 0x10, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf1, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x0b, 0xf0, 0xef, 0xf0, 0x1c,
-0xef, 0xef, 0xef, 0x31, 0xee, 0xec, 0xef, 0x47, 0xed, 0xeb, 0xed, 0x61,
-0xea, 0xe8, 0xec, 0x7b, 0xe5, 0xe5, 0xeb, 0x87, 0xe1, 0xe2, 0xe9, 0x8e,
-0xdb, 0xdf, 0xe7, 0x98, 0xd6, 0xdd, 0xe6, 0xa0, 0xd0, 0xdb, 0xe5, 0xa4,
-0xcc, 0xd9, 0xe4, 0xaa, 0xca, 0xd7, 0xe3, 0xb9, 0xca, 0xd6, 0xe3, 0xc2,
-0xcc, 0xd9, 0xe4, 0xb7, 0xcf, 0xda, 0xe5, 0xa7, 0xd5, 0xdb, 0xe6, 0xa0,
-0xd9, 0xde, 0xe6, 0xa1, 0xdf, 0xe1, 0xe7, 0x9b, 0xe4, 0xe5, 0xea, 0x85,
-0xe9, 0xe8, 0xec, 0x71, 0xec, 0xeb, 0xed, 0x67, 0xed, 0xed, 0xee, 0x4f,
-0xef, 0xee, 0xef, 0x2b, 0xf0, 0xf0, 0xf0, 0x1a, 0xf0, 0xf0, 0xf0, 0x18,
-0xf1, 0xf0, 0xf0, 0x17, 0xf0, 0xf0, 0xf0, 0x16, 0xf0, 0xf0, 0xf0, 0x17,
-0xf0, 0xf0, 0xf0, 0x12, 0xf0, 0xf0, 0xf0, 0x0f, 0xf0, 0xf0, 0xf0, 0x0c,
-0xf0, 0xf0, 0xf0, 0x02, 0xf0, 0xf0, 0xf0, 0x01, 0xf0, 0xf0, 0xf0, 0x0c,
-0xf0, 0xf0, 0xf0, 0x0f, 0xf0, 0xf0, 0xf0, 0x0f, 0xf0, 0xf0, 0xf0, 0x18,
-0xf0, 0xf0, 0xf0, 0x1b, 0xf0, 0xf0, 0xf0, 0x1c, 0xef, 0xef, 0xf0, 0x23,
-0xe9, 0xeb, 0xee, 0x5a, 0xe1, 0xe5, 0xea, 0x9b, 0xd7, 0xdd, 0xe6, 0xb2,
-0xd5, 0xdc, 0xe6, 0xb2, 0xd5, 0xdc, 0xe6, 0xa9, 0xd6, 0xdd, 0xe6, 0x9f,
-0xd7, 0xde, 0xe7, 0x9c, 0xd8, 0xde, 0xe7, 0x9c, 0xda, 0xdf, 0xe7, 0x9f,
-0xdb, 0xe0, 0xe8, 0xa4, 0xdc, 0xe0, 0xe8, 0xa7, 0xde, 0xe2, 0xe9, 0xa6,
-0xe1, 0xe3, 0xe9, 0x9e, 0xe2, 0xe4, 0xea, 0x8f, 0xe3, 0xe4, 0xea, 0x84,
-0xe5, 0xe5, 0xea, 0x81, 0xe6, 0xe6, 0xea, 0x7f, 0xe8, 0xe8, 0xec, 0x7f,
-0xe9, 0xe9, 0xec, 0x76, 0xea, 0xe9, 0xed, 0x69, 0xec, 0xea, 0xed, 0x67,
-0xeb, 0xea, 0xed, 0x68, 0xed, 0xeb, 0xee, 0x5a, 0xee, 0xec, 0xef, 0x4a,
-0xee, 0xee, 0xef, 0x41, 0xef, 0xee, 0xef, 0x39, 0xef, 0xee, 0xef, 0x30,
-0xef, 0xef, 0xf0, 0x27, 0xf0, 0xef, 0xf0, 0x1f, 0xf0, 0xef, 0xf0, 0x17,
-0xf0, 0xf0, 0xf0, 0x0f, 0xf1, 0xf0, 0xf0, 0x09, 0xf0, 0xf0, 0xf0, 0x04,
-0xf1, 0xf0, 0xf0, 0x00, 0xf1, 0xf1, 0xf0, 0x00, 0xf1, 0xf0, 0xf0, 0x00,
-0xf1, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00,
-0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c,
-0xff, 0xff, 0xff, 0x29, 0xff, 0xff, 0xff, 0x4c, 0xfd, 0xfd, 0xff, 0x75,
-0xf4, 0xf7, 0xfd, 0x9c, 0xe5, 0xee, 0xf9, 0xbd, 0xd0, 0xe7, 0xf5, 0xd6,
-0xb7, 0xdc, 0xef, 0xe8, 0x9d, 0xd4, 0xeb, 0xf4, 0x85, 0xcf, 0xe9, 0xfa,
-0x74, 0xcb, 0xe7, 0xff, 0x5e, 0xc6, 0xe5, 0xff, 0x53, 0xc3, 0xe2, 0xff,
-0x4e, 0xc6, 0xe6, 0xff, 0x46, 0xc0, 0xde, 0xff, 0x3c, 0xbf, 0xde, 0xff,
-0x39, 0xc2, 0xe1, 0xff, 0x38, 0xba, 0xd8, 0xff, 0x3a, 0xb8, 0xd6, 0xff,
-0x40, 0xbe, 0xdd, 0xff, 0x4c, 0xc4, 0xe3, 0xff, 0x4f, 0xc5, 0xe6, 0xff,
-0x59, 0xc4, 0xe4, 0xff, 0x72, 0xca, 0xe6, 0xff, 0x85, 0xce, 0xe7, 0xfc,
-0xa0, 0xd5, 0xeb, 0xf1, 0xbb, 0xdd, 0xef, 0xe2, 0xd6, 0xe6, 0xf3, 0xcf,
-0xeb, 0xf1, 0xf9, 0xb0, 0xf8, 0xf9, 0xfe, 0x86, 0xff, 0xfe, 0xff, 0x59,
-0xff, 0xff, 0xff, 0x2f, 0xff, 0xff, 0xff, 0x0d, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x2b, 0xd3, 0xe5, 0xf2, 0xc1,
-0x54, 0xb1, 0xd4, 0xff, 0x49, 0xc2, 0xe3, 0xff, 0x50, 0xc4, 0xe2, 0xff,
-0x50, 0xc1, 0xde, 0xff, 0x4d, 0xc2, 0xdf, 0xff, 0x4f, 0xc0, 0xde, 0xff,
-0x53, 0xc3, 0xe0, 0xff, 0x54, 0xc3, 0xe1, 0xff, 0x55, 0xc3, 0xe1, 0xff,
-0x58, 0xc5, 0xe4, 0xff, 0x5c, 0xc4, 0xe0, 0xff, 0x61, 0xc6, 0xe3, 0xff,
-0x62, 0xc5, 0xe1, 0xff, 0x69, 0xc8, 0xe3, 0xff, 0x74, 0xca, 0xe7, 0xff,
-0x7a, 0xcb, 0xe6, 0xff, 0x81, 0xcc, 0xe6, 0xfc, 0x85, 0xcf, 0xe8, 0xfb,
-0x8c, 0xd0, 0xe9, 0xfa, 0x92, 0xd1, 0xe8, 0xf6, 0xa1, 0xd4, 0xea, 0xf1,
-0xa9, 0xd8, 0xed, 0xed, 0xb1, 0xdb, 0xef, 0xea, 0xba, 0xde, 0xf0, 0xe5,
-0xc5, 0xe2, 0xf2, 0xde, 0xd0, 0xe5, 0xf4, 0xd5, 0xd7, 0xe7, 0xf3, 0xcd,
-0xde, 0xeb, 0xf5, 0xc2, 0xe7, 0xf0, 0xf9, 0xb7, 0xee, 0xf4, 0xfc, 0xa9,
-0xf3, 0xf6, 0xfd, 0x9a, 0xf7, 0xf8, 0xfd, 0x8a, 0xfc, 0xfb, 0xff, 0x7a,
-0xff, 0xfe, 0xff, 0x68, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0x46,
-0xff, 0xff, 0xff, 0x34, 0xff, 0xff, 0xff, 0x24, 0xff, 0xff, 0xff, 0x18,
-0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0f, 0xfd, 0xfd, 0xff, 0x35,
-0xfb, 0xfa, 0xfd, 0x67, 0xf0, 0xf2, 0xf8, 0x9e, 0xd7, 0xe6, 0xf2, 0xcb,
-0xb2, 0xd8, 0xeb, 0xe9, 0x87, 0xcb, 0xe3, 0xfa, 0x60, 0xc4, 0xe0, 0xff,
-0x45, 0xc3, 0xe2, 0xff, 0x30, 0xbc, 0xda, 0xff, 0x25, 0xbe, 0xdd, 0xff,
-0x20, 0xc4, 0xe5, 0xff, 0x15, 0xbe, 0xdc, 0xff, 0x11, 0xba, 0xd7, 0xff,
-0x10, 0xbf, 0xdf, 0xff, 0x09, 0xb9, 0xd8, 0xff, 0x0f, 0xba, 0xd7, 0xff,
-0x11, 0xb8, 0xd7, 0xff, 0x11, 0xb9, 0xd9, 0xff, 0x0d, 0xb8, 0xd8, 0xff,
-0x10, 0xb6, 0xd4, 0xff, 0x11, 0xb6, 0xd4, 0xff, 0x0e, 0xb5, 0xd3, 0xff,
-0x09, 0xb5, 0xd4, 0xff, 0x01, 0xb5, 0xd7, 0xff, 0x03, 0xb8, 0xda, 0xff,
-0x09, 0xb4, 0xd3, 0xff, 0x09, 0xb8, 0xd9, 0xff, 0x09, 0xb3, 0xd5, 0xff,
-0x13, 0xb4, 0xd6, 0xff, 0x26, 0xb4, 0xd6, 0xff, 0x45, 0xb8, 0xd8, 0xff,
-0x6e, 0xc0, 0xdb, 0xff, 0x9e, 0xce, 0xe4, 0xf3, 0xca, 0xdd, 0xec, 0xd7,
-0xe9, 0xee, 0xf6, 0xa9, 0xf8, 0xf8, 0xfc, 0x6d, 0xfd, 0xfd, 0xfe, 0x34,
-0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfc, 0xfe, 0x4a, 0xab, 0xd3, 0xe6, 0xea, 0x00, 0xaf, 0xd8, 0xff,
-0x0a, 0xbe, 0xdd, 0xff, 0x10, 0xb6, 0xd3, 0xff, 0x14, 0xba, 0xd7, 0xff,
-0x13, 0xbe, 0xde, 0xff, 0x12, 0xb7, 0xd5, 0xff, 0x14, 0xba, 0xd8, 0xff,
-0x10, 0xb6, 0xd6, 0xff, 0x0d, 0xb6, 0xd5, 0xff, 0x0f, 0xb7, 0xd5, 0xff,
-0x0e, 0xb9, 0xd7, 0xff, 0x0b, 0xb6, 0xd5, 0xff, 0x09, 0xb7, 0xd4, 0xff,
-0x0e, 0xbb, 0xdb, 0xff, 0x09, 0xb7, 0xd7, 0xff, 0x09, 0xb8, 0xd7, 0xff,
-0x11, 0xb9, 0xd6, 0xff, 0x12, 0xb6, 0xd3, 0xff, 0x18, 0xbb, 0xd9, 0xff,
-0x14, 0xbc, 0xdc, 0xff, 0x1b, 0xc3, 0xe7, 0xff, 0x15, 0xb9, 0xd8, 0xff,
-0x17, 0xba, 0xdc, 0xff, 0x1a, 0xb6, 0xd7, 0xff, 0x20, 0xb9, 0xdb, 0xff,
-0x26, 0xba, 0xdc, 0xff, 0x29, 0xb2, 0xd2, 0xff, 0x39, 0xbf, 0xe0, 0xff,
-0x4e, 0xc2, 0xe0, 0xff, 0x54, 0xbe, 0xda, 0xff, 0x5d, 0xc3, 0xdf, 0xff,
-0x72, 0xc7, 0xe3, 0xff, 0x7f, 0xc8, 0xe2, 0xfc, 0x8e, 0xcb, 0xe3, 0xf7,
-0xa4, 0xd3, 0xe7, 0xf0, 0xb3, 0xd8, 0xea, 0xe6, 0xc5, 0xdf, 0xee, 0xda,
-0xd4, 0xe5, 0xf1, 0xca, 0xe1, 0xeb, 0xf4, 0xb7, 0xec, 0xf0, 0xf7, 0xa0,
-0xf4, 0xf4, 0xf9, 0x87, 0xfa, 0xf9, 0xfb, 0x6d, 0xfd, 0xfc, 0xfd, 0x52,
-0xfe, 0xfd, 0xfe, 0x38, 0xff, 0xfe, 0xff, 0x22, 0xff, 0xff, 0xff, 0x10,
-0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x04, 0xfd, 0xfe, 0xff, 0x27, 0xfb, 0xfb, 0xfd, 0x61,
-0xef, 0xf2, 0xf8, 0xa2, 0xcd, 0xe3, 0xf1, 0xd6, 0x99, 0xd1, 0xe7, 0xf5,
-0x62, 0xc4, 0xe1, 0xff, 0x3c, 0xc2, 0xe2, 0xff, 0x31, 0xc6, 0xe4, 0xff,
-0x2d, 0xc8, 0xe6, 0xff, 0x30, 0xd0, 0xef, 0xff, 0x2d, 0xcc, 0xee, 0xff,
-0x25, 0xc1, 0xe1, 0xff, 0x1d, 0xb6, 0xd5, 0xff, 0x16, 0xb3, 0xd4, 0xff,
-0x09, 0xa6, 0xc8, 0xff, 0x03, 0x9e, 0xc1, 0xff, 0x01, 0x9d, 0xc5, 0xff,
-0x00, 0x97, 0xbd, 0xff, 0x00, 0x90, 0xb4, 0xff, 0x00, 0x91, 0xb8, 0xff,
-0x00, 0x8d, 0xb2, 0xff, 0x00, 0x93, 0xba, 0xff, 0x00, 0x8e, 0xb3, 0xff,
-0x00, 0x90, 0xb5, 0xff, 0x00, 0x8d, 0xb1, 0xff, 0x00, 0x8c, 0xaf, 0xff,
-0x00, 0x90, 0xb6, 0xff, 0x01, 0x93, 0xb8, 0xff, 0x01, 0x9a, 0xbf, 0xff,
-0x02, 0xa3, 0xca, 0xff, 0x02, 0xa2, 0xc6, 0xff, 0x03, 0xaa, 0xce, 0xff,
-0x02, 0xaf, 0xd4, 0xff, 0x02, 0xb5, 0xdc, 0xff, 0x00, 0xba, 0xe2, 0xff,
-0x0a, 0xbb, 0xe5, 0xff, 0x25, 0xba, 0xe1, 0xff, 0x55, 0xbb, 0xdb, 0xff,
-0x92, 0xc9, 0xe0, 0xf7, 0xcd, 0xe0, 0xed, 0xd5, 0xef, 0xf1, 0xf6, 0x99,
-0xfb, 0xfb, 0xfc, 0x4f, 0xff, 0xff, 0xff, 0x16, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xfa, 0xfc, 0x51,
-0xa5, 0xd0, 0xe4, 0xed, 0x04, 0xaf, 0xd6, 0xff, 0x01, 0xa7, 0xd1, 0xff,
-0x00, 0x95, 0xbb, 0xff, 0x00, 0x95, 0xb9, 0xff, 0x01, 0x9a, 0xc1, 0xff,
-0x00, 0x96, 0xbb, 0xff, 0x01, 0x90, 0xb0, 0xff, 0x01, 0x90, 0xb1, 0xff,
-0x02, 0x8e, 0xaf, 0xff, 0x00, 0x93, 0xb6, 0xff, 0x00, 0x97, 0xbc, 0xff,
-0x01, 0x9a, 0xc1, 0xff, 0x02, 0x99, 0xbe, 0xff, 0x02, 0x99, 0xbc, 0xff,
-0x02, 0x9f, 0xc4, 0xff, 0x03, 0xa4, 0xcd, 0xff, 0x05, 0xa7, 0xcf, 0xff,
-0x06, 0xa3, 0xc6, 0xff, 0x0a, 0xa1, 0xc0, 0xff, 0x0a, 0x9f, 0xbe, 0xff,
-0x0c, 0xab, 0xd0, 0xff, 0x07, 0xa7, 0xc9, 0xff, 0x09, 0xb0, 0xd6, 0xff,
-0x0c, 0xa8, 0xc9, 0xff, 0x0a, 0xae, 0xd2, 0xff, 0x04, 0xb3, 0xd9, 0xff,
-0x05, 0xb1, 0xd2, 0xff, 0x15, 0xb8, 0xd7, 0xff, 0x20, 0xbb, 0xd8, 0xff,
-0x1b, 0xb5, 0xd0, 0xff, 0x17, 0xb9, 0xd7, 0xff, 0x1c, 0xbb, 0xd9, 0xff,
-0x20, 0xbc, 0xda, 0xff, 0x24, 0xc3, 0xe6, 0xff, 0x26, 0xc3, 0xe6, 0xff,
-0x28, 0xbf, 0xe3, 0xff, 0x39, 0xc3, 0xe3, 0xff, 0x43, 0xc2, 0xe2, 0xff,
-0x52, 0xc1, 0xdf, 0xff, 0x5e, 0xc3, 0xe0, 0xff, 0x73, 0xc6, 0xe1, 0xff,
-0x8a, 0xcc, 0xe3, 0xf8, 0xa7, 0xd4, 0xe8, 0xed, 0xc1, 0xdd, 0xec, 0xdd,
-0xd7, 0xe6, 0xf1, 0xc6, 0xe8, 0xee, 0xf6, 0xa9, 0xf4, 0xf5, 0xf9, 0x86,
-0xfa, 0xfa, 0xfc, 0x61, 0xfd, 0xfd, 0xfe, 0x3e, 0xfe, 0xff, 0xff, 0x1e,
-0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x07, 0xfc, 0xfd, 0xff, 0x35, 0xf6, 0xf7, 0xfb, 0x7e,
-0xdc, 0xe9, 0xf4, 0xc5, 0xa6, 0xd4, 0xe9, 0xf2, 0x6b, 0xc7, 0xe2, 0xff,
-0x4c, 0xc8, 0xe3, 0xff, 0x43, 0xcd, 0xe6, 0xff, 0x42, 0xd1, 0xed, 0xff,
-0x45, 0xd2, 0xf1, 0xff, 0x42, 0xcc, 0xf1, 0xff, 0x2e, 0xc0, 0xe8, 0xff,
-0x17, 0xae, 0xd5, 0xff, 0x05, 0x9e, 0xc6, 0xff, 0x00, 0x8f, 0xb2, 0xff,
-0x00, 0x86, 0xa7, 0xff, 0x00, 0x81, 0xa0, 0xff, 0x00, 0x81, 0xa1, 0xff,
-0x00, 0x77, 0x99, 0xff, 0x00, 0x77, 0x9a, 0xff, 0x00, 0x74, 0x99, 0xff,
-0x00, 0x73, 0x9c, 0xff, 0x00, 0x67, 0x92, 0xff, 0x00, 0x65, 0x90, 0xff,
-0x00, 0x65, 0x92, 0xff, 0x00, 0x61, 0x8b, 0xff, 0x00, 0x68, 0x93, 0xff,
-0x00, 0x6f, 0x9b, 0xff, 0x00, 0x6b, 0x96, 0xff, 0x00, 0x6f, 0x99, 0xff,
-0x00, 0x77, 0x9f, 0xff, 0x00, 0x74, 0x99, 0xff, 0x00, 0x77, 0x9c, 0xff,
-0x00, 0x81, 0xa6, 0xff, 0x00, 0x85, 0xa8, 0xff, 0x00, 0x82, 0xa4, 0xff,
-0x00, 0x8c, 0xae, 0xff, 0x02, 0x9e, 0xc8, 0xff, 0x04, 0xaa, 0xd4, 0xff,
-0x10, 0xb9, 0xe2, 0xff, 0x18, 0xb8, 0xdb, 0xff, 0x15, 0xb0, 0xd3, 0xff,
-0x2a, 0xb1, 0xd4, 0xff, 0x68, 0xbf, 0xdc, 0xff, 0xb4, 0xd5, 0xe6, 0xe8,
-0xe9, 0xed, 0xf4, 0xaa, 0xfa, 0xfb, 0xfd, 0x55, 0xfe, 0xfe, 0xff, 0x14,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfb, 0xfa, 0xfc, 0x50, 0xa3, 0xcd, 0xe1, 0xec,
-0x06, 0xa7, 0xce, 0xff, 0x00, 0xa3, 0xd0, 0xff, 0x00, 0x92, 0xbb, 0xff,
-0x00, 0x85, 0xa9, 0xff, 0x00, 0x85, 0xa8, 0xff, 0x00, 0x84, 0xa6, 0xff,
-0x01, 0x7e, 0x9f, 0xff, 0x00, 0x79, 0x95, 0xff, 0x00, 0x78, 0x98, 0xff,
-0x01, 0x7c, 0xa1, 0xff, 0x01, 0x71, 0x93, 0xff, 0x01, 0x76, 0x9b, 0xff,
-0x00, 0x77, 0x9e, 0xff, 0x00, 0x70, 0x90, 0xff, 0x00, 0x77, 0x9a, 0xff,
-0x00, 0x79, 0x9e, 0xff, 0x00, 0x7b, 0x9e, 0xff, 0x00, 0x79, 0x99, 0xff,
-0x00, 0x7d, 0xa0, 0xff, 0x00, 0x7e, 0x9e, 0xff, 0x00, 0x7e, 0x9f, 0xff,
-0x00, 0x85, 0xa8, 0xff, 0x00, 0x85, 0xa9, 0xff, 0x00, 0x81, 0xa3, 0xff,
-0x00, 0x87, 0xab, 0xff, 0x00, 0x8d, 0xb3, 0xff, 0x00, 0x8a, 0xad, 0xff,
-0x00, 0x94, 0xbb, 0xff, 0x00, 0x8e, 0xac, 0xff, 0x02, 0x92, 0xb1, 0xff,
-0x03, 0x98, 0xba, 0xff, 0x06, 0x9b, 0xbb, 0xff, 0x0d, 0x9f, 0xbd, 0xff,
-0x14, 0xab, 0xce, 0xff, 0x13, 0xa9, 0xc9, 0xff, 0x18, 0xaf, 0xcf, 0xff,
-0x27, 0xba, 0xdd, 0xff, 0x31, 0xc0, 0xe3, 0xff, 0x2c, 0xb6, 0xd3, 0xff,
-0x2e, 0xc0, 0xde, 0xff, 0x30, 0xc9, 0xeb, 0xff, 0x30, 0xc5, 0xe9, 0xff,
-0x2d, 0xc1, 0xe4, 0xff, 0x32, 0xbe, 0xde, 0xff, 0x43, 0xbd, 0xdc, 0xff,
-0x5a, 0xc3, 0xe0, 0xff, 0x76, 0xc5, 0xe0, 0xff, 0x9a, 0xcf, 0xe4, 0xf4,
-0xbd, 0xdb, 0xea, 0xdf, 0xdb, 0xe7, 0xf1, 0xc0, 0xef, 0xf3, 0xf8, 0x93,
-0xfa, 0xfa, 0xfc, 0x5f, 0xfd, 0xfe, 0xff, 0x30, 0xff, 0xff, 0xff, 0x0e,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x05, 0xfc, 0xfe, 0xff, 0x34, 0xf4, 0xf7, 0xfb, 0x86,
-0xd4, 0xe6, 0xf2, 0xd3, 0x96, 0xcf, 0xe6, 0xfb, 0x5e, 0xc6, 0xe0, 0xff,
-0x4a, 0xcb, 0xe4, 0xff, 0x59, 0xd5, 0xec, 0xff, 0x67, 0xd7, 0xf0, 0xff,
-0x62, 0xcc, 0xec, 0xff, 0x47, 0xbc, 0xe1, 0xff, 0x2c, 0xb0, 0xda, 0xff,
-0x0f, 0xa0, 0xc9, 0xff, 0x00, 0x89, 0xa9, 0xff, 0x00, 0x81, 0x9e, 0xff,
-0x00, 0x81, 0x9f, 0xff, 0x01, 0x78, 0x97, 0xff, 0x00, 0x71, 0x97, 0xff,
-0x00, 0x5b, 0x84, 0xff, 0x00, 0x54, 0x85, 0xff, 0x00, 0x41, 0x7a, 0xff,
-0x00, 0x2f, 0x6e, 0xff, 0x00, 0x2e, 0x6c, 0xff, 0x00, 0x32, 0x70, 0xff,
-0x00, 0x2c, 0x69, 0xff, 0x00, 0x27, 0x63, 0xff, 0x00, 0x25, 0x63, 0xff,
-0x00, 0x2b, 0x68, 0xff, 0x00, 0x2f, 0x68, 0xff, 0x00, 0x2d, 0x6a, 0xff,
-0x00, 0x31, 0x70, 0xff, 0x00, 0x2e, 0x6e, 0xff, 0x00, 0x39, 0x77, 0xff,
-0x00, 0x3b, 0x76, 0xff, 0x00, 0x40, 0x78, 0xff, 0x00, 0x4c, 0x83, 0xff,
-0x00, 0x4c, 0x80, 0xff, 0x00, 0x5a, 0x88, 0xff, 0x00, 0x6a, 0x97, 0xff,
-0x00, 0x6e, 0x93, 0xff, 0x00, 0x75, 0x96, 0xff, 0x00, 0x84, 0xa5, 0xff,
-0x04, 0x90, 0xb1, 0xff, 0x07, 0x9d, 0xbc, 0xff, 0x08, 0xa9, 0xcb, 0xff,
-0x10, 0xb6, 0xde, 0xff, 0x29, 0xb8, 0xe0, 0xff, 0x65, 0xbe, 0xdb, 0xff,
-0xb5, 0xd5, 0xe4, 0xe8, 0xec, 0xef, 0xf5, 0xa0, 0xfb, 0xfb, 0xfd, 0x41,
-0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfb, 0xfa, 0xfc, 0x50, 0xa3, 0xce, 0xe2, 0xec, 0x20, 0xb6, 0xe1, 0xff,
-0x11, 0xab, 0xd8, 0xff, 0x00, 0x97, 0xbe, 0xff, 0x01, 0x93, 0xba, 0xff,
-0x02, 0x95, 0xbb, 0xff, 0x01, 0x90, 0xb5, 0xff, 0x00, 0x8a, 0xad, 0xff,
-0x00, 0x84, 0xa6, 0xff, 0x00, 0x8c, 0xb4, 0xff, 0x00, 0x61, 0x94, 0xff,
-0x00, 0x34, 0x70, 0xff, 0x00, 0x33, 0x6f, 0xff, 0x00, 0x31, 0x6d, 0xff,
-0x00, 0x2b, 0x6a, 0xff, 0x00, 0x31, 0x6c, 0xff, 0x00, 0x3b, 0x74, 0xff,
-0x00, 0x42, 0x79, 0xff, 0x00, 0x3c, 0x71, 0xff, 0x00, 0x41, 0x78, 0xff,
-0x00, 0x46, 0x7d, 0xff, 0x00, 0x4a, 0x7d, 0xff, 0x00, 0x4a, 0x7e, 0xff,
-0x00, 0x4a, 0x7d, 0xff, 0x00, 0x57, 0x86, 0xff, 0x00, 0x58, 0x89, 0xff,
-0x00, 0x56, 0x84, 0xff, 0x00, 0x6c, 0x9a, 0xff, 0x00, 0x75, 0xa0, 0xff,
-0x00, 0x68, 0x8c, 0xff, 0x00, 0x6b, 0x91, 0xff, 0x00, 0x70, 0x95, 0xff,
-0x00, 0x77, 0x9b, 0xff, 0x00, 0x7a, 0x9e, 0xff, 0x00, 0x84, 0xa8, 0xff,
-0x00, 0x82, 0xa1, 0xff, 0x00, 0x85, 0xa4, 0xff, 0x00, 0x85, 0xa3, 0xff,
-0x01, 0x8a, 0xa7, 0xff, 0x02, 0x90, 0xae, 0xff, 0x06, 0x94, 0xb2, 0xff,
-0x13, 0xa1, 0xc2, 0xff, 0x1e, 0xa9, 0xcc, 0xff, 0x24, 0xb6, 0xdc, 0xff,
-0x26, 0xb8, 0xdc, 0xff, 0x32, 0xbc, 0xdf, 0xff, 0x3c, 0xc5, 0xe8, 0xff,
-0x42, 0xc8, 0xea, 0xff, 0x43, 0xc5, 0xe6, 0xff, 0x3f, 0xbf, 0xdf, 0xff,
-0x4e, 0xbe, 0xdd, 0xff, 0x75, 0xc5, 0xdf, 0xff, 0xa2, 0xd2, 0xe5, 0xf2,
-0xcd, 0xe1, 0xee, 0xd2, 0xec, 0xf1, 0xf7, 0x9e, 0xf9, 0xfa, 0xfc, 0x5a,
-0xfe, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xff, 0x21, 0xf6, 0xf9, 0xfd, 0x76,
-0xd9, 0xe9, 0xf4, 0xce, 0x9e, 0xd0, 0xe5, 0xfc, 0x6c, 0xc8, 0xde, 0xff,
-0x68, 0xd8, 0xe8, 0xff, 0x74, 0xdd, 0xee, 0xff, 0x74, 0xd3, 0xec, 0xff,
-0x61, 0xc0, 0xe2, 0xff, 0x4c, 0xb1, 0xd6, 0xff, 0x3f, 0xa5, 0xca, 0xff,
-0x2c, 0x98, 0xb7, 0xff, 0x1e, 0x9d, 0xc1, 0xff, 0x04, 0x8b, 0xac, 0xff,
-0x00, 0x74, 0x8d, 0xff, 0x01, 0x74, 0x95, 0xff, 0x00, 0x5a, 0x87, 0xff,
-0x00, 0x3a, 0x70, 0xff, 0x00, 0x33, 0x6f, 0xff, 0x00, 0x26, 0x5e, 0xff,
-0x0f, 0x35, 0x66, 0xf8, 0x24, 0x47, 0x6e, 0xe8, 0x3b, 0x5a, 0x76, 0xd5,
-0x52, 0x6e, 0x82, 0xc3, 0x64, 0x7d, 0x8d, 0xb3, 0x71, 0x89, 0x96, 0xa9,
-0x7a, 0x90, 0x9b, 0xa2, 0x7c, 0x93, 0x9d, 0xa1, 0x7c, 0x92, 0x9d, 0xa2,
-0x7a, 0x8f, 0x9b, 0xa6, 0x75, 0x8c, 0x99, 0xab, 0x6d, 0x86, 0x95, 0xb3,
-0x64, 0x80, 0x91, 0xbc, 0x5a, 0x77, 0x8a, 0xc7, 0x4e, 0x6e, 0x87, 0xd2,
-0x41, 0x67, 0x82, 0xdd, 0x32, 0x5c, 0x7c, 0xe9, 0x24, 0x4f, 0x76, 0xf3,
-0x16, 0x4a, 0x75, 0xfb, 0x09, 0x45, 0x74, 0xff, 0x00, 0x45, 0x76, 0xff,
-0x00, 0x47, 0x79, 0xff, 0x00, 0x53, 0x84, 0xff, 0x00, 0x62, 0x8e, 0xff,
-0x00, 0x6b, 0x91, 0xff, 0x00, 0x7e, 0xa4, 0xff, 0x07, 0x9a, 0xc0, 0xff,
-0x1e, 0xb0, 0xd7, 0xff, 0x25, 0xb1, 0xd4, 0xff, 0x33, 0xb5, 0xd9, 0xff,
-0x71, 0xbe, 0xd9, 0xff, 0xcc, 0xdd, 0xe9, 0xd6, 0xf5, 0xf6, 0xf9, 0x76,
-0xfd, 0xfd, 0xff, 0x1b, 0xff, 0xff, 0xff, 0x00, 0xfb, 0xfa, 0xfc, 0x4f,
-0xa5, 0xd1, 0xe2, 0xec, 0x41, 0xba, 0xe1, 0xff, 0x34, 0xab, 0xd2, 0xff,
-0x1a, 0x98, 0xba, 0xff, 0x25, 0x9a, 0xbd, 0xff, 0x27, 0x9b, 0xbc, 0xff,
-0x22, 0x9b, 0xbd, 0xff, 0x19, 0x99, 0xbd, 0xff, 0x0c, 0x97, 0xbb, 0xff,
-0x00, 0x89, 0xb0, 0xff, 0x00, 0x41, 0x76, 0xff, 0x24, 0x47, 0x6d, 0xeb,
-0x49, 0x69, 0x80, 0xcf, 0x4c, 0x6b, 0x83, 0xcf, 0x49, 0x69, 0x83, 0xd2,
-0x46, 0x66, 0x80, 0xd5, 0x42, 0x65, 0x80, 0xd8, 0x3e, 0x63, 0x80, 0xdc,
-0x3a, 0x60, 0x7e, 0xe0, 0x33, 0x5b, 0x7a, 0xe4, 0x2e, 0x54, 0x77, 0xe9,
-0x29, 0x52, 0x76, 0xed, 0x24, 0x4f, 0x75, 0xf1, 0x1e, 0x4c, 0x73, 0xf4,
-0x18, 0x48, 0x72, 0xf8, 0x12, 0x3f, 0x6e, 0xfb, 0x0d, 0x3c, 0x6d, 0xfd,
-0x09, 0x43, 0x72, 0xff, 0x04, 0x47, 0x73, 0xff, 0x01, 0x42, 0x72, 0xff,
-0x00, 0x35, 0x6d, 0xff, 0x00, 0x31, 0x6c, 0xff, 0x00, 0x40, 0x77, 0xff,
-0x00, 0x42, 0x7a, 0xff, 0x00, 0x44, 0x7a, 0xff, 0x00, 0x4e, 0x7f, 0xff,
-0x00, 0x54, 0x84, 0xff, 0x00, 0x50, 0x7c, 0xff, 0x00, 0x5a, 0x84, 0xff,
-0x00, 0x66, 0x8f, 0xff, 0x00, 0x6c, 0x94, 0xff, 0x00, 0x6e, 0x93, 0xff,
-0x00, 0x76, 0x96, 0xff, 0x00, 0x7b, 0x9c, 0xff, 0x00, 0x81, 0xa0, 0xff,
-0x01, 0x8d, 0xaf, 0xff, 0x0d, 0x9c, 0xc1, 0xff, 0x27, 0xa8, 0xcc, 0xff,
-0x41, 0xb9, 0xdf, 0xff, 0x4b, 0xc4, 0xe9, 0xff, 0x49, 0xc4, 0xe7, 0xff,
-0x51, 0xc7, 0xe7, 0xff, 0x50, 0xc5, 0xe4, 0xff, 0x56, 0xbf, 0xdd, 0xff,
-0x7b, 0xc6, 0xdf, 0xff, 0xb2, 0xd6, 0xe6, 0xed, 0xe2, 0xeb, 0xf2, 0xb7,
-0xf8, 0xf9, 0xfc, 0x60, 0xfe, 0xfe, 0xff, 0x16, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x08, 0xfb, 0xfd, 0xfe, 0x4a,
-0xe9, 0xf1, 0xf8, 0xb1, 0xb5, 0xd8, 0xe9, 0xf6, 0x81, 0xcb, 0xe0, 0xff,
-0x7b, 0xd9, 0xe7, 0xff, 0x8c, 0xe6, 0xf2, 0xff, 0x87, 0xda, 0xf1, 0xff,
-0x70, 0xbf, 0xdf, 0xff, 0x5e, 0xad, 0xce, 0xff, 0x51, 0xa6, 0xc7, 0xff,
-0x41, 0x9c, 0xba, 0xff, 0x2f, 0x8b, 0xa6, 0xff, 0x1f, 0x86, 0xa0, 0xff,
-0x13, 0x96, 0xb7, 0xff, 0x00, 0x83, 0xa7, 0xff, 0x00, 0x4e, 0x7d, 0xff,
-0x00, 0x31, 0x69, 0xff, 0x03, 0x2b, 0x5e, 0xfe, 0x22, 0x40, 0x66, 0xe8,
-0x4d, 0x68, 0x7d, 0xc2, 0x7b, 0x8f, 0x97, 0x97, 0xa1, 0xab, 0xaf, 0x6c,
-0xbc, 0xc1, 0xc2, 0x4a, 0xd0, 0xd2, 0xd1, 0x30, 0xdc, 0xdc, 0xda, 0x1f,
-0xe4, 0xe2, 0xe1, 0x14, 0xe9, 0xe7, 0xe6, 0x0f, 0xea, 0xe9, 0xe8, 0x0c,
-0xeb, 0xea, 0xe9, 0x0b, 0xeb, 0xea, 0xe9, 0x0d, 0xeb, 0xe9, 0xe9, 0x0e,
-0xea, 0xe8, 0xe8, 0x0f, 0xe8, 0xe7, 0xe6, 0x14, 0xe5, 0xe4, 0xe3, 0x19,
-0xe1, 0xe0, 0xe0, 0x22, 0xdc, 0xdc, 0xdb, 0x2d, 0xd4, 0xd6, 0xd5, 0x39,
-0xca, 0xce, 0xce, 0x4a, 0xbd, 0xc5, 0xc6, 0x5e, 0xad, 0xb8, 0xba, 0x77,
-0x99, 0xa9, 0xaf, 0x92, 0x80, 0x96, 0xa1, 0xae, 0x64, 0x82, 0x93, 0xca,
-0x46, 0x6e, 0x85, 0xe3, 0x27, 0x5c, 0x7c, 0xf6, 0x0f, 0x4c, 0x75, 0xff,
-0x00, 0x49, 0x78, 0xff, 0x00, 0x60, 0x8c, 0xff, 0x00, 0x71, 0x9a, 0xff,
-0x05, 0x8b, 0xb0, 0xff, 0x16, 0x9c, 0xbd, 0xff, 0x19, 0xad, 0xd5, 0xff,
-0x3b, 0xb2, 0xd8, 0xff, 0xa4, 0xcd, 0xdf, 0xf4, 0xed, 0xef, 0xf5, 0xa0,
-0xfc, 0xfd, 0xfd, 0x29, 0xfa, 0xfa, 0xfc, 0x4f, 0xad, 0xd2, 0xe3, 0xeb,
-0x5c, 0xbe, 0xe0, 0xff, 0x55, 0xaf, 0xd0, 0xff, 0x44, 0x9b, 0xb9, 0xff,
-0x4d, 0x9f, 0xbe, 0xff, 0x50, 0xa1, 0xc0, 0xff, 0x4b, 0x9f, 0xbd, 0xff,
-0x49, 0x9f, 0xbf, 0xff, 0x33, 0x9b, 0xbb, 0xff, 0x02, 0x85, 0xa8, 0xff,
-0x10, 0x62, 0x83, 0xff, 0x98, 0xa8, 0xae, 0xa7, 0xd6, 0xd5, 0xd4, 0x2f,
-0xdb, 0xdb, 0xda, 0x27, 0xd9, 0xda, 0xd9, 0x2b, 0xd7, 0xd8, 0xd7, 0x30,
-0xd5, 0xd6, 0xd5, 0x33, 0xd2, 0xd4, 0xd4, 0x37, 0xcf, 0xd2, 0xd1, 0x3d,
-0xcb, 0xcf, 0xce, 0x43, 0xc7, 0xcb, 0xcb, 0x4a, 0xc2, 0xc7, 0xc8, 0x51,
-0xbd, 0xc3, 0xc5, 0x59, 0xb7, 0xbf, 0xc0, 0x62, 0xb0, 0xb9, 0xbb, 0x6b,
-0xa8, 0xb4, 0xb7, 0x74, 0xa0, 0xae, 0xb2, 0x80, 0x97, 0xa6, 0xac, 0x8b,
-0x8f, 0x9f, 0xa6, 0x96, 0x84, 0x98, 0xa2, 0xa2, 0x77, 0x8e, 0x9b, 0xae,
-0x6a, 0x85, 0x93, 0xba, 0x5d, 0x7a, 0x8d, 0xc5, 0x51, 0x71, 0x87, 0xd0,
-0x46, 0x6a, 0x82, 0xdb, 0x39, 0x62, 0x7e, 0xe4, 0x2e, 0x59, 0x78, 0xec,
-0x23, 0x51, 0x74, 0xf3, 0x19, 0x4d, 0x73, 0xf9, 0x0f, 0x47, 0x72, 0xfe,
-0x07, 0x42, 0x71, 0xff, 0x00, 0x3e, 0x6f, 0xff, 0x00, 0x47, 0x77, 0xff,
-0x00, 0x42, 0x71, 0xff, 0x00, 0x46, 0x76, 0xff, 0x00, 0x54, 0x82, 0xff,
-0x00, 0x5d, 0x89, 0xff, 0x00, 0x61, 0x85, 0xff, 0x00, 0x72, 0x95, 0xff,
-0x05, 0x80, 0xa7, 0xff, 0x0b, 0x91, 0xb4, 0xff, 0x20, 0x9b, 0xbb, 0xff,
-0x44, 0xb5, 0xd7, 0xff, 0x59, 0xc7, 0xea, 0xff, 0x58, 0xc1, 0xe0, 0xff,
-0x58, 0xbe, 0xdc, 0xff, 0x70, 0xc0, 0xdc, 0xff, 0xb4, 0xd5, 0xe5, 0xed,
-0xed, 0xf1, 0xf5, 0x98, 0xfc, 0xfc, 0xfd, 0x2a, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xff, 0x19,
-0xf6, 0xfa, 0xfd, 0x77, 0xd6, 0xe7, 0xf1, 0xdb, 0x9d, 0xd0, 0xe4, 0xff,
-0x89, 0xd9, 0xe6, 0xff, 0x9b, 0xea, 0xf3, 0xff, 0x99, 0xe1, 0xf3, 0xff,
-0x81, 0xc3, 0xdf, 0xff, 0x6f, 0xb0, 0xcc, 0xff, 0x63, 0xa4, 0xbe, 0xff,
-0x61, 0xa3, 0xbe, 0xff, 0x60, 0xa4, 0xc0, 0xff, 0x4e, 0x97, 0xb2, 0xff,
-0x34, 0x8e, 0xa8, 0xff, 0x18, 0x8d, 0xad, 0xff, 0x00, 0x61, 0x8c, 0xff,
-0x00, 0x34, 0x68, 0xff, 0x13, 0x37, 0x62, 0xf4, 0x48, 0x63, 0x78, 0xc7,
-0x85, 0x97, 0x9c, 0x88, 0xb7, 0xbe, 0xbd, 0x4c, 0xd7, 0xd6, 0xd5, 0x21,
-0xe9, 0xe7, 0xe6, 0x09, 0xf2, 0xf1, 0xf0, 0x00, 0xf8, 0xf7, 0xf6, 0x00,
-0xfb, 0xfb, 0xfa, 0x00, 0xfd, 0xfc, 0xfc, 0x00, 0xfd, 0xfd, 0xfd, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfd, 0x00, 0xfd, 0xfd, 0xfd, 0x00,
-0xfd, 0xfc, 0xfc, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xfa, 0xf9, 0xf9, 0x00,
-0xf8, 0xf8, 0xf7, 0x00, 0xf6, 0xf5, 0xf5, 0x00, 0xf1, 0xf1, 0xf0, 0x07,
-0xec, 0xea, 0xea, 0x13, 0xe3, 0xe2, 0xe2, 0x26, 0xd6, 0xd6, 0xd7, 0x42,
-0xc0, 0xc5, 0xc8, 0x65, 0xa3, 0xb0, 0xb6, 0x8f, 0x7e, 0x95, 0xa1, 0xba,
-0x55, 0x7b, 0x8e, 0xdf, 0x2c, 0x68, 0x83, 0xf7, 0x0d, 0x59, 0x7c, 0xff,
-0x00, 0x58, 0x7e, 0xff, 0x00, 0x78, 0x9e, 0xff, 0x06, 0x9e, 0xca, 0xff,
-0x11, 0xa3, 0xcb, 0xff, 0x7b, 0xbc, 0xd2, 0xfd, 0xe5, 0xeb, 0xf1, 0xaf,
-0xf3, 0xf6, 0xf8, 0x82, 0xb4, 0xd4, 0xe3, 0xea, 0x70, 0xc1, 0xdf, 0xff,
-0x6f, 0xb8, 0xd7, 0xff, 0x60, 0xa1, 0xbb, 0xff, 0x65, 0xa4, 0xbe, 0xff,
-0x65, 0xa4, 0xbf, 0xff, 0x62, 0xa3, 0xbe, 0xff, 0x64, 0xa4, 0xc0, 0xff,
-0x54, 0x9d, 0xb8, 0xff, 0x18, 0x88, 0xa6, 0xff, 0x23, 0x72, 0x8d, 0xff,
-0xba, 0xc0, 0xc6, 0x93, 0xf7, 0xf5, 0xf5, 0x02, 0xfd, 0xfc, 0xfc, 0x00,
-0xfd, 0xfc, 0xfc, 0x00, 0xfc, 0xfb, 0xfb, 0x00, 0xfc, 0xfb, 0xfb, 0x00,
-0xfc, 0xfb, 0xfb, 0x00, 0xfb, 0xfa, 0xfa, 0x00, 0xfa, 0xfa, 0xf9, 0x00,
-0xfa, 0xf9, 0xf9, 0x00, 0xfa, 0xf8, 0xf8, 0x00, 0xf8, 0xf7, 0xf7, 0x00,
-0xf7, 0xf6, 0xf5, 0x00, 0xf6, 0xf5, 0xf4, 0x00, 0xf6, 0xf4, 0xf3, 0x00,
-0xf4, 0xf2, 0xf2, 0x02, 0xf1, 0xf0, 0xef, 0x04, 0xef, 0xee, 0xed, 0x08,
-0xed, 0xeb, 0xeb, 0x0c, 0xea, 0xe8, 0xe8, 0x12, 0xe6, 0xe4, 0xe4, 0x18,
-0xe2, 0xe1, 0xe0, 0x21, 0xdd, 0xdc, 0xdc, 0x2b, 0xd6, 0xd7, 0xd7, 0x36,
-0xcf, 0xd0, 0xd1, 0x42, 0xc7, 0xcb, 0xcb, 0x50, 0xbd, 0xc3, 0xc5, 0x5e,
-0xb0, 0xb9, 0xbc, 0x6f, 0xa3, 0xaf, 0xb3, 0x7f, 0x94, 0xa4, 0xaa, 0x92,
-0x84, 0x98, 0xa1, 0xa5, 0x73, 0x8c, 0x98, 0xb6, 0x61, 0x80, 0x90, 0xc7,
-0x4f, 0x72, 0x87, 0xd6, 0x3d, 0x66, 0x7f, 0xe4, 0x2d, 0x5b, 0x78, 0xf0,
-0x1f, 0x56, 0x76, 0xf9, 0x11, 0x51, 0x74, 0xff, 0x03, 0x4d, 0x74, 0xff,
-0x00, 0x54, 0x7c, 0xff, 0x00, 0x5b, 0x80, 0xff, 0x00, 0x63, 0x88, 0xff,
-0x04, 0x78, 0x9e, 0xff, 0x1b, 0x8b, 0xad, 0xff, 0x32, 0xa0, 0xbf, 0xff,
-0x3b, 0xad, 0xce, 0xff, 0x36, 0xa8, 0xca, 0xff, 0x89, 0xc2, 0xd7, 0xfc,
-0xe7, 0xeb, 0xf1, 0xa4, 0xfb, 0xfc, 0xfc, 0x22, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfd, 0xfe, 0xff, 0x2c, 0xf1, 0xf6, 0xfc, 0x9e, 0xc3, 0xde, 0xeb, 0xf4,
-0x9b, 0xd4, 0xe3, 0xff, 0xa4, 0xe7, 0xee, 0xff, 0xae, 0xed, 0xf8, 0xff,
-0x97, 0xd2, 0xe9, 0xff, 0x81, 0xb7, 0xd0, 0xff, 0x79, 0xab, 0xc2, 0xff,
-0x75, 0xa9, 0xbf, 0xff, 0x74, 0xa8, 0xbf, 0xff, 0x71, 0xa7, 0xbf, 0xff,
-0x68, 0xa1, 0xba, 0xff, 0x4c, 0x98, 0xb1, 0xff, 0x15, 0x7b, 0x9a, 0xff,
-0x00, 0x40, 0x6a, 0xff, 0x15, 0x3a, 0x5e, 0xf3, 0x5a, 0x70, 0x7f, 0xb7,
-0xa2, 0xab, 0xad, 0x64, 0xd2, 0xd3, 0xd2, 0x25, 0xeb, 0xe9, 0xe9, 0x05,
-0xf6, 0xf5, 0xf4, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xfe, 0x00,
-0xfe, 0xfe, 0xfd, 0x00, 0xfc, 0xfc, 0xfc, 0x00, 0xf9, 0xf9, 0xf9, 0x00,
-0xf4, 0xf3, 0xf3, 0x06, 0xec, 0xeb, 0xeb, 0x19, 0xde, 0xdd, 0xdd, 0x3a,
-0xc4, 0xc8, 0xca, 0x69, 0xa0, 0xad, 0xb4, 0xa0, 0x71, 0x8c, 0x9a, 0xd3,
-0x3e, 0x70, 0x87, 0xf6, 0x16, 0x6c, 0x8c, 0xff, 0x00, 0x7c, 0xa2, 0xff,
-0x00, 0x86, 0xae, 0xff, 0x60, 0xab, 0xc6, 0xfc, 0xd9, 0xe3, 0xec, 0xd9,
-0xb5, 0xd3, 0xe2, 0xf1, 0x85, 0xcb, 0xe4, 0xff, 0x7f, 0xbb, 0xd5, 0xff,
-0x72, 0xa7, 0xbe, 0xff, 0x74, 0xa9, 0xc0, 0xff, 0x74, 0xa9, 0xc0, 0xff,
-0x74, 0xa9, 0xc0, 0xff, 0x71, 0xa8, 0xbf, 0xff, 0x6a, 0xa1, 0xb8, 0xff,
-0x3c, 0x91, 0xad, 0xff, 0x2c, 0x78, 0x90, 0xff, 0xbe, 0xc2, 0xc8, 0x96,
-0xf9, 0xf8, 0xf8, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfd, 0x00, 0xfe, 0xfe, 0xfd, 0x00,
-0xfd, 0xfd, 0xfd, 0x00, 0xfc, 0xfc, 0xfc, 0x00, 0xfc, 0xfb, 0xfb, 0x00,
-0xfa, 0xfa, 0xf9, 0x00, 0xf9, 0xf8, 0xf8, 0x00, 0xf7, 0xf6, 0xf5, 0x00,
-0xf5, 0xf4, 0xf3, 0x00, 0xf2, 0xf1, 0xf0, 0x05, 0xef, 0xed, 0xec, 0x0c,
-0xea, 0xe8, 0xe7, 0x14, 0xe4, 0xe2, 0xe2, 0x20, 0xdd, 0xdc, 0xdc, 0x2d,
-0xd3, 0xd4, 0xd4, 0x3f, 0xc6, 0xcb, 0xcc, 0x52, 0xb8, 0xbf, 0xc1, 0x69,
-0xa7, 0xb1, 0xb6, 0x81, 0x92, 0xa1, 0xa9, 0x9c, 0x7c, 0x90, 0x9b, 0xb5,
-0x64, 0x81, 0x90, 0xce, 0x48, 0x71, 0x85, 0xe4, 0x2d, 0x62, 0x7a, 0xf5,
-0x17, 0x5e, 0x7a, 0xff, 0x03, 0x60, 0x80, 0xff, 0x00, 0x71, 0x93, 0xff,
-0x09, 0x8f, 0xb5, 0xff, 0x0f, 0x99, 0xc0, 0xff, 0x8b, 0xbb, 0xce, 0xf5,
-0xef, 0xf0, 0xf2, 0x71, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfd, 0xfe, 0xff, 0x36, 0xed, 0xf4, 0xfa, 0xb3,
-0xbc, 0xda, 0xe6, 0xfd, 0xa7, 0xd8, 0xe2, 0xff, 0xbd, 0xef, 0xf4, 0xff,
-0xb3, 0xe6, 0xf2, 0xff, 0x94, 0xc2, 0xd7, 0xff, 0x85, 0xb1, 0xc5, 0xff,
-0x82, 0xae, 0xc2, 0xff, 0x6b, 0x8e, 0x9a, 0xff, 0x61, 0x80, 0x89, 0xff,
-0x77, 0xa3, 0xb5, 0xff, 0x77, 0xa6, 0xbc, 0xff, 0x4f, 0x91, 0xa6, 0xff,
-0x07, 0x63, 0x80, 0xff, 0x02, 0x3c, 0x5f, 0xff, 0x46, 0x61, 0x72, 0xcd,
-0x9e, 0xa6, 0xa8, 0x6d, 0xd5, 0xd5, 0xd4, 0x1f, 0xef, 0xee, 0xee, 0x00,
-0xf9, 0xf9, 0xf9, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfd, 0xfd, 0xfc, 0x00, 0xf9, 0xf8, 0xf8, 0x00,
-0xf2, 0xf1, 0xf1, 0x0e, 0xe4, 0xe3, 0xe4, 0x31, 0xcb, 0xcd, 0xd0, 0x6b,
-0xa2, 0xad, 0xb5, 0xae, 0x70, 0x90, 0x9f, 0xe5, 0x3e, 0x80, 0x9a, 0xfe,
-0x0a, 0x69, 0x91, 0xff, 0x58, 0x92, 0xae, 0xfe, 0xac, 0xce, 0xdd, 0xfb,
-0x9a, 0xd5, 0xe8, 0xff, 0x8f, 0xc2, 0xd8, 0xff, 0x7f, 0xab, 0xc0, 0xff,
-0x81, 0xae, 0xc1, 0xff, 0x81, 0xae, 0xc1, 0xff, 0x82, 0xae, 0xc2, 0xff,
-0x7d, 0xaa, 0xbd, 0xff, 0x7a, 0xa6, 0xba, 0xff, 0x53, 0x94, 0xac, 0xff,
-0x3a, 0x7b, 0x90, 0xff, 0xbe, 0xc4, 0xc8, 0x96, 0xf8, 0xf7, 0xf8, 0x08,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xfe, 0xfe, 0xfd, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xfc, 0xfb, 0xfb, 0x00,
-0xfa, 0xfa, 0xf9, 0x00, 0xf8, 0xf7, 0xf6, 0x00, 0xf4, 0xf3, 0xf3, 0x01,
-0xf0, 0xee, 0xee, 0x0a, 0xea, 0xe8, 0xe8, 0x15, 0xe1, 0xdf, 0xe0, 0x28,
-0xd4, 0xd4, 0xd5, 0x41, 0xc4, 0xc6, 0xc9, 0x5f, 0xac, 0xb3, 0xb8, 0x85,
-0x8b, 0x9c, 0xa5, 0xb0, 0x62, 0x85, 0x95, 0xde, 0x33, 0x7a, 0x94, 0xfb,
-0x06, 0x83, 0xa5, 0xff, 0x2e, 0x8e, 0xab, 0xff, 0xd2, 0xd8, 0xde, 0xa8,
-0xfd, 0xfd, 0xfd, 0x0d, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfe, 0xff, 0x36,
-0xec, 0xf4, 0xf9, 0xba, 0xbc, 0xd9, 0xe4, 0xff, 0xb5, 0xdb, 0xe3, 0xff,
-0xcc, 0xf0, 0xf4, 0xff, 0xb3, 0xdb, 0xe9, 0xff, 0x96, 0xbb, 0xcc, 0xff,
-0x8c, 0xaf, 0xbf, 0xff, 0x8e, 0xb3, 0xc4, 0xff, 0x8e, 0xb3, 0xc5, 0xff,
-0x77, 0x95, 0x9f, 0xff, 0x6d, 0x8a, 0x94, 0xff, 0x7b, 0xa1, 0xb3, 0xff,
-0x63, 0x9a, 0xad, 0xff, 0x10, 0x60, 0x7c, 0xff, 0x14, 0x46, 0x61, 0xf7,
-0x72, 0x82, 0x89, 0xa8, 0xc6, 0xc5, 0xc6, 0x39, 0xea, 0xe9, 0xe9, 0x03,
-0xf9, 0xf9, 0xf9, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfd, 0xfd, 0x00, 0xf9, 0xf8, 0xf8, 0x00, 0xef, 0xef, 0xef, 0x17,
-0xdc, 0xdc, 0xde, 0x4d, 0xbf, 0xc4, 0xc9, 0x99, 0x98, 0xa8, 0xb6, 0xd4,
-0x55, 0x85, 0x9e, 0xf2, 0x78, 0xad, 0xc1, 0xfe, 0xaa, 0xda, 0xe8, 0xff,
-0x95, 0xbd, 0xcf, 0xff, 0x8b, 0xb0, 0xc2, 0xff, 0x8d, 0xb2, 0xc3, 0xff,
-0x8b, 0xb0, 0xc1, 0xff, 0x8e, 0xb3, 0xc4, 0xff, 0x8c, 0xb1, 0xc3, 0xff,
-0x80, 0xa6, 0xb6, 0xff, 0x62, 0x94, 0xa7, 0xff, 0x49, 0x7e, 0x90, 0xff,
-0xbf, 0xc5, 0xc9, 0x95, 0xf8, 0xf8, 0xf8, 0x08, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xfe, 0xfe, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xfc, 0xfb, 0xfa, 0x04,
-0xf9, 0xf7, 0xf8, 0x16, 0xf2, 0xf2, 0xf4, 0x37, 0xe8, 0xe9, 0xea, 0x6e,
-0xd2, 0xd7, 0xdb, 0xbd, 0xa6, 0xba, 0xc8, 0xf7, 0x54, 0x9e, 0xb9, 0xff,
-0x2a, 0x84, 0x9f, 0xff, 0xbb, 0xc3, 0xca, 0xad, 0xfa, 0xfa, 0xfa, 0x0f,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfe, 0xff, 0x2b, 0xee, 0xf5, 0xf9, 0xb2, 0xc2, 0xdb, 0xe5, 0xff,
-0xc3, 0xe1, 0xe7, 0xff, 0xd3, 0xef, 0xf3, 0xff, 0xb7, 0xdb, 0xe7, 0xff,
-0x9c, 0xba, 0xc8, 0xff, 0x95, 0xb2, 0xbf, 0xff, 0x99, 0xb7, 0xc5, 0xff,
-0x99, 0xb7, 0xc4, 0xff, 0x97, 0xb6, 0xc5, 0xff, 0x95, 0xb6, 0xc7, 0xff,
-0x8a, 0xac, 0xbd, 0xff, 0x73, 0x9c, 0xad, 0xff, 0x1c, 0x62, 0x7a, 0xff,
-0x21, 0x4e, 0x63, 0xf0, 0x90, 0x97, 0x9b, 0x8b, 0xd7, 0xd5, 0xd5, 0x1f,
-0xf4, 0xf3, 0xf3, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xfe, 0x00, 0xfc, 0xfb, 0xfb, 0x00,
-0xf3, 0xf3, 0xf3, 0x0f, 0xe5, 0xe6, 0xe7, 0x41, 0xd3, 0xd8, 0xdc, 0x9f,
-0xa7, 0xc2, 0xcf, 0xf8, 0xa7, 0xd1, 0xdd, 0xff, 0x9c, 0xbe, 0xcc, 0xff,
-0x91, 0xb0, 0xbf, 0xff, 0x96, 0xb4, 0xc3, 0xff, 0x98, 0xb7, 0xc4, 0xff,
-0x98, 0xb6, 0xc4, 0xff, 0x97, 0xb5, 0xc3, 0xff, 0x89, 0xa8, 0xb5, 0xff,
-0x6a, 0x94, 0xa5, 0xff, 0x54, 0x7f, 0x8f, 0xff, 0xc0, 0xc5, 0xca, 0x93,
-0xf8, 0xf8, 0xf8, 0x03, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x05,
-0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x0e, 0xff, 0xff, 0xff, 0x15,
-0xff, 0xff, 0xff, 0x1c, 0xff, 0xff, 0xff, 0x26, 0xfe, 0xfe, 0xff, 0x32,
-0xfd, 0xfe, 0xff, 0x41, 0xfd, 0xfd, 0xff, 0x52, 0xfa, 0xfd, 0xfe, 0x67,
-0xf7, 0xfb, 0xfe, 0x80, 0xf2, 0xf8, 0xfb, 0x9a, 0xeb, 0xf3, 0xf8, 0xb7,
-0xe0, 0xec, 0xf2, 0xd4, 0xd0, 0xe3, 0xeb, 0xeb, 0xbc, 0xda, 0xe4, 0xfa,
-0xa5, 0xd5, 0xe1, 0xff, 0x6b, 0xb1, 0xca, 0xff, 0x5d, 0x8e, 0xa0, 0xfb,
-0xc2, 0xc5, 0xc8, 0x80, 0xfa, 0xfa, 0xfa, 0x05, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x17, 0xf4, 0xf8, 0xfb, 0x99,
-0xcd, 0xe0, 0xe8, 0xfc, 0xcb, 0xe0, 0xe6, 0xff, 0xdf, 0xf4, 0xf7, 0xff,
-0xbf, 0xdc, 0xe8, 0xff, 0x9f, 0xb7, 0xc3, 0xff, 0x9c, 0xb3, 0xbd, 0xff,
-0xa1, 0xb9, 0xc4, 0xff, 0xa1, 0xb8, 0xc4, 0xff, 0xa1, 0xb9, 0xc5, 0xff,
-0x9c, 0xb5, 0xc0, 0xff, 0x99, 0xb6, 0xc3, 0xff, 0x87, 0xa4, 0xb3, 0xff,
-0x34, 0x6c, 0x7d, 0xff, 0x29, 0x56, 0x66, 0xf3, 0x99, 0x9d, 0xa0, 0x85,
-0xde, 0xdd, 0xdd, 0x14, 0xf7, 0xf7, 0xf7, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xfe, 0x00,
-0xfd, 0xfc, 0xfc, 0x00, 0xf1, 0xf3, 0xf4, 0x57, 0xc6, 0xd7, 0xdf, 0xef,
-0xad, 0xce, 0xd7, 0xff, 0xa9, 0xc6, 0xd2, 0xff, 0x99, 0xb2, 0xbd, 0xff,
-0x9b, 0xb2, 0xbd, 0xff, 0xa2, 0xba, 0xc5, 0xff, 0xa2, 0xba, 0xc5, 0xff,
-0x9a, 0xb1, 0xbc, 0xff, 0x95, 0xaf, 0xbc, 0xff, 0x7c, 0xa0, 0xb0, 0xff,
-0x64, 0x85, 0x93, 0xff, 0xbf, 0xc5, 0xc9, 0xa2, 0xf8, 0xf8, 0xf8, 0x27,
-0xff, 0xff, 0xff, 0x1e, 0xff, 0xff, 0xff, 0x20, 0xff, 0xff, 0xff, 0x20,
-0xfe, 0xff, 0xff, 0x21, 0xff, 0xff, 0xff, 0x22, 0xff, 0xff, 0xff, 0x24,
-0xfe, 0xff, 0xff, 0x26, 0xfe, 0xff, 0xff, 0x27, 0xfe, 0xff, 0xff, 0x28,
-0xff, 0xff, 0xff, 0x2a, 0xfe, 0xfe, 0xff, 0x2b, 0xfe, 0xfe, 0xff, 0x2d,
-0xfe, 0xfe, 0xff, 0x2f, 0xfe, 0xff, 0xff, 0x32, 0xfe, 0xff, 0xff, 0x34,
-0xfe, 0xfe, 0xff, 0x37, 0xfd, 0xfe, 0xfe, 0x3b, 0xfd, 0xfe, 0xff, 0x3f,
-0xfd, 0xfe, 0xff, 0x43, 0xfc, 0xfe, 0xff, 0x49, 0xfc, 0xfe, 0xff, 0x4d,
-0xfc, 0xfd, 0xfe, 0x52, 0xfb, 0xfd, 0xfe, 0x59, 0xfb, 0xfc, 0xfe, 0x60,
-0xfa, 0xfc, 0xfd, 0x68, 0xfa, 0xfc, 0xfe, 0x70, 0xf7, 0xfa, 0xfc, 0x79,
-0xf6, 0xfa, 0xfc, 0x83, 0xf4, 0xf8, 0xfb, 0x8e, 0xf2, 0xf7, 0xfa, 0x9a,
-0xef, 0xf6, 0xf9, 0xa5, 0xed, 0xf4, 0xf8, 0xb2, 0xea, 0xf2, 0xf6, 0xbe,
-0xe6, 0xef, 0xf4, 0xcb, 0xe1, 0xed, 0xf3, 0xd7, 0xdf, 0xeb, 0xf1, 0xe2,
-0xd9, 0xe6, 0xee, 0xed, 0xd3, 0xe4, 0xeb, 0xf6, 0xce, 0xe1, 0xe8, 0xfe,
-0xc7, 0xdd, 0xe4, 0xff, 0xc3, 0xdb, 0xe3, 0xff, 0xc0, 0xdd, 0xe3, 0xff,
-0xbc, 0xe0, 0xe6, 0xff, 0xb1, 0xdd, 0xe5, 0xff, 0x86, 0xbc, 0xcc, 0xff,
-0x5c, 0x8a, 0x9c, 0xff, 0x92, 0x9d, 0xa4, 0xc0, 0xd8, 0xd9, 0xda, 0x33,
-0xfd, 0xfc, 0xfc, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x05,
-0xf9, 0xfb, 0xfd, 0x6e, 0xd8, 0xe6, 0xec, 0xf1, 0xcf, 0xe0, 0xe6, 0xff,
-0xe7, 0xf3, 0xf5, 0xff, 0xc7, 0xde, 0xe6, 0xff, 0xab, 0xbf, 0xc9, 0xff,
-0xa5, 0xb6, 0xbe, 0xff, 0xa6, 0xb6, 0xbf, 0xff, 0xa7, 0xb9, 0xc1, 0xff,
-0xac, 0xbe, 0xc6, 0xff, 0xa9, 0xb9, 0xc2, 0xff, 0x9b, 0xad, 0xb6, 0xff,
-0x95, 0xab, 0xb5, 0xff, 0x5f, 0x84, 0x92, 0xff, 0x2e, 0x5a, 0x67, 0xfc,
-0x91, 0x97, 0x9b, 0x98, 0xdd, 0xdc, 0xdc, 0x18, 0xf8, 0xf8, 0xf8, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xf9, 0xfb, 0xfc, 0x4e, 0xd1, 0xdf, 0xe5, 0xec, 0xbf, 0xdb, 0xe0, 0xff,
-0xc0, 0xd8, 0xe4, 0xff, 0xa4, 0xb6, 0xbf, 0xff, 0xa5, 0xb6, 0xbf, 0xff,
-0xa0, 0xb1, 0xba, 0xff, 0xa3, 0xb4, 0xbd, 0xff, 0xa1, 0xb3, 0xbb, 0xff,
-0xa0, 0xb5, 0xc0, 0xff, 0x96, 0xb1, 0xbf, 0xff, 0x7b, 0x94, 0xa0, 0xff,
-0xb7, 0xc3, 0xc9, 0xe6, 0xe5, 0xed, 0xf1, 0xc6, 0xeb, 0xf2, 0xf6, 0xc4,
-0xeb, 0xf2, 0xf7, 0xc4, 0xea, 0xf2, 0xf5, 0xc5, 0xea, 0xf1, 0xf6, 0xc6,
-0xe9, 0xf1, 0xf5, 0xc7, 0xea, 0xf1, 0xf5, 0xc9, 0xeb, 0xf3, 0xf6, 0xca,
-0xe9, 0xf2, 0xf6, 0xcc, 0xe9, 0xf1, 0xf5, 0xce, 0xe9, 0xf0, 0xf5, 0xcf,
-0xe7, 0xf0, 0xf4, 0xd1, 0xe7, 0xef, 0xf3, 0xd3, 0xe6, 0xee, 0xf3, 0xd5,
-0xe5, 0xee, 0xf3, 0xd7, 0xe5, 0xef, 0xf3, 0xd9, 0xe4, 0xee, 0xf2, 0xdc,
-0xe3, 0xed, 0xf1, 0xdf, 0xe3, 0xed, 0xf2, 0xe2, 0xe2, 0xeb, 0xf1, 0xe5,
-0xdf, 0xea, 0xef, 0xe8, 0xde, 0xe9, 0xee, 0xeb, 0xdc, 0xe9, 0xee, 0xee,
-0xdc, 0xe8, 0xee, 0xf1, 0xda, 0xe7, 0xec, 0xf4, 0xd9, 0xe6, 0xec, 0xf7,
-0xd5, 0xe3, 0xe9, 0xfa, 0xd6, 0xe4, 0xea, 0xfc, 0xd3, 0xe1, 0xe8, 0xff,
-0xd3, 0xe3, 0xe9, 0xff, 0xd1, 0xe2, 0xe8, 0xff, 0xd1, 0xe1, 0xe7, 0xff,
-0xd1, 0xe1, 0xe7, 0xff, 0xd2, 0xe1, 0xe8, 0xff, 0xd1, 0xe1, 0xe7, 0xff,
-0xd3, 0xe1, 0xe6, 0xff, 0xcf, 0xdc, 0xe2, 0xff, 0xcf, 0xdb, 0xe1, 0xff,
-0xd3, 0xe0, 0xe5, 0xff, 0xd4, 0xe4, 0xe8, 0xff, 0xd4, 0xe6, 0xea, 0xff,
-0xd0, 0xe8, 0xec, 0xff, 0xc4, 0xe4, 0xec, 0xff, 0x9e, 0xc7, 0xd5, 0xff,
-0x69, 0x96, 0xa7, 0xff, 0x56, 0x77, 0x85, 0xfc, 0x85, 0x90, 0x96, 0xbf,
-0xc6, 0xc7, 0xc9, 0x47, 0xf0, 0xf0, 0xf0, 0x03, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x38, 0xe9, 0xf0, 0xf5, 0xd0,
-0xce, 0xde, 0xe3, 0xff, 0xed, 0xf2, 0xf3, 0xff, 0xd8, 0xe9, 0xee, 0xff,
-0xb0, 0xbe, 0xc6, 0xff, 0xa4, 0xb0, 0xb7, 0xff, 0xa8, 0xb5, 0xbc, 0xff,
-0xaf, 0xbc, 0xc3, 0xff, 0x9f, 0xad, 0xb3, 0xff, 0x90, 0x9b, 0xa1, 0xff,
-0x9d, 0xa8, 0xae, 0xff, 0xa3, 0xb2, 0xba, 0xff, 0x8c, 0xa2, 0xac, 0xff,
-0x43, 0x65, 0x71, 0xff, 0x78, 0x84, 0x89, 0xc3, 0xd3, 0xd3, 0xd3, 0x2e,
-0xf7, 0xf6, 0xf6, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfb, 0xfc, 0xfe, 0x50,
-0xd6, 0xe1, 0xe7, 0xec, 0xc3, 0xd5, 0xd9, 0xff, 0xc2, 0xd3, 0xdb, 0xff,
-0xab, 0xb8, 0xc0, 0xff, 0xac, 0xb9, 0xc0, 0xff, 0x9c, 0xa7, 0xae, 0xff,
-0xa5, 0xb2, 0xb9, 0xff, 0xa8, 0xb6, 0xbc, 0xff, 0xa7, 0xb6, 0xbe, 0xff,
-0xaa, 0xbd, 0xc7, 0xff, 0xad, 0xc1, 0xcb, 0xff, 0xc7, 0xd5, 0xda, 0xff,
-0xd1, 0xdb, 0xe0, 0xff, 0xd1, 0xdd, 0xe2, 0xff, 0xd3, 0xde, 0xe3, 0xff,
-0xd3, 0xde, 0xe4, 0xff, 0xcd, 0xd9, 0xde, 0xff, 0xce, 0xd9, 0xde, 0xff,
-0xd0, 0xdb, 0xe1, 0xff, 0xd0, 0xdb, 0xe0, 0xff, 0xd0, 0xda, 0xe0, 0xff,
-0xd0, 0xdb, 0xdf, 0xff, 0xd0, 0xdb, 0xdf, 0xff, 0xcf, 0xda, 0xdf, 0xff,
-0xd0, 0xda, 0xdf, 0xff, 0xd0, 0xda, 0xe0, 0xff, 0xd2, 0xdd, 0xe2, 0xff,
-0xd4, 0xdf, 0xe4, 0xff, 0xd0, 0xdb, 0xdf, 0xff, 0xd6, 0xe0, 0xe5, 0xff,
-0xdc, 0xe5, 0xea, 0xff, 0xd7, 0xe1, 0xe5, 0xff, 0xd9, 0xe3, 0xe7, 0xff,
-0xd9, 0xe2, 0xe6, 0xff, 0xd8, 0xe1, 0xe5, 0xff, 0xd9, 0xe1, 0xe5, 0xff,
-0xdd, 0xe6, 0xe9, 0xff, 0xdf, 0xe8, 0xec, 0xff, 0xe1, 0xe8, 0xeb, 0xff,
-0xe6, 0xed, 0xf0, 0xff, 0xe5, 0xeb, 0xee, 0xff, 0xe5, 0xec, 0xef, 0xff,
-0xe7, 0xed, 0xef, 0xff, 0xe6, 0xed, 0xef, 0xff, 0xe4, 0xeb, 0xed, 0xff,
-0xe5, 0xeb, 0xee, 0xff, 0xe0, 0xe8, 0xeb, 0xff, 0xde, 0xe9, 0xec, 0xff,
-0xd9, 0xe5, 0xe9, 0xff, 0xd3, 0xe3, 0xe8, 0xff, 0xcd, 0xe1, 0xe7, 0xff,
-0xba, 0xd0, 0xd8, 0xff, 0xa5, 0xc2, 0xcd, 0xff, 0x7f, 0xa0, 0xac, 0xff,
-0x56, 0x7e, 0x8c, 0xff, 0x44, 0x68, 0x76, 0xff, 0x60, 0x73, 0x7a, 0xde,
-0x97, 0x9b, 0x9e, 0x8e, 0xcc, 0xcc, 0xcd, 0x30, 0xef, 0xee, 0xee, 0x01,
-0xfc, 0xfc, 0xfc, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0a,
-0xf7, 0xfa, 0xfc, 0x8c, 0xd8, 0xe3, 0xe8, 0xfd, 0xe4, 0xe9, 0xec, 0xff,
-0xe9, 0xf1, 0xf3, 0xff, 0xc0, 0xcc, 0xd2, 0xff, 0x9c, 0xa5, 0xab, 0xff,
-0x9b, 0xa3, 0xaa, 0xff, 0xa8, 0xb0, 0xb6, 0xff, 0xaa, 0xb4, 0xba, 0xff,
-0x7a, 0x7f, 0x82, 0xff, 0x4e, 0x4a, 0x44, 0xff, 0x88, 0x8f, 0x91, 0xff,
-0xa7, 0xb3, 0xbb, 0xff, 0x75, 0x89, 0x93, 0xff, 0x5f, 0x6f, 0x77, 0xf1,
-0xba, 0xbc, 0xbd, 0x66, 0xf1, 0xf1, 0xf0, 0x01, 0xfe, 0xfd, 0xfe, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfb, 0xfd, 0xfe, 0x50, 0xd9, 0xe3, 0xe7, 0xec,
-0xc6, 0xd1, 0xd5, 0xff, 0xb8, 0xc2, 0xc8, 0xff, 0xb0, 0xb9, 0xbe, 0xff,
-0x96, 0x9e, 0xa4, 0xff, 0x93, 0x9b, 0xa1, 0xff, 0xa0, 0xa9, 0xaf, 0xff,
-0xa8, 0xb2, 0xb7, 0xff, 0xb0, 0xba, 0xc0, 0xff, 0xad, 0xb8, 0xbf, 0xff,
-0xc9, 0xd8, 0xdf, 0xff, 0xe3, 0xec, 0xef, 0xff, 0xde, 0xe3, 0xe5, 0xff,
-0xdd, 0xe2, 0xe4, 0xff, 0xd7, 0xdd, 0xdf, 0xff, 0xdb, 0xe1, 0xe4, 0xff,
-0xdc, 0xe2, 0xe5, 0xff, 0xdc, 0xe2, 0xe4, 0xff, 0xdd, 0xe2, 0xe5, 0xff,
-0xdd, 0xe1, 0xe5, 0xff, 0xdb, 0xe0, 0xe3, 0xff, 0xe0, 0xe6, 0xe9, 0xff,
-0xe1, 0xe7, 0xea, 0xff, 0xdd, 0xe3, 0xe5, 0xff, 0xde, 0xe3, 0xe6, 0xff,
-0xdd, 0xe3, 0xe6, 0xff, 0xe3, 0xe9, 0xeb, 0xff, 0xdd, 0xe3, 0xe5, 0xff,
-0xd9, 0xe0, 0xe3, 0xff, 0xe0, 0xe7, 0xe9, 0xff, 0xdd, 0xe3, 0xe6, 0xff,
-0xd4, 0xd9, 0xdc, 0xff, 0xdd, 0xe3, 0xe5, 0xff, 0xda, 0xe0, 0xe4, 0xff,
-0xd3, 0xd9, 0xdd, 0xff, 0xd5, 0xdc, 0xde, 0xff, 0xd1, 0xd8, 0xdb, 0xff,
-0xd5, 0xdd, 0xe1, 0xff, 0xd5, 0xde, 0xe2, 0xff, 0xd1, 0xda, 0xdf, 0xff,
-0xcb, 0xd5, 0xd9, 0xff, 0xc5, 0xd0, 0xd4, 0xff, 0xba, 0xc7, 0xcb, 0xff,
-0xbb, 0xc7, 0xcd, 0xff, 0xb8, 0xc4, 0xcb, 0xff, 0xb1, 0xbd, 0xc2, 0xff,
-0xb0, 0xbe, 0xc5, 0xff, 0xa3, 0xb4, 0xbc, 0xff, 0xa0, 0xb3, 0xbd, 0xff,
-0x8a, 0xa0, 0xaa, 0xff, 0x74, 0x8d, 0x97, 0xff, 0x5a, 0x77, 0x82, 0xff,
-0x44, 0x63, 0x6e, 0xff, 0x49, 0x63, 0x6c, 0xf4, 0x65, 0x75, 0x7b, 0xcf,
-0x93, 0x97, 0x9b, 0x8f, 0xbf, 0xc0, 0xc0, 0x43, 0xe1, 0xe1, 0xe1, 0x0d,
-0xf6, 0xf5, 0xf5, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x2d, 0xeb, 0xf1, 0xf4, 0xd4,
-0xdc, 0xe2, 0xe6, 0xff, 0xf2, 0xf4, 0xf6, 0xff, 0xd6, 0xdf, 0xe2, 0xff,
-0x90, 0x94, 0x98, 0xff, 0x69, 0x6a, 0x6b, 0xff, 0x6e, 0x70, 0x74, 0xff,
-0x6a, 0x6d, 0x70, 0xff, 0x5e, 0x5e, 0x60, 0xff, 0x4f, 0x4b, 0x47, 0xff,
-0x64, 0x63, 0x62, 0xff, 0xa9, 0xb2, 0xb7, 0xff, 0x97, 0xa2, 0xa7, 0xff,
-0x69, 0x77, 0x7e, 0xff, 0x8f, 0x95, 0x99, 0xbe, 0xe0, 0xe0, 0xe0, 0x20,
-0xfc, 0xfb, 0xfc, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfb, 0xfd, 0xfe, 0x50, 0xdd, 0xe5, 0xe8, 0xec, 0xcc, 0xd3, 0xd6, 0xff,
-0xc1, 0xc9, 0xcd, 0xff, 0xa0, 0xa5, 0xa7, 0xff, 0x57, 0x55, 0x54, 0xff,
-0x9b, 0xa1, 0xa6, 0xff, 0x95, 0x9a, 0x9f, 0xff, 0xb0, 0xb6, 0xba, 0xff,
-0xa6, 0xab, 0xaf, 0xff, 0x9c, 0xa0, 0xa3, 0xff, 0xa1, 0xa7, 0xaa, 0xff,
-0xaf, 0xb7, 0xba, 0xff, 0xb8, 0xc0, 0xc3, 0xff, 0xbb, 0xc2, 0xc5, 0xff,
-0xbd, 0xc5, 0xc8, 0xff, 0xbf, 0xc8, 0xcc, 0xff, 0xc2, 0xcb, 0xd0, 0xff,
-0xc2, 0xca, 0xce, 0xff, 0xb8, 0xbf, 0xc2, 0xff, 0xa9, 0xad, 0xb0, 0xff,
-0xaf, 0xb5, 0xb8, 0xff, 0xa6, 0xac, 0xad, 0xff, 0xa3, 0xa8, 0xab, 0xff,
-0xb1, 0xb8, 0xbc, 0xff, 0xb7, 0xc0, 0xc3, 0xff, 0xb5, 0xbc, 0xc1, 0xff,
-0x9b, 0xa0, 0xa4, 0xff, 0xa0, 0xa6, 0xa9, 0xff, 0xad, 0xb6, 0xba, 0xff,
-0xb4, 0xbc, 0xc0, 0xff, 0xb5, 0xbe, 0xc2, 0xff, 0xaf, 0xb8, 0xbc, 0xff,
-0xa7, 0xaf, 0xb4, 0xff, 0x96, 0x9b, 0x9f, 0xff, 0x8d, 0x92, 0x95, 0xff,
-0x93, 0x99, 0x9e, 0xff, 0x8e, 0x95, 0x9a, 0xff, 0x94, 0x9c, 0xa1, 0xff,
-0x9f, 0xa9, 0xad, 0xff, 0xa8, 0xb0, 0xb6, 0xff, 0x9c, 0xa5, 0xab, 0xff,
-0x9a, 0xa5, 0xab, 0xff, 0x92, 0x9d, 0xa4, 0xff, 0x87, 0x93, 0x9a, 0xff,
-0x8e, 0x9c, 0xa3, 0xff, 0x72, 0x7f, 0x86, 0xff, 0x6d, 0x7e, 0x86, 0xff,
-0x5b, 0x6f, 0x78, 0xff, 0x56, 0x6b, 0x74, 0xff, 0x4d, 0x62, 0x6a, 0xfe,
-0x55, 0x67, 0x6d, 0xed, 0x6b, 0x77, 0x7d, 0xcd, 0x8b, 0x91, 0x94, 0x9e,
-0xae, 0xaf, 0xb1, 0x65, 0xcd, 0xcd, 0xcd, 0x2f, 0xe5, 0xe5, 0xe5, 0x09,
-0xf4, 0xf4, 0xf3, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfd, 0xfe, 0xfe, 0x57, 0xe1, 0xe7, 0xea, 0xfb, 0xde, 0xe0, 0xe3, 0xff,
-0xe0, 0xe3, 0xe6, 0xff, 0x93, 0x95, 0x96, 0xff, 0x30, 0x2b, 0x28, 0xff,
-0x5e, 0x5f, 0x60, 0xff, 0x62, 0x64, 0x66, 0xff, 0x46, 0x44, 0x43, 0xff,
-0x31, 0x2a, 0x25, 0xff, 0x46, 0x42, 0x3f, 0xff, 0x7d, 0x7d, 0x7f, 0xff,
-0xb8, 0xbf, 0xc2, 0xff, 0x8a, 0x91, 0x95, 0xff, 0x73, 0x7b, 0x7f, 0xfc,
-0xba, 0xbb, 0xbd, 0x80, 0xf2, 0xf2, 0xf2, 0x03, 0xfe, 0xfe, 0xfe, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xfc, 0xfd, 0x50,
-0xe2, 0xe6, 0xea, 0xec, 0xcc, 0xd0, 0xd2, 0xff, 0xcc, 0xd2, 0xd5, 0xff,
-0x5a, 0x59, 0x5a, 0xff, 0x14, 0x0b, 0x05, 0xff, 0x62, 0x61, 0x61, 0xff,
-0x5e, 0x5e, 0x5e, 0xff, 0x5d, 0x5c, 0x5c, 0xff, 0x39, 0x35, 0x32, 0xff,
-0x43, 0x3f, 0x3c, 0xff, 0x4b, 0x49, 0x47, 0xff, 0x49, 0x46, 0x46, 0xff,
-0x62, 0x62, 0x62, 0xff, 0x5c, 0x5b, 0x5c, 0xff, 0x72, 0x74, 0x77, 0xff,
-0x83, 0x85, 0x86, 0xff, 0x73, 0x75, 0x77, 0xff, 0x6e, 0x6e, 0x70, 0xff,
-0x57, 0x56, 0x56, 0xff, 0x4e, 0x4b, 0x48, 0xff, 0x41, 0x3e, 0x3c, 0xff,
-0x52, 0x4f, 0x4d, 0xff, 0x65, 0x63, 0x62, 0xff, 0x66, 0x66, 0x67, 0xff,
-0x75, 0x77, 0x79, 0xff, 0x8f, 0x92, 0x96, 0xff, 0x6e, 0x70, 0x72, 0xff,
-0x7f, 0x82, 0x84, 0xff, 0x87, 0x8b, 0x8e, 0xff, 0x88, 0x8c, 0x8e, 0xff,
-0x92, 0x98, 0x9c, 0xff, 0x9d, 0xa2, 0xa6, 0xff, 0xa1, 0xa6, 0xaa, 0xff,
-0x84, 0x88, 0x8a, 0xff, 0x87, 0x8c, 0x8f, 0xff, 0x8e, 0x95, 0x99, 0xff,
-0x79, 0x80, 0x84, 0xff, 0x87, 0x8f, 0x94, 0xff, 0x83, 0x8d, 0x92, 0xff,
-0x80, 0x8b, 0x90, 0xff, 0x79, 0x85, 0x8b, 0xff, 0x65, 0x72, 0x79, 0xff,
-0x5f, 0x6b, 0x72, 0xff, 0x5f, 0x6d, 0x73, 0xff, 0x5d, 0x6a, 0x70, 0xfd,
-0x62, 0x6d, 0x73, 0xf3, 0x68, 0x72, 0x76, 0xe1, 0x76, 0x7e, 0x82, 0xc7,
-0x8a, 0x90, 0x93, 0xa5, 0xa4, 0xa6, 0xa8, 0x7b, 0xbc, 0xbd, 0xbd, 0x50,
-0xd3, 0xd2, 0xd2, 0x29, 0xe4, 0xe3, 0xe3, 0x0c, 0xf1, 0xf0, 0xf0, 0x00,
-0xf9, 0xf9, 0xf9, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xfb, 0xfc, 0x74,
-0xd9, 0xdd, 0xe0, 0xff, 0xdb, 0xdc, 0xde, 0xff, 0xbe, 0xc0, 0xc2, 0xff,
-0x54, 0x53, 0x52, 0xff, 0x46, 0x46, 0x44, 0xff, 0x52, 0x54, 0x53, 0xff,
-0x54, 0x54, 0x54, 0xff, 0x55, 0x56, 0x55, 0xff, 0x56, 0x55, 0x53, 0xff,
-0x47, 0x45, 0x44, 0xff, 0x63, 0x63, 0x63, 0xff, 0xa6, 0xa9, 0xac, 0xff,
-0x85, 0x8b, 0x8f, 0xff, 0x88, 0x8c, 0x8f, 0xee, 0xd4, 0xd5, 0xd5, 0x52,
-0xfa, 0xfa, 0xf9, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfc, 0xfd, 0xfd, 0x50, 0xe3, 0xe6, 0xe9, 0xec,
-0xd1, 0xd4, 0xd6, 0xff, 0xd3, 0xd7, 0xd9, 0xff, 0x61, 0x61, 0x62, 0xff,
-0x33, 0x33, 0x31, 0xff, 0x4c, 0x4b, 0x47, 0xff, 0x56, 0x57, 0x56, 0xff,
-0x44, 0x44, 0x43, 0xff, 0x55, 0x55, 0x54, 0xff, 0x8f, 0x91, 0x93, 0xff,
-0x88, 0x8b, 0x8d, 0xff, 0x90, 0x93, 0x95, 0xff, 0x6c, 0x6d, 0x6f, 0xff,
-0x4b, 0x4d, 0x4e, 0xff, 0x55, 0x58, 0x5a, 0xff, 0x5b, 0x5b, 0x5c, 0xff,
-0x5b, 0x5d, 0x5d, 0xff, 0x72, 0x74, 0x74, 0xff, 0x8b, 0x8f, 0x92, 0xff,
-0x79, 0x7c, 0x7d, 0xff, 0x73, 0x77, 0x7a, 0xff, 0x7a, 0x7f, 0x82, 0xff,
-0x9b, 0xa1, 0xa4, 0xff, 0x8e, 0x94, 0x97, 0xff, 0x86, 0x8b, 0x8e, 0xff,
-0x94, 0x99, 0x9d, 0xff, 0x91, 0x97, 0x9a, 0xff, 0x8c, 0x92, 0x95, 0xff,
-0x8a, 0x90, 0x94, 0xff, 0x85, 0x8b, 0x8f, 0xff, 0x76, 0x7b, 0x7f, 0xff,
-0x74, 0x7a, 0x7e, 0xff, 0x72, 0x78, 0x7d, 0xff, 0x74, 0x7d, 0x80, 0xff,
-0x69, 0x73, 0x77, 0xff, 0x62, 0x6b, 0x70, 0xff, 0x58, 0x61, 0x66, 0xff,
-0x60, 0x69, 0x6f, 0xff, 0x63, 0x6b, 0x70, 0xf9, 0x67, 0x6f, 0x73, 0xf0,
-0x6e, 0x75, 0x79, 0xe2, 0x78, 0x7f, 0x82, 0xd0, 0x85, 0x8a, 0x8c, 0xb9,
-0x94, 0x98, 0x99, 0x9e, 0xa5, 0xa7, 0xa8, 0x80, 0xb7, 0xb8, 0xb8, 0x5f,
-0xc7, 0xc7, 0xc7, 0x3f, 0xd7, 0xd6, 0xd6, 0x23, 0xe4, 0xe3, 0xe3, 0x0e,
-0xee, 0xed, 0xed, 0x01, 0xf5, 0xf5, 0xf5, 0x00, 0xfa, 0xfa, 0xfa, 0x00,
-0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xf6, 0xf7, 0xf8, 0x82, 0xd7, 0xda, 0xdc, 0xff,
-0xe0, 0xe0, 0xe1, 0xff, 0xbe, 0xbf, 0xbf, 0xff, 0xac, 0xad, 0xad, 0xff,
-0xb6, 0xb8, 0xb8, 0xff, 0xad, 0xae, 0xae, 0xff, 0xb0, 0xb0, 0xb0, 0xff,
-0xb2, 0xb2, 0xb2, 0xff, 0xb4, 0xb5, 0xb5, 0xff, 0xae, 0xaf, 0xaf, 0xff,
-0xab, 0xac, 0xab, 0xff, 0xb2, 0xb4, 0xb5, 0xff, 0x8a, 0x8e, 0x91, 0xff,
-0x9a, 0x9c, 0x9e, 0xdd, 0xe2, 0xe2, 0xe2, 0x39, 0xfc, 0xfc, 0xfc, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfd, 0xfd, 0xfe, 0x50, 0xe4, 0xe7, 0xe9, 0xec, 0xcc, 0xce, 0xd0, 0xff,
-0xcf, 0xd0, 0xd1, 0xff, 0xb0, 0xb1, 0xb1, 0xff, 0xab, 0xac, 0xab, 0xff,
-0xb2, 0xb4, 0xb3, 0xff, 0xb2, 0xb3, 0xb2, 0xff, 0xab, 0xad, 0xad, 0xff,
-0xaf, 0xb1, 0xb2, 0xff, 0xb8, 0xba, 0xba, 0xff, 0x9b, 0x9e, 0xa0, 0xff,
-0x8a, 0x8e, 0x90, 0xff, 0x80, 0x84, 0x87, 0xff, 0x72, 0x77, 0x7a, 0xff,
-0x4f, 0x54, 0x57, 0xff, 0x66, 0x6b, 0x6d, 0xff, 0x75, 0x7a, 0x7d, 0xff,
-0x7a, 0x80, 0x84, 0xff, 0x77, 0x7c, 0x80, 0xff, 0x73, 0x79, 0x7d, 0xff,
-0x72, 0x78, 0x7c, 0xff, 0x72, 0x76, 0x7a, 0xff, 0x6b, 0x71, 0x74, 0xff,
-0x6e, 0x73, 0x77, 0xff, 0x6b, 0x71, 0x75, 0xff, 0x68, 0x6e, 0x72, 0xff,
-0x68, 0x6e, 0x72, 0xfe, 0x68, 0x6e, 0x71, 0xfb, 0x69, 0x6e, 0x71, 0xf8,
-0x6d, 0x72, 0x76, 0xf3, 0x71, 0x75, 0x79, 0xec, 0x76, 0x7a, 0x7c, 0xe4,
-0x79, 0x7d, 0x80, 0xd9, 0x80, 0x84, 0x86, 0xcc, 0x88, 0x8b, 0x8e, 0xbd,
-0x92, 0x95, 0x96, 0xad, 0x9d, 0x9f, 0xa0, 0x9a, 0xa5, 0xa7, 0xa9, 0x86,
-0xb1, 0xb2, 0xb3, 0x6f, 0xbd, 0xbd, 0xbe, 0x58, 0xc8, 0xc8, 0xc9, 0x41,
-0xd4, 0xd3, 0xd4, 0x2b, 0xdd, 0xdd, 0xdd, 0x1a, 0xe6, 0xe6, 0xe6, 0x0b,
-0xed, 0xed, 0xec, 0x02, 0xf3, 0xf3, 0xf3, 0x00, 0xf7, 0xf7, 0xf7, 0x00,
-0xfb, 0xfb, 0xfb, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xf4, 0xf5, 0xf6, 0x86, 0xda, 0xdb, 0xdb, 0xff, 0xc7, 0xc7, 0xc5, 0xff,
-0xad, 0xaa, 0xa0, 0xff, 0xac, 0xa5, 0x8f, 0xff, 0xae, 0xa6, 0x8d, 0xff,
-0xad, 0xa5, 0x8c, 0xff, 0xab, 0xa3, 0x8a, 0xff, 0xac, 0xa4, 0x8b, 0xff,
-0xad, 0xa5, 0x8c, 0xff, 0xaa, 0xa4, 0x8e, 0xff, 0xa6, 0xa1, 0x98, 0xff,
-0xa4, 0xa4, 0xa1, 0xff, 0x91, 0x94, 0x93, 0xff, 0xa9, 0xaa, 0xab, 0xd5,
-0xe9, 0xea, 0xea, 0x2f, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfd, 0xfd, 0x50,
-0xe9, 0xea, 0xea, 0xec, 0xd5, 0xd5, 0xd5, 0xff, 0xbd, 0xbc, 0xb7, 0xff,
-0xa8, 0xa3, 0x96, 0xff, 0xad, 0xa6, 0x90, 0xff, 0xac, 0xa4, 0x8c, 0xff,
-0xac, 0xa6, 0x8c, 0xff, 0xab, 0xa5, 0x8e, 0xff, 0xa9, 0xa4, 0x96, 0xff,
-0xa5, 0xa4, 0x9e, 0xff, 0x9e, 0x9e, 0x9c, 0xff, 0x88, 0x8a, 0x8a, 0xff,
-0x87, 0x89, 0x8b, 0xfe, 0x8a, 0x8c, 0x8f, 0xf1, 0x8c, 0x8f, 0x91, 0xd9,
-0x89, 0x8c, 0x8e, 0xc9, 0x88, 0x8b, 0x8d, 0xc6, 0x89, 0x8b, 0x8d, 0xc6,
-0x8b, 0x8d, 0x8f, 0xc2, 0x8e, 0x8f, 0x92, 0xbd, 0x91, 0x93, 0x94, 0xb8,
-0x94, 0x96, 0x97, 0xb1, 0x97, 0x9a, 0x9b, 0xaa, 0x9b, 0x9c, 0x9e, 0xa1,
-0x9f, 0xa1, 0xa2, 0x98, 0xa6, 0xa7, 0xa8, 0x8d, 0xab, 0xab, 0xad, 0x83,
-0xb1, 0xb1, 0xb2, 0x77, 0xb7, 0xb8, 0xb9, 0x6b, 0xbd, 0xbe, 0xbf, 0x5d,
-0xc4, 0xc4, 0xc4, 0x4f, 0xca, 0xca, 0xca, 0x42, 0xd1, 0xd1, 0xd1, 0x34,
-0xd7, 0xd7, 0xd7, 0x27, 0xde, 0xde, 0xdd, 0x1b, 0xe4, 0xe4, 0xe3, 0x11,
-0xe8, 0xe8, 0xe8, 0x09, 0xed, 0xec, 0xed, 0x03, 0xf1, 0xf1, 0xf1, 0x00,
-0xf6, 0xf5, 0xf5, 0x00, 0xf8, 0xf8, 0xf8, 0x00, 0xfb, 0xfb, 0xfb, 0x00,
-0xfd, 0xfc, 0xfd, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf4, 0xf4, 0xf4, 0x86,
-0xcd, 0xcd, 0xcb, 0xff, 0xc8, 0xc1, 0xae, 0xff, 0xb3, 0xa1, 0x59, 0xff,
-0xa4, 0x8b, 0x22, 0xff, 0xa4, 0x88, 0x1a, 0xff, 0xa5, 0x8a, 0x1b, 0xff,
-0xa4, 0x89, 0x1c, 0xff, 0xa2, 0x88, 0x19, 0xff, 0xa2, 0x88, 0x1b, 0xff,
-0xa3, 0x89, 0x20, 0xff, 0xab, 0x96, 0x43, 0xff, 0xa8, 0x9f, 0x7f, 0xff,
-0x8a, 0x88, 0x82, 0xff, 0xad, 0xae, 0xad, 0xd9, 0xec, 0xec, 0xec, 0x33,
-0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x50, 0xe4, 0xe5, 0xe4, 0xec,
-0xcc, 0xca, 0xc3, 0xff, 0xc8, 0xbc, 0x99, 0xff, 0xad, 0x97, 0x3e, 0xff,
-0xa3, 0x8a, 0x20, 0xff, 0xa4, 0x8a, 0x1d, 0xff, 0xa2, 0x88, 0x1c, 0xff,
-0xa4, 0x8a, 0x1f, 0xff, 0xa7, 0x90, 0x2d, 0xff, 0xab, 0x99, 0x52, 0xff,
-0xb7, 0xac, 0x86, 0xff, 0xca, 0xc3, 0xb2, 0xff, 0xc9, 0xc5, 0xba, 0xff,
-0xc6, 0xc5, 0xbe, 0xf8, 0xcf, 0xcf, 0xce, 0xcf, 0xd7, 0xd7, 0xd8, 0x81,
-0xdb, 0xdb, 0xdb, 0x3c, 0xdc, 0xdc, 0xdd, 0x20, 0xde, 0xde, 0xde, 0x1b,
-0xe0, 0xe0, 0xe0, 0x1b, 0xe1, 0xe1, 0xe1, 0x17, 0xe4, 0xe3, 0xe3, 0x14,
-0xe6, 0xe6, 0xe5, 0x0f, 0xe7, 0xe8, 0xe8, 0x0c, 0xea, 0xea, 0xea, 0x08,
-0xed, 0xec, 0xec, 0x05, 0xef, 0xee, 0xee, 0x02, 0xf1, 0xf0, 0xf0, 0x00,
-0xf3, 0xf3, 0xf3, 0x00, 0xf5, 0xf5, 0xf5, 0x00, 0xf7, 0xf7, 0xf7, 0x00,
-0xf8, 0xf8, 0xf8, 0x00, 0xfa, 0xfa, 0xfa, 0x00, 0xfb, 0xfb, 0xfb, 0x00,
-0xfc, 0xfc, 0xfc, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xff, 0xff, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xf2, 0xf3, 0xf2, 0x81, 0xcf, 0xca, 0xbd, 0xff,
-0xcd, 0xba, 0x79, 0xff, 0xa5, 0x84, 0x02, 0xff, 0x9b, 0x73, 0x00, 0xff,
-0x9c, 0x75, 0x00, 0xff, 0x9d, 0x76, 0x00, 0xff, 0x9b, 0x75, 0x00, 0xff,
-0x9b, 0x73, 0x00, 0xff, 0x9a, 0x72, 0x00, 0xff, 0x99, 0x71, 0x00, 0xff,
-0x9d, 0x7a, 0x00, 0xff, 0xa4, 0x8e, 0x22, 0xff, 0x97, 0x8b, 0x60, 0xff,
-0xaa, 0xa8, 0xa2, 0xe7, 0xeb, 0xeb, 0xeb, 0x49, 0xfe, 0xfe, 0xfe, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfd, 0xfd, 0xfd, 0x50, 0xe3, 0xe1, 0xdb, 0xec, 0xdb, 0xcf, 0xaf, 0xff,
-0xc2, 0xa8, 0x3f, 0xff, 0xa0, 0x7d, 0x00, 0xff, 0x9a, 0x74, 0x00, 0xff,
-0x9b, 0x74, 0x00, 0xff, 0x9b, 0x73, 0x00, 0xff, 0x9d, 0x75, 0x00, 0xff,
-0x9a, 0x74, 0x00, 0xff, 0x9f, 0x7c, 0x00, 0xff, 0xaa, 0x8d, 0x13, 0xff,
-0xc0, 0xa8, 0x45, 0xff, 0xd8, 0xc5, 0x82, 0xff, 0xdd, 0xce, 0xa3, 0xff,
-0xd4, 0xca, 0xb1, 0xff, 0xdc, 0xd7, 0xce, 0xe8, 0xef, 0xee, 0xf0, 0xa0,
-0xf9, 0xf9, 0xf9, 0x42, 0xfc, 0xfc, 0xfc, 0x06, 0xfd, 0xfd, 0xfd, 0x00,
-0xfd, 0xfd, 0xfd, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xf4, 0xf4, 0xf5, 0x73, 0xcc, 0xbf, 0x9b, 0xff, 0xc0, 0xa5, 0x28, 0xff,
-0xac, 0x86, 0x00, 0xff, 0xa6, 0x7d, 0x00, 0xff, 0xa6, 0x7f, 0x01, 0xff,
-0xa6, 0x7f, 0x01, 0xff, 0xa8, 0x81, 0x01, 0xff, 0xa6, 0x7e, 0x01, 0xff,
-0xa6, 0x7d, 0x01, 0xff, 0xa6, 0x7d, 0x01, 0xff, 0xa5, 0x7e, 0x01, 0xff,
-0xa3, 0x81, 0x00, 0xff, 0x98, 0x7f, 0x09, 0xff, 0x9f, 0x94, 0x6b, 0xfa,
-0xe2, 0xe1, 0xe2, 0x78, 0xfd, 0xfd, 0xfd, 0x01, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfb, 0xfb, 0xfc, 0x50,
-0xde, 0xd7, 0xc5, 0xec, 0xd0, 0xb7, 0x51, 0xff, 0xbb, 0x98, 0x03, 0xff,
-0xa5, 0x7d, 0x00, 0xff, 0xa6, 0x7e, 0x01, 0xff, 0xa6, 0x7e, 0x00, 0xff,
-0xa6, 0x7d, 0x01, 0xff, 0xa7, 0x7f, 0x01, 0xff, 0xa5, 0x7d, 0x01, 0xff,
-0xa4, 0x7d, 0x00, 0xff, 0xa3, 0x7d, 0x00, 0xff, 0xa6, 0x83, 0x00, 0xff,
-0xb2, 0x91, 0x03, 0xff, 0xc7, 0xaa, 0x26, 0xff, 0xd5, 0xbc, 0x4c, 0xff,
-0xd3, 0xbc, 0x65, 0xff, 0xd0, 0xc0, 0x81, 0xff, 0xe0, 0xd9, 0xc5, 0xdf,
-0xf4, 0xf2, 0xf1, 0x8d, 0xfd, 0xfd, 0xfc, 0x32, 0xff, 0xff, 0xff, 0x03,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf7, 0xf7, 0xfa, 0x59,
-0xc6, 0xb8, 0x84, 0xfc, 0xb8, 0x95, 0x00, 0xff, 0xb3, 0x8e, 0x00, 0xff,
-0xb0, 0x88, 0x01, 0xff, 0xb1, 0x8b, 0x01, 0xff, 0xb1, 0x89, 0x01, 0xff,
-0xab, 0x86, 0x01, 0xff, 0xb0, 0x89, 0x01, 0xff, 0xb2, 0x8b, 0x01, 0xff,
-0xb2, 0x8b, 0x01, 0xff, 0xb1, 0x89, 0x01, 0xff, 0xad, 0x87, 0x01, 0xff,
-0xa0, 0x7d, 0x00, 0xff, 0x97, 0x7d, 0x21, 0xff, 0xcf, 0xca, 0xbd, 0xba,
-0xf9, 0xf9, 0xf9, 0x1f, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfb, 0xfa, 0xfc, 0x50, 0xd8, 0xcc, 0xa5, 0xec,
-0xcd, 0xaa, 0x00, 0xff, 0xc1, 0x9b, 0x00, 0xff, 0xb0, 0x89, 0x00, 0xff,
-0xaf, 0x88, 0x01, 0xff, 0xb0, 0x89, 0x01, 0xff, 0xb0, 0x89, 0x01, 0xff,
-0xaf, 0x88, 0x01, 0xff, 0xb1, 0x8a, 0x01, 0xff, 0xb3, 0x8c, 0x01, 0xff,
-0xb2, 0x8b, 0x00, 0xff, 0xb1, 0x8b, 0x01, 0xff, 0xaf, 0x89, 0x00, 0xff,
-0xb2, 0x8e, 0x00, 0xff, 0xbd, 0x9a, 0x00, 0xff, 0xcb, 0xab, 0x06, 0xff,
-0xd1, 0xb0, 0x00, 0xff, 0xcb, 0xac, 0x1e, 0xff, 0xd0, 0xbc, 0x7a, 0xfd,
-0xe5, 0xde, 0xd0, 0xcc, 0xf7, 0xf6, 0xf4, 0x71, 0xfe, 0xfe, 0xfd, 0x23,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfb, 0xfb, 0xfc, 0x33, 0xd3, 0xc9, 0xaf, 0xdd,
-0xb1, 0x8d, 0x0d, 0xff, 0xbd, 0x95, 0x00, 0xff, 0xb9, 0x92, 0x01, 0xff,
-0xb2, 0x8d, 0x01, 0xff, 0xb0, 0x8b, 0x01, 0xff, 0xa3, 0x83, 0x01, 0xff,
-0xaf, 0x8c, 0x01, 0xff, 0xb1, 0x8c, 0x01, 0xff, 0xb4, 0x8f, 0x01, 0xff,
-0xaf, 0x8b, 0x01, 0xff, 0xb4, 0x8e, 0x01, 0xff, 0xb0, 0x8b, 0x00, 0xff,
-0xa4, 0x7f, 0x00, 0xff, 0xb8, 0xa7, 0x72, 0xf2, 0xee, 0xec, 0xeb, 0x6e,
-0xfe, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfa, 0xf9, 0xfa, 0x50, 0xd9, 0xca, 0x9c, 0xec, 0xd5, 0xae, 0x00, 0xff,
-0xcf, 0xa6, 0x00, 0xff, 0xb8, 0x94, 0x01, 0xff, 0xb7, 0x92, 0x01, 0xff,
-0xb9, 0x94, 0x01, 0xff, 0xb9, 0x94, 0x01, 0xff, 0xb7, 0x93, 0x01, 0xff,
-0xb3, 0x8e, 0x01, 0xff, 0xaf, 0x8c, 0x01, 0xff, 0xa6, 0x86, 0x01, 0xff,
-0xaa, 0x89, 0x01, 0xff, 0xb2, 0x8f, 0x01, 0xff, 0xb7, 0x93, 0x01, 0xff,
-0xbc, 0x97, 0x00, 0xff, 0xbf, 0x9b, 0x00, 0xff, 0xca, 0xa5, 0x00, 0xff,
-0xd8, 0xaf, 0x00, 0xff, 0xd8, 0xaf, 0x00, 0xff, 0xce, 0xae, 0x2e, 0xff,
-0xd7, 0xc6, 0x91, 0xf5, 0xed, 0xe6, 0xdc, 0xb9, 0xfa, 0xf9, 0xf8, 0x5e,
-0xfe, 0xff, 0xfe, 0x17, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xff, 0xfe, 0x0e, 0xe7, 0xe4, 0xdc, 0x9c, 0xb8, 0x9d, 0x47, 0xff,
-0xba, 0x91, 0x00, 0xff, 0xbf, 0x9a, 0x01, 0xff, 0xb9, 0x96, 0x01, 0xff,
-0xb9, 0x97, 0x01, 0xff, 0xb8, 0x97, 0x01, 0xff, 0xb6, 0x94, 0x01, 0xff,
-0xb4, 0x92, 0x01, 0xff, 0xb7, 0x95, 0x01, 0xff, 0xb2, 0x91, 0x01, 0xff,
-0xb1, 0x8f, 0x01, 0xff, 0xbb, 0x97, 0x01, 0xff, 0xbc, 0x96, 0x00, 0xff,
-0xb4, 0x94, 0x1a, 0xff, 0xd6, 0xcc, 0xb1, 0xd6, 0xf7, 0xf7, 0xf6, 0x49,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfa, 0xfa, 0xfa, 0x50,
-0xde, 0xce, 0x9b, 0xec, 0xde, 0xb7, 0x01, 0xff, 0xd1, 0xad, 0x00, 0xff,
-0xbb, 0x9a, 0x01, 0xff, 0xbe, 0x9b, 0x01, 0xff, 0xbc, 0x9b, 0x01, 0xff,
-0xb6, 0x96, 0x01, 0xff, 0xba, 0x98, 0x00, 0xff, 0xac, 0x8c, 0x00, 0xff,
-0x91, 0x7a, 0x01, 0xff, 0x93, 0x7d, 0x01, 0xff, 0x9a, 0x82, 0x01, 0xff,
-0x96, 0x7f, 0x01, 0xff, 0x99, 0x81, 0x01, 0xff, 0x9f, 0x85, 0x01, 0xff,
-0xab, 0x8e, 0x01, 0xff, 0xbd, 0x9c, 0x01, 0xff, 0xc6, 0xa2, 0x01, 0xff,
-0xd5, 0xb0, 0x00, 0xff, 0xe1, 0xb8, 0x00, 0xff, 0xdc, 0xb5, 0x01, 0xff,
-0xd6, 0xba, 0x40, 0xff, 0xdf, 0xd0, 0xa0, 0xee, 0xf1, 0xec, 0xe2, 0xac,
-0xfb, 0xfa, 0xf8, 0x53, 0xff, 0xff, 0xfe, 0x13, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xf6, 0xf6, 0xf5, 0x49, 0xcf, 0xc3, 0x9e, 0xe1, 0xb7, 0x92, 0x09, 0xff,
-0xc1, 0x9d, 0x00, 0xff, 0xbb, 0x9c, 0x01, 0xff, 0xc1, 0xa2, 0x01, 0xff,
-0xc1, 0xa2, 0x01, 0xff, 0xbe, 0x9f, 0x01, 0xff, 0xc2, 0xa3, 0x01, 0xff,
-0xc2, 0xa3, 0x01, 0xff, 0xbe, 0x9e, 0x01, 0xff, 0xbc, 0x9c, 0x01, 0xff,
-0xbc, 0x9c, 0x01, 0xff, 0xc2, 0xa0, 0x00, 0xff, 0xc7, 0xa2, 0x00, 0xff,
-0xc4, 0xa9, 0x3e, 0xff, 0xe4, 0xdd, 0xcb, 0xc6, 0xfb, 0xf9, 0xf7, 0x43,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfb, 0xfb, 0xfa, 0x4f, 0xe2, 0xd2, 0x9c, 0xec,
-0xde, 0xbd, 0x01, 0xff, 0xd0, 0xb0, 0x00, 0xff, 0xbd, 0x9f, 0x01, 0xff,
-0xbe, 0x9f, 0x01, 0xff, 0xb7, 0x9a, 0x01, 0xff, 0xaf, 0x93, 0x01, 0xff,
-0xbc, 0x9c, 0x01, 0xff, 0xbd, 0x9e, 0x01, 0xff, 0x9d, 0x84, 0x01, 0xff,
-0x9b, 0x83, 0x01, 0xff, 0x90, 0x7c, 0x01, 0xff, 0x83, 0x72, 0x01, 0xff,
-0x9a, 0x84, 0x01, 0xff, 0x91, 0x7e, 0x01, 0xff, 0x96, 0x81, 0x01, 0xff,
-0xa8, 0x8e, 0x01, 0xff, 0xb7, 0x9a, 0x01, 0xff, 0xbe, 0xa0, 0x01, 0xff,
-0xcb, 0xab, 0x01, 0xff, 0xde, 0xbc, 0x00, 0xff, 0xe5, 0xc3, 0x00, 0xff,
-0xd9, 0xbb, 0x07, 0xff, 0xd7, 0xc0, 0x4e, 0xff, 0xe5, 0xd8, 0xaf, 0xe9,
-0xf5, 0xef, 0xe8, 0xa1, 0xfc, 0xfb, 0xf9, 0x48, 0xfe, 0xff, 0xff, 0x0d,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfd, 0xfd, 0x0d,
-0xea, 0xe6, 0xdf, 0x8d, 0xbd, 0xa7, 0x59, 0xfc, 0xb4, 0x91, 0x00, 0xff,
-0xbd, 0x9f, 0x00, 0xff, 0xc2, 0xa6, 0x01, 0xff, 0xc1, 0xa5, 0x01, 0xff,
-0xc1, 0xa6, 0x01, 0xff, 0xc2, 0xa7, 0x00, 0xff, 0xc0, 0xa5, 0x01, 0xff,
-0xbe, 0xa3, 0x01, 0xff, 0xbf, 0xa3, 0x01, 0xff, 0xbe, 0xa3, 0x01, 0xff,
-0xbb, 0x9f, 0x01, 0xff, 0xca, 0xac, 0x00, 0xff, 0xcf, 0xae, 0x00, 0xff,
-0xce, 0xb6, 0x4d, 0xff, 0xe9, 0xe0, 0xce, 0xcb, 0xfa, 0xf9, 0xf6, 0x55,
-0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfb, 0xfb, 0xfa, 0x51, 0xe4, 0xd5, 0x9d, 0xee, 0xdc, 0xc1, 0x01, 0xff,
-0xd5, 0xb7, 0x00, 0xff, 0xbb, 0xa2, 0x01, 0xff, 0xc0, 0xa6, 0x01, 0xff,
-0xc4, 0xa8, 0x00, 0xff, 0xc4, 0xa8, 0x01, 0xff, 0xc2, 0xa6, 0x01, 0xff,
-0xb8, 0x9d, 0x01, 0xff, 0xb8, 0x99, 0x01, 0xff, 0x9a, 0x79, 0x01, 0xff,
-0x7f, 0x64, 0x00, 0xff, 0x9e, 0x82, 0x00, 0xff, 0xbd, 0x9d, 0x01, 0xff,
-0xba, 0x9d, 0x01, 0xff, 0xb4, 0x9a, 0x01, 0xff, 0xbc, 0xa0, 0x01, 0xff,
-0xbd, 0xa2, 0x01, 0xff, 0xbf, 0xa3, 0x01, 0xff, 0xbf, 0xa5, 0x01, 0xff,
-0xbf, 0xa5, 0x01, 0xff, 0xd2, 0xb4, 0x01, 0xff, 0xe6, 0xc7, 0x00, 0xff,
-0xe6, 0xc9, 0x00, 0xff, 0xdc, 0xc3, 0x10, 0xff, 0xda, 0xc6, 0x60, 0xff,
-0xe9, 0xdd, 0xbc, 0xe0, 0xf7, 0xf3, 0xed, 0x95, 0xfd, 0xfc, 0xfb, 0x3f,
-0xff, 0xff, 0xff, 0x0a, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf8, 0xf7, 0x2d,
-0xdb, 0xd4, 0xbf, 0xbd, 0xaf, 0x96, 0x2d, 0xff, 0xb6, 0x98, 0x00, 0xff,
-0xc3, 0xa7, 0x01, 0xff, 0xc5, 0xaa, 0x01, 0xff, 0xc0, 0xa8, 0x00, 0xff,
-0xc1, 0xaa, 0x00, 0xff, 0xbe, 0xa8, 0x00, 0xff, 0xb9, 0xa4, 0x00, 0xff,
-0xba, 0xa4, 0x00, 0xff, 0xb9, 0xa5, 0x00, 0xff, 0xb2, 0x9d, 0x00, 0xff,
-0xc2, 0xa9, 0x00, 0xff, 0xd5, 0xb8, 0x00, 0xff, 0xdc, 0xbf, 0x00, 0xff,
-0xd5, 0xbf, 0x3f, 0xff, 0xe6, 0xdc, 0xbc, 0xe0, 0xf8, 0xf5, 0xf1, 0x7f,
-0xfe, 0xfe, 0xfc, 0x22, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xfd, 0x2c, 0xfe, 0xfb, 0xf7, 0x8c,
-0xe5, 0xd7, 0x97, 0xf6, 0xde, 0xc9, 0x00, 0xff, 0xde, 0xc2, 0x00, 0xff,
-0xbe, 0xa7, 0x00, 0xff, 0xbd, 0xa8, 0x00, 0xff, 0xbf, 0xa7, 0x00, 0xff,
-0xc1, 0xa9, 0x00, 0xff, 0xb8, 0xa3, 0x00, 0xff, 0xb9, 0xa0, 0x00, 0xff,
-0xad, 0x93, 0x01, 0xff, 0x7b, 0x56, 0x00, 0xff, 0x72, 0x4f, 0x00, 0xff,
-0x93, 0x73, 0x00, 0xff, 0xac, 0x8c, 0x00, 0xff, 0xa4, 0x8b, 0x00, 0xff,
-0xb0, 0x96, 0x01, 0xff, 0xbc, 0xa2, 0x01, 0xff, 0xc4, 0xab, 0x01, 0xff,
-0xc5, 0xac, 0x01, 0xff, 0xc2, 0xaa, 0x00, 0xff, 0xba, 0xa5, 0x00, 0xff,
-0xb7, 0xa2, 0x00, 0xff, 0xc8, 0xb0, 0x00, 0xff, 0xdb, 0xbf, 0x00, 0xff,
-0xe8, 0xcd, 0x00, 0xff, 0xe5, 0xcf, 0x00, 0xff, 0xdd, 0xc9, 0x1a, 0xff,
-0xdf, 0xcf, 0x6c, 0xff, 0xec, 0xe3, 0xc4, 0xd9, 0xf8, 0xf5, 0xf0, 0x8b,
-0xfe, 0xfd, 0xfc, 0x36, 0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x01, 0xf4, 0xf3, 0xf0, 0x4a,
-0xcf, 0xc5, 0xa5, 0xd4, 0xa9, 0x91, 0x1c, 0xff, 0xb7, 0x9c, 0x00, 0xff,
-0xbf, 0xa7, 0x00, 0xff, 0xbc, 0xa7, 0x04, 0xff, 0xc5, 0xaf, 0x0f, 0xff,
-0xc4, 0xaf, 0x15, 0xff, 0xb9, 0xa6, 0x13, 0xff, 0xb6, 0xa5, 0x13, 0xff,
-0xb8, 0xa7, 0x15, 0xff, 0xb2, 0xa1, 0x0d, 0xff, 0xbf, 0xab, 0x10, 0xff,
-0xcc, 0xb5, 0x0d, 0xff, 0xdb, 0xc3, 0x11, 0xff, 0xe5, 0xcd, 0x14, 0xff,
-0xda, 0xc7, 0x30, 0xff, 0xe0, 0xd2, 0x90, 0xf8, 0xf1, 0xeb, 0xdd, 0xb7,
-0xfc, 0xfa, 0xf7, 0x5c, 0xff, 0xfe, 0xfe, 0x19, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x13, 0xff, 0xfe, 0xfc, 0x43, 0xfe, 0xfa, 0xf6, 0x88,
-0xf7, 0xf0, 0xdd, 0xc5, 0xdc, 0xcb, 0x96, 0xea, 0xd1, 0xbb, 0x49, 0xfe,
-0xe9, 0xd9, 0x16, 0xff, 0xde, 0xc6, 0x17, 0xff, 0xbf, 0xab, 0x13, 0xff,
-0xb7, 0xa6, 0x16, 0xff, 0xb4, 0xa2, 0x10, 0xff, 0xb6, 0xa5, 0x11, 0xff,
-0xbb, 0xa8, 0x10, 0xff, 0xc3, 0xac, 0x02, 0xff, 0xb2, 0x98, 0x00, 0xff,
-0x88, 0x70, 0x05, 0xfe, 0x9a, 0x8e, 0x54, 0xdb, 0x9e, 0x90, 0x56, 0xdf,
-0x8c, 0x75, 0x17, 0xff, 0x8b, 0x70, 0x00, 0xff, 0xa1, 0x86, 0x00, 0xff,
-0xb8, 0x9f, 0x00, 0xff, 0xbf, 0xa9, 0x01, 0xff, 0xb1, 0x9c, 0x01, 0xff,
-0xbe, 0xa9, 0x06, 0xff, 0xc3, 0xae, 0x0e, 0xff, 0xbf, 0xab, 0x14, 0xff,
-0xbb, 0xa9, 0x12, 0xff, 0xc1, 0xad, 0x13, 0xff, 0xce, 0xb7, 0x18, 0xff,
-0xe0, 0xc8, 0x23, 0xff, 0xeb, 0xd5, 0x28, 0xff, 0xe7, 0xd6, 0x24, 0xff,
-0xdf, 0xcf, 0x37, 0xff, 0xe1, 0xd4, 0x80, 0xfd, 0xef, 0xe6, 0xcd, 0xd1,
-0xf9, 0xf6, 0xf1, 0x83, 0xfe, 0xfd, 0xfc, 0x33, 0xff, 0xff, 0xff, 0x06,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfd, 0xfe, 0xfd, 0x05, 0xef, 0xed, 0xea, 0x59,
-0xc6, 0xbc, 0x98, 0xda, 0xa3, 0x8d, 0x1c, 0xff, 0xa9, 0x92, 0x00, 0xff,
-0xb8, 0xa6, 0x0a, 0xff, 0xc9, 0xb5, 0x39, 0xff, 0xc4, 0xb2, 0x48, 0xff,
-0xc0, 0xb0, 0x4d, 0xff, 0xbe, 0xaf, 0x52, 0xff, 0xbc, 0xad, 0x50, 0xff,
-0xb9, 0xaa, 0x4d, 0xff, 0xb8, 0xa9, 0x4a, 0xff, 0xbc, 0xac, 0x47, 0xff,
-0xc2, 0xb1, 0x44, 0xff, 0xd8, 0xc3, 0x52, 0xff, 0xe7, 0xd3, 0x50, 0xff,
-0xe3, 0xd3, 0x48, 0xff, 0xdd, 0xd0, 0x73, 0xff, 0xe7, 0xdf, 0xb7, 0xec,
-0xf5, 0xf0, 0xe3, 0xb0, 0xfc, 0xfa, 0xf6, 0x64, 0xff, 0xfe, 0xfd, 0x27,
-0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c,
-0xff, 0xfe, 0xfd, 0x30, 0xfe, 0xfc, 0xf9, 0x67, 0xfb, 0xf6, 0xeb, 0xa8,
-0xf3, 0xea, 0xc8, 0xdf, 0xe7, 0xd8, 0x83, 0xfc, 0xc8, 0xac, 0x2d, 0xff,
-0xaf, 0x91, 0x24, 0xff, 0xce, 0xbc, 0x60, 0xfe, 0xe8, 0xd7, 0x44, 0xff,
-0xdf, 0xc9, 0x58, 0xff, 0xc3, 0xb3, 0x53, 0xff, 0xb8, 0xaa, 0x52, 0xff,
-0xb6, 0xa8, 0x4c, 0xff, 0xba, 0xab, 0x4e, 0xff, 0xb8, 0xa8, 0x48, 0xff,
-0xc2, 0xaf, 0x2b, 0xff, 0xb7, 0xa0, 0x01, 0xff, 0x93, 0x80, 0x17, 0xff,
-0xbf, 0xba, 0xac, 0x9f, 0xdb, 0xda, 0xd9, 0x4e, 0xc4, 0xc0, 0xac, 0x99,
-0xa1, 0x95, 0x5f, 0xe1, 0x8e, 0x7a, 0x1b, 0xff, 0x94, 0x7c, 0x00, 0xff,
-0xaa, 0x92, 0x00, 0xff, 0xae, 0x98, 0x00, 0xff, 0xb2, 0x9e, 0x09, 0xff,
-0xb0, 0x9d, 0x1e, 0xff, 0xb9, 0xa7, 0x3b, 0xff, 0xc2, 0xb0, 0x4a, 0xff,
-0xb3, 0xa4, 0x45, 0xff, 0xbd, 0xad, 0x4e, 0xff, 0xba, 0xab, 0x47, 0xff,
-0xca, 0xb7, 0x50, 0xff, 0xe1, 0xcc, 0x60, 0xff, 0xeb, 0xdb, 0x61, 0xff,
-0xe8, 0xdd, 0x56, 0xff, 0xdf, 0xd4, 0x65, 0xff, 0xe3, 0xd8, 0x9b, 0xfb,
-0xef, 0xe8, 0xd2, 0xcf, 0xf9, 0xf7, 0xf0, 0x81, 0xfe, 0xfd, 0xfc, 0x33,
-0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfc, 0xfc, 0xfc, 0x06, 0xec, 0xeb, 0xe8, 0x59,
-0xc4, 0xbc, 0x9e, 0xd4, 0x9d, 0x8b, 0x2a, 0xff, 0xa2, 0x8f, 0x00, 0xff,
-0xbc, 0xaa, 0x2d, 0xff, 0xc3, 0xb3, 0x61, 0xff, 0xc5, 0xb5, 0x6b, 0xff,
-0xc3, 0xb6, 0x71, 0xff, 0xc5, 0xb7, 0x75, 0xff, 0xc7, 0xb9, 0x76, 0xff,
-0xc1, 0xb4, 0x73, 0xff, 0xb2, 0xa7, 0x6a, 0xff, 0xb9, 0xad, 0x6b, 0xff,
-0xc9, 0xba, 0x70, 0xff, 0xd4, 0xc3, 0x73, 0xff, 0xe6, 0xd4, 0x7c, 0xff,
-0xec, 0xe2, 0x7c, 0xff, 0xe2, 0xdc, 0x7c, 0xff, 0xe1, 0xd8, 0x95, 0xff,
-0xe8, 0xe0, 0xb9, 0xf2, 0xf2, 0xed, 0xdb, 0xc7, 0xfa, 0xf6, 0xef, 0x8b,
-0xfd, 0xfc, 0xfa, 0x50, 0xff, 0xfe, 0xfe, 0x24, 0xff, 0xff, 0xff, 0x0a,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x14, 0xff, 0xfe, 0xfc, 0x36,
-0xfe, 0xfc, 0xf8, 0x65, 0xfc, 0xf8, 0xee, 0x9d, 0xf5, 0xf0, 0xda, 0xd1,
-0xec, 0xe3, 0xb5, 0xf4, 0xe3, 0xd8, 0x7d, 0xff, 0xdf, 0xd4, 0x2c, 0xff,
-0xd2, 0xbd, 0x00, 0xff, 0xb0, 0x97, 0x17, 0xff, 0xb9, 0xad, 0x84, 0xed,
-0xca, 0xbe, 0x87, 0xf6, 0xe6, 0xd9, 0x6d, 0xff, 0xdf, 0xce, 0x79, 0xff,
-0xc1, 0xb4, 0x6f, 0xff, 0xbd, 0xb1, 0x72, 0xff, 0xbf, 0xb2, 0x73, 0xff,
-0xbf, 0xb2, 0x71, 0xff, 0xb5, 0xa9, 0x67, 0xff, 0xc4, 0xb3, 0x64, 0xff,
-0xb1, 0x9e, 0x18, 0xff, 0x91, 0x81, 0x1e, 0xff, 0xc9, 0xc5, 0xba, 0x94,
-0xf4, 0xf5, 0xf5, 0x04, 0xf4, 0xf4, 0xf4, 0x0d, 0xe2, 0xe2, 0xdf, 0x47,
-0xc5, 0xc1, 0xb2, 0x96, 0xa2, 0x99, 0x6b, 0xda, 0x8c, 0x7b, 0x27, 0xfd,
-0x8c, 0x78, 0x01, 0xff, 0xa2, 0x8d, 0x00, 0xff, 0xac, 0x9a, 0x0e, 0xff,
-0xad, 0x9e, 0x35, 0xff, 0xb1, 0xa1, 0x50, 0xff, 0xa2, 0x96, 0x50, 0xff,
-0xc0, 0xb1, 0x6a, 0xff, 0xc2, 0xb3, 0x6c, 0xff, 0xb9, 0xad, 0x6a, 0xff,
-0xc3, 0xb5, 0x6f, 0xff, 0xd2, 0xc2, 0x75, 0xff, 0xe4, 0xd3, 0x81, 0xff,
-0xeb, 0xe0, 0x80, 0xff, 0xe6, 0xde, 0x78, 0xff, 0xdf, 0xd6, 0x81, 0xff,
-0xe3, 0xd9, 0xa8, 0xfb, 0xef, 0xe9, 0xd5, 0xcf, 0xf9, 0xf7, 0xf0, 0x82,
-0xfe, 0xfd, 0xfc, 0x35, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfb, 0xfc, 0xfc, 0x05, 0xed, 0xec, 0xea, 0x4a,
-0xc9, 0xc3, 0xb1, 0xbf, 0x9d, 0x90, 0x48, 0xfd, 0x96, 0x86, 0x09, 0xff,
-0xb0, 0xa0, 0x3b, 0xff, 0xc2, 0xb4, 0x6f, 0xff, 0xc2, 0xb6, 0x7a, 0xff,
-0xc2, 0xb7, 0x80, 0xff, 0xbd, 0xb1, 0x7e, 0xff, 0xc2, 0xb7, 0x84, 0xff,
-0xc3, 0xb7, 0x85, 0xff, 0xba, 0xb0, 0x7f, 0xff, 0xb8, 0xad, 0x7c, 0xff,
-0xc4, 0xb8, 0x83, 0xff, 0xcb, 0xbf, 0x86, 0xff, 0xdb, 0xcd, 0x90, 0xff,
-0xed, 0xe2, 0x9c, 0xff, 0xed, 0xe7, 0x9c, 0xff, 0xe6, 0xe1, 0x98, 0xff,
-0xe1, 0xda, 0x9e, 0xff, 0xe5, 0xde, 0xb1, 0xfe, 0xec, 0xe5, 0xc9, 0xea,
-0xf3, 0xef, 0xdf, 0xc6, 0xf9, 0xf7, 0xee, 0x99, 0xfc, 0xfb, 0xf6, 0x6b,
-0xfe, 0xfd, 0xfb, 0x44, 0xff, 0xff, 0xfe, 0x26, 0xff, 0xff, 0xff, 0x12,
-0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x0b, 0xff, 0xff, 0xfe, 0x1b,
-0xff, 0xff, 0xfe, 0x35, 0xff, 0xfd, 0xfa, 0x58, 0xfd, 0xfb, 0xf4, 0x83,
-0xfa, 0xf6, 0xea, 0xb0, 0xf5, 0xef, 0xda, 0xd8, 0xed, 0xe6, 0xc2, 0xf4,
-0xe5, 0xdc, 0xa7, 0xff, 0xe1, 0xd9, 0x93, 0xff, 0xe3, 0xdd, 0x85, 0xff,
-0xe8, 0xdf, 0x66, 0xff, 0xcc, 0xbb, 0x10, 0xff, 0xa0, 0x8c, 0x12, 0xff,
-0x9e, 0x95, 0x74, 0xd1, 0xc2, 0xbe, 0xb5, 0x9e, 0xd7, 0xce, 0xa7, 0xeb,
-0xe6, 0xde, 0x8b, 0xff, 0xe2, 0xd5, 0x90, 0xff, 0xc1, 0xb6, 0x82, 0xff,
-0xb9, 0xb0, 0x80, 0xff, 0xb8, 0xae, 0x80, 0xff, 0xb1, 0xa8, 0x7b, 0xff,
-0xbf, 0xb4, 0x81, 0xff, 0xc7, 0xba, 0x7f, 0xff, 0xb5, 0xa4, 0x46, 0xff,
-0x94, 0x86, 0x2a, 0xff, 0xc9, 0xc6, 0xbc, 0x96, 0xf8, 0xf7, 0xf9, 0x07,
-0xfe, 0xff, 0xff, 0x00, 0xfc, 0xfc, 0xfd, 0x00, 0xf4, 0xf5, 0xf5, 0x0d,
-0xe5, 0xe3, 0xe3, 0x3d, 0xca, 0xc6, 0xbc, 0x87, 0xa8, 0xa1, 0x80, 0xcd,
-0x8e, 0x82, 0x3c, 0xf7, 0x8d, 0x7c, 0x0e, 0xff, 0x98, 0x87, 0x06, 0xff,
-0x9e, 0x8f, 0x22, 0xff, 0xa7, 0x98, 0x4b, 0xff, 0xae, 0xa0, 0x63, 0xff,
-0xc1, 0xb4, 0x77, 0xff, 0xbd, 0xb1, 0x7a, 0xff, 0xb2, 0xa9, 0x77, 0xff,
-0xbd, 0xb1, 0x7e, 0xff, 0xc3, 0xb8, 0x82, 0xff, 0xcf, 0xc3, 0x89, 0xff,
-0xe6, 0xda, 0x97, 0xff, 0xee, 0xe5, 0x99, 0xff, 0xe7, 0xe1, 0x92, 0xff,
-0xdf, 0xd7, 0x96, 0xff, 0xe3, 0xdc, 0xb2, 0xfb, 0xef, 0xea, 0xd7, 0xd2,
-0xf9, 0xf7, 0xf1, 0x89, 0xfd, 0xfd, 0xfb, 0x3c, 0xff, 0xff, 0xff, 0x0c,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfc, 0xfd, 0xfd, 0x01, 0xf1, 0xf1, 0xee, 0x30,
-0xd3, 0xd0, 0xc8, 0x99, 0xa7, 0x9f, 0x75, 0xec, 0x93, 0x85, 0x29, 0xff,
-0xa1, 0x93, 0x39, 0xff, 0xb7, 0xab, 0x6d, 0xff, 0xba, 0xaf, 0x7f, 0xff,
-0x9b, 0x93, 0x71, 0xff, 0xba, 0xb1, 0x88, 0xff, 0xb3, 0xab, 0x86, 0xff,
-0xbe, 0xb6, 0x90, 0xff, 0xbd, 0xb6, 0x90, 0xff, 0xbd, 0xb5, 0x91, 0xff,
-0xbf, 0xb7, 0x93, 0xff, 0xb8, 0xb1, 0x8e, 0xff, 0xca, 0xc0, 0x97, 0xff,
-0xde, 0xd3, 0xa3, 0xff, 0xea, 0xe2, 0xad, 0xff, 0xf1, 0xec, 0xb6, 0xff,
-0xec, 0xea, 0xb3, 0xff, 0xe7, 0xe3, 0xb0, 0xff, 0xe2, 0xdd, 0xb0, 0xff,
-0xe4, 0xde, 0xb9, 0xff, 0xe9, 0xe3, 0xc6, 0xf7, 0xef, 0xea, 0xd4, 0xe4,
-0xf4, 0xf1, 0xe1, 0xca, 0xf8, 0xf6, 0xeb, 0xad, 0xfa, 0xf9, 0xf2, 0x90,
-0xfc, 0xfc, 0xf6, 0x76, 0xfe, 0xfd, 0xf9, 0x60, 0xfe, 0xfd, 0xfb, 0x4e,
-0xfe, 0xfe, 0xfc, 0x40, 0xff, 0xff, 0xfd, 0x36, 0xff, 0xff, 0xfe, 0x2f,
-0xff, 0xff, 0xfe, 0x2c, 0xff, 0xfe, 0xfe, 0x29, 0xff, 0xff, 0xfe, 0x2a,
-0xff, 0xff, 0xfe, 0x2f, 0xff, 0xff, 0xfd, 0x36, 0xff, 0xfe, 0xfc, 0x41,
-0xfe, 0xfe, 0xfb, 0x52, 0xfe, 0xfd, 0xf8, 0x66, 0xfd, 0xfb, 0xf5, 0x80,
-0xfa, 0xf8, 0xef, 0x9e, 0xf8, 0xf5, 0xe8, 0xbc, 0xf3, 0xf0, 0xdd, 0xd8,
-0xed, 0xe8, 0xd0, 0xef, 0xe9, 0xe3, 0xc1, 0xfe, 0xe5, 0xde, 0xb6, 0xff,
-0xe3, 0xdd, 0xaf, 0xff, 0xe6, 0xe2, 0xab, 0xff, 0xe9, 0xe5, 0xa8, 0xff,
-0xed, 0xe7, 0x9f, 0xff, 0xd3, 0xc8, 0x6b, 0xff, 0xa8, 0x97, 0x1c, 0xff,
-0x83, 0x74, 0x1b, 0xfb, 0x92, 0x8b, 0x72, 0xbd, 0xc1, 0xc0, 0xbe, 0x46,
-0xe6, 0xe5, 0xe2, 0x57, 0xe4, 0xdd, 0xbe, 0xeb, 0xe4, 0xde, 0x9d, 0xff,
-0xe1, 0xd6, 0xa2, 0xff, 0xc0, 0xb8, 0x91, 0xff, 0xba, 0xb3, 0x90, 0xff,
-0xbf, 0xb7, 0x94, 0xff, 0xb6, 0xaf, 0x8e, 0xff, 0xba, 0xb2, 0x8e, 0xff,
-0xc8, 0xbe, 0x91, 0xff, 0xb9, 0xac, 0x6b, 0xff, 0x96, 0x8b, 0x46, 0xff,
-0xc9, 0xc6, 0xbd, 0x96, 0xf7, 0xf7, 0xf8, 0x08, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xfc, 0xfd, 0x00,
-0xf5, 0xf6, 0xf6, 0x07, 0xe8, 0xe8, 0xe8, 0x2e, 0xd0, 0xce, 0xca, 0x73,
-0xb0, 0xab, 0x96, 0xbb, 0x95, 0x8c, 0x59, 0xec, 0x88, 0x7b, 0x24, 0xff,
-0x8f, 0x80, 0x16, 0xff, 0x9a, 0x8d, 0x33, 0xff, 0xab, 0x9f, 0x5c, 0xff,
-0xaa, 0x9f, 0x6f, 0xff, 0xa2, 0x98, 0x71, 0xff, 0xad, 0xa4, 0x7d, 0xff,
-0xb4, 0xab, 0x85, 0xff, 0xb8, 0xb1, 0x8c, 0xff, 0xc1, 0xb9, 0x92, 0xff,
-0xd6, 0xcc, 0xa0, 0xff, 0xeb, 0xe0, 0xac, 0xff, 0xee, 0xe8, 0xad, 0xff,
-0xe7, 0xe4, 0xa7, 0xff, 0xe0, 0xdb, 0xa9, 0xff, 0xe4, 0xdd, 0xbc, 0xfd,
-0xee, 0xea, 0xd8, 0xd9, 0xf9, 0xf6, 0xef, 0x94, 0xfd, 0xfd, 0xfb, 0x46,
-0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfd, 0xfd, 0xfe, 0x00, 0xf6, 0xf6, 0xf6, 0x13,
-0xe2, 0xe1, 0xde, 0x5d, 0xbd, 0xb8, 0xa8, 0xbc, 0x98, 0x8f, 0x5c, 0xf6,
-0x8d, 0x83, 0x3d, 0xff, 0x9b, 0x90, 0x53, 0xff, 0xa5, 0x9c, 0x6f, 0xff,
-0xb4, 0xac, 0x88, 0xff, 0xb7, 0xb0, 0x90, 0xff, 0xba, 0xb4, 0x96, 0xff,
-0xbf, 0xb9, 0x9c, 0xff, 0xc2, 0xbc, 0xa0, 0xff, 0xbe, 0xb8, 0x9e, 0xff,
-0xbb, 0xb6, 0x9e, 0xff, 0xb8, 0xb3, 0x9c, 0xff, 0xc1, 0xba, 0xa0, 0xff,
-0xc6, 0xbf, 0xa3, 0xff, 0xd9, 0xd1, 0xb1, 0xff, 0xe8, 0xe1, 0xbe, 0xff,
-0xee, 0xe9, 0xc5, 0xff, 0xf0, 0xec, 0xc9, 0xff, 0xef, 0xed, 0xca, 0xff,
-0xec, 0xe9, 0xc7, 0xff, 0xe8, 0xe4, 0xc5, 0xff, 0xe5, 0xe1, 0xc3, 0xff,
-0xe5, 0xe1, 0xc7, 0xff, 0xe8, 0xe4, 0xcc, 0xff, 0xe9, 0xe5, 0xce, 0xfb,
-0xeb, 0xe6, 0xd2, 0xf4, 0xed, 0xe9, 0xd6, 0xec, 0xf0, 0xed, 0xdc, 0xe3,
-0xf3, 0xef, 0xe0, 0xdc, 0xf3, 0xef, 0xe1, 0xd6, 0xf3, 0xf0, 0xe2, 0xd3,
-0xf4, 0xf0, 0xe3, 0xd1, 0xf3, 0xf0, 0xe3, 0xd2, 0xf4, 0xf1, 0xe2, 0xd5,
-0xf3, 0xf0, 0xe0, 0xdc, 0xf1, 0xed, 0xdc, 0xe4, 0xed, 0xe8, 0xd5, 0xed,
-0xec, 0xe7, 0xd1, 0xf6, 0xea, 0xe5, 0xcc, 0xfe, 0xea, 0xe4, 0xca, 0xff,
-0xe8, 0xe3, 0xc8, 0xff, 0xe6, 0xe1, 0xc5, 0xff, 0xe4, 0xe0, 0xc4, 0xff,
-0xe6, 0xe3, 0xc3, 0xff, 0xea, 0xe7, 0xc4, 0xff, 0xe7, 0xe3, 0xbd, 0xff,
-0xda, 0xd4, 0xa7, 0xff, 0xc2, 0xb8, 0x75, 0xff, 0x9a, 0x8d, 0x31, 0xff,
-0x78, 0x6b, 0x13, 0xff, 0x7a, 0x73, 0x45, 0xdc, 0xa1, 0x9e, 0x96, 0x86,
-0xcf, 0xcf, 0xce, 0x2a, 0xef, 0xef, 0xef, 0x00, 0xf8, 0xf8, 0xf5, 0x4e,
-0xe7, 0xe2, 0xca, 0xec, 0xe5, 0xe1, 0xb2, 0xff, 0xe4, 0xdb, 0xb4, 0xff,
-0xc3, 0xbc, 0xa0, 0xff, 0xb5, 0xb1, 0x9a, 0xff, 0xc1, 0xbb, 0xa3, 0xff,
-0xbf, 0xba, 0xa2, 0xff, 0xb7, 0xb2, 0x9b, 0xff, 0xc2, 0xbb, 0x9c, 0xff,
-0xb9, 0xaf, 0x80, 0xff, 0x97, 0x8e, 0x60, 0xff, 0xc9, 0xc7, 0xbe, 0x96,
-0xf7, 0xf7, 0xf8, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfd, 0xfe, 0xfe, 0x00, 0xf8, 0xf8, 0xf8, 0x02, 0xed, 0xed, 0xed, 0x1e,
-0xdb, 0xd9, 0xd8, 0x54, 0xbf, 0xbc, 0xb4, 0x96, 0xa2, 0x9d, 0x80, 0xd2,
-0x8c, 0x84, 0x4a, 0xf6, 0x86, 0x7b, 0x33, 0xff, 0x8e, 0x83, 0x3e, 0xff,
-0xa2, 0x98, 0x5e, 0xff, 0xa5, 0x9d, 0x72, 0xff, 0x8a, 0x83, 0x65, 0xff,
-0xbd, 0xb6, 0x94, 0xff, 0xb4, 0xae, 0x92, 0xff, 0xa2, 0x9d, 0x85, 0xff,
-0xac, 0xa7, 0x8d, 0xff, 0xd3, 0xcb, 0xa8, 0xff, 0xe4, 0xdd, 0xb6, 0xff,
-0xec, 0xe8, 0xc0, 0xff, 0xeb, 0xe8, 0xc0, 0xff, 0xe3, 0xdf, 0xbb, 0xff,
-0xe3, 0xdd, 0xc2, 0xff, 0xec, 0xe8, 0xd8, 0xe2, 0xf7, 0xf5, 0xee, 0xa5,
-0xfd, 0xfd, 0xf9, 0x5b, 0xfe, 0xff, 0xfe, 0x21, 0xff, 0xff, 0xff, 0x02,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfb, 0xfb, 0xfc, 0x00,
-0xf0, 0xf0, 0xef, 0x23, 0xd6, 0xd5, 0xd2, 0x74, 0xb2, 0xad, 0x9d, 0xc5,
-0x93, 0x8c, 0x67, 0xf5, 0x86, 0x7e, 0x4e, 0xff, 0x8d, 0x85, 0x5b, 0xff,
-0x9f, 0x99, 0x75, 0xff, 0x9c, 0x96, 0x7b, 0xff, 0xb6, 0xb1, 0x97, 0xff,
-0xbc, 0xb7, 0xa0, 0xff, 0xac, 0xa7, 0x94, 0xff, 0xae, 0xaa, 0x98, 0xff,
-0xa1, 0x9d, 0x8f, 0xff, 0xa6, 0xa3, 0x96, 0xff, 0xb8, 0xb4, 0xa6, 0xff,
-0xb5, 0xb2, 0xa3, 0xff, 0xb4, 0xb0, 0xa1, 0xff, 0xc3, 0xbe, 0xac, 0xff,
-0xd3, 0xce, 0xb9, 0xff, 0xde, 0xd9, 0xc2, 0xff, 0xe9, 0xe5, 0xcd, 0xff,
-0xf1, 0xee, 0xd8, 0xff, 0xf1, 0xee, 0xdb, 0xff, 0xf1, 0xef, 0xde, 0xff,
-0xef, 0xed, 0xe0, 0xff, 0xec, 0xeb, 0xdf, 0xff, 0xe9, 0xe6, 0xd9, 0xff,
-0xea, 0xe7, 0xd9, 0xff, 0xeb, 0xe8, 0xd9, 0xff, 0xe9, 0xe6, 0xd8, 0xff,
-0xe9, 0xe6, 0xd6, 0xff, 0xe8, 0xe4, 0xd5, 0xff, 0xe0, 0xdc, 0xcc, 0xff,
-0xe1, 0xdd, 0xcd, 0xff, 0xe8, 0xe5, 0xd7, 0xff, 0xea, 0xe7, 0xd9, 0xff,
-0xea, 0xe8, 0xd9, 0xff, 0xea, 0xe7, 0xda, 0xff, 0xeb, 0xe9, 0xdc, 0xff,
-0xed, 0xeb, 0xde, 0xff, 0xee, 0xec, 0xdf, 0xff, 0xee, 0xeb, 0xdc, 0xff,
-0xe8, 0xe6, 0xd3, 0xff, 0xe1, 0xde, 0xc6, 0xff, 0xd7, 0xd2, 0xb3, 0xff,
-0xc5, 0xbe, 0x97, 0xff, 0xa5, 0x9c, 0x68, 0xff, 0x82, 0x77, 0x35, 0xff,
-0x6c, 0x62, 0x1e, 0xff, 0x72, 0x6b, 0x3e, 0xe0, 0x94, 0x91, 0x84, 0x9a,
-0xc0, 0xc0, 0xc0, 0x42, 0xe3, 0xe4, 0xe5, 0x09, 0xf6, 0xf6, 0xf7, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfc, 0xfc, 0xf9, 0x50, 0xe9, 0xe5, 0xd2, 0xec,
-0xe7, 0xe4, 0xc6, 0xff, 0xe3, 0xde, 0xc3, 0xff, 0xc7, 0xc2, 0xb0, 0xff,
-0xba, 0xb6, 0xa9, 0xff, 0xc6, 0xc2, 0xb3, 0xff, 0xc4, 0xbf, 0xb0, 0xff,
-0xb5, 0xb1, 0xa3, 0xff, 0xc2, 0xbc, 0xa8, 0xff, 0xba, 0xb3, 0x91, 0xff,
-0x98, 0x91, 0x71, 0xff, 0xca, 0xc8, 0xc1, 0x96, 0xf7, 0xf8, 0xf8, 0x08,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfb, 0xfb, 0xfc, 0x00,
-0xf4, 0xf4, 0xf4, 0x0a, 0xe6, 0xe6, 0xe6, 0x30, 0xd0, 0xcf, 0xcd, 0x6a,
-0xb5, 0xb2, 0xa6, 0xaa, 0x9a, 0x94, 0x78, 0xdd, 0x87, 0x81, 0x55, 0xfa,
-0x84, 0x7c, 0x4c, 0xff, 0x93, 0x8a, 0x5d, 0xff, 0x9e, 0x97, 0x72, 0xff,
-0xa2, 0x9c, 0x80, 0xff, 0x94, 0x8e, 0x78, 0xff, 0xa5, 0xa1, 0x8d, 0xff,
-0xb8, 0xb2, 0x9d, 0xff, 0xc0, 0xba, 0xa6, 0xff, 0xcb, 0xc5, 0xae, 0xff,
-0xdd, 0xd8, 0xbf, 0xff, 0xed, 0xea, 0xd0, 0xff, 0xec, 0xea, 0xd0, 0xff,
-0xe5, 0xe2, 0xcb, 0xff, 0xe2, 0xde, 0xcb, 0xff, 0xea, 0xe7, 0xd9, 0xef,
-0xf5, 0xf3, 0xeb, 0xbe, 0xfc, 0xfb, 0xf8, 0x78, 0xfe, 0xfe, 0xfd, 0x36,
-0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xf9, 0xf9, 0xf9, 0x03, 0xeb, 0xeb, 0xeb, 0x28, 0xd4, 0xd4, 0xd0, 0x6c,
-0xb6, 0xb3, 0xa7, 0xb5, 0x99, 0x94, 0x7f, 0xe7, 0x88, 0x82, 0x65, 0xff,
-0x82, 0x7c, 0x5d, 0xff, 0x8c, 0x85, 0x69, 0xff, 0xa0, 0x99, 0x80, 0xff,
-0xad, 0xa8, 0x92, 0xff, 0xa9, 0xa4, 0x92, 0xff, 0xa1, 0x9d, 0x90, 0xff,
-0x99, 0x96, 0x8c, 0xff, 0xb3, 0xb0, 0xa5, 0xff, 0x98, 0x96, 0x8e, 0xff,
-0x81, 0x7e, 0x78, 0xff, 0xa4, 0xa0, 0x97, 0xff, 0xaa, 0xa7, 0x9d, 0xff,
-0xaf, 0xac, 0xa3, 0xff, 0xb9, 0xb6, 0xac, 0xff, 0xb9, 0xb6, 0xab, 0xff,
-0xca, 0xc7, 0xba, 0xff, 0xcf, 0xcb, 0xbd, 0xff, 0xd9, 0xd6, 0xc9, 0xff,
-0xde, 0xdc, 0xcf, 0xff, 0xea, 0xe9, 0xdd, 0xff, 0xef, 0xee, 0xe4, 0xff,
-0xed, 0xec, 0xe3, 0xff, 0xed, 0xec, 0xe4, 0xff, 0xeb, 0xea, 0xe4, 0xff,
-0xe6, 0xe4, 0xde, 0xff, 0xe3, 0xe1, 0xdb, 0xff, 0xe5, 0xe4, 0xde, 0xff,
-0xeb, 0xea, 0xe3, 0xff, 0xe7, 0xe6, 0xde, 0xff, 0xe5, 0xe3, 0xdb, 0xff,
-0xe7, 0xe6, 0xdb, 0xff, 0xe4, 0xe2, 0xd5, 0xff, 0xdc, 0xd9, 0xc9, 0xff,
-0xd6, 0xd2, 0xbf, 0xff, 0xc5, 0xc1, 0xaa, 0xff, 0xb5, 0xaf, 0x95, 0xff,
-0xa0, 0x9a, 0x78, 0xff, 0x87, 0x7f, 0x56, 0xff, 0x71, 0x69, 0x38, 0xff,
-0x68, 0x62, 0x35, 0xf7, 0x78, 0x74, 0x57, 0xd2, 0x99, 0x97, 0x8e, 0x92,
-0xbf, 0xbe, 0xbe, 0x46, 0xdf, 0xdf, 0xdf, 0x0f, 0xf3, 0xf3, 0xf3, 0x00,
-0xfc, 0xfc, 0xfc, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfc, 0xfc, 0xfa, 0x50, 0xe8, 0xe5, 0xd8, 0xec, 0xe5, 0xe4, 0xd2, 0xff,
-0xe2, 0xdd, 0xce, 0xff, 0xbe, 0xbb, 0xb1, 0xff, 0x9b, 0x99, 0x93, 0xff,
-0x9b, 0x99, 0x93, 0xff, 0x96, 0x94, 0x8d, 0xff, 0xad, 0xab, 0xa2, 0xff,
-0xc2, 0xbf, 0xb2, 0xff, 0xbd, 0xb7, 0xa1, 0xff, 0x98, 0x92, 0x7b, 0xff,
-0xca, 0xc8, 0xc3, 0x96, 0xf7, 0xf8, 0xf7, 0x08, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfd, 0xfd, 0xfd, 0x00, 0xf8, 0xf8, 0xf9, 0x00, 0xef, 0xef, 0xef, 0x13,
-0xe0, 0xdf, 0xdf, 0x3d, 0xca, 0xc9, 0xc5, 0x77, 0xb0, 0xad, 0xa2, 0xb2,
-0x97, 0x92, 0x7f, 0xe0, 0x87, 0x81, 0x65, 0xfb, 0x80, 0x7a, 0x5c, 0xff,
-0x8e, 0x88, 0x68, 0xff, 0x9e, 0x99, 0x7e, 0xff, 0xa6, 0xa1, 0x8c, 0xff,
-0xaf, 0xab, 0x98, 0xff, 0xaa, 0xa6, 0x97, 0xff, 0x9f, 0x9a, 0x90, 0xff,
-0xbc, 0xb7, 0xa8, 0xff, 0xd6, 0xd3, 0xc1, 0xff, 0xe3, 0xe1, 0xd2, 0xff,
-0xe7, 0xe5, 0xda, 0xff, 0xde, 0xdc, 0xd1, 0xff, 0xdf, 0xdc, 0xcf, 0xff,
-0xe6, 0xe4, 0xd7, 0xf9, 0xf2, 0xf0, 0xe8, 0xd6, 0xfa, 0xf9, 0xf5, 0x99,
-0xfe, 0xfd, 0xfc, 0x56, 0xfe, 0xff, 0xfe, 0x21, 0xff, 0xff, 0xff, 0x04,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfd, 0xfd, 0xfe, 0x00, 0xf8, 0xf9, 0xf9, 0x00, 0xee, 0xee, 0xed, 0x1b,
-0xdd, 0xdc, 0xda, 0x4d, 0xc3, 0xc2, 0xbd, 0x8a, 0xa9, 0xa6, 0x9b, 0xc1,
-0x90, 0x8c, 0x7c, 0xe7, 0x81, 0x7d, 0x68, 0xfb, 0x83, 0x7e, 0x68, 0xff,
-0x85, 0x81, 0x6d, 0xff, 0x95, 0x90, 0x7d, 0xff, 0xa1, 0x9e, 0x8d, 0xff,
-0x97, 0x94, 0x86, 0xff, 0x9b, 0x98, 0x8d, 0xff, 0xa0, 0x9e, 0x93, 0xff,
-0xa1, 0x9f, 0x96, 0xff, 0xa2, 0xa0, 0x98, 0xff, 0xa3, 0xa1, 0x99, 0xff,
-0x83, 0x82, 0x7e, 0xff, 0x7e, 0x7d, 0x7a, 0xff, 0x73, 0x72, 0x70, 0xff,
-0x82, 0x81, 0x7f, 0xff, 0x88, 0x86, 0x81, 0xff, 0x71, 0x70, 0x6f, 0xff,
-0x8f, 0x8e, 0x8c, 0xff, 0xa7, 0xa5, 0x9e, 0xff, 0x91, 0x90, 0x8b, 0xff,
-0xad, 0xab, 0xa3, 0xff, 0xb2, 0xaf, 0xa6, 0xff, 0xbd, 0xbb, 0xb1, 0xff,
-0xc4, 0xc1, 0xb6, 0xff, 0xbb, 0xb8, 0xad, 0xff, 0xba, 0xb7, 0xab, 0xff,
-0xc0, 0xbc, 0xaf, 0xff, 0xab, 0xa7, 0x9b, 0xff, 0xa9, 0xa5, 0x95, 0xff,
-0xaa, 0xa6, 0x93, 0xff, 0x9b, 0x96, 0x80, 0xff, 0x85, 0x80, 0x69, 0xff,
-0x73, 0x6e, 0x53, 0xff, 0x6c, 0x67, 0x4a, 0xff, 0x6b, 0x66, 0x4a, 0xf6,
-0x76, 0x72, 0x5c, 0xda, 0x8d, 0x8a, 0x7e, 0xab, 0xac, 0xaa, 0xa8, 0x6e,
-0xcb, 0xca, 0xca, 0x32, 0xe3, 0xe3, 0xe4, 0x0b, 0xf3, 0xf3, 0xf4, 0x00,
-0xfb, 0xfb, 0xfb, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfd, 0xfb, 0x51,
-0xe8, 0xe5, 0xdb, 0xed, 0xda, 0xd7, 0xcf, 0xff, 0xd3, 0xd1, 0xc7, 0xff,
-0x95, 0x93, 0x8e, 0xff, 0x6c, 0x6b, 0x69, 0xff, 0x82, 0x81, 0x7f, 0xff,
-0x3f, 0x3f, 0x42, 0xff, 0x62, 0x61, 0x61, 0xff, 0xae, 0xab, 0xa4, 0xff,
-0xa9, 0xa5, 0x98, 0xff, 0x95, 0x90, 0x80, 0xff, 0xca, 0xc9, 0xc4, 0x96,
-0xf7, 0xf7, 0xf7, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0x00, 0xfc, 0xfc, 0xfd, 0x00,
-0xf6, 0xf7, 0xf7, 0x02, 0xed, 0xed, 0xed, 0x18, 0xde, 0xde, 0xdc, 0x40,
-0xc8, 0xc7, 0xc4, 0x77, 0xb0, 0xaf, 0xa6, 0xae, 0x98, 0x95, 0x87, 0xd9,
-0x87, 0x83, 0x71, 0xf5, 0x81, 0x7d, 0x68, 0xff, 0x85, 0x80, 0x6c, 0xff,
-0x8b, 0x87, 0x75, 0xff, 0x98, 0x95, 0x86, 0xff, 0xa2, 0x9f, 0x93, 0xff,
-0xac, 0xaa, 0x9f, 0xff, 0xb9, 0xb7, 0xab, 0xff, 0xc3, 0xbf, 0xb4, 0xff,
-0xd6, 0xd5, 0xcb, 0xff, 0xde, 0xdd, 0xd6, 0xff, 0xdb, 0xd9, 0xd2, 0xff,
-0xd9, 0xd7, 0xce, 0xff, 0xe1, 0xde, 0xd5, 0xff, 0xeb, 0xe9, 0xe2, 0xec,
-0xf6, 0xf4, 0xf0, 0xc0, 0xfc, 0xfb, 0xf8, 0x84, 0xfe, 0xfe, 0xfd, 0x49,
-0xff, 0xff, 0xff, 0x1b, 0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfb, 0xfb, 0xfb, 0x00,
-0xf4, 0xf5, 0xf4, 0x06, 0xe9, 0xe9, 0xe9, 0x21, 0xd9, 0xd9, 0xd7, 0x4a,
-0xc5, 0xc4, 0xc1, 0x7a, 0xae, 0xad, 0xa7, 0xa7, 0x9a, 0x98, 0x8e, 0xcd,
-0x8a, 0x87, 0x7c, 0xe7, 0x80, 0x7d, 0x72, 0xf7, 0x7c, 0x79, 0x6d, 0xff,
-0x7c, 0x78, 0x6c, 0xff, 0x7f, 0x7c, 0x70, 0xff, 0x87, 0x84, 0x79, 0xff,
-0x8a, 0x87, 0x7d, 0xff, 0x8d, 0x8b, 0x82, 0xff, 0x91, 0x8e, 0x85, 0xff,
-0x97, 0x94, 0x8d, 0xff, 0x8c, 0x8a, 0x82, 0xff, 0x90, 0x8f, 0x86, 0xff,
-0x64, 0x62, 0x5b, 0xff, 0x57, 0x56, 0x51, 0xff, 0x64, 0x62, 0x5e, 0xff,
-0x6c, 0x6b, 0x65, 0xff, 0x85, 0x83, 0x7c, 0xff, 0x94, 0x92, 0x8a, 0xff,
-0x8e, 0x8c, 0x84, 0xff, 0x96, 0x94, 0x8b, 0xff, 0x8f, 0x8c, 0x83, 0xff,
-0x87, 0x83, 0x79, 0xff, 0x7e, 0x7b, 0x6e, 0xff, 0x79, 0x76, 0x69, 0xff,
-0x6e, 0x6b, 0x5d, 0xff, 0x6d, 0x69, 0x5a, 0xff, 0x6c, 0x68, 0x58, 0xfe,
-0x6f, 0x6b, 0x5b, 0xf3, 0x76, 0x72, 0x65, 0xe0, 0x84, 0x82, 0x77, 0xc2,
-0x97, 0x97, 0x90, 0x9a, 0xb1, 0xb0, 0xae, 0x69, 0xc9, 0xc9, 0xc8, 0x38,
-0xde, 0xdd, 0xde, 0x13, 0xee, 0xee, 0xee, 0x00, 0xf8, 0xf8, 0xf8, 0x00,
-0xfc, 0xfc, 0xfc, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfc, 0x47, 0xe5, 0xe3, 0xda, 0xe7,
-0xc6, 0xc4, 0xb7, 0xff, 0xbf, 0xbc, 0xb2, 0xff, 0x88, 0x86, 0x80, 0xff,
-0x5d, 0x5c, 0x5a, 0xff, 0x71, 0x70, 0x6b, 0xff, 0x80, 0x7f, 0x7a, 0xff,
-0x80, 0x7e, 0x78, 0xff, 0x99, 0x97, 0x8f, 0xff, 0x90, 0x8d, 0x81, 0xff,
-0x89, 0x86, 0x76, 0xff, 0xcc, 0xcb, 0xc7, 0x8b, 0xf8, 0xf8, 0xf8, 0x06,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfc, 0xfc, 0xfc, 0x00, 0xf6, 0xf7, 0xf7, 0x01,
-0xee, 0xee, 0xed, 0x14, 0xe0, 0xe0, 0xdf, 0x37, 0xce, 0xcd, 0xca, 0x65,
-0xb8, 0xb6, 0xb1, 0x98, 0xa2, 0x9f, 0x98, 0xc4, 0x90, 0x8e, 0x83, 0xe6,
-0x84, 0x81, 0x75, 0xf9, 0x80, 0x7d, 0x71, 0xff, 0x82, 0x7f, 0x74, 0xff,
-0x8b, 0x88, 0x7e, 0xff, 0x8d, 0x8a, 0x81, 0xff, 0xa6, 0xa3, 0x99, 0xff,
-0xb1, 0xae, 0xa4, 0xff, 0xca, 0xc9, 0xc0, 0xff, 0xd9, 0xd9, 0xd2, 0xff,
-0xd7, 0xd6, 0xd0, 0xff, 0xda, 0xd8, 0xd2, 0xff, 0xdc, 0xd9, 0xd2, 0xff,
-0xe4, 0xe1, 0xda, 0xfd, 0xef, 0xed, 0xe8, 0xe5, 0xf9, 0xf8, 0xf4, 0xb8,
-0xfe, 0xfd, 0xfb, 0x81, 0xff, 0xff, 0xfe, 0x4d, 0xff, 0xff, 0xfe, 0x26,
-0xff, 0xff, 0xff, 0x0e, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfd, 0xfd, 0xfe, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xf5, 0xf5, 0xf6, 0x02,
-0xee, 0xed, 0xee, 0x10, 0xe2, 0xe2, 0xe2, 0x29, 0xd5, 0xd5, 0xd5, 0x48,
-0xc7, 0xc6, 0xc4, 0x69, 0xb7, 0xb7, 0xb4, 0x88, 0xa9, 0xa8, 0xa4, 0xa3,
-0x9c, 0x9b, 0x96, 0xbb, 0x91, 0x8f, 0x8a, 0xcd, 0x89, 0x88, 0x82, 0xdb,
-0x83, 0x82, 0x7c, 0xe6, 0x81, 0x7f, 0x78, 0xee, 0x7d, 0x7b, 0x75, 0xf3,
-0x78, 0x76, 0x6f, 0xf7, 0x78, 0x76, 0x6e, 0xfa, 0x74, 0x73, 0x6b, 0xfb,
-0x74, 0x72, 0x69, 0xfc, 0x70, 0x6e, 0x66, 0xfc, 0x74, 0x73, 0x6a, 0xfc,
-0x76, 0x73, 0x6d, 0xfb, 0x73, 0x71, 0x6a, 0xfa, 0x76, 0x74, 0x6c, 0xf7,
-0x75, 0x73, 0x6c, 0xf4, 0x76, 0x74, 0x6d, 0xee, 0x79, 0x77, 0x70, 0xe6,
-0x7e, 0x7c, 0x75, 0xda, 0x84, 0x83, 0x7d, 0xcb, 0x8e, 0x8d, 0x87, 0xb7,
-0x99, 0x99, 0x94, 0x9e, 0xa8, 0xa7, 0xa3, 0x81, 0xb8, 0xb7, 0xb5, 0x5f,
-0xc8, 0xc8, 0xc7, 0x3e, 0xd7, 0xd7, 0xd8, 0x21, 0xe4, 0xe5, 0xe5, 0x0b,
-0xf0, 0xf0, 0xf0, 0x00, 0xf7, 0xf7, 0xf7, 0x00, 0xfc, 0xfc, 0xfc, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfe, 0xfe, 0x28, 0xea, 0xe8, 0xe4, 0xb4, 0xb3, 0xb1, 0xa6, 0xfb,
-0x8c, 0x89, 0x80, 0xff, 0x71, 0x70, 0x69, 0xff, 0x70, 0x6e, 0x67, 0xff,
-0x66, 0x64, 0x5c, 0xff, 0x67, 0x65, 0x5d, 0xff, 0x71, 0x6f, 0x67, 0xff,
-0x79, 0x77, 0x6f, 0xff, 0x70, 0x6d, 0x5f, 0xff, 0x85, 0x82, 0x75, 0xe1,
-0xd4, 0xd4, 0xd2, 0x5b, 0xf9, 0xf9, 0xf9, 0x01, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xfd, 0xfd, 0xfd, 0x00, 0xf8, 0xf8, 0xf8, 0x00, 0xf1, 0xf1, 0xf1, 0x0a,
-0xe7, 0xe7, 0xe6, 0x23, 0xd8, 0xd8, 0xd7, 0x46, 0xc7, 0xc6, 0xc4, 0x71,
-0xb3, 0xb3, 0xaf, 0x9d, 0xa0, 0x9f, 0x9b, 0xc3, 0x90, 0x8e, 0x88, 0xe1,
-0x84, 0x83, 0x7c, 0xf5, 0x7c, 0x7a, 0x73, 0xff, 0x79, 0x76, 0x6f, 0xff,
-0x87, 0x84, 0x7c, 0xff, 0x9b, 0x98, 0x90, 0xff, 0xa9, 0xa7, 0x9e, 0xff,
-0xb4, 0xb1, 0xaa, 0xff, 0xc8, 0xc6, 0xbf, 0xff, 0xcc, 0xcb, 0xc2, 0xff,
-0xd0, 0xce, 0xc6, 0xff, 0xd4, 0xd1, 0xc7, 0xff, 0xe0, 0xdd, 0xd3, 0xfb,
-0xee, 0xec, 0xe5, 0xe3, 0xf9, 0xf8, 0xf4, 0xbc, 0xff, 0xff, 0xfe, 0x8b,
-0xff, 0xff, 0xff, 0x5b, 0xff, 0xff, 0xff, 0x35, 0xff, 0xff, 0xff, 0x1b,
-0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfd, 0xfd, 0xfd, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xf7, 0xf7, 0xf7, 0x00,
-0xf2, 0xf2, 0xf3, 0x04, 0xec, 0xec, 0xec, 0x0d, 0xe6, 0xe6, 0xe6, 0x1a,
-0xde, 0xde, 0xde, 0x29, 0xd7, 0xd7, 0xd6, 0x37, 0xd0, 0xd0, 0xcf, 0x45,
-0xca, 0xca, 0xc8, 0x53, 0xc4, 0xc4, 0xc2, 0x5e, 0xc0, 0xc0, 0xbe, 0x68,
-0xbb, 0xbb, 0xb9, 0x70, 0xb8, 0xb8, 0xb6, 0x75, 0xb7, 0xb6, 0xb5, 0x79,
-0xb5, 0xb5, 0xb3, 0x7a, 0xb4, 0xb4, 0xb2, 0x79, 0xb5, 0xb5, 0xb3, 0x76,
-0xb7, 0xb6, 0xb5, 0x70, 0xb9, 0xb9, 0xb8, 0x69, 0xbd, 0xbd, 0xbb, 0x5f,
-0xc2, 0xc2, 0xc2, 0x53, 0xc8, 0xc9, 0xc8, 0x45, 0xcf, 0xcf, 0xcf, 0x36,
-0xd7, 0xd7, 0xd7, 0x26, 0xdf, 0xdf, 0xde, 0x18, 0xe6, 0xe6, 0xe6, 0x0b,
-0xed, 0xed, 0xed, 0x03, 0xf3, 0xf3, 0xf3, 0x00, 0xf8, 0xf8, 0xf8, 0x00,
-0xfc, 0xfc, 0xfc, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xff, 0x07,
-0xf5, 0xf5, 0xf5, 0x3f, 0xd9, 0xd9, 0xd6, 0x80, 0xb4, 0xb4, 0xb0, 0x98,
-0xa7, 0xa7, 0xa4, 0x9a, 0xa6, 0xa6, 0xa3, 0x9a, 0xa7, 0xa6, 0xa4, 0x9c,
-0xa6, 0xa5, 0xa1, 0x9c, 0xa4, 0xa4, 0xa1, 0x9d, 0xa2, 0xa2, 0xa0, 0x9d,
-0xa8, 0xa7, 0xa5, 0x92, 0xc1, 0xc0, 0xbf, 0x5f, 0xe6, 0xe6, 0xe6, 0x18,
-0xfb, 0xfb, 0xfb, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xfb, 0xfb, 0xfb, 0x00, 0xf6, 0xf6, 0xf6, 0x00, 0xf0, 0xf0, 0xf0, 0x0c,
-0xe6, 0xe6, 0xe6, 0x21, 0xd9, 0xd9, 0xd8, 0x40, 0xca, 0xca, 0xc8, 0x64,
-0xba, 0xba, 0xb7, 0x88, 0xaa, 0xa9, 0xa7, 0xab, 0x9a, 0x99, 0x95, 0xc8,
-0x8e, 0x8c, 0x88, 0xdf, 0x87, 0x86, 0x81, 0xf0, 0x86, 0x84, 0x7f, 0xfa,
-0x8d, 0x8b, 0x84, 0xff, 0x98, 0x95, 0x8c, 0xff, 0xa2, 0x9f, 0x96, 0xff,
-0xa8, 0xa5, 0x9a, 0xff, 0xad, 0xa9, 0x9c, 0xff, 0xb0, 0xad, 0x9e, 0xff,
-0xb1, 0xae, 0xa0, 0xff, 0xb9, 0xb6, 0xac, 0xf6, 0xc2, 0xc0, 0xb7, 0xd7,
-0xce, 0xce, 0xcc, 0xa9, 0xe5, 0xe5, 0xe4, 0x70, 0xf2, 0xf2, 0xf1, 0x3a,
-0xfa, 0xfa, 0xfa, 0x13, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xfc, 0xfc, 0xfd, 0x00,
-0xfb, 0xfb, 0xfb, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0xf9, 0xf9, 0xf9, 0x00,
-0xf7, 0xf7, 0xf7, 0x00, 0xf5, 0xf5, 0xf5, 0x00, 0xf4, 0xf4, 0xf4, 0x00,
-0xf3, 0xf3, 0xf3, 0x00, 0xf2, 0xf2, 0xf2, 0x00, 0xf2, 0xf2, 0xf2, 0x00,
-0xf2, 0xf2, 0xf2, 0x00, 0xf2, 0xf2, 0xf2, 0x00, 0xf2, 0xf2, 0xf2, 0x00,
-0xf4, 0xf4, 0xf4, 0x00, 0xf5, 0xf5, 0xf5, 0x00, 0xf6, 0xf6, 0xf6, 0x00,
-0xf8, 0xf8, 0xf8, 0x00, 0xfa, 0xfa, 0xfa, 0x00, 0xfb, 0xfb, 0xfb, 0x00,
-0xfd, 0xfd, 0xfd, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xfe, 0xfe, 0xfe, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfd, 0xfd, 0x00,
-0xf6, 0xf6, 0xf5, 0x05, 0xee, 0xee, 0xee, 0x09, 0xeb, 0xeb, 0xeb, 0x09,
-0xeb, 0xeb, 0xeb, 0x06, 0xeb, 0xeb, 0xeb, 0x04, 0xea, 0xea, 0xea, 0x08,
-0xea, 0xea, 0xeb, 0x0a, 0xea, 0xea, 0xeb, 0x0a, 0xec, 0xec, 0xec, 0x08,
-0xf0, 0xf1, 0xf1, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfe, 0xfe, 0x00,
-0xfb, 0xfb, 0xfb, 0x00, 0xf8, 0xf8, 0xf8, 0x00, 0xf3, 0xf3, 0xf3, 0x01,
-0xec, 0xec, 0xec, 0x0e, 0xe2, 0xe3, 0xe3, 0x24, 0xd9, 0xd8, 0xd8, 0x3c,
-0xcd, 0xcd, 0xcc, 0x56, 0xc1, 0xc1, 0xc0, 0x72, 0xb7, 0xb6, 0xb5, 0x8c,
-0xae, 0xae, 0xab, 0xa3, 0xaa, 0xaa, 0xa7, 0xb7, 0xac, 0xab, 0xa6, 0xc7,
-0xb1, 0xb0, 0xab, 0xd3, 0xb8, 0xb7, 0xb1, 0xd8, 0xbc, 0xbb, 0xb4, 0xd5,
-0xbe, 0xbc, 0xb5, 0xd3, 0xbb, 0xb9, 0xb1, 0xcb, 0xba, 0xb9, 0xb6, 0xb1,
-0xc1, 0xc1, 0xc1, 0x87, 0xd4, 0xd4, 0xd4, 0x50, 0xeb, 0xeb, 0xeb, 0x19,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0xff, 0x31,
-0xff, 0xff, 0xff, 0x37, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x01,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x0e,
-0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0x05,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x19, 0xff, 0xff, 0xff, 0x1d,
-0xff, 0xff, 0xff, 0x1d, 0xff, 0xff, 0xff, 0x1b, 0xff, 0xff, 0xff, 0x0d,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x1d, 0xff, 0xff, 0xff, 0x36,
-0xff, 0xff, 0xff, 0x34, 0xff, 0xff, 0xff, 0x17, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x08,
-0xff, 0xff, 0xff, 0x15, 0xff, 0xff, 0xff, 0x03, 0xfe, 0xfe, 0xfe, 0x00,
-0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x08,
-0xff, 0xff, 0xff, 0x18, 0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x07,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x0f,
-0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x0b, 0xff, 0xff, 0xff, 0x04,
-0xfc, 0xfc, 0xfc, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xf9, 0xf8, 0xf9, 0x00,
-0xf5, 0xf5, 0xf6, 0x00, 0xf1, 0xf1, 0xf1, 0x05, 0xec, 0xec, 0xec, 0x0d,
-0xe6, 0xe6, 0xe6, 0x18, 0xe0, 0xe1, 0xe0, 0x25, 0xdd, 0xdd, 0xdd, 0x33,
-0xdf, 0xdf, 0xde, 0x45, 0xef, 0xee, 0xee, 0x5f, 0xed, 0xed, 0xec, 0x5a,
-0xec, 0xec, 0xeb, 0x4e, 0xf4, 0xf4, 0xf4, 0x46, 0xf9, 0xf9, 0xf8, 0x34,
-0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1d, 0xff, 0xff, 0xff, 0x0a,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x4a,
-0xab, 0xab, 0xab, 0xbb, 0x5f, 0x5f, 0x5f, 0xee, 0x5c, 0x5c, 0x5c, 0xf5,
-0x7e, 0x7e, 0x7e, 0xd8, 0xe8, 0xe8, 0xe8, 0x7a, 0xff, 0xff, 0xff, 0x10,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x03,
-0xdd, 0xdd, 0xdd, 0x78, 0xaa, 0xaa, 0xaa, 0xbc, 0xfd, 0xfd, 0xfd, 0x30,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf0, 0xf0, 0xf0, 0x50,
-0xa1, 0xa1, 0xa1, 0xc2, 0xf3, 0xf3, 0xf3, 0x4f, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x03, 0xe0, 0xe0, 0xe0, 0x78,
-0x8e, 0x8e, 0x8e, 0xd3, 0x83, 0x83, 0x83, 0xda, 0x83, 0x83, 0x83, 0xdc,
-0x82, 0x82, 0x82, 0xd9, 0xa3, 0xa3, 0xa3, 0xbe, 0xf6, 0xf6, 0xf6, 0x62,
-0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0e, 0xeb, 0xeb, 0xeb, 0x78,
-0x85, 0x85, 0x85, 0xd5, 0x5c, 0x5c, 0x5c, 0xf3, 0x5d, 0x5d, 0x5d, 0xf1,
-0x97, 0x97, 0x97, 0xca, 0xf8, 0xf8, 0xf8, 0x63, 0xff, 0xff, 0xff, 0x07,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x09, 0xd5, 0xd5, 0xd5, 0x8b, 0x90, 0x90, 0x90, 0xd2,
-0xe6, 0xe6, 0xe6, 0x77, 0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x0d, 0xd5, 0xd5, 0xd5, 0x90, 0x8e, 0x8e, 0x8e, 0xd1,
-0xe1, 0xe1, 0xe1, 0x71, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x26,
-0xac, 0xac, 0xac, 0xb4, 0xd3, 0xd3, 0xd3, 0x81, 0xff, 0xff, 0xff, 0x06,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfb, 0xfb, 0xfb, 0x39, 0xa6, 0xa6, 0xa6, 0xc0, 0xe4, 0xe4, 0xe4, 0x6a,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x20,
-0xb4, 0xb4, 0xb4, 0xb2, 0xcf, 0xcf, 0xcf, 0x8a, 0xff, 0xff, 0xff, 0x08,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfd, 0xfd, 0xfe, 0x00,
-0xfc, 0xfc, 0xfd, 0x00, 0xfc, 0xfc, 0xfc, 0x00, 0xe8, 0xe8, 0xe8, 0x58,
-0x8e, 0x8e, 0x8e, 0xcc, 0xc1, 0xc1, 0xc1, 0xa4, 0xfb, 0xfb, 0xfb, 0x1e,
-0xf8, 0xf9, 0xf9, 0x08, 0xfb, 0xfb, 0xfb, 0x07, 0xf2, 0xf2, 0xf2, 0x5c,
-0x97, 0x97, 0x97, 0xca, 0xd9, 0xd9, 0xd9, 0x7b, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x41, 0x74, 0x74, 0x74, 0xe7, 0x23, 0x23, 0x23, 0xff,
-0x90, 0x90, 0x90, 0xd7, 0xa4, 0xa4, 0xa4, 0xc5, 0x55, 0x55, 0x55, 0xf7,
-0x30, 0x30, 0x30, 0xff, 0xe7, 0xe7, 0xe7, 0x7a, 0xff, 0xff, 0xff, 0x02,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0b, 0xaa, 0xaa, 0xaa, 0xbd,
-0x30, 0x30, 0x30, 0xff, 0xfa, 0xfa, 0xfa, 0x57, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xda, 0xda, 0xda, 0x87, 0x15, 0x15, 0x15, 0xff,
-0xe1, 0xe1, 0xe1, 0x87, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x0c, 0xaa, 0xaa, 0xaa, 0xbe, 0x12, 0x12, 0x12, 0xff,
-0x76, 0x76, 0x76, 0xeb, 0x79, 0x79, 0x79, 0xdc, 0x7a, 0x7a, 0x7a, 0xe3,
-0x37, 0x37, 0x37, 0xff, 0x55, 0x55, 0x55, 0xf5, 0xfb, 0xfb, 0xfb, 0x4c,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x04,
-0xea, 0xea, 0xea, 0x7e, 0x31, 0x31, 0x31, 0xff, 0x45, 0x45, 0x45, 0xfe,
-0x9d, 0x9d, 0x9d, 0xcb, 0x96, 0x96, 0x96, 0xd2, 0x35, 0x35, 0x35, 0xff,
-0x4a, 0x4a, 0x4a, 0xf8, 0xf6, 0xf6, 0xf6, 0x66, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x17,
-0x98, 0x98, 0x98, 0xd3, 0x00, 0x00, 0x00, 0xff, 0x85, 0x85, 0x85, 0xdf,
-0xff, 0xff, 0xff, 0x25, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x3e,
-0x5c, 0x5c, 0x5c, 0xf4, 0x00, 0x00, 0x00, 0xff, 0xb4, 0xb4, 0xb4, 0xb5,
-0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x4a, 0x34, 0x34, 0x34, 0xff,
-0x92, 0x92, 0x92, 0xcc, 0xff, 0xff, 0xff, 0x11, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf4, 0xf4, 0xf4, 0x67,
-0x26, 0x26, 0x26, 0xff, 0xbc, 0xbc, 0xbc, 0xab, 0xff, 0xff, 0xff, 0x04,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x41, 0x47, 0x47, 0x47, 0xff,
-0x88, 0x88, 0x88, 0xd3, 0xff, 0xff, 0xff, 0x15, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xcf, 0xcf, 0xcf, 0x99, 0x00, 0x00, 0x00, 0xff,
-0x3a, 0x3a, 0x3a, 0xff, 0xff, 0xff, 0xff, 0x58, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x0e, 0xb0, 0xb0, 0xb0, 0xbf, 0x00, 0x00, 0x00, 0xff,
-0xa3, 0xa3, 0xa3, 0xbd, 0xff, 0xff, 0xff, 0x06, 0xc8, 0xc8, 0xc8, 0xa5,
-0x15, 0x15, 0x15, 0xff, 0xd4, 0xd4, 0xd4, 0xab, 0xff, 0xff, 0xff, 0x22,
-0xff, 0xff, 0xff, 0x0e, 0xff, 0xff, 0xff, 0x64, 0x50, 0x50, 0x50, 0xf9,
-0x9b, 0x9b, 0x9b, 0xc1, 0xff, 0xff, 0xff, 0x0b, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x0c, 0xad, 0xad, 0xad, 0xba, 0x3c, 0x3c, 0x3c, 0xff,
-0xff, 0xff, 0xff, 0x5d, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x02,
-0xe5, 0xe5, 0xe5, 0x8a, 0x21, 0x21, 0x21, 0xff, 0xe3, 0xe3, 0xe3, 0x88,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0f,
-0xa8, 0xa8, 0xa8, 0xbd, 0x3f, 0x3f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x68,
-0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0x26, 0xd3, 0xd3, 0xd3, 0xb6,
-0x0c, 0x0c, 0x0c, 0xff, 0xdf, 0xdf, 0xdf, 0x80, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x2e, 0x70, 0x70, 0x70, 0xe6,
-0x43, 0x43, 0x43, 0xf9, 0xff, 0xff, 0xff, 0x71, 0xff, 0xff, 0xff, 0x13,
-0xff, 0xff, 0xff, 0x1a, 0xef, 0xef, 0xef, 0x8c, 0x23, 0x23, 0x23, 0xff,
-0x92, 0x92, 0x92, 0xd1, 0xff, 0xff, 0xff, 0x1c, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x19, 0x97, 0x97, 0x97, 0xd0,
-0x20, 0x20, 0x20, 0xff, 0x49, 0x49, 0x49, 0xfc, 0xfb, 0xfb, 0xfb, 0x5e,
-0xff, 0xff, 0xff, 0x00, 0xe9, 0xe9, 0xe9, 0x7f, 0x3c, 0x3c, 0x3c, 0xff,
-0x2a, 0x2a, 0x2a, 0xff, 0xb2, 0xb2, 0xb2, 0xb3, 0xff, 0xff, 0xff, 0x09,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfe, 0xfe, 0x4d, 0x3c, 0x3c, 0x3c, 0xff, 0x97, 0x97, 0x97, 0xc9,
-0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xf5, 0xf5, 0xf5, 0x69, 0x2f, 0x2f, 0x2f, 0xff,
-0xbf, 0xbf, 0xbf, 0xa9, 0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x44, 0x4e, 0x4e, 0x4e, 0xfb, 0x8e, 0x8e, 0x8e, 0xd0,
-0xff, 0xff, 0xff, 0x17, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01,
-0xcc, 0xcc, 0xcc, 0x99, 0x2b, 0x2b, 0x2b, 0xff, 0x34, 0x34, 0x34, 0xff,
-0xce, 0xce, 0xce, 0x9d, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x3a,
-0x6a, 0x6a, 0x6a, 0xee, 0x26, 0x26, 0x26, 0xff, 0xa6, 0xa6, 0xa6, 0xb9,
-0xff, 0xff, 0xff, 0x1d, 0x7d, 0x7d, 0x7d, 0xd9, 0x4b, 0x4b, 0x4b, 0xfa,
-0xff, 0xff, 0xff, 0x49, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x07, 0xf9, 0xf9, 0xf9, 0x4e, 0xf4, 0xf4, 0xf4, 0x43,
-0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c,
-0xb1, 0xb1, 0xb1, 0xb9, 0x2c, 0x2c, 0x2c, 0xff, 0xbc, 0xbc, 0xbc, 0xc3,
-0xc0, 0xc0, 0xc0, 0x9e, 0xc1, 0xc1, 0xc1, 0xa1, 0xa7, 0xa7, 0xa7, 0xd4,
-0x1f, 0x1f, 0x1f, 0xff, 0xe4, 0xe4, 0xe4, 0x87, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0f, 0xa9, 0xa9, 0xa9, 0xbd,
-0x3a, 0x3a, 0x3a, 0xff, 0xf4, 0xf4, 0xf4, 0x93, 0xf8, 0xf8, 0xf8, 0x55,
-0xf6, 0xf6, 0xf6, 0x6a, 0xa0, 0xa0, 0xa0, 0xd4, 0x2e, 0x2e, 0x2e, 0xfd,
-0xf1, 0xf1, 0xf1, 0x66, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xf9, 0xf9, 0xf9, 0x60, 0x30, 0x30, 0x30, 0xff, 0xad, 0xad, 0xad, 0xc1,
-0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x24, 0x85, 0x85, 0x85, 0xde, 0x42, 0x42, 0x42, 0xfc,
-0xfe, 0xfe, 0xfe, 0x47, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x19, 0x91, 0x91, 0x91, 0xcf, 0x58, 0x58, 0x58, 0xff,
-0x4f, 0x4f, 0x4f, 0xff, 0xc5, 0xc5, 0xc5, 0x9f, 0xff, 0xff, 0xff, 0x16,
-0xa1, 0xa1, 0xa1, 0xbe, 0x5f, 0x5f, 0x5f, 0xff, 0x4b, 0x4b, 0x4b, 0xff,
-0xaf, 0xaf, 0xaf, 0xb2, 0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x4c,
-0x3d, 0x3d, 0x3d, 0xff, 0x97, 0x97, 0x97, 0xc8, 0xff, 0xff, 0xff, 0x13,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xf5, 0xf5, 0xf5, 0x68, 0x30, 0x30, 0x30, 0xff, 0xbf, 0xbf, 0xbf, 0xa8,
-0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x43,
-0x4f, 0x4f, 0x4f, 0xfb, 0x8e, 0x8e, 0x8e, 0xcf, 0xff, 0xff, 0xff, 0x17,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01, 0xca, 0xca, 0xca, 0x97,
-0x3c, 0x3c, 0x3c, 0xff, 0x6a, 0x6a, 0x6a, 0xff, 0x81, 0x81, 0x81, 0xd7,
-0xff, 0xff, 0xff, 0x20, 0xea, 0xea, 0xea, 0x76, 0x48, 0x48, 0x48, 0xff,
-0x6d, 0x6d, 0x6d, 0xff, 0x9e, 0x9e, 0x9e, 0xb8, 0xff, 0xff, 0xff, 0x28,
-0x61, 0x61, 0x61, 0xe5, 0x5c, 0x5c, 0x5c, 0xee, 0xff, 0xff, 0xff, 0x32,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x01,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c, 0xb6, 0xb6, 0xb6, 0xb8,
-0x0f, 0x0f, 0x0f, 0xff, 0x3f, 0x3f, 0x3f, 0xff, 0x41, 0x41, 0x41, 0xff,
-0x42, 0x42, 0x42, 0xff, 0x37, 0x37, 0x37, 0xff, 0x18, 0x18, 0x18, 0xff,
-0xe7, 0xe7, 0xe7, 0x87, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x0e, 0xb0, 0xb0, 0xb0, 0xbb, 0x0e, 0x0e, 0x0e, 0xff,
-0x3d, 0x3d, 0x3d, 0xff, 0x3f, 0x3f, 0x3f, 0xff, 0x39, 0x39, 0x39, 0xff,
-0x01, 0x01, 0x01, 0xff, 0xa1, 0xa1, 0xa1, 0xe1, 0xff, 0xff, 0xff, 0x31,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf0, 0xf0, 0xf0, 0x74,
-0x24, 0x24, 0x24, 0xff, 0xc4, 0xc4, 0xc4, 0xa2, 0xff, 0xff, 0xff, 0x03,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x11,
-0xa6, 0xa6, 0xa6, 0xc4, 0x31, 0x31, 0x31, 0xff, 0xfb, 0xfb, 0xfb, 0x59,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x19,
-0x8f, 0x8f, 0x8f, 0xd0, 0x67, 0x67, 0x67, 0xf9, 0x84, 0x84, 0x84, 0xf3,
-0x79, 0x79, 0x79, 0xd7, 0xff, 0xff, 0xff, 0x62, 0x5d, 0x5d, 0x5d, 0xea,
-0x9e, 0x9e, 0x9e, 0xee, 0x44, 0x44, 0x44, 0xff, 0xaf, 0xaf, 0xaf, 0xb2,
-0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x4c, 0x3d, 0x3d, 0x3d, 0xff,
-0x97, 0x97, 0x97, 0xc8, 0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf5, 0xf5, 0xf5, 0x68,
-0x30, 0x30, 0x30, 0xff, 0xbf, 0xbf, 0xbf, 0xa7, 0xff, 0xff, 0xff, 0x05,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x42, 0x50, 0x50, 0x50, 0xfb,
-0x8e, 0x8e, 0x8e, 0xcf, 0xff, 0xff, 0xff, 0x17, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x01, 0xca, 0xca, 0xca, 0x97, 0x35, 0x35, 0x35, 0xff,
-0xb9, 0xb9, 0xb9, 0xea, 0x45, 0x45, 0x45, 0xf8, 0xff, 0xff, 0xff, 0x6b,
-0xa4, 0xa4, 0xa4, 0xb8, 0x6a, 0x6a, 0x6a, 0xf8, 0x8d, 0x8d, 0x8d, 0xf6,
-0x99, 0x99, 0x99, 0xb9, 0xff, 0xff, 0xff, 0x1f, 0x79, 0x79, 0x79, 0xdb,
-0x4e, 0x4e, 0x4e, 0xf9, 0xff, 0xff, 0xff, 0x43, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x12, 0xc6, 0xc6, 0xc6, 0x9a,
-0xbe, 0xbe, 0xbe, 0x95, 0xff, 0xff, 0xff, 0x0e, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x0c, 0xae, 0xae, 0xae, 0xb9, 0x3a, 0x3a, 0x3a, 0xff,
-0xf6, 0xf6, 0xf6, 0x94, 0xfa, 0xfa, 0xfa, 0x55, 0xfa, 0xfa, 0xfa, 0x59,
-0xda, 0xda, 0xda, 0xb2, 0x21, 0x21, 0x21, 0xff, 0xe3, 0xe3, 0xe3, 0x87,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0f,
-0xaa, 0xaa, 0xaa, 0xbc, 0x34, 0x34, 0x34, 0xff, 0xcc, 0xcc, 0xcc, 0xba,
-0xcf, 0xcf, 0xcf, 0x94, 0xce, 0xce, 0xce, 0xa6, 0x66, 0x66, 0x66, 0xee,
-0x49, 0x49, 0x49, 0xf6, 0xfc, 0xfc, 0xfc, 0x4d, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xf8, 0xf8, 0xf8, 0x63, 0x2e, 0x2e, 0x2e, 0xff,
-0xb1, 0xb1, 0xb1, 0xbc, 0xff, 0xff, 0xff, 0x0d, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x20, 0x8b, 0x8b, 0x8b, 0xdb,
-0x3f, 0x3f, 0x3f, 0xfd, 0xfe, 0xfe, 0xfe, 0x49, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x19, 0x8f, 0x8f, 0x8f, 0xd1,
-0x5e, 0x5e, 0x5e, 0xee, 0xd0, 0xd0, 0xd0, 0xc6, 0x45, 0x45, 0x45, 0xf7,
-0xe3, 0xe3, 0xe3, 0xc6, 0x3d, 0x3d, 0x3d, 0xf8, 0xe4, 0xe4, 0xe4, 0xc3,
-0x3c, 0x3c, 0x3c, 0xfe, 0xaf, 0xaf, 0xaf, 0xb4, 0xff, 0xff, 0xff, 0x0a,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfe, 0xfe, 0xfe, 0x4c, 0x3d, 0x3d, 0x3d, 0xff, 0x97, 0x97, 0x97, 0xc8,
-0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xf5, 0xf5, 0xf5, 0x69, 0x2e, 0x2e, 0x2e, 0xff,
-0xc2, 0xc2, 0xc2, 0xaa, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x43, 0x4f, 0x4f, 0x4f, 0xfd, 0x8c, 0x8c, 0x8c, 0xcf,
-0xff, 0xff, 0xff, 0x16, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01,
-0xca, 0xca, 0xca, 0x98, 0x2e, 0x2e, 0x2e, 0xff, 0xee, 0xee, 0xee, 0xbf,
-0x43, 0x43, 0x43, 0xf6, 0xd3, 0xd3, 0xd3, 0xc9, 0x65, 0x65, 0x65, 0xec,
-0xae, 0xae, 0xae, 0xd1, 0x8f, 0x8f, 0x8f, 0xe3, 0x99, 0x99, 0x99, 0xbc,
-0xff, 0xff, 0xff, 0x09, 0xbd, 0xbd, 0xbd, 0xae, 0x1a, 0x1a, 0x1a, 0xff,
-0xe6, 0xe6, 0xe6, 0x9a, 0xff, 0xff, 0xff, 0x15, 0xff, 0xff, 0xff, 0x0a,
-0xff, 0xff, 0xff, 0x71, 0x30, 0x30, 0x30, 0xff, 0x90, 0x90, 0x90, 0xcd,
-0xff, 0xff, 0xff, 0x11, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c,
-0xae, 0xae, 0xae, 0xbb, 0x3a, 0x3a, 0x3a, 0xff, 0xfd, 0xfd, 0xfd, 0x57,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xde, 0xde, 0xde, 0x86,
-0x21, 0x21, 0x21, 0xff, 0xe3, 0xe3, 0xe3, 0x87, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0e, 0xa8, 0xa8, 0xa8, 0xbe,
-0x41, 0x41, 0x41, 0xff, 0xff, 0xff, 0xff, 0x54, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x0b, 0xc9, 0xc9, 0xc9, 0xad, 0x2e, 0x2e, 0x2e, 0xff,
-0xf6, 0xf6, 0xf6, 0x6b, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x33, 0x68, 0x68, 0x68, 0xeb, 0x4d, 0x4d, 0x4d, 0xf5,
-0xff, 0xff, 0xff, 0x64, 0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x11,
-0xf7, 0xf7, 0xf7, 0x80, 0x2b, 0x2b, 0x2b, 0xff, 0x88, 0x88, 0x88, 0xd7,
-0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x19, 0x8f, 0x8f, 0x8f, 0xd2, 0x58, 0x58, 0x58, 0xec,
-0xff, 0xff, 0xff, 0x8e, 0x4e, 0x4e, 0x4e, 0xf5, 0x6d, 0x6d, 0x6d, 0xfe,
-0x6b, 0x6b, 0x6b, 0xe4, 0xff, 0xff, 0xff, 0x91, 0x38, 0x38, 0x38, 0xfe,
-0xaf, 0xaf, 0xaf, 0xb5, 0xff, 0xff, 0xff, 0x0a, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x4c,
-0x3d, 0x3d, 0x3d, 0xff, 0x97, 0x97, 0x97, 0xc9, 0xff, 0xff, 0xff, 0x13,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xfb, 0xfb, 0xfb, 0x59, 0x2e, 0x2e, 0x2e, 0xff, 0x9b, 0x9b, 0x9b, 0xd4,
-0xff, 0xff, 0xff, 0x2b, 0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x7b,
-0x2b, 0x2b, 0x2b, 0xff, 0xa6, 0xa6, 0xa6, 0xbd, 0xff, 0xff, 0xff, 0x0c,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01, 0xca, 0xca, 0xca, 0x99,
-0x2c, 0x2c, 0x2c, 0xff, 0xfe, 0xfe, 0xfe, 0x95, 0x7f, 0x7f, 0x7f, 0xd5,
-0x61, 0x61, 0x61, 0xfe, 0x45, 0x45, 0x45, 0xff, 0xf3, 0xf3, 0xf3, 0x97,
-0x86, 0x86, 0x86, 0xd8, 0x99, 0x99, 0x99, 0xbe, 0xff, 0xff, 0xff, 0x00,
-0xfd, 0xfd, 0xfd, 0x4f, 0x5c, 0x5c, 0x5c, 0xf2, 0x31, 0x31, 0x31, 0xff,
-0xa8, 0xa8, 0xa8, 0xc5, 0xb7, 0xb7, 0xb7, 0xb8, 0x51, 0x51, 0x51, 0xf7,
-0x3c, 0x3c, 0x3c, 0xfd, 0xf2, 0xf2, 0xf2, 0x6b, 0xff, 0xff, 0xff, 0x01,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0b, 0xa9, 0xa9, 0xa9, 0xbd,
-0x2e, 0x2e, 0x2e, 0xff, 0xfa, 0xfa, 0xfa, 0x59, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xda, 0xda, 0xda, 0x89, 0x13, 0x13, 0x13, 0xff,
-0xe1, 0xe1, 0xe1, 0x88, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x0d, 0xa3, 0xa3, 0xa3, 0xc0, 0x34, 0x34, 0x34, 0xff,
-0xfc, 0xfc, 0xfc, 0x50, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xc9, 0xc9, 0xc9, 0x99, 0x17, 0x17, 0x17, 0xff, 0xe9, 0xe9, 0xe9, 0x7e,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x05,
-0xe4, 0xe4, 0xe4, 0x89, 0x25, 0x25, 0x25, 0xff, 0x53, 0x53, 0x53, 0xf6,
-0xb3, 0xb3, 0xb3, 0xbb, 0xaa, 0xaa, 0xaa, 0xc3, 0x3c, 0x3c, 0x3c, 0xff,
-0x3c, 0x3c, 0x3c, 0xfd, 0xf1, 0xf1, 0xf1, 0x71, 0xff, 0xff, 0xff, 0x01,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x18,
-0x88, 0x88, 0x88, 0xd7, 0x4c, 0x4c, 0x4c, 0xf4, 0xff, 0xff, 0xff, 0x59,
-0x89, 0x89, 0x89, 0xd5, 0x00, 0x00, 0x00, 0xff, 0xb4, 0xb4, 0xb4, 0xb6,
-0xff, 0xff, 0xff, 0x6a, 0x2b, 0x2b, 0x2b, 0xff, 0xaa, 0xaa, 0xaa, 0xb7,
-0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x4c, 0x32, 0x32, 0x32, 0xff,
-0x91, 0x91, 0x91, 0xcd, 0xff, 0xff, 0xff, 0x12, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x25,
-0x8e, 0x8e, 0x8e, 0xd7, 0x18, 0x18, 0x18, 0xff, 0xa1, 0xa1, 0xa1, 0xd0,
-0xb9, 0xb9, 0xb9, 0xb7, 0x57, 0x57, 0x57, 0xf4, 0x32, 0x32, 0x32, 0xff,
-0xf0, 0xf0, 0xf0, 0x70, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x01, 0xc7, 0xc7, 0xc7, 0x9a, 0x1f, 0x1f, 0x1f, 0xff,
-0xf9, 0xf9, 0xf9, 0x78, 0xd1, 0xd1, 0xd1, 0x9e, 0x00, 0x00, 0x00, 0xff,
-0x5c, 0x5c, 0x5c, 0xee, 0xff, 0xff, 0xff, 0x5b, 0x7a, 0x7a, 0x7a, 0xdd,
-0x92, 0x92, 0x92, 0xc3, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x05,
-0xfa, 0xfa, 0xfa, 0x63, 0x89, 0x89, 0x89, 0xd5, 0x4b, 0x4b, 0x4b, 0xfc,
-0x4b, 0x4b, 0x4b, 0xfe, 0x77, 0x77, 0x77, 0xdf, 0xec, 0xec, 0xec, 0x7a,
-0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x03, 0xd1, 0xd1, 0xd1, 0x86, 0x8e, 0x8e, 0x8e, 0xd1,
-0xfd, 0xfd, 0xfd, 0x37, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xeb, 0xeb, 0xeb, 0x5b, 0x81, 0x81, 0x81, 0xd4, 0xef, 0xef, 0xef, 0x5b,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x04,
-0xce, 0xce, 0xce, 0x89, 0x91, 0x91, 0x91, 0xcd, 0xfe, 0xfe, 0xfe, 0x31,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xef, 0xef, 0xef, 0x5d,
-0x7a, 0x7a, 0x7a, 0xd9, 0xda, 0xda, 0xda, 0x73, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x14,
-0xe0, 0xe0, 0xe0, 0x8c, 0x6a, 0x6a, 0x6a, 0xe5, 0x49, 0x49, 0x49, 0xff,
-0x4a, 0x4a, 0x4a, 0xfd, 0x7b, 0x7b, 0x7b, 0xdc, 0xf0, 0xf0, 0xf0, 0x77,
-0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0b, 0xbf, 0xbf, 0xbf, 0x9e,
-0x9e, 0x9e, 0x9e, 0xbb, 0xff, 0xff, 0xff, 0x22, 0xdd, 0xdd, 0xdd, 0x7d,
-0x79, 0x79, 0x79, 0xda, 0xf2, 0xf2, 0xf2, 0x5c, 0xff, 0xff, 0xff, 0x36,
-0x8d, 0x8d, 0x8d, 0xd0, 0xd1, 0xd1, 0xd1, 0x80, 0xff, 0xff, 0xff, 0x01,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x2e, 0x8b, 0x8b, 0x8b, 0xcf, 0xc0, 0xc0, 0xc0, 0x97,
-0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x4d,
-0x9a, 0x9a, 0x9a, 0xcc, 0x4c, 0x4c, 0x4c, 0xfa, 0x49, 0x49, 0x49, 0xff,
-0x6a, 0x6a, 0x6a, 0xe6, 0xe2, 0xe2, 0xe2, 0x88, 0xff, 0xff, 0xff, 0x11,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xe1, 0xe1, 0xe1, 0x68, 0x86, 0x86, 0x86, 0xd3, 0xf9, 0xf9, 0xf9, 0x46,
-0xff, 0xff, 0xff, 0x46, 0x80, 0x80, 0x80, 0xd7, 0xc5, 0xc5, 0xc5, 0x9a,
-0xff, 0xff, 0xff, 0x1c, 0xb7, 0xb7, 0xb7, 0xa0, 0xc5, 0xc5, 0xc5, 0x8a,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x21, 0xff, 0xff, 0xff, 0x44, 0xfe, 0xfe, 0xfe, 0x45,
-0xff, 0xff, 0xff, 0x28, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0xff, 0x1b, 0xff, 0xff, 0xff, 0x05,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0a,
-0xff, 0xff, 0xff, 0x1d, 0xff, 0xff, 0xff, 0x0a, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x10,
-0xff, 0xff, 0xff, 0x1b, 0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x21,
-0xff, 0xff, 0xff, 0x11, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x06,
-0xff, 0xff, 0xff, 0x2d, 0xfe, 0xfe, 0xfe, 0x47, 0xff, 0xff, 0xff, 0x46,
-0xff, 0xff, 0xff, 0x26, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0x17,
-0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x0d, 0xff, 0xff, 0xff, 0x21,
-0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x1b,
-0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x05,
-0xff, 0xff, 0xff, 0x1e, 0xff, 0xff, 0xff, 0x14, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x1c,
-0xff, 0xff, 0xff, 0x42, 0xfd, 0xfd, 0xfd, 0x48, 0xff, 0xff, 0xff, 0x2e,
-0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00,
-0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c,
-0xff, 0xff, 0xff, 0x1c, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x05,
-0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x12, 0xff, 0xff, 0xff, 0x01,
-0xff, 0xff, 0xff, 0x11, 0xff, 0xff, 0xff, 0x0e };
-
-#endif /* CR_LOGO_H */
Index: /trunk/src/VBox/GuestHost/OpenGL/include/cr_mem.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_mem.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/cr_mem.h	(revision 78190)
@@ -8,5 +8,10 @@
 #define CR_MEM_H
 
+#include "cr_error.h"
+
+#include <stdlib.h>
 #include <iprt/types.h>
+#include <iprt/mem.h>
+#include <iprt/string.h>
 
 #ifdef __cplusplus
@@ -14,21 +19,34 @@
 #endif
 
-#define DEBUG_MEM 0
+DECLINLINE(void) crMemcpy( void *dst, const void *src, unsigned int bytes )
+{
+	CRASSERT(dst || 0==bytes);
+	CRASSERT(src || 0==bytes);
+	(void) memcpy( dst, src, bytes );
+}
 
-void *crAllocDebug( unsigned int nbytes, const char *file, int line );
-void *crCallocDebug( unsigned int nbytes, const char *file, int line );
-#if DEBUG_MEM
-#define crAlloc(N) crAllocDebug(N, __FILE__, __LINE__)
-#define crCalloc(N) crCallocDebug(N, __FILE__, __LINE__)
-#else
+DECLINLINE(void) crMemset( void *ptr, int value, unsigned int bytes )
+{
+	CRASSERT(ptr);
+	memset( ptr, value, bytes );
+}
+
+DECLINLINE(void) crMemZero( void *ptr, unsigned int bytes )
+{
+	CRASSERT(ptr);
+	memset( ptr, 0, bytes );
+}
+
+DECLINLINE(int) crMemcmp( const void *p1, const void *p2, unsigned int bytes )
+{
+	CRASSERT(p1);
+	CRASSERT(p2);
+	return memcmp( p1, p2, bytes );
+}
+
 extern DECLEXPORT(void *) crAlloc( unsigned int nbytes );
 extern DECLEXPORT(void *) crCalloc( unsigned int nbytes );
-#endif
 extern DECLEXPORT(void) crRealloc( void **ptr, unsigned int bytes );
 extern DECLEXPORT(void) crFree( void *ptr );
-extern DECLEXPORT(void) crMemcpy( void *dst, const void *src, unsigned int bytes );
-extern DECLEXPORT(void) crMemset( void *ptr, int value, unsigned int bytes );
-extern DECLEXPORT(void) crMemZero( void *ptr, unsigned int bytes );
-extern DECLEXPORT(int)  crMemcmp( const void *p1, const void *p2, unsigned int bytes );
 
 #ifdef __cplusplus
Index: /trunk/src/VBox/GuestHost/OpenGL/include/cr_net.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_net.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/cr_net.h	(revision 78190)
@@ -8,29 +8,6 @@
 #define CR_NET_H
 
-#ifdef WINDOWS
-#define WIN32_LEAN_AND_MEAN
-# ifndef VBOX
-#pragma warning( push, 3 ) /* shut up about warnings in YOUR OWN HEADER FILES!!! */
-#include <winsock.h>
-# else
+#ifdef RT_OS_WINDOWS
 # include <iprt/win/winsock.h>
-# endif /* VBOX */
-#endif
-
-#include <stdio.h>
-
-#ifndef WINDOWS
-#include <sys/socket.h>
-#ifndef DARWIN
-#ifdef AF_INET6
-/* getaddrinfo & co appeared with ipv6 */
-#define ADDRINFO
-#endif
-#endif
-#include <netinet/in.h>
-#endif
-
-#ifdef SunOS
-#include <sys/types.h>
 #endif
 
@@ -46,30 +23,11 @@
 #endif
 
-#define DEFAULT_SERVER_PORT 7000
-
-/* If you change this, update DefaultMothershipPort in mothership.py */
-#define DEFAULT_MOTHERSHIP_PORT 10000
-
 typedef struct CRConnection CRConnection;
 
 typedef enum {
     CR_NO_CONNECTION,
-    CR_SDP,
-    CR_TCPIP,
-    CR_UDPTCPIP,
-    CR_FILE,
-    CR_GM,
-    CR_IB,
-    CR_TEAC,
-    CR_TCSCOMM,
     CR_VBOXHGCM,
     CR_DROP_PACKETS
 } CRConnectionType;
-
-#if defined(WINDOWS)
-typedef SOCKET CRSocket;
-#else
-typedef int    CRSocket;
-#endif
 
 typedef void (*CRVoidFunc)( void );
@@ -143,12 +101,9 @@
     int broker;              /* is connection brokered through mothership? */
     int threaded;            /* is this a threaded connection? */
-    int endianness, swap;
+    int swap;
     int actual_network;      /* is this a real network? */
 
     unsigned char *userbuf;
     int userbuf_len;
-
-    char *hostname;
-    int port;
 
     /* To allocate a data buffer of size conn->buffer_size bytes */
@@ -173,5 +128,5 @@
     void  (*HandleNewMessage)( CRConnection *conn, CRMessage *mess, unsigned int len );
     /* To accept a new connection from a client */
-    void  (*Accept)( CRConnection *conn, const char *hostname, unsigned short port );
+    void  (*Accept)( CRConnection *conn);
     /* To connect to a server (return 0 if error, 1 if success) */
     int  (*Connect)( CRConnection *conn );
@@ -191,46 +146,6 @@
     int recv_credits;
 
-    /* TCP/IP */
-    CRSocket tcp_socket;
-    int index;
-
-    CRSocket sdp_socket;
-
-    /* UDP/IP */
-    CRSocket udp_socket;
-#ifndef ADDRINFO
-    struct sockaddr_in remoteaddr;
-#else
-    struct sockaddr_storage remoteaddr;
-#endif
-
-    /* UDP/TCP/IP */
-    unsigned int seq;
-    unsigned int ack;
-    void *udp_packet;
-    int udp_packetlen;
-
-    /* FILE Tracing */
-    enum { CR_FILE_WRITE, CR_FILE_READ } file_direction;
-    char *filename;
-    int fd;
-
-    /* Myrinet GM */
-    unsigned int gm_node_id;
-    unsigned int gm_port_num;
-
-    /* Mellanox IB */
-    unsigned int ib_node_id;
-    unsigned int ib_port_num;
-
-    /* Quadrics Elan3 (teac) */
-    int teac_id;
-    int teac_rank;
-
-    /* Quadrics Elan3 (tcscomm) */
-    int tcscomm_id;
-    int tcscomm_rank;
-
     /* VBox HGCM */
+    int      index;
     uint32_t u32ClientID;
     uint8_t  *pBuffer;
@@ -275,9 +190,8 @@
 extern DECLEXPORT(void) crNetFree( CRConnection *conn, void *buf );
 
-extern DECLEXPORT(void) crNetAccept( CRConnection *conn, const char *hostname, unsigned short port );
+extern DECLEXPORT(void) crNetAccept( CRConnection *conn );
 extern DECLEXPORT(int) crNetConnect( CRConnection *conn );
 extern DECLEXPORT(void) crNetDisconnect( CRConnection *conn );
 extern DECLEXPORT(void) crNetFreeConnection( CRConnection *conn );
-extern DECLEXPORT(void) crCloseSocket( CRSocket sock );
 
 extern DECLEXPORT(void) crNetSend( CRConnection *conn, void **bufp, const void *start, unsigned int len );
@@ -318,5 +232,5 @@
 extern DECLEXPORT(void) crNetDispatchMessage( CRNetReceiveFuncList *rfl, CRConnection *conn, CRMessage *msg, unsigned int len );
 
-extern DECLEXPORT(CRConnection *) crNetConnectToServer( const char *server, unsigned short default_port, int mtu, int broker
+extern DECLEXPORT(CRConnection *) crNetConnectToServer( const char *server, int mtu, int broker
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
                 , struct VBOXUHGSMI *pHgsmi
@@ -331,16 +245,4 @@
 
 extern DECLEXPORT(void) crNetRecvReadPixels( const CRMessageReadPixels *rp, unsigned int len );
-
-
-/*
- * Quadrics stuff
- */
-#define CR_QUADRICS_DEFAULT_LOW_CONTEXT  32
-#define CR_QUADRICS_DEFAULT_HIGH_CONTEXT 35
-
-extern DECLEXPORT(void) crNetSetRank( int my_rank );
-extern DECLEXPORT(void) crNetSetContextRange( int low_context, int high_context );
-extern DECLEXPORT(void) crNetSetNodeRange( const char *low_node, const char *high_node );
-extern DECLEXPORT(void) crNetSetKey( const unsigned char* key, const int keyLength );
 
 
Index: /trunk/src/VBox/GuestHost/OpenGL/include/cr_pack.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_pack.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/cr_pack.h	(revision 78190)
@@ -12,5 +12,4 @@
 #include "cr_protocol.h"
 #include "cr_opcodes.h"
-#include "cr_endian.h"
 #include "state/cr_statetypes.h"
 #include "state/cr_currentpointers.h"
@@ -84,5 +83,4 @@
     GLvectorf bounds_min, bounds_max;
     int updateBBOX;
-    int swapping;
     CRPackBuffer *currentBuffer;
 #ifdef CHROMIUM_THREADSAFE
@@ -122,5 +120,5 @@
 #endif
 
-extern DECLEXPORT(CRPackContext *) crPackNewContext(int swapping);
+extern DECLEXPORT(CRPackContext *) crPackNewContext(void);
 extern DECLEXPORT(void) crPackDeleteContext(CRPackContext *pc);
 extern DECLEXPORT(void) crPackSetContext( CRPackContext *pc );
@@ -164,5 +162,4 @@
 #ifndef IN_RING0
 extern DECLEXPORT(void) crWriteUnalignedDouble( void *buffer, double d );
-extern DECLEXPORT(void) crWriteSwappedDouble( void *buffer, double d );
 #endif
 
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_perf.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_perf.h	(revision 78189)
+++ 	(revision )
@@ -1,76 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved.
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifndef CR_PERF_H
-#define CR_PERF_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** 
- * For the performance SPU. Allows application to obtain it's own
- * statistics, and reset etc. 
- */
-typedef struct {
-	int 	count;
-
-	int 	v2d, v2f, v2i, v2s;
-	int 	v2dv, v2fv, v2iv, v2sv;
-	int 	v3d, v3f, v3i, v3s;
-	int 	v3dv, v3fv, v3iv, v3sv;
-	int 	v4d, v4f, v4i, v4s;
-	int 	v4dv, v4fv, v4iv, v4sv;
-
-	int	ipoints;	/**< Interpreted points */
-	int	ilines; 	/**< Interpreted lines */
-	int	itris;		/**< Interpreted tris */
-	int	iquads; 	/**< Interpreted quads */
-	int	ipolygons; 	/**< Interpreted polygons */
-} PerfVertex;
-
-/**
- * Primitives data
- */
-typedef struct {
-	PerfVertex points;
-	PerfVertex lines;
-	PerfVertex lineloop;
-	PerfVertex linestrip;
-	PerfVertex triangles;
-	PerfVertex tristrip;
-	PerfVertex trifan;
-	PerfVertex quads;
-	PerfVertex quadstrip;
-	PerfVertex polygon;
-} PerfPrim;
-
-typedef struct {
-	int draw_pixels;
-	int read_pixels;
-
-	int teximage1DBytes;  /**< bytes given to glTexImage1D */
-	int teximage2DBytes;  /**< bytes given to glTexImage2D */
-	int teximage3DBytes;  /**< bytes given to glTexImage3D */
-	int texsubimage1DBytes;  /**< bytes given to glTexSubImage1D */
-	int texsubimage2DBytes;  /**< bytes given to glTexSubImage2D */
-	int texsubimage3DBytes;  /**< bytes given to glTexSubImage3D */
-	int newLists;       /**< glNewList calls */
-	int callLists;      /**< glCallList(s) calls */
-
-	PerfVertex *cur_vertex;
-	PerfVertex vertex_snapshot;
-	PerfPrim vertex_data;
-} PerfData;
-
-
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* CR_PERF_H */
Index: /trunk/src/VBox/GuestHost/OpenGL/include/cr_process.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_process.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/cr_process.h	(revision 78190)
@@ -33,15 +33,5 @@
 
 
-extern DECLEXPORT(void) crSleep( unsigned int seconds );
-
-extern DECLEXPORT(void) crMsleep( unsigned int msec );
-
-extern DECLEXPORT(CRpid) crSpawn( const char *command, const char *argv[] );
-
-extern DECLEXPORT(void) crKill( CRpid pid );
-
 extern DECLEXPORT(void) crGetProcName( char *name, int maxLen );
-
-extern DECLEXPORT(void) crGetCurrentDir( char *dir, int maxLen );
 
 extern DECLEXPORT(CRpid) crGetPID(void);
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_rand.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_rand.h	(revision 78189)
+++ 	(revision )
@@ -1,25 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved.
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifndef CR_RAND_H
-#define CR_RAND_H
-
-#include <iprt/cdefs.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-DECLEXPORT(void) crRandSeed( unsigned long seed );
-DECLEXPORT(void) crRandAutoSeed(void);
-DECLEXPORT(float) crRandFloat( float min, float max );
-DECLEXPORT(int) crRandInt( int min, int max );
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* CR_RAND_H */
Index: /trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/cr_server.h	(revision 78190)
@@ -16,4 +16,5 @@
 #include "cr_blitter.h"
 #include "cr_htable.h"
+#include "cr_unpack.h"
 #include "spu_dispatch_table.h"
 #include "cr_dump.h"
@@ -389,4 +390,10 @@
     CRNetworkPointer return_ptr;
     CRNetworkPointer writeback_ptr;
+    /*
+     * The current active unpacker state, this hack is required for the server dispatch routines
+     * (see crServerDispatchReadPixels for example) as it needs to read data from the buffer
+     * but it is not possible to supply the state as a parameter unfortunately.
+     */
+    PCrUnpackerState pUnpackerState;
 
     CRLimitsState limits; /**< GL limits for any contexts we create */
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_sortarray.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_sortarray.h	(revision 78189)
+++ 	(revision )
@@ -1,102 +1,0 @@
-/* $Id$ */
-
-/** @file
- * Sorted array API
- */
-
-/*
- * Copyright (C) 2014-2019 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-#ifndef ___cr_sortarray_h_
-#define ___cr_sortarray_h_
-
-#include <iprt/types.h>
-#include <iprt/assert.h>
-
-typedef struct CR_SORTARRAY
-{
-    uint32_t cBufferSize;
-    uint32_t cSize;
-    uint64_t *pElements;
-} CR_SORTARRAY;
-
-
-#ifndef IN_RING0
-# define VBOXSADECL(_type) DECLEXPORT(_type)
-#else
-# define VBOXSADECL(_type) RTDECL(_type)
-#endif
-
-
-DECLINLINE(uint32_t) CrSaGetSize(const CR_SORTARRAY *pArray)
-{
-    return pArray->cSize;
-}
-
-DECLINLINE(uint64_t) CrSaGetVal(const CR_SORTARRAY *pArray, uint32_t i)
-{
-    Assert(i < pArray->cSize);
-    return pArray->pElements[i];
-}
-
-DECLINLINE(const uint64_t*) CrSaGetElements(const CR_SORTARRAY *pArray)
-{
-    return pArray->pElements;
-}
-
-DECLINLINE(void) CrSaClear(CR_SORTARRAY *pArray)
-{
-    pArray->cSize = 0;
-}
-
-VBOXSADECL(int) CrSaInit(CR_SORTARRAY *pArray, uint32_t cInitBuffer);
-VBOXSADECL(void) CrSaCleanup(CR_SORTARRAY *pArray);
-/*
- * @return true if element is found */
-VBOXSADECL(bool) CrSaContains(const CR_SORTARRAY *pArray, uint64_t element);
-
-/*
- * @return VINF_SUCCESS  if element is added
- * VINF_ALREADY_INITIALIZED if element was in array already
- * VERR_NO_MEMORY - no memory
- *  */
-VBOXSADECL(int) CrSaAdd(CR_SORTARRAY *pArray, uint64_t element);
-
-/*
- * @return VINF_SUCCESS  if element is removed
- * VINF_ALREADY_INITIALIZED if element was NOT in array
- *  */
-VBOXSADECL(int) CrSaRemove(CR_SORTARRAY *pArray, uint64_t element);
-
-/*
- * @return VINF_SUCCESS on success
- * VERR_NO_MEMORY - no memory
- *  */
-VBOXSADECL(void) CrSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2);
-VBOXSADECL(int) CrSaIntersected(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult);
-
-/*
- * @return VINF_SUCCESS on success
- * VERR_NO_MEMORY - no memory
- *  */
-VBOXSADECL(int) CrSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult);
-
-/*
- * @return VINF_SUCCESS on success
- * VERR_NO_MEMORY - no memory
- *  */
-VBOXSADECL(int) CrSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult);
-
-VBOXSADECL(int) CrSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2);
-
-VBOXSADECL(bool) CrSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2);
-
-#endif /* ___cr_sortarray_h_ */
Index: /trunk/src/VBox/GuestHost/OpenGL/include/cr_spu.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_spu.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/cr_spu.h	(revision 78190)
@@ -21,8 +21,4 @@
 #ifdef DARWIN
 # include <OpenGL/OpenGL.h>
-# ifdef VBOX_WITH_COCOA_QT
-# else
-#  include <AGL/agl.h>
-# endif
 #endif
 
@@ -55,28 +51,4 @@
     SPUNamedFunctionTable *table;
 } SPUFunctions;
-
-/**
- * SPU Option callback
- * \param spu
- * \param response
- */
-typedef void (*SPUOptionCB)( void *spu, const char *response );
-
-typedef enum { CR_BOOL, CR_INT, CR_FLOAT, CR_STRING, CR_ENUM } cr_type;
-
-/**
- * SPU Options table
- */
-typedef struct {
-    const char *option; /**< Name of the option */
-    cr_type type;       /**< Type of option */
-    int numValues;  /**< usually 1 */
-    const char *deflt;  /**< comma-separated string of [numValues] defaults */
-    const char *min;    /**< comma-separated string of [numValues] minimums */
-    const char *max;    /**< comma-separated string of [numValues] maximums */
-    const char *description; /**< Textual description of the option */
-    SPUOptionCB cb;     /**< Callback function */
-} SPUOptions, *SPUOptionsPtr;
-
 
 /** Init spu */
@@ -87,6 +59,5 @@
 typedef int (*SPUCleanupFuncPtr)(void);
 /** Load spu */
-typedef int (*SPULoadFunction)(char **, char **, void *, void *, void *,
-                   SPUOptionsPtr *, int *);
+typedef int (*SPULoadFunction)(char **, char **, void *, void *, void *, int *);
 
 
@@ -121,5 +92,4 @@
     SPUCleanupFuncPtr cleanup;  /**< SPU cleanup func */
     SPUFunctions *function_table;   /**< Function table for spu */
-    SPUOptions *options;        /**< Options table */
     SPUDispatchTable dispatch_table;
     void *privatePtr;       /**< pointer to SPU-private data */
@@ -154,47 +124,4 @@
 /*@}*/
 #elif defined(DARWIN)
-# ifndef VBOX_WITH_COCOA_QT
-/**
- * Apple/AGL
- */
-/*@{*/
-typedef AGLContext (*aglCreateContextFunc_t)( AGLPixelFormat, AGLContext );
-typedef GLboolean (*aglDestroyContextFunc_t)( AGLContext );
-typedef GLboolean (*aglSetCurrentContextFunc_t)( AGLContext );
-typedef void (*aglSwapBuffersFunc_t)( AGLContext );
-typedef AGLPixelFormat (*aglChoosePixelFormatFunc_t) (const AGLDevice *, GLint, const GLint *);
-typedef GLboolean (*aglDescribePixelFormatFunc_t)( AGLPixelFormat, GLint, GLint * );
-/* <--set pixel format */
-typedef AGLContext (*aglGetCurrentContextFunc_t)();
-/* <--get proc address -- none exists */
-typedef void* (*aglGetProcAddressFunc_t)( const GLubyte *name );
-
-/* These are here just in case */
-typedef GLboolean (*aglDescribeRendererFunc_t)( AGLRendererInfo, GLint, GLint * );
-typedef void (*aglDestroyPixelFormatFunc_t)( AGLPixelFormat );
-typedef void (*aglDestroyRendererInfoFunc_t)( AGLRendererInfo );
-typedef AGLDevice* (*aglDevicesOfPixelFormatFunc_t)( AGLPixelFormat, GLint );
-typedef GLboolean (*aglDisableFunc_t)( AGLContext, GLenum );
-typedef GLboolean (*aglEnableFunc_t)( AGLContext, GLenum );
-typedef const GLubyte* (*aglErrorStringFunc_t)( GLenum );
-typedef AGLDrawable (*aglGetDrawableFunc_t)( AGLContext );
-typedef GLenum (*aglGetErrorFunc_t)();
-typedef GLboolean (*aglGetIntegerFunc_t)( AGLContext, GLenum, GLint* );
-typedef void (*aglGetVersionFunc_t)( GLint *, GLint * );
-typedef GLint (*aglGetVirtualScreenFunc_t)( AGLContext );
-typedef GLboolean (*aglIsEnabledFunc_t)( AGLContext, GLenum );
-typedef AGLPixelFormat (*aglNextPixelFormatFunc_t)( AGLPixelFormat );
-typedef AGLRendererInfo (*aglNextRendererInfoFunc_t)( AGLRendererInfo );
-typedef AGLRendererInfo (*aglQueryRendererInfoFunc_t)( const AGLDevice *, GLint );
-typedef void (*aglReserLibraryFunc_t)();
-typedef GLboolean (*aglSetDrawableFunc_t)( AGLContext, AGLDrawable );
-typedef GLboolean (*aglSetFullScreenFunc_t)( AGLContext, GLsizei, GLsizei, GLsizei, GLint );
-typedef GLboolean (*aglSetIntegerFunc_t)( AGLContext, GLenum, const GLint * );
-typedef GLboolean (*aglSetOffScreenFunc_t)( AGLContext, GLsizei, GLsizei, GLsizei, void * );
-typedef GLboolean (*aglSetVirtualScreenFunc_t)( AGLContext, GLint );
-typedef GLboolean (*aglUpdateContextFunc_t)( AGLContext );
-typedef GLboolean (*aglUseFontFunc_t)( AGLContext, GLint, Style, GLint, GLint, GLint, GLint );
-# endif
-
 typedef const GLubyte *(*glGetStringFunc_t)( GLenum );
 /*@}*/
@@ -328,26 +255,4 @@
     wglGetExtensionsStringEXTFunc_t wglGetExtensionsStringEXT;
 #elif defined(DARWIN)
-# ifndef VBOX_WITH_COCOA_QT
-    aglCreateContextFunc_t          aglCreateContext;
-    aglDestroyContextFunc_t         aglDestroyContext;
-    aglSetCurrentContextFunc_t      aglSetCurrentContext;
-    aglSwapBuffersFunc_t            aglSwapBuffers;
-    aglChoosePixelFormatFunc_t      aglChoosePixelFormat;
-    aglDestroyPixelFormatFunc_t     aglDestroyPixelFormat;
-    aglDescribePixelFormatFunc_t    aglDescribePixelFormat;
-    aglGetCurrentContextFunc_t      aglGetCurrentContext;
-    aglSetDrawableFunc_t            aglSetDrawable;
-    aglGetDrawableFunc_t            aglGetDrawable;
-    aglSetFullScreenFunc_t          aglSetFullScreen;
-    aglGetProcAddressFunc_t         aglGetProcAddress;
-    aglUpdateContextFunc_t          aglUpdateContext;
-    aglUseFontFunc_t                aglUseFont;
-    aglSetIntegerFunc_t             aglSetInteger;
-    aglGetErrorFunc_t               aglGetError;
-    aglGetIntegerFunc_t             aglGetInteger;
-    aglEnableFunc_t                 aglEnable;
-    aglDisableFunc_t                aglDisable;
-# endif
-
     CGLChoosePixelFormatFunc_t      CGLChoosePixelFormat;
     CGLDestroyPixelFormatFunc_t     CGLDestroyPixelFormat;
@@ -435,5 +340,5 @@
 DECLEXPORT(int) SPULoad( char **name, char **super, SPUInitFuncPtr *init,
                     SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
-                    SPUOptionsPtr *options, int *flags );
+                    int *flags );
 
 DECLEXPORT(SPU *) crSPULoad( SPU *child, int id, char *name, char *dir, void *server);
@@ -444,8 +349,4 @@
 DECLEXPORT(void) crSPUCopyDispatchTable( SPUDispatchTable *dst, SPUDispatchTable *src );
 DECLEXPORT(void) crSPUChangeInterface( SPUDispatchTable *table, void *origFunc, void *newFunc );
-
-
-DECLEXPORT(void) crSPUSetDefaultParams( void *spu, SPUOptions *options );
-DECLEXPORT(int) crSPUGetEnumIndex( const SPUOptions *option, const char *optName, const char *value );
 
 
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_timer.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_timer.h	(revision 78189)
+++ 	(revision )
@@ -1,58 +1,0 @@
-#ifndef CR_TIMER_H
-#define CR_TIMER_H
-
-#ifndef WINDOWS
-#include <sys/time.h>
-
-#if defined (IRIX) || defined( IRIX64 )
-typedef unsigned long long iotimer64_t;
-typedef unsigned int iotimer32_t;
-#endif
-#else
-# ifdef VBOX
-#  include <iprt/win/windows.h>
-# else
-#include <windows.h>
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct Timer 
-{
-	double time0, elapsed;
-	char running;
-
-	int fd;
-#if defined (IRIX) || defined( IRIX64 )
-	unsigned long long counter64;
-	unsigned int counter32;
-	unsigned int cycleval;
-
-	volatile iotimer64_t *iotimer_addr64;
-	volatile iotimer32_t *iotimer_addr32;
-
-	void *unmapLocation;
-	int unmapSize;
-#elif defined(WINDOWS)
-	LARGE_INTEGER performance_counter, performance_frequency;
-	double one_over_frequency;
-#elif defined( Linux ) || defined( FreeBSD ) || defined(DARWIN) || defined(AIX) || defined (SunOS) || defined(OSF1)
-	struct timeval timeofday;
-#endif
-} CRTimer;
-
-CRTimer *crTimerNewTimer( void );
-void crDestroyTimer( CRTimer *t );
-void crStartTimer( CRTimer *t );
-void crStopTimer( CRTimer *t );
-void crResetTimer( CRTimer *t );
-double crTimerTime( CRTimer *t );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CR_TIMER_H */
Index: /trunk/src/VBox/GuestHost/OpenGL/include/cr_unpack.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_unpack.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/cr_unpack.h	(revision 78190)
@@ -20,14 +20,33 @@
 #endif
 
-extern SPUDispatchTable cr_unpackDispatch;
-/*extern DLLDATA(const unsigned char *) cr_unpackData;*/
-extern DECLEXPORT(const unsigned char *) cr_unpackData;
-extern DECLEXPORT(const unsigned char *) cr_unpackDataEnd;
-
-DECLEXPORT(void) crUnpackSetReturnPointer( CRNetworkPointer *ptr );
-DECLEXPORT(void) crUnpackSetWritebackPointer( CRNetworkPointer *ptr );
-DECLEXPORT(void) crUnpack( const void *data, const void *data_end, const void *opcodes, unsigned int num_opcodes, SPUDispatchTable *table );
-DECLEXPORT(void) crUnpackPush(void);
-DECLEXPORT(void) crUnpackPop(void);
+/**
+ * Unpacker state.
+ */
+typedef struct CrUnpackerState
+{
+    /** Opcodes which are going to be unpacked. */
+    const uint8_t               *pbOpcodes;
+    /** NUmber of Opcodes to unpack. */
+    size_t                      cOpcodes;
+    /** Start of the data buffer to unpack. */
+    const uint8_t               *pbUnpackData;
+    /** Number of bytes remaining the inpack buffer. */
+    size_t                      cbUnpackDataLeft;
+    /** Return pointer. */
+    CRNetworkPointer            *pReturnPtr;
+    /** Writeback pointer. */
+    CRNetworkPointer            *pWritebackPtr;
+    /** Pointer to the dispatch table to use. */
+    SPUDispatchTable            *pDispatchTbl;
+    /** Status code from the unpacker (mostly returns VERR_BUFFER_OVERFLOW
+     * on error if one unpacker detected out of bounds buffer access). */
+    int                         rcUnpack;
+} CrUnpackerState;
+/** Pointer to an unpacker state. */
+typedef CrUnpackerState *PCrUnpackerState;
+/** Pointer to a const unpacker state. */
+typedef const CrUnpackerState *PCCrUnpackerState;
+
+DECLEXPORT(void) crUnpack(PCrUnpackerState pState);
 
 typedef enum
@@ -41,7 +60,4 @@
 DECLEXPORT(CR_UNPACK_BUFFER_TYPE) crUnpackGetBufferType(const void *opcodes, unsigned int num_opcodes);
 
-extern CRNetworkPointer * return_ptr;
-extern CRNetworkPointer * writeback_ptr;
-
 #if defined(LINUX) || defined(WINDOWS)
 #define CR_UNALIGNED_ACCESS_OKAY
@@ -51,53 +67,137 @@
 DECLEXPORT(double) crReadUnalignedDouble( const void *buffer );
 
-#define READ_DATA( offset, type ) \
-    *( (const type *) (cr_unpackData + (offset)))
+/**
+ * Paranoid helper for debug builds to make sure the buffer size is validated correctly.
+ */
+DECLINLINE(const void *) crUnpackAccessChk(PCCrUnpackerState pState, size_t cbAccessVerified,
+                                     size_t offAccess, size_t cbType)
+{
+    AssertMsg(offAccess + cbType <= cbAccessVerified,
+             ("CHECK_BUFFER_SIZE_STATIC() has a wrong size given (verified %zu bytes vs tried access %zu)!\n",
+             cbAccessVerified, offAccess + cbType));
+    RT_NOREF(cbAccessVerified, cbType);
+    return pState->pbUnpackData + offAccess;
+}
+
+/**
+ * Does a one time check whether the buffer has sufficient data to access at least a_cbAccess
+ * bytes. Sets an error for the state and returns.
+ *
+ * @note Should only be used in the prologue of a method.
+ * @remark The introduction of int_cbAccessVerified makes sure CHECK_BUFFER_SIZE_STATIC() is there in each method for at least
+  *        some rudimentary sanity check (fails to compile otherwise).
+ */
+#define CHECK_BUFFER_SIZE_STATIC(a_pState, a_cbAccess) \
+    if (RT_UNLIKELY((a_pState)->cbUnpackDataLeft < (a_cbAccess))) \
+    { \
+        (a_pState)->rcUnpack = VERR_BUFFER_OVERFLOW; \
+        return; \
+    } \
+    size_t int_cbAccessVerified = (a_cbAccess)
+
+#define CHECK_BUFFER_SIZE_STATIC_LAST(a_pState, a_offAccessLast, a_Type) CHECK_BUFFER_SIZE_STATIC(a_pState, (a_offAccessLast) + sizeof( a_Type ))
+
+#define CHECK_BUFFER_SIZE_STATIC_UPDATE(a_pState, a_cbAccess) \
+    do \
+    { \
+        if (RT_UNLIKELY((a_pState)->cbUnpackDataLeft < (a_cbAccess))) \
+        { \
+            (a_pState)->rcUnpack = VERR_BUFFER_OVERFLOW; \
+            return; \
+        } \
+        int_cbAccessVerified = (a_cbAccess); \
+    } \
+    while (0)
+
+#define CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(a_pState, a_offAccessLast, a_Type) CHECK_BUFFER_SIZE_STATIC_UPDATE(a_pState, (a_offAccessLast) + sizeof( a_Type ))
+
+#define CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(a_pState, a_pArrayStart, a_cElements, a_Type) \
+    CHECK_BUFFER_SIZE_STATIC_UPDATE(a_pState, ((const uint8_t *)a_pArrayStart - (a_pState)->pbUnpackData) + (a_cElements) * sizeof(a_Type))
+#define CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_SZ_LAST(a_pState, a_pArrayStart, a_cElements, a_cbType) \
+    CHECK_BUFFER_SIZE_STATIC_UPDATE(a_pState, ((const uint8_t *)a_pArrayStart - (a_pState)->pbUnpackData) + (a_cElements) * (a_cbType))
+
+
+DECLINLINE(size_t) crUnpackAcccessChkStrUpdate(PCrUnpackerState pState, const char *psz, size_t *pcbVerified)
+{
+    size_t cchStr = 0;
+    size_t cbChkMax = pState->cbUnpackDataLeft - ((const uint8_t *)psz - pState->pbUnpackData);
+    void *pv = memchr((void *)psz, '\0', cbChkMax);
+    if (!pv)
+    {
+        pState->rcUnpack = VERR_BUFFER_OVERFLOW;
+        return SIZE_MAX;
+    }
+
+    cchStr = (uint8_t *)pv - pState->pbUnpackData + 1;
+    *pcbVerified = cchStr;
+
+    return cchStr;
+}
+
+#define CHECK_STRING_FROM_PTR_UPDATE_NO_RETURN(a_pState, a_pszStr) crUnpackAcccessChkStrUpdate((a_pState), (a_pszStr), &int_cbAccessVerified);
+
+#define CHECK_STRING_FROM_PTR_UPDATE_NO_SZ(a_pState, a_pszStr) \
+    do \
+    { \
+        size_t cchStr = crUnpackAcccessChkStrUpdate((a_pState), (a_pszStr), &int_cbAccessVerified); \
+        if (RT_UNLIKELY(cchStr == SIZE_MAX)) \
+            return; \
+    } \
+    while (0)
+
+/**
+ * Reads data at the given offset of the given type from the supplied data buffer.
+ */
+#define READ_DATA(a_pState, offset, type ) *(const type *)crUnpackAccessChk((a_pState), int_cbAccessVerified, (offset), sizeof( type ))
 
 #ifdef CR_UNALIGNED_ACCESS_OKAY
-#define READ_DOUBLE( offset ) \
-    READ_DATA( offset, GLdouble )
+#define READ_DOUBLE(a_pState, offset ) READ_DATA(a_pState, offset, GLdouble )
 #else
-#define READ_DOUBLE( offset ) \
-    crReadUnalignedDouble( cr_unpackData + (offset) )
-#endif
-
-#define READ_NETWORK_POINTER( offset ) \
-    ( cr_unpackData + (offset) )
-
-/* XXX make this const */
-#define DATA_POINTER( offset, type ) \
-    ( (type *) (cr_unpackData + (offset)) )
-
-#define DATA_POINTER_CHECK( offset ) \
-    ( (cr_unpackDataEnd >= cr_unpackData) && (size_t)(cr_unpackDataEnd - cr_unpackData) >= (size_t)(offset) )
-
-#define INCR_DATA_PTR( delta ) \
-    cr_unpackData += (delta)
-
-#define INCR_DATA_PTR_NO_ARGS() \
-    INCR_DATA_PTR( 4 )
-
-#define INCR_VAR_PTR() \
-    INCR_DATA_PTR( *((int *) cr_unpackData ) )
-
-#define SET_RETURN_PTR( offset ) do { \
-        CRDBGPTR_CHECKZ(return_ptr); \
-        if (!DATA_POINTER_CHECK(offset + sizeof(*return_ptr))) \
+#define READ_DOUBLE(a_pState, offset ) crReadUnalignedDouble(crUnpackAccessChk((a_pState), int_cbAccessVerified, (offset), sizeof( GLdouble ) ))
+#endif
+
+#define READ_NETWORK_POINTER(a_pState, offset ) (uint8_t *)crUnpackAccessChk((a_pState), int_cbAccessVerified, (offset), 0)
+#define DATA_POINTER(a_pState, offset, type )   ((type *) (crUnpackAccessChk((a_pState), int_cbAccessVerified, (offset), 0)) )
+
+#define DATA_POINTER_CHECK(a_pState, offset )   ((offset) < (a_pState)->cbUnpackDataLeft)
+
+#define INCR_DATA_PTR(a_pState, delta ) \
+    do \
+    { \
+        if (RT_UNLIKELY((a_pState)->cbUnpackDataLeft < (delta))) \
+        { \
+          (a_pState)->rcUnpack = VERR_BUFFER_OVERFLOW; \
+          return; \
+        } \
+        (a_pState)->pbUnpackData     += (delta); \
+        (a_pState)->cbUnpackDataLeft -= (delta); \
+    } while(0)
+
+#define INCR_DATA_PTR_NO_ARGS(a_pState) INCR_DATA_PTR(a_pState, 4 )
+
+#define INCR_VAR_PTR(a_pState) INCR_DATA_PTR(a_pState, *((int *)(a_pState)->pbUnpackData) )
+
+#define SET_RETURN_PTR(a_pState, offset ) \
+    do \
+    { \
+        CRDBGPTR_CHECKZ((a_pState)->pReturnPtr); \
+        if (!DATA_POINTER_CHECK(a_pState, offset + sizeof(*(a_pState)->pReturnPtr))) \
         { \
              crError("%s: SET_RETURN_PTR(%u) offset out of bounds\n", __FUNCTION__, offset); \
              return; \
         } \
-        crMemcpy( return_ptr, cr_unpackData + (offset), sizeof( *return_ptr ) ); \
-    } while (0);
-
-
-#define SET_WRITEBACK_PTR( offset ) do { \
-        CRDBGPTR_CHECKZ(writeback_ptr); \
-        if (!DATA_POINTER_CHECK(offset + sizeof(*writeback_ptr))) \
-        { \
-             crError("%s: SET_WRITEBACK_PTR(%u) offset out of bounds\n", __FUNCTION__, offset); \
+        crMemcpy((a_pState)->pReturnPtr, crUnpackAccessChk((a_pState), int_cbAccessVerified, (offset), sizeof( *(a_pState)->pReturnPtr )), sizeof( *(a_pState)->pReturnPtr ) ); \
+    } while (0)
+
+#define SET_WRITEBACK_PTR(a_pState, offset ) \
+    do \
+    { \
+        CRDBGPTR_CHECKZ((a_pState)->pWritebackPtr); \
+        if (!DATA_POINTER_CHECK(a_pState, offset + sizeof(*(a_pState)->pWritebackPtr))) \
+        { \
+             crError("%s: SET_RETURN_PTR(%u) offset out of bounds\n", __FUNCTION__, offset); \
              return; \
         } \
-        crMemcpy( writeback_ptr, cr_unpackData + (offset), sizeof( *writeback_ptr ) ); \
+        crMemcpy((a_pState)->pWritebackPtr, crUnpackAccessChk((a_pState), int_cbAccessVerified, (offset), sizeof( *(a_pState)->pWritebackPtr )), sizeof( *(a_pState)->pWritebackPtr) ); \
     } while (0);
 
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_url.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_url.h	(revision 78189)
+++ 	(revision )
@@ -1,23 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved.
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifndef CR_URL_H
-#define CR_URL_H
-
-#include <iprt/cdefs.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-DECLEXPORT(int) crParseURL( const char *url, char *protocol, char *hostname,
-				            unsigned short *port, unsigned short default_port );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CR_URL_H */
Index: /trunk/src/VBox/GuestHost/OpenGL/include/cr_version.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_version.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/cr_version.h	(revision 78190)
@@ -76,8 +76,14 @@
 #ifdef CR_OPENGL_VERSION_2_1
 # define CR_OPENGL_VERSION_STRING "2.1"
+# define CR_OPENGL_VERSION_MAJOR  2
+# define CR_OPENGL_VERSION_MINOR  1
 #elif defined(CR_OPENGL_VERSION_2_0)
 # define CR_OPENGL_VERSION_STRING "2.0"
+# define CR_OPENGL_VERSION_MAJOR  2
+# define CR_OPENGL_VERSION_MINOR  0
 #else
 # define CR_OPENGL_VERSION_STRING "1.5"
+# define CR_OPENGL_VERSION_MAJOR  1
+# define CR_OPENGL_VERSION_MINOR  5
 #endif
 
Index: unk/src/VBox/GuestHost/OpenGL/include/cr_warp.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_warp.h	(revision 78189)
+++ 	(revision )
@@ -1,22 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved.
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifndef CR_WARP_H
-#define CR_WARP_H
-
-#include <iprt/cdefs.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-DECLEXPORT(void) crWarpPoint(const float *align, const float *point, float *result);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CR_BBOX_H */
Index: unk/src/VBox/GuestHost/OpenGL/include/crut_api.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/crut_api.h	(revision 78189)
+++ 	(revision )
@@ -1,211 +1,0 @@
-#ifndef CRUTAPI_H
-#define CRUTAPI_H
-
-#ifdef WINDOWS
-#define CRUT_APIENTRY __stdcall
-#else
-#define CRUT_APIENTRY
-#endif
-
-#include "cr_net.h"
-#include "cr_protocol.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Compile-time version tests */
-#define CRUT_MAJOR_VERSION 1
-#define CRUT_MINOR_VERSION 9
-#define CRUT_PATCH_VERSION 0
-
-/* Display mode bit masks. */
-#define CRUT_RGB			0
-#define CRUT_RGBA			GLUT_RGB
-#define CRUT_INDEX			1
-#define CRUT_SINGLE			0
-#define CRUT_DOUBLE			2
-#define CRUT_ACCUM			4
-#define CRUT_ALPHA			8
-#define CRUT_DEPTH			16
-#define CRUT_STENCIL			32
-
-/* Mouse buttons. */
-/* CRUT_NO_BUTTON provided for menu definition.  Not every menu will
-   have a button associated with it. */
-#define CRUT_NO_BUTTON                  -1
-#define CRUT_LEFT_BUTTON		0
-#define CRUT_MIDDLE_BUTTON		1
-#define CRUT_RIGHT_BUTTON		2
-
-/* Mouse button state. */
-#define CRUT_DOWN			0
-#define CRUT_UP				1
-
-/* Visibility  state. */
-#define CRUT_NOT_VISIBLE		0
-#define CRUT_VISIBLE			1
-
-/* function keys */
-#define CRUT_KEY_F1			1
-#define CRUT_KEY_F2			2
-#define CRUT_KEY_F3			3
-#define CRUT_KEY_F4			4
-#define CRUT_KEY_F5			5
-#define CRUT_KEY_F6			6
-#define CRUT_KEY_F7			7
-#define CRUT_KEY_F8			8
-#define CRUT_KEY_F9			9
-#define CRUT_KEY_F10			10
-#define CRUT_KEY_F11			11
-#define CRUT_KEY_F12			12
-/* directional keys */
-#define CRUT_KEY_LEFT			100
-#define CRUT_KEY_UP			101
-#define CRUT_KEY_RIGHT			102
-#define CRUT_KEY_DOWN			103
-#define CRUT_KEY_PAGE_UP		104
-#define CRUT_KEY_PAGE_DOWN		105
-#define CRUT_KEY_HOME			106
-#define CRUT_KEY_END			107
-#define CRUT_KEY_INSERT			108
-
-/* event types */
-#define CRUT_NO_EVENT                   0
-#define CRUT_MOUSE_EVENT                1
-#define CRUT_RESHAPE_EVENT              2
-#define CRUT_KEYBOARD_EVENT             3
-#define CRUT_MOTION_EVENT               4
-#define CRUT_PASSIVE_MOTION_EVENT       5
-#define CRUT_MENU_EVENT                 6
-#define CRUT_VISIBILITY_EVENT           7
-
-#define DEFAULT_CRUT_PORT 9000
-
-#define MENU_MAX_SIZE 1024
-#define MENU_ITEM_REGULAR 0
-#define MENU_ITEM_SUBMENU 1
-
-/* CRUTMessage is just a placeholder to find the msg_type */
-typedef struct
-{
-	CRMessageHeader header;
-	int msg_type;
-
-} CRUTMessage;
-
-typedef struct
-{
-    CRMessageHeader header;
-    int msg_type;
-    int button;
-    int state;
-    int x;
-    int y;
-
-} CRUTMouseMsg;
-
-typedef struct
-{
-    CRMessageHeader header;
-    int msg_type;
-    int width;
-    int height;
-
-} CRUTReshapeMsg;
-
-typedef struct
-{
-	CRMessageHeader header;
-	int msg_type;
-	int state;
-	
-} CRUTVisibilityMsg;
-
-typedef struct
-{
-    CRMessageHeader header;
-    int msg_type;
-    unsigned char key;
-    int x;
-    int y;
-
-} CRUTKeyboardMsg;
-
-typedef struct
-{
-    CRMessageHeader header;
-    int msg_type;
-    int x;
-    int y;
-
-} CRUTMotionMsg;
-
-typedef struct
-{
-    CRMessageHeader header;
-    int msg_type;
-    int x;
-    int y;
-
-} CRUTPassiveMotionMsg;
-
-typedef struct
-{
-    CRMessageHeader header;
-    int msg_type;
-    int menuID;
-    int value;
-
-} CRUTMenuMsg;
-
-typedef struct
-{
-    unsigned short tcpip_port;
-    int mtu;
-    char protocol[1024];
-    CRConnection *send_conn;
-
-} CRUTClientPointer;
-
-typedef struct
-{
-    CRUTClientPointer *crutclients;
-    CRConnection *mothershipConn;
-    int numclients;
-    int winX;
-    int winY;
-    int winWidth;
-    int winHeight;
-
-    int compositeAlpha;
-    int compositeDepth;
-
-    char menuBuffer[MENU_MAX_SIZE];
-
-} CRUTAPI;
-
-#define MAX_MSG_SIZE sizeof(CRUTMouseMsg)
-
-
-/* extern CRUTAPI crut_api;*/
-
-void CRUT_APIENTRY crutInitAPI( CRUTAPI *crut_api, const char *mothership );
-void CRUT_APIENTRY crutGetWindowParams( CRUTAPI *crut_api );
-void CRUT_APIENTRY crutGetMenuXML( CRUTAPI *crut_api );
-void CRUT_APIENTRY crutSetWindowID( CRUTAPI *crut_api, int windowID );
-void CRUT_APIENTRY crutConnectToClients( CRUTAPI *crut_api );
-void crutSendEvent( CRUTAPI *crut_api, void *msg, int size );
-void CRUT_APIENTRY crutSendMouseEvent( CRUTAPI *crut_api, int button, int state, int x, int y );
-void CRUT_APIENTRY crutSendKeyboardEvent( CRUTAPI *crut_api, int key, int x, int y );
-void CRUT_APIENTRY crutSendReshapeEvent( CRUTAPI *crut_api, int width, int height );
-void CRUT_APIENTRY crutSendVisibilityEvent( CRUTAPI *crut_api, int state );
-void CRUT_APIENTRY crutSendMotionEvent( CRUTAPI *crut_api, int x, int y );
-void CRUT_APIENTRY crutSendPassiveMotionEvent( CRUTAPI *crut_api, int x, int y );
-void CRUT_APIENTRY crutSendMenuEvent( CRUTAPI *crut_api, int menuID, int value );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CRUTAPI_H */
Index: unk/src/VBox/GuestHost/OpenGL/include/crut_clientapi.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/crut_clientapi.h	(revision 78189)
+++ 	(revision )
@@ -1,45 +1,0 @@
-#ifndef CRUT_CLIENTAPI_H
-#define CRUT_CLEINTAPI_H
-
-#ifdef WINDOWS
-#define CRUT_CLIENT_APIENTRY __stdcall
-#else
-#define CRUT_CLIENT_APIENTRY
-#endif
-
-#include "chromium.h"
-#include "crut_api.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void CRUT_CLIENT_APIENTRY crutInitClient(void);
-void CRUT_CLIENT_APIENTRY crutReceiveEventType(int type);
-void CRUT_CLIENT_APIENTRY crutMouseFunc( void (*func)(int button, int state, int x, int y) );
-void CRUT_CLIENT_APIENTRY crutKeyboardFunc( void (*func) (unsigned char key, int x, int y) );
-void CRUT_CLIENT_APIENTRY crutReshapeFunc( void (*func) (int width, int height) );
-void CRUT_CLIENT_APIENTRY crutVisibilityFunc( void (*func) (int state) );
-void CRUT_CLIENT_APIENTRY crutMotionFunc( void (*func) (int x, int y) );
-void CRUT_CLIENT_APIENTRY crutPassiveMotionFunc( void (*func) (int x, int y) );
-void CRUT_CLIENT_APIENTRY crutIdleFunc( void (*func)(void));
-void CRUT_CLIENT_APIENTRY crutDisplayFunc(void (*func)(void));
-void CRUT_CLIENT_APIENTRY crutPostRedisplay(void);
-void CRUT_CLIENT_APIENTRY crutMainLoop(void);
-int  CRUT_CLIENT_APIENTRY crutCreateContext ( unsigned int visual );
-int  CRUT_CLIENT_APIENTRY crutCreateWindow ( unsigned int visual );
-void CRUT_CLIENT_APIENTRY crutMakeCurrent( int window, int context );
-void CRUT_CLIENT_APIENTRY crutSwapBuffers( int window, int flags );
-void CRUT_CLIENT_APIENTRY crutReceiveEvent(CRUTMessage **msg);
-int  CRUT_CLIENT_APIENTRY crutCheckEvent( void );
-int  CRUT_CLIENT_APIENTRY crutPeekNextEvent( void );
-int  CRUT_CLIENT_APIENTRY crutCreateMenu( void (*func) (int val) );
-void CRUT_CLIENT_APIENTRY crutAddMenuEntry( char* name, int value );
-void CRUT_CLIENT_APIENTRY crutAddSubMenu( char* name, int menuID );
-void CRUT_CLIENT_APIENTRY crutAttachMenu( int button );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CRUT_CLIENTAPI_H */
Index: /trunk/src/VBox/GuestHost/OpenGL/include/state/cr_limits.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/state/cr_limits.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/state/cr_limits.h	(revision 78190)
@@ -272,5 +272,5 @@
 extern DECLEXPORT(void) crStateLimitsPrint(const CRLimitsState *limits);
 
-extern DECLEXPORT(GLfloat) crStateComputeVersion(float minVersion);
+extern DECLEXPORT(void) crStateComputeVersion(uint32_t *puMajorMin, uint32_t *puMinorMin);
 
 extern DECLEXPORT(GLubyte *) crStateMergeExtensions(GLuint n, const GLubyte **extensions);
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_beginend.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_beginend.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_beginend.c	(revision 78190)
@@ -39,27 +39,4 @@
 }
 
-void PACK_APIENTRY crPackBeginSWAP( GLenum mode )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    unsigned char *data_ptr;
-    (void) pc;
-#ifndef VBOX
-    if (pc->buffer.canBarf)
-    {
-        if (!pc->buffer.holds_BeginEnd)
-            pc->Flush( pc->flush_arg );
-        pc->buffer.in_BeginEnd = 1;
-        pc->buffer.holds_BeginEnd = 1;
-    }
-#endif
-    CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, 4, GL_FALSE);
-    pc->current.begin_data = data_ptr;
-    pc->current.begin_op = pc->buffer.opcode_current;
-    pc->current.attribsUsedMask = 0;
-    WRITE_DATA( 0, GLenum, SWAP32(mode) );
-    WRITE_OPCODE( pc, CR_BEGIN_OPCODE );
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
 void PACK_APIENTRY crPackEnd( void )
 {
@@ -74,13 +51,2 @@
 }
 
-void PACK_APIENTRY crPackEndSWAP( void )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    unsigned char *data_ptr;
-    (void) pc;
-    CR_GET_BUFFERED_POINTER_NO_ARGS( pc );
-    WRITE_OPCODE( pc, CR_END_OPCODE );
-    pc->buffer.in_BeginEnd = 0;
-    CR_CMDBLOCK_END( pc, CRPACKBLOCKSTATE_OP_BEGIN );
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_buffer.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_buffer.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_buffer.c	(revision 78190)
@@ -20,11 +20,4 @@
 	ui[0] = ((unsigned int *) &d)[0];
 	ui[1] = ((unsigned int *) &d)[1];
-}
-
-void crWriteSwappedDouble( void *buffer, double d )
-{
-	unsigned int *ui = (unsigned int *) buffer;
-	ui[0] = SWAP32(((unsigned int *) &d)[1]);
-	ui[1] = SWAP32(((unsigned int *) &d)[0]);
 }
 
@@ -375,9 +368,5 @@
 	}
 
-	if (pc->swapping)
-		crPackBoundsInfoCRSWAP( CR_PACKER_CONTEXT_ARG bounds, payload, length, num_opcodes );
-	else
-		crPackBoundsInfoCR( CR_PACKER_CONTEXT_ARG bounds, payload, length, num_opcodes );
-
+	crPackBoundsInfoCR( CR_PACKER_CONTEXT_ARG bounds, payload, length, num_opcodes );
 	pc->buffer.holds_BeginEnd |= src->holds_BeginEnd;
 	pc->buffer.in_BeginEnd = src->in_BeginEnd;
@@ -462,13 +451,5 @@
 	 */
 
-	if (pc->swapping)
-	{
-		*((unsigned int *) data_ptr) = SWAP32(size);
-		crDebug( "Just swapped the length, putting %d on the wire!", *((unsigned int *) data_ptr));
-	}
-	else
-	{
-		*((unsigned int *) data_ptr) = size;
-	}
+	*((unsigned int *) data_ptr) = size;
 #ifndef CHROMIUM_THREADSAFE
 	sanityCheckPointer = data_ptr + 4;
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_context.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_context.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_context.c	(revision 78190)
@@ -50,38 +50,4 @@
 }
 
-void PACK_APIENTRY
-crPackCreateContextSWAP( const char *dpyName, GLint visual, GLint shareCtx,
-                         GLint *return_value, int *writeback )
-{
-	char displayName[DISPLAY_NAME_LEN];
-	CR_GET_PACKER_CONTEXT(pc);
-	unsigned char *data_ptr;
-        int len = DISPLAY_NAME_LEN + 32;
-
-	/* clear the buffer, to silence valgrind */
-	crMemZero(displayName, DISPLAY_NAME_LEN);
-
-	if (dpyName) {
-		crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
-		displayName[DISPLAY_NAME_LEN - 1] = 0;
-	}
-	else {
-		displayName[0] = 0;
-	}
-
-	CR_GET_BUFFERED_POINTER(pc, len);
-	WRITE_DATA( 0, GLint, SWAP32(len) );
-	WRITE_DATA( 4, GLenum, SWAP32(CR_CREATECONTEXT_EXTEND_OPCODE) );
-	WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
-	WRITE_DATA( DISPLAY_NAME_LEN + 8, GLenum, SWAP32(visual) );
-	WRITE_DATA( DISPLAY_NAME_LEN + 12, GLenum, SWAP32(shareCtx) );
-	WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 16, (void *) return_value );
-	WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 24, (void *) writeback );
-	WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
-	CR_CMDBLOCK_CHECK_FLUSH(pc);
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
-
 void PACK_APIENTRY crPackWindowCreate( const char *dpyName, GLint visBits, GLint *return_value, int *writeback )
 {
@@ -113,30 +79,2 @@
 }
 
-void PACK_APIENTRY crPackWindowCreateSWAP( const char *dpyName, GLint visBits, GLint *return_value, int *writeback )
-{
-	char displayName[DISPLAY_NAME_LEN];
-	CR_GET_PACKER_CONTEXT(pc);
-	unsigned char *data_ptr;
-
-	/* clear the buffer, to silence valgrind */
-	crMemZero(displayName, DISPLAY_NAME_LEN);
-
-	if (dpyName) {
-		crStrncpy( displayName, dpyName, DISPLAY_NAME_LEN );
-		displayName[DISPLAY_NAME_LEN - 1] = 0;
-	}
-	else {
-		displayName[0] = 0;
-	}
-
-	CR_GET_BUFFERED_POINTER(pc, DISPLAY_NAME_LEN + 28 );
-	WRITE_DATA( 0, GLint, SWAP32(28) );
-	WRITE_DATA( 4, GLenum, SWAP32(CR_WINDOWCREATE_EXTEND_OPCODE) );
-	WRITE_BYTES( 8, displayName, DISPLAY_NAME_LEN );
-	WRITE_DATA( DISPLAY_NAME_LEN + 8, GLint, SWAP32(visBits) );
-	WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 12, (void *) return_value );
-	WRITE_NETWORK_POINTER( DISPLAY_NAME_LEN + 20, (void *) writeback );
-	WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
-	CR_CMDBLOCK_CHECK_FLUSH(pc);
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_error.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_error.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_error.c	(revision 78190)
@@ -7,7 +7,8 @@
 
 #include "cr_error.h"
-#include "cr_environment.h"
 #include "cr_pack.h"
 #include "packer.h"
+
+#include <iprt/env.h>
 
 
@@ -32,5 +33,5 @@
         pc->Error( line, file, error, info );
 
-    if (crGetenv("CR_DEBUG"))
+    if (RTEnvExist("CR_DEBUG"))
     {
         char *glerr;
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_feedback.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_feedback.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_feedback.c	(revision 78190)
@@ -18,14 +18,4 @@
 }
 
-void PACK_APIENTRY crPackFeedbackBufferSWAP( GLsizei size, GLenum type, GLfloat *buffer )
-{
-    (void) size;
-    (void) type;
-    (void) buffer;
-
-    crWarning("Packer wont pass FeedbackBuffer()\n");
-    crWarning("Try using the feedbackspu\n");
-}
-
 void PACK_APIENTRY crPackSelectBuffer( GLsizei size, GLuint *buffer )
 {
@@ -37,10 +27,2 @@
 }
 
-void PACK_APIENTRY crPackSelectBufferSWAP( GLsizei size, GLuint *buffer )
-{
-    (void) size;
-    (void) buffer;
-
-    crWarning("Packer wont pass SelectBuffer()\n");
-    crWarning("Try using the feedbackspu\n");
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_fence.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_fence.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_fence.c	(revision 78190)
@@ -24,22 +24,2 @@
 }
 
-void PACK_APIENTRY crPackDeleteFencesNVSWAP( GLsizei n, const GLuint *fences )
-{
-    unsigned char *data_ptr;
-    int i;
-    int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*fences);
-
-    if( !fences )
-        return;
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA(0, GLenum, CR_DELETEFENCESNV_EXTEND_OPCODE);
-    WRITE_DATA(4, GLsizei, n);
-    for (i = 0 ; i < n ; i++)
-    {
-        WRITE_DATA(i*sizeof(GLuint) + 8, GLuint, SWAP32(fences[i]));
-    }
-    crHugePacket(CR_EXTEND_OPCODE, data_ptr);
-    crPackFree(data_ptr);
-}
-
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_framebuffer.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_framebuffer.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_framebuffer.c	(revision 78190)
@@ -55,17 +55,2 @@
 }
 
-void PACK_APIENTRY
-crPackDeleteRenderbuffersEXTSWAP(GLsizei n, const GLuint * renderbuffers)
-{
-    (void) n;
-    (void) renderbuffers;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY
-crPackDeleteFramebuffersEXTSWAP(GLsizei n, const GLuint * framebuffers)
-{
-    (void) n;
-    (void) framebuffers;
-    crError ("No swap version");
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_header.py
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_header.py	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_header.py	(revision 78190)
@@ -62,5 +62,4 @@
 
 		print('void PACK_APIENTRY crPack%s(%s);' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', args)))
-		print('void PACK_APIENTRY crPack%sSWAP(%s);' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', args)))
 
 
@@ -79,6 +78,4 @@
 		print('void PACK_APIENTRY crPack%sBBOX(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
 		print('void PACK_APIENTRY crPack%sBBOX_COUNT(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
-		print('void PACK_APIENTRY crPack%sBBOXSWAP(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
-		print('void PACK_APIENTRY crPack%sBBOX_COUNTSWAP(%s);' % (func_name, apiutil.MakeDeclarationString(args)))
 
 
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_init.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_init.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_init.c	(revision 78190)
@@ -20,5 +20,5 @@
 uint32_t cr_packer_cmd_blocks_enabled = 0;
 
-CRPackContext *crPackNewContext( int swapping )
+CRPackContext *crPackNewContext(void)
 {
 #ifdef CHROMIUM_THREADSAFE
@@ -32,5 +32,4 @@
 #endif
     pc->u32CmdBlockState = 0;
-    pc->swapping = swapping;
     pc->Flush = NULL;
     pc->SendHuge = NULL;
Index: unk/src/VBox/GuestHost/OpenGL/packer/pack_pica.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_pica.c	(revision 78189)
+++ 	(revision )
@@ -1,650 +1,0 @@
-/* Copyright (c) 2003, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "packer.h"
-#include "cr_error.h"
-#include "cr_string.h"
-
-void PACK_APIENTRY crPackPicaListCompositors(const PICAuint *config, 
-                     PICAint *numResults, 
-                     PICAcompItem *results, PICAerror *return_value, int* writeback )
-{
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) config;
-     (void) numResults;
-     (void) results;
-     (void) writeback;
-}
-void PACK_APIENTRY crPackPicaListCompositorsSWAP(const PICAuint *config, 
-                         PICAint *numResults, 
-                         PICAcompItem *results, PICAerror *return_value, int* writeback )
-{
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) config;
-     (void) numResults;
-     (void) results;
-     (void) writeback;
-}
-void PACK_APIENTRY crPackPicaGetCompositorParamiv(PICAcompID compositor,
-                          PICAparam pname,
-                          PICAint *params, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) compositor;
-     (void) pname;
-     (void) params;
-}
-void PACK_APIENTRY crPackPicaGetCompositorParamivSWAP(PICAcompID compositor,
-                          PICAparam pname,
-                          PICAint *params, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) compositor;
-     (void) pname;
-     (void) params;
-}
-void PACK_APIENTRY crPackPicaGetCompositorParamfv(PICAcompID compositor,
-                          PICAparam pname,
-                          PICAfloat *params, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) compositor;
-     (void) pname;
-     (void) params;
-}
-void PACK_APIENTRY crPackPicaGetCompositorParamfvSWAP(PICAcompID compositor,
-                          PICAparam pname,
-                          PICAfloat *params, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) compositor;
-     (void) pname;
-     (void) params;
-}
-void PACK_APIENTRY crPackPicaGetCompositorParamcv(PICAcompID compositor,
-                          PICAparam pname,
-                          PICAchar **params, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) compositor;
-     (void) pname;
-     (void) params;
-}
-void PACK_APIENTRY crPackPicaGetCompositorParamcvSWAP(PICAcompID compositor,
-                          PICAparam pname,
-                          PICAchar **params, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) compositor;
-     (void) pname;
-     (void) params;
-}
-void PACK_APIENTRY crPackPicaListNodes(PICAcompID compositor, 
-                   PICAint *num,
-                   PICAnodeItem *results, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) compositor;
-     (void) num;
-     (void) results;
-}
-void PACK_APIENTRY crPackPicaListNodesSWAP(PICAcompID compositor, 
-                       PICAint *num,
-                       PICAnodeItem *results, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) compositor;
-     (void) num;
-     (void) results;
-}
-
-void PACK_APIENTRY crPackPicaCreateContext(const PICAuint *config, 
-                       const PICAnodeID *nodes, 
-                       PICAuint numNodes, PICAcontextID *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = (PICAcontextID) -1;
-     (void) writeback;
-     (void) config;
-     (void) nodes;
-     (void) numNodes;
-}
-void PACK_APIENTRY crPackPicaCreateContextSWAP(const PICAuint *config, 
-                       const PICAnodeID *nodes, 
-                       PICAuint numNodes, PICAcontextID *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = (PICAcontextID) -1;
-     (void) writeback;
-     (void) config;
-     (void) nodes;
-     (void) numNodes;
-}
-void PACK_APIENTRY crPackPicaDestroyContext(PICAcontextID ctx, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-}
-void PACK_APIENTRY crPackPicaDestroyContextSWAP(PICAcontextID ctx, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-}
-
-void PACK_APIENTRY crPackPicaSetContextParami(PICAcontextID ctx,
-                      PICAparam pname,
-                      PICAint param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}
-void PACK_APIENTRY crPackPicaSetContextParamiSWAP(PICAcontextID ctx,
-                          PICAparam pname,
-                          PICAint param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}
-void PACK_APIENTRY crPackPicaSetContextParamiv(PICAcontextID ctx,
-                       PICAparam pname,
-                       const PICAint *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}
-void PACK_APIENTRY crPackPicaSetContextParamivSWAP(PICAcontextID ctx,
-                           PICAparam pname,
-                           const PICAint *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}
-void PACK_APIENTRY crPackPicaSetContextParamf(PICAcontextID ctx,
-                      PICAparam pname,
-                      PICAfloat param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}
-void PACK_APIENTRY crPackPicaSetContextParamfSWAP(PICAcontextID ctx,
-                          PICAparam pname,
-                          PICAfloat param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}
-void PACK_APIENTRY crPackPicaSetContextParamfv(PICAcontextID ctx,
-                       PICAparam pname,
-                       const PICAfloat *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}
-void PACK_APIENTRY crPackPicaSetContextParamfvSWAP(PICAcontextID ctx,
-                           PICAparam pname,
-                           const PICAfloat *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}
-void PACK_APIENTRY crPackPicaSetContextParamv(PICAcontextID ctx,
-                      PICAparam pname,
-                      const PICAvoid *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}
-void PACK_APIENTRY crPackPicaSetContextParamvSWAP(PICAcontextID ctx,
-                          PICAparam pname,
-                          const PICAvoid *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}
-
-void PACK_APIENTRY crPackPicaGetContextParamiv(PICAcontextID ctx,
-                       PICAparam pname,
-                       PICAint *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}  
-
-void PACK_APIENTRY crPackPicaGetContextParamivSWAP(PICAcontextID ctx,
-                           PICAparam pname,
-                           PICAint *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}  
-void PACK_APIENTRY crPackPicaGetContextParamfv(PICAcontextID ctx,
-                       PICAparam pname,
-                       PICAfloat *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}  
-void PACK_APIENTRY crPackPicaGetContextParamfvSWAP(PICAcontextID ctx,
-                           PICAparam pname,
-                           PICAfloat *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}  
-void PACK_APIENTRY crPackPicaGetContextParamcv(PICAcontextID ctx,
-                       PICAparam pname,
-                       PICAchar **param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}  
-void PACK_APIENTRY crPackPicaGetContextParamcvSWAP(PICAcontextID ctx,
-                           PICAparam pname,
-                           PICAchar **param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}  
-void PACK_APIENTRY crPackPicaGetContextParamv(PICAcontextID ctx,
-                      PICAparam pname,
-                      PICAvoid *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}  
-void PACK_APIENTRY crPackPicaGetContextParamvSWAP(PICAcontextID ctx,
-                          PICAparam pname,
-                          PICAvoid *param, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) pname;
-     (void) param;
-}  
-
-void PACK_APIENTRY crPackPicaBindLocalContext(PICAcontextID globalCtx, 
-                      PICAnodeID node, PICAcontextID *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = (PICAcontextID) -1;
-     (void) writeback;
-     (void) globalCtx;
-     (void) node;
-}
-
-void PACK_APIENTRY crPackPicaBindLocalContextSWAP(PICAcontextID globalCtx, 
-                          PICAnodeID node, PICAcontextID *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = (PICAcontextID) -1;
-     (void) writeback;
-     (void) globalCtx;
-     (void) node;
-}
-void PACK_APIENTRY crPackPicaDestroyLocalContext(PICAcontextID lctx, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) lctx;
-}
-void PACK_APIENTRY crPackPicaDestroyLocalContextSWAP(PICAcontextID lctx, PICAerror *return_value, int* writeback )
-{
-
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) lctx;
-}
-
-void PACK_APIENTRY crPackPicaStartFrame(PICAcontextID lctx,
-                    const PICAframeID *frameID,
-                    PICAuint numLocalFramelets,
-                    PICAuint numOrders,
-                    const PICAuint *orderList,
-                    const PICArect *srcRectList,
-                    const PICApoint *dstList, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) lctx;
-     (void) frameID;
-     (void) numLocalFramelets;
-     (void) numOrders;
-     (void) orderList;
-     (void) srcRectList;
-     (void) dstList;
-}
-
-void PACK_APIENTRY crPackPicaStartFrameSWAP(PICAcontextID lctx,
-                    const PICAframeID *frameID,
-                    PICAuint numLocalFramelets,
-                    PICAuint numOrders,
-                    const PICAuint *orderList,
-                    const PICArect *srcRectList,
-                    const PICApoint *dstList, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) lctx;
-     (void) frameID;
-     (void) numLocalFramelets;
-     (void) numOrders;
-     (void) orderList;
-     (void) srcRectList;
-     (void) dstList;
-}
-void PACK_APIENTRY crPackPicaEndFrame(PICAcontextID lctx, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) lctx;
-}
-void PACK_APIENTRY crPackPicaEndFrameSWAP(PICAcontextID lctx, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) lctx;
-}
-void PACK_APIENTRY crPackPicaCancelFrame(PICAcontextID ctx, 
-                     PICAframeID frameID, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) frameID;
-}
-void PACK_APIENTRY crPackPicaCancelFrameSWAP(PICAcontextID ctx, 
-                     PICAframeID frameID, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) ctx;
-     (void) frameID;
-}
-void PACK_APIENTRY crPackPicaQueryFrame(PICAcontextID ctx,
-                    PICAframeID frameID,
-                    PICAnodeID nodeID,
-                    PICAfloat timeout, PICAstatus *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) ctx;
-     (void) writeback;
-     (void) frameID;
-     (void) nodeID;
-     (void) timeout;
-}
-void PACK_APIENTRY crPackPicaQueryFrameSWAP(PICAcontextID ctx,
-                    PICAframeID frameID,
-                    PICAnodeID nodeID,
-                    PICAfloat timeout, PICAstatus *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) ctx;
-     (void) writeback;
-     (void) frameID;
-     (void) nodeID;
-     (void) timeout;
-}
-void PACK_APIENTRY crPackPicaAddGfxFramelet(PICAcontextID lctx,
-                    const PICArect *srcRect,
-                    const PICApoint *dstPos,
-                    PICAuint order,
-                    PICAint iVolatile, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) lctx;
-     (void) writeback;
-     (void) srcRect;
-     (void) dstPos;
-     (void) order;
-     (void) iVolatile;
-}
-void PACK_APIENTRY crPackPicaAddGfxFrameletSWAP(PICAcontextID lctx,
-                        const PICArect *srcRect,
-                        const PICApoint *dstPos,
-                        PICAuint order,
-                        PICAint iVolatile, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) lctx;
-     (void) writeback;
-     (void) srcRect;
-     (void) dstPos;
-     (void) order;
-     (void) iVolatile;
-}
-void PACK_APIENTRY crPackPicaAddMemFramelet(PICAcontextID lctx,
-                    const PICAvoid *colorBuffer,
-                    const PICAvoid *depthBuffer,
-                    PICAuint span_x,
-                    const PICArect *srcRect,
-                    const PICApoint *dstPos,
-                    PICAuint order,
-                    PICAint iVolatile, PICAerror *return_value, int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) lctx;
-     (void) writeback;
-     (void) colorBuffer;
-     (void) depthBuffer;
-     (void) span_x;
-     (void) srcRect;
-     (void) dstPos;
-     (void) order;
-     (void) iVolatile;
-}
-void PACK_APIENTRY crPackPicaAddMemFrameletSWAP(PICAcontextID lctx,
-                        const PICAvoid *colorBuffer,
-                        const PICAvoid *depthBuffer,
-                        PICAuint span_x,
-                        const PICArect *srcRect,
-                        const PICApoint *dstPos,
-                        PICAuint order,
-                        PICAint iVolatile, 
-                        PICAerror *return_value, 
-                        int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) lctx;
-     (void) writeback;
-     (void) colorBuffer;
-     (void) depthBuffer;
-     (void) span_x;
-     (void) srcRect;
-     (void) dstPos;
-     (void) order;
-     (void) iVolatile;
-}
-void PACK_APIENTRY crPackPicaReadFrame(PICAcontextID lctx,
-                   PICAframeID frameID,
-                   PICAuint format,
-                   PICAvoid *colorbuffer,
-                   PICAvoid *depthbuffer,
-                   const PICArect *rect, 
-                   PICAerror *return_value, 
-                   int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) lctx;
-     (void) frameID;
-     (void) format;
-     (void) colorbuffer;
-     (void) depthbuffer;
-     (void) rect;
-}
-void PACK_APIENTRY crPackPicaReadFrameSWAP(PICAcontextID lctx,
-                       PICAframeID frameID,
-                       PICAuint format,
-                       PICAvoid *colorbuffer,
-                       PICAvoid *depthbuffer,
-                       const PICArect *rect, 
-                       PICAerror *return_value, 
-                       int* writeback )
-{
-     
-     crWarning("You can't really pack PICA calls!");
-     *return_value = -1;
-     (void) writeback;
-     (void) lctx;
-     (void) frameID;
-     (void) format;
-     (void) colorbuffer;
-     (void) depthbuffer;
-     (void) rect;
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_shaders.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_shaders.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_shaders.c	(revision 78190)
@@ -634,233 +634,2 @@
 }
 
-void PACK_APIENTRY crPackBindAttribLocationSWAP(GLuint program, GLuint index, const char *name)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)program;
-    (void)index;
-    (void)name;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackShaderSourceSWAP(GLuint shader, GLsizei count, const char **string, const GLint *length)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)shader;
-    (void)count;
-    (void)string;
-    (void)length;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniform1fvSWAP(GLint location, GLsizei count, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-
-void PACK_APIENTRY crPackUniform1ivSWAP(GLint location, GLsizei count, const GLint *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniform2fvSWAP(GLint location, GLsizei count, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniform2ivSWAP(GLint location, GLsizei count, const GLint * value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniform3fvSWAP(GLint location, GLsizei count, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniform3ivSWAP(GLint location, GLsizei count, const GLint *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniform4fvSWAP(GLint location, GLsizei count, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniform4ivSWAP(GLint location, GLsizei count, const GLint *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniformMatrix2fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)transpose;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniformMatrix3fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)transpose;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniformMatrix4fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)transpose;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniformMatrix2x3fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)transpose;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniformMatrix3x2fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)transpose;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniformMatrix2x4fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)transpose;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniformMatrix4x2fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)transpose;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniformMatrix3x4fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)transpose;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackUniformMatrix4x3fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)location;
-    (void)count;
-    (void)transpose;
-    (void)value;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackDrawBuffersSWAP(GLsizei n, const GLenum *bufs)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)n;
-    (void)bufs;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackGetAttribLocationSWAP(GLuint program, const char * name, GLint * return_value, int * writeback)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)program;
-    (void)name;
-    (void)return_value;
-    (void)writeback;
-    (void)pc;
-    crError ("No swap version");
-}
-
-void PACK_APIENTRY crPackGetUniformLocationSWAP(GLuint program, const char * name, GLint * return_value, int * writeback)
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    (void)program;
-    (void)name;
-    (void)return_value;
-    (void)writeback;
-    (void)pc;
-    crError ("No swap version");
-}
Index: unk/src/VBox/GuestHost/OpenGL/packer/pack_swap.py
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap.py	(revision 78189)
+++ 	(revision )
@@ -1,74 +1,0 @@
-# Copyright (c) 2001, Stanford University
-# All rights reserved.
-#
-# See the file LICENSE.txt for information on redistributing this software.
-
-from __future__ import print_function
-import sys, string
-
-sys.path.append( "../glapi_parser" )
-import apiutil
-
-
-if len(sys.argv) != 2:
-    print >> sys.stderr, "Usage: %s <filename>" % sys.argv[0]
-    sys.exit(-1)
-
-file = open(sys.argv[1])
-
-print("/* THIS FILE IS AUTOGENERATED FROM %s BY pack_swap.py */\n\n" % sys.argv[1])
-
-for line in file.readlines():
-    line = line.rstrip()
-    if line.find( "crPackAlloc" ) != -1 or line.find( "crPackFree" ) != -1:
-        print(line)
-        continue
-    elif line.find( "crPack" ) != -1:
-        fun_index = line.find( "crPack" )
-        paren_index = line.find( "(", fun_index )
-        space_index = line.find( " ", fun_index )
-        quote_index = line.find( '"', fun_index )
-        if paren_index == -1:
-            paren_index = 1000000; # HACK HACK
-        if space_index == -1:
-            space_index = 1000000; # HACK HACK
-        if quote_index == -1:
-            quote_index = 1000000; # HACK HACK
-        the_index = min( min( paren_index, space_index ), quote_index )
-        print("%sSWAP%s" % (line[:the_index], line[the_index:]))
-    elif line.find("WRITE_DATA_AI") != -1:
-        lparen_index = line.find( "(" )
-        rparen_index = line.rfind( ")" )
-        args = list(map( str.strip, line[lparen_index+1:rparen_index].split( "," ) ))
-        indentation = line[:line.find( "WRITE_DATA_AI" )]
-        if apiutil.sizeof(args[0]) == 1:
-            print("%sWRITE_DATA_AI(%s, %s);" % (indentation, args[0], args[1]))
-        elif apiutil.sizeof(args[0]) == 2:
-            print("%sWRITE_DATA_AI(%s, SWAP16(%s) );" % (indentation, args[0], args[1]))
-        elif args[0] == 'GLfloat' or args[0] == 'GLclampf':
-            print("%sWRITE_DATA_AI(GLuint, SWAPFLOAT(%s) );" % (indentation, args[0]))
-        elif apiutil.sizeof(args[0]) == 4:
-            print("%sWRITE_DATA_AI(%s, SWAP32(%s));" % (indentation, args[0], args[1]))
-        else:
-            print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1]
-            sys.exit(-1)
-    elif line.find( "WRITE_DATA" ) != -1:
-        lparen_index = line.find( "(" )
-        rparen_index = line.rfind( ")" )
-        args = list(map( str.strip, line[lparen_index+1:rparen_index].split( "," ) ))
-        indentation = line[:line.find( "WRITE_DATA" )]
-        if apiutil.sizeof(args[1]) == 1:
-            print("%sWRITE_DATA(%s, %s, %s);" % (indentation, args[0], args[1], args[2]))
-        elif apiutil.sizeof(args[1]) == 2:
-            print("%sWRITE_DATA(%s, %s, SWAP16(%s));" % (indentation, args[0], args[1], args[2]))
-        elif args[1] == 'GLfloat' or args[1] == 'GLclampf':
-            print("%sWRITE_DATA(%s, GLuint, SWAPFLOAT(%s));" % (indentation, args[0], args[2]))
-        elif apiutil.sizeof(args[1]) == 4:
-            print("%sWRITE_DATA(%s, %s, SWAP32(%s));" % (indentation, args[0], args[1], args[2]))
-        else:
-            print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1]
-            sys.exit(-1)
-    elif line.find( "WRITE_DOUBLE" ) != -1:
-        print(line.replace( "WRITE_DOUBLE", "WRITE_SWAPPED_DOUBLE" ))
-    else:
-        print(line)
Index: unk/src/VBox/GuestHost/OpenGL/packer/pack_swap_lists.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap_lists.c	(revision 78189)
+++ 	(revision )
@@ -1,117 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "packer.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-
-static int __gl_CallListsNumBytes( GLenum type )
-{
-    switch( type )
-    {
-        case GL_BYTE:
-        case GL_UNSIGNED_BYTE:
-        case GL_2_BYTES:
-            return 1;
-        case GL_SHORT:
-        case GL_UNSIGNED_SHORT:
-        case GL_3_BYTES:
-            return 2;
-        case GL_INT:
-        case GL_UNSIGNED_INT:
-        case GL_FLOAT:
-        case GL_4_BYTES:
-            return 4;
-        default:
-            return -1;
-    }
-}
-
-void PACK_APIENTRY crPackCallListsSWAP(GLint n, GLenum type, 
-        const GLvoid *lists )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    GLshort *shortPtr;
-    GLint   *intPtr;
-    int i;
-
-    int bytesPerList = __gl_CallListsNumBytes( type );
-    int numBytes = bytesPerList * n;
-
-    if (numBytes < 0)
-    {
-        __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
-                                 "crPackCallLists(bad type)" );
-        return;
-    }
-
-    packet_length = sizeof( n ) + 
-        sizeof( type ) + 
-        numBytes;
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLint, SWAP32(n) );
-    WRITE_DATA( 4, GLenum, SWAP32(type) );
-
-    crMemcpy( data_ptr + 8, lists, numBytes );
-    shortPtr = (GLshort *) (data_ptr + 8);
-    intPtr   = (GLint *) (data_ptr + 8);
-
-    if (bytesPerList > 1)
-    {
-        for ( i = 0 ; i < n ; i++)
-        {
-            switch( bytesPerList )
-            {
-                case 2:
-                  *shortPtr = SWAP16(*shortPtr);
-                  shortPtr+=1;
-                    break;
-                case 4:
-                  *intPtr = SWAP32(*intPtr);
-                  intPtr+=1;
-                    break;
-            }
-        }
-    }
-
-    crHugePacket( CR_CALLLISTS_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-
-void PACK_APIENTRY crPackNewListSWAP( GLuint list, GLenum mode )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    unsigned char *data_ptr;
-    (void) pc;
-    CR_CMDBLOCK_BEGIN( pc, CRPACKBLOCKSTATE_OP_NEWLIST );
-    CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, 16, GL_FALSE );
-    WRITE_DATA( 0, GLint, SWAP32(16) );
-    WRITE_DATA( 4, GLenum, SWAP32(CR_NEWLIST_EXTEND_OPCODE) );
-    WRITE_DATA( 8, GLuint, SWAP32(list) );
-    WRITE_DATA( 12, GLenum, SWAP32(mode) );
-    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
-    pc->buffer.in_List = GL_TRUE;
-    pc->buffer.holds_List = GL_TRUE;
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
-
-void PACK_APIENTRY crPackEndListSWAP( void )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    unsigned char *data_ptr;
-    (void) pc;
-    CR_GET_BUFFERED_POINTER( pc, 8 );
-    WRITE_DATA( 0, GLint, SWAP32(8) );
-    WRITE_DATA( 4, GLenum, SWAP32(CR_ENDLIST_EXTEND_OPCODE) );
-    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
-    pc->buffer.in_List = GL_FALSE;
-    CR_CMDBLOCK_END( pc, CRPACKBLOCKSTATE_OP_NEWLIST );
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
Index: unk/src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c	(revision 78189)
+++ 	(revision )
@@ -1,278 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "packer.h"
-#include "cr_opcodes.h"
-#include "cr_error.h"
-
-
-/* Note -- for these packets, the ustride and vstride are implicit,
- * and are computed into the packet instead of copied.
- */
-
-static int __gl_Map2NumComponents(GLenum target)
-{
-    switch(target)
-    {
-    case GL_MAP2_VERTEX_3:
-    case GL_MAP2_NORMAL:
-    case GL_MAP2_TEXTURE_COORD_3:
-        return 3;
-    case GL_MAP2_VERTEX_4:
-    case GL_MAP2_COLOR_4:
-    case GL_MAP2_TEXTURE_COORD_4:
-        return 4;
-    case GL_MAP2_INDEX:
-    case GL_MAP2_TEXTURE_COORD_1:
-        return 1;
-    case GL_MAP2_TEXTURE_COORD_2:
-        return 2;
-    default:
-        return -1;
-    }
-}
-
-static int __gl_Map1NumComponents(GLenum target)
-{
-    switch(target)
-    {
-    case GL_MAP1_VERTEX_3:
-    case GL_MAP1_NORMAL:
-    case GL_MAP1_TEXTURE_COORD_3:
-        return 3;
-    case GL_MAP1_VERTEX_4:
-    case GL_MAP1_COLOR_4:
-    case GL_MAP1_TEXTURE_COORD_4:
-        return 4;
-    case GL_MAP1_INDEX:
-    case GL_MAP1_TEXTURE_COORD_1:
-        return 1;
-    case GL_MAP1_TEXTURE_COORD_2:
-        return 2;
-    default:
-        return -1;
-    }
-}
-
-void PACK_APIENTRY crPackMap2dSWAP(GLenum target, GLdouble u1, 
-        GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, 
-        GLint vstride, GLint vorder, const GLdouble *points)
-{
-    unsigned char *data_ptr;
-    int u,v;
-    int comp;
-    GLdouble *dest_data, *src_data;
-    int packet_length = 
-        sizeof(target) + 
-        sizeof(u1) +
-        sizeof(u2) +
-        sizeof(uorder) +
-        sizeof(ustride) +
-        sizeof(v1) +
-        sizeof(v2) + 
-        sizeof(vorder) +
-        sizeof(vstride);
-
-    int num_components = __gl_Map2NumComponents(target);
-    if (num_components < 0)
-    {
-        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
-                                 "crPackMap2d(bad target)");
-        return;
-    }
-
-    packet_length += num_components*uorder*vorder*sizeof(*points);
-
-    data_ptr = (unsigned char *) crPackAlloc(packet_length);
-
-    WRITE_DATA(0, GLenum, SWAP32(target));
-    WRITE_SWAPPED_DOUBLE(4, u1);
-    WRITE_SWAPPED_DOUBLE(12, u2);
-    WRITE_DATA(20, GLint, SWAP32(num_components));
-    WRITE_DATA(24, GLint, SWAP32(uorder));
-    WRITE_SWAPPED_DOUBLE(28, v1);
-    WRITE_SWAPPED_DOUBLE(36, v2);
-    WRITE_DATA(44, GLint, SWAP32(num_components*uorder));
-    WRITE_DATA(48, GLint, SWAP32(vorder));
-
-    dest_data = (GLdouble *) (data_ptr + 52);
-    src_data = (GLdouble *) points;
-    for (v = 0 ; v < vorder ; v++)
-    {
-        for (u = 0 ; u < uorder ; u++)
-        {
-            for (comp = 0 ; comp < num_components ; comp++)
-            {
-                WRITE_SWAPPED_DOUBLE(((unsigned char *) dest_data + comp*sizeof(*points)) - data_ptr, *(src_data + comp));
-            }
-            dest_data += num_components;
-            src_data += ustride;
-        }
-        src_data += vstride - ustride*uorder;
-    }
-
-    crHugePacket(CR_MAP2D_OPCODE, data_ptr);
-    crPackFree(data_ptr);
-}
-
-void PACK_APIENTRY crPackMap2fSWAP(GLenum target, GLfloat u1, 
-        GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, 
-        GLint vstride, GLint vorder, const GLfloat *points)
-{
-    unsigned char *data_ptr;
-    int u,v;
-    int comp;
-    GLfloat *dest_data, *src_data;
-    int packet_length = 
-        sizeof(target) + 
-        sizeof(u1) +
-        sizeof(u2) +
-        sizeof(uorder) +
-        sizeof(ustride) +
-        sizeof(v1) +
-        sizeof(v2) + 
-        sizeof(vorder) +
-        sizeof(vstride);
-
-    int num_components = __gl_Map2NumComponents(target);
-    if (num_components < 0)
-    {
-        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
-                                 "crPackMap2f(bad target)");
-        return;
-    }
-
-    packet_length += num_components*uorder*vorder*sizeof(*points);
-
-    data_ptr = (unsigned char *) crPackAlloc(packet_length);
-
-    WRITE_DATA(0, GLenum, SWAP32(target));
-    WRITE_DATA(4, GLuint, SWAPFLOAT(u1));
-    WRITE_DATA(8, GLuint, SWAPFLOAT(u2));
-    WRITE_DATA(12, GLint, SWAP32(num_components));
-    WRITE_DATA(16, GLint, SWAP32(uorder));
-    WRITE_DATA(20, GLuint, SWAPFLOAT(v1));
-    WRITE_DATA(24, GLuint, SWAPFLOAT(v2));
-    WRITE_DATA(28, GLint, SWAP32(num_components*uorder));
-    WRITE_DATA(32, GLint, SWAP32(vorder));
-
-    dest_data = (GLfloat *) (data_ptr + 36);
-    src_data = (GLfloat *) points;
-    for (v = 0 ; v < vorder ; v++)
-    {
-        for (u = 0 ; u < uorder ; u++)
-        {
-            for (comp = 0 ; comp < num_components ; comp++)
-            {
-                WRITE_DATA((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT(*(src_data + comp)));
-            }
-            dest_data += num_components;
-            src_data += ustride;
-        }
-        src_data += vstride - ustride*uorder;
-    }
-
-    crHugePacket(CR_MAP2F_OPCODE, data_ptr);
-    crPackFree(data_ptr);
-}
-
-void PACK_APIENTRY crPackMap1dSWAP(GLenum target, GLdouble u1,
-        GLdouble u2, GLint stride, GLint order, const GLdouble *points)
-{
-    unsigned char *data_ptr;
-    int packet_length = 
-        sizeof(target) + 
-        sizeof(u1) +
-        sizeof(u2) + 
-        sizeof(stride) + 
-        sizeof(order);
-
-    int num_components = __gl_Map1NumComponents(target);
-    GLdouble *src_data, *dest_data;
-    int u;
-    int comp;
-
-    if (num_components < 0)
-    {
-        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
-                                 "crPackMap1d(bad target)");
-        return;
-    }
-
-    packet_length += num_components * order * sizeof(*points);
-
-    data_ptr = (unsigned char *) crPackAlloc(packet_length);
-
-    WRITE_DATA(0, GLenum, SWAP32(target));
-    WRITE_SWAPPED_DOUBLE(4, u1);
-    WRITE_SWAPPED_DOUBLE(12, u2);
-    WRITE_DATA(20, GLint, SWAP32(num_components));
-    WRITE_DATA(24, GLint, SWAP32(order));
-
-    dest_data = (GLdouble *) (data_ptr + 28);
-    src_data = (GLdouble *) points;
-    for (u = 0 ; u < order ; u++)
-    {
-        for (comp = 0 ; comp < num_components ; comp++)
-        {
-            WRITE_SWAPPED_DOUBLE((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, *(src_data + comp));
-        }
-        dest_data += num_components;
-        src_data += stride;
-    }
-
-    crHugePacket(CR_MAP1D_OPCODE, data_ptr);
-    crPackFree(data_ptr);
-}
-
-void PACK_APIENTRY crPackMap1fSWAP(GLenum target, GLfloat u1,
-        GLfloat u2, GLint stride, GLint order, const GLfloat *points)
-{
-    unsigned char *data_ptr;
-    int packet_length = 
-        sizeof(target) + 
-        sizeof(u1) +
-        sizeof(u2) + 
-        sizeof(stride) + 
-        sizeof(order);
-
-    int num_components = __gl_Map1NumComponents(target);
-    GLfloat *src_data, *dest_data;
-    int u;
-    int comp;
-
-    if (num_components < 0)
-    {
-        __PackError(__LINE__, __FILE__, GL_INVALID_ENUM,
-                                 "crPackMap1f(bad target)");
-        return;
-    }
-
-    packet_length += num_components * order * sizeof(*points);
-
-    data_ptr = (unsigned char *) crPackAlloc(packet_length);
-
-    WRITE_DATA(0, GLenum, SWAP32(target));
-    WRITE_DATA(4, GLuint, SWAPFLOAT(u1));
-    WRITE_DATA(8, GLuint, SWAPFLOAT(u2));
-    WRITE_DATA(12, GLint, SWAP32(num_components));
-    WRITE_DATA(16, GLint, SWAP32(order));
-
-    dest_data = (GLfloat *) (data_ptr + 20);
-    src_data = (GLfloat *) points;
-    for (u = 0 ; u < order ; u++)
-    {
-        for (comp = 0 ; comp < num_components ; comp++)
-        {
-            WRITE_DATA((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT(*(src_data + comp)));
-        }
-        dest_data += num_components;
-        src_data += stride;
-    }
-
-    crHugePacket(CR_MAP1F_OPCODE, data_ptr);
-    crPackFree(data_ptr);
-}
Index: unk/src/VBox/GuestHost/OpenGL/packer/pack_swap_pixelmap.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap_pixelmap.c	(revision 78189)
+++ 	(revision )
@@ -1,62 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "packer.h"
-
-static unsigned char * __gl_HandlePixelMapData( GLenum map, GLsizei mapsize, int size_of_value, const GLvoid *values )
-{
-    int i;
-
-    int packet_length = 
-        sizeof( map ) + 
-        sizeof( mapsize ) + 
-        mapsize*size_of_value;
-    unsigned char *data_ptr = (unsigned char *) crPackAlloc( packet_length );
-
-    WRITE_DATA( 0, GLenum, SWAP32(map) );
-    WRITE_DATA( 4, GLsizei, SWAP32(mapsize) );
-
-    for (i = 0 ; i < mapsize ; i++)
-    {
-        switch( size_of_value )
-        {
-            case 2:
-                WRITE_DATA( 8 + i*sizeof(GLshort), GLshort, SWAP16(*((GLshort *)values + i) ));
-                break;
-            case 4:
-                WRITE_DATA( 8 + i*sizeof(GLint), GLint, SWAP32(*((GLint *)values + i) ));
-                break;
-        }
-    }
-    return data_ptr;
-}
-
-void PACK_APIENTRY crPackPixelMapfvSWAP(GLenum map, GLsizei mapsize, 
-        const GLfloat *values )
-{
-    unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values );
-
-    crHugePacket( CR_PIXELMAPFV_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackPixelMapuivSWAP(GLenum map, GLsizei mapsize, 
-        const GLuint *values )
-{
-    unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values );
-
-    crHugePacket( CR_PIXELMAPUIV_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackPixelMapusvSWAP(GLenum map, GLsizei mapsize, 
-        const GLushort *values )
-{
-    unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values );
-
-    crHugePacket( CR_PIXELMAPUSV_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
Index: unk/src/VBox/GuestHost/OpenGL/packer/pack_swap_texture.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_swap_texture.c	(revision 78189)
+++ 	(revision )
@@ -1,981 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "packer.h"
-#include "cr_pixeldata.h"
-#include "cr_error.h"
-#include "cr_string.h"
-#include "cr_version.h"
-
-void PACK_APIENTRY crPackTexImage1DSWAP(GLenum target, GLint level, 
-        GLint internalformat, GLsizei width, GLint border, GLenum format, 
-        GLenum type, const GLvoid *pixels, const CRPixelPackState *unpackstate )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    int isnull = (pixels == NULL);
-
-    packet_length = 
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( internalformat ) +
-        sizeof( width ) + 
-        sizeof( border ) +
-        sizeof( format ) +
-        sizeof( type ) +
-        sizeof( int );
-
-    if (pixels)
-    {
-        packet_length += crImageSize( format, type, width, 1 );
-    }
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32(target) );
-    WRITE_DATA( 4, GLint, SWAP32(level) );
-    WRITE_DATA( 8, GLint, SWAP32(internalformat) );
-    WRITE_DATA( 12, GLsizei, SWAP32(width) );
-    WRITE_DATA( 16, GLint, SWAP32(border) );
-    WRITE_DATA( 20, GLenum, SWAP32(format) );
-    WRITE_DATA( 24, GLenum, SWAP32(type) );
-    WRITE_DATA( 28, int, SWAP32(isnull) );
-
-    if (pixels) {
-        CRPixelPackState tmpUnpackState = *unpackstate;
-        /* flip application-requested swapBytes state */
-        tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
-
-        crPixelCopy1D( (void *)(data_ptr + 32), format, type,
-                                     pixels, format, type, width, &tmpUnpackState );
-    }
-
-    crHugePacket( CR_TEXIMAGE1D_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackTexImage2DSWAP(GLenum target, GLint level, 
-        GLint internalformat, GLsizei width, GLsizei height, GLint border, 
-        GLenum format, GLenum type, const GLvoid *pixels,
-        const CRPixelPackState *unpackstate )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    int isnull = (pixels == NULL);
-
-    packet_length = 
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( internalformat ) +
-        sizeof( width ) +
-        sizeof( height ) + 
-        sizeof( border ) +
-        sizeof( format ) +
-        sizeof( type ) +
-        sizeof( int );
-
-    if (pixels)
-    {
-        packet_length += crImageSize( format, type, width, height );
-    }
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32(target) );
-    WRITE_DATA( 4, GLint, SWAP32(level) );
-    WRITE_DATA( 8, GLint, SWAP32(internalformat) );
-    WRITE_DATA( 12, GLsizei, SWAP32(width) );
-    WRITE_DATA( 16, GLsizei, SWAP32(height) );
-    WRITE_DATA( 20, GLint, SWAP32(border) );
-    WRITE_DATA( 24, GLenum, SWAP32(format) );
-    WRITE_DATA( 28, GLenum, SWAP32(type) );
-    WRITE_DATA( 32, int, SWAP32(isnull) );
-
-    if (pixels)
-    {
-        CRPixelPackState tmpUnpackState = *unpackstate;
-        /* flip application-requested swapBytes state */
-        tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
-
-        crPixelCopy2D( width, height,
-                                     (void *)(data_ptr + 36), format, type, NULL,  /* dst */
-                                     pixels, format, type, &tmpUnpackState );  /* src */
-    }
-
-    crHugePacket( CR_TEXIMAGE2D_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-#if defined( GL_EXT_texture3D ) 
-void PACK_APIENTRY crPackTexImage3DEXTSWAP(GLenum target, GLint level,
-                                                                                     GLenum internalformat,
-                GLsizei width, GLsizei height, GLsizei depth, GLint border,
-                GLenum format, GLenum type, const GLvoid *pixels,
-                const CRPixelPackState *unpackstate )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    int isnull = (pixels == NULL);
-    int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ;
-    int distrib_buf_len = 0;
-    int tex_size = 0;
-
-    packet_length =
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( internalformat ) +
-        sizeof( width ) +
-        sizeof( height ) +
-        sizeof( depth ) +
-        sizeof( border ) +
-        sizeof( format ) +
-        sizeof( type ) +
-        sizeof( int );
-
-    if (pixels)
-    {
-        if ( is_distrib )
-        {
-            distrib_buf_len = crStrlen( pixels ) + 1 +
-                ( (type == GL_TRUE) ? width*height*3 : 0 ) ;
-            packet_length += distrib_buf_len ;
-        }
-        else
-        {
-            tex_size = crTextureSize( format, type, width, height, depth );
-            packet_length += tex_size;
-        }
-    }
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32( target ) );
-    WRITE_DATA( 4, GLint, SWAP32( level ) );
-    WRITE_DATA( 8, GLint, SWAP32( internalformat ) );
-    WRITE_DATA( 12, GLsizei, SWAP32( width ) );
-    WRITE_DATA( 16, GLsizei, SWAP32( height ) );
-    WRITE_DATA( 20, GLsizei, SWAP32( depth ) );
-    WRITE_DATA( 24, GLint, SWAP32( border ) );
-    WRITE_DATA( 28, GLenum, SWAP32( format ) );
-    WRITE_DATA( 32, GLenum, SWAP32( type ) );
-    WRITE_DATA( 36, int, SWAP32( isnull ) );
-
-    if (pixels)
-    {
-        if ( is_distrib )
-        {
-            crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ;
-        }
-        else
-        {
-            CRPixelPackState tmpUnpackState = *unpackstate;
-            /* flip application-requested swapBytes state */
-            tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
-
-            crPixelCopy3D( width, height, depth,
-                                         (void *)(data_ptr + 40), format, type, NULL,
-                                         pixels, format, type, &tmpUnpackState );
-        }
-    }
-
-    crHugePacket( CR_TEXIMAGE3DEXT_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-#endif /* GL_EXT_texture3D */
-
-#ifdef CR_OPENGL_VERSION_1_2
-void PACK_APIENTRY crPackTexImage3DSWAP(GLenum target, GLint level,
-                                                                                GLint internalformat,
-                                                                                GLsizei width, GLsizei height,
-                                                                                GLsizei depth, GLint border,
-                                                                                GLenum format, GLenum type,
-                                                                                const GLvoid *pixels,
-                                                                                const CRPixelPackState *unpackstate )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    int isnull = (pixels == NULL);
-    int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ;
-    int distrib_buf_len = 0;
-    int tex_size = 0;
-
-    packet_length =
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( internalformat ) +
-        sizeof( width ) +
-        sizeof( height ) +
-        sizeof( depth ) +
-        sizeof( border ) +
-        sizeof( format ) +
-        sizeof( type ) +
-        sizeof( int );
-
-    if (pixels)
-    {
-        if ( is_distrib )
-        {
-            distrib_buf_len = crStrlen( pixels ) + 1 +
-                ( (type == GL_TRUE) ? width*height*3 : 0 ) ;
-            packet_length += distrib_buf_len ;
-        }
-        else
-        {
-            tex_size = crTextureSize( format, type, width, height, depth );
-            packet_length += tex_size;
-        }
-    }
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32( target ) );
-    WRITE_DATA( 4, GLint, SWAP32( level ) );
-    WRITE_DATA( 8, GLint, SWAP32( internalformat ) );
-    WRITE_DATA( 12, GLsizei, SWAP32( width ) );
-    WRITE_DATA( 16, GLsizei, SWAP32( height ) );
-    WRITE_DATA( 20, GLsizei, SWAP32( depth ) );
-    WRITE_DATA( 24, GLint, SWAP32( border ) );
-    WRITE_DATA( 28, GLenum, SWAP32( format ) );
-    WRITE_DATA( 32, GLenum, SWAP32( type ) );
-    WRITE_DATA( 36, int, SWAP32( isnull ) );
-
-    if (pixels)
-    {
-        if ( is_distrib )
-        {
-            crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ;
-        }
-        else
-        {
-            CRPixelPackState tmpUnpackState = *unpackstate;
-            /* flip application-requested swapBytes state */
-            tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
-
-            crPixelCopy3D( width, height, depth,
-                                         (void *)(data_ptr + 40), format, type, NULL,
-                                         pixels, format, type, &tmpUnpackState );
-        }
-    }
-
-    crHugePacket( CR_TEXIMAGE3D_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-#endif /* CR_OPENGL_VERSION_1_2 */
-
-
-void PACK_APIENTRY crPackDeleteTexturesSWAP( GLsizei n, const GLuint *textures )
-{
-    unsigned char *data_ptr;
-    int i;
-
-    int packet_length = 
-        sizeof( n ) + 
-        n*sizeof( *textures );
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLsizei, SWAP32(n) );
-
-    for ( i = 0 ; i < n ; i++)
-    {
-        WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]) );
-    }
-    crHugePacket( CR_DELETETEXTURES_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-static void __handleTexEnvData( GLenum target, GLenum pname, const GLfloat *params )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    unsigned char *data_ptr;
-    int num_params;
-    int i;
-
-    int packet_length = 
-        sizeof( int ) + 
-        sizeof( target ) + 
-        sizeof( pname );
-
-    num_params = 1;
-    if ( pname == GL_TEXTURE_ENV_COLOR )
-    {
-        num_params = 4;
-    }
-
-    packet_length += num_params*sizeof(*params);
-
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0, int, SWAP32(packet_length) );
-    WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) );
-    WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) );
-    for ( i = 0 ; i < num_params ; i++)
-    {
-        WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT( params[i] ) );
-    }
-}
-
-
-void PACK_APIENTRY crPackTexEnvfvSWAP( GLenum target, GLenum pname,
-        const GLfloat *params )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    __handleTexEnvData( target, pname, params );
-    WRITE_OPCODE( pc, CR_TEXENVFV_OPCODE );
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
-void PACK_APIENTRY crPackTexEnvivSWAP( GLenum target, GLenum pname,
-        const GLint *params )
-{
-    /* floats and ints are the same size, so the packing should be the same */
-    CR_GET_PACKER_CONTEXT(pc);
-    __handleTexEnvData( target, pname, (const GLfloat *) params );
-    WRITE_OPCODE( pc, CR_TEXENVIV_OPCODE );
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
-void PACK_APIENTRY crPackTexEnviSWAP( GLenum target, GLenum pname, GLint param )
-{
-    crPackTexEnvivSWAP( target, pname, &param );
-}
-
-void PACK_APIENTRY crPackTexEnvfSWAP( GLenum target, GLenum pname, GLfloat param )
-{
-    crPackTexEnvfvSWAP( target, pname, &param );
-}
-
-void PACK_APIENTRY crPackPrioritizeTexturesSWAP( GLsizei n,
-        const GLuint *textures, const GLclampf *priorities )
-{
-    unsigned char *data_ptr;
-    int packet_length = 
-        sizeof( n ) + 
-        n*sizeof( *textures ) + 
-        n*sizeof( *priorities );
-    int i;
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLsizei, SWAP32(n) );
-    for ( i = 0 ; i < n ; i++)
-    {
-        WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]));
-    }
-    for ( i = 0 ; i < n ; i++)
-    {
-        WRITE_DATA( i*sizeof(int) + 4 + n*sizeof( *textures ),
-                GLuint, SWAPFLOAT(priorities[i]));
-    }
-
-    crHugePacket( CR_PRIORITIZETEXTURES_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-static void __handleTexGenData( GLenum coord, GLenum pname, 
-        int sizeof_param, const GLvoid *params )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    unsigned char *data_ptr;
-    int packet_length = sizeof( int ) + sizeof( coord ) + sizeof( pname );
-    int num_params = 1;
-    int i;
-    if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE)
-    {
-        num_params = 4;
-    }
-    packet_length += num_params * sizeof_param;
-    
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0, int, SWAP32(packet_length) );
-    WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(coord) );
-    WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) );
-    for ( i = 0 ; i < num_params ; i++)
-    {
-        WRITE_DATA( (i+1)*sizeof( int ) + 8, GLint, SWAP32(((GLint *)params)[i]) );
-    }
-}
-
-void PACK_APIENTRY crPackTexGendvSWAP( GLenum coord, GLenum pname,
-        const GLdouble *params )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    __handleTexGenData( coord, pname, sizeof( *params ), params );
-    WRITE_OPCODE( pc, CR_TEXGENDV_OPCODE );
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
-void PACK_APIENTRY crPackTexGenfvSWAP( GLenum coord, GLenum pname,
-        const GLfloat *params )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    __handleTexGenData( coord, pname, sizeof( *params ), params );
-    WRITE_OPCODE( pc, CR_TEXGENFV_OPCODE );
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
-void PACK_APIENTRY crPackTexGenivSWAP( GLenum coord, GLenum pname,
-        const GLint *params )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    __handleTexGenData( coord, pname, sizeof( *params ), params );
-    WRITE_OPCODE( pc, CR_TEXGENIV_OPCODE );
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
-void PACK_APIENTRY crPackTexGendSWAP( GLenum coord, GLenum pname, GLdouble param )
-{
-    crPackTexGendvSWAP( coord, pname, &param );
-}
-
-void PACK_APIENTRY crPackTexGenfSWAP( GLenum coord, GLenum pname, GLfloat param )
-{
-    crPackTexGenfvSWAP( coord, pname, &param );
-}
-
-void PACK_APIENTRY crPackTexGeniSWAP( GLenum coord, GLenum pname, GLint param )
-{
-    crPackTexGenivSWAP( coord, pname, &param );
-}
-
-static GLboolean __handleTexParameterData( GLenum target, GLenum pname, const GLfloat *params )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    unsigned char *data_ptr;
-    int packet_length = sizeof( int ) + sizeof( target ) + sizeof( pname );
-    int num_params = 0;
-    int i;
-
-    switch( pname )
-    {
-
-    case GL_TEXTURE_MIN_FILTER:
-    case GL_TEXTURE_MAG_FILTER:
-    case GL_TEXTURE_WRAP_R:
-    case GL_TEXTURE_WRAP_S:
-    case GL_TEXTURE_WRAP_T:
-#ifdef GL_TEXTURE_PRIORITY
-    case GL_TEXTURE_PRIORITY:
-#endif
-      num_params = 1;
-        break;
-    case GL_TEXTURE_MAX_ANISOTROPY_EXT:
-        num_params = 1;
-        break;
-    case GL_TEXTURE_MIN_LOD:
-    case GL_TEXTURE_MAX_LOD:
-    case GL_TEXTURE_BASE_LEVEL:
-    case GL_TEXTURE_MAX_LEVEL:
-        num_params = 1;
-        break;
-    case GL_TEXTURE_BORDER_COLOR:
-        num_params = 4;
-        break;
-#ifdef CR_ARB_shadow
-    case GL_TEXTURE_COMPARE_MODE_ARB:
-    case GL_TEXTURE_COMPARE_FUNC_ARB:
-        num_params = 1;
-        break;
-#endif
-#ifdef CR_ARB_shadow_ambient
-    case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
-        num_params = 1;
-        break;
-#endif
-#ifdef CR_ARB_depth_texture
-    case GL_DEPTH_TEXTURE_MODE_ARB:
-        num_params = 1;
-        break;
-#endif
-#ifdef CR_SGIS_generate_mipmap
-    case GL_GENERATE_MIPMAP_SGIS:
-        num_params = 1;
-        break;
-#endif
-        default:
-            num_params = __packTexParameterNumParams( pname );
-            if (!num_params)
-            {
-                __PackError( __LINE__, __FILE__, GL_INVALID_ENUM,
-                                         "crPackTexParameter(bad pname)" );
-                return GL_FALSE;
-            }
-    }
-    packet_length += num_params * sizeof(*params);
-
-    CR_GET_BUFFERED_POINTER(pc, packet_length );
-    WRITE_DATA( 0, int, SWAP32(packet_length) );
-    WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) );
-    WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) );
-    for ( i = 0 ; i < num_params ; i++)
-    {
-        WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT(params[i]) );
-    }
-    return GL_TRUE;
-}
-
-void PACK_APIENTRY crPackTexParameterfvSWAP( GLenum target, GLenum pname, 
-        const GLfloat *params )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    if (__handleTexParameterData( target, pname, params ))
-        WRITE_OPCODE( pc, CR_TEXPARAMETERFV_OPCODE );
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
-void PACK_APIENTRY crPackTexParameterivSWAP( GLenum target, GLenum pname, 
-        const GLint *params )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    if (__handleTexParameterData( target, pname, (GLfloat *) params ))
-        WRITE_OPCODE( pc, CR_TEXPARAMETERIV_OPCODE );
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
-void PACK_APIENTRY crPackTexParameterfSWAP( GLenum target, GLenum pname, GLfloat param )
-{
-    crPackTexParameterfvSWAP( target, pname, &param );
-}
-
-void PACK_APIENTRY crPackTexParameteriSWAP( GLenum target, GLenum pname, GLint param )
-{
-    crPackTexParameterivSWAP( target, pname, &param );
-}
-
-#ifdef CR_OPENGL_VERSION_1_2
-void PACK_APIENTRY crPackTexSubImage3DSWAP (GLenum target, GLint level,
-                GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
-                GLenum format, GLenum type, const GLvoid *pixels,
-                const CRPixelPackState *unpackstate )
-{
-        unsigned char *data_ptr;
-        int packet_length;
-
-        packet_length =
-                sizeof( target ) +
-                sizeof( level ) +
-                sizeof( xoffset ) +
-                sizeof( yoffset ) +
-        sizeof( zoffset ) +
-                sizeof( width ) +
-                sizeof( height ) +
-        sizeof( depth ) +
-                sizeof( format ) +
-                sizeof( type ) +
-                crTextureSize( format, type, width, height, depth );
-
-        data_ptr = (unsigned char *) crPackAlloc( packet_length );
-        WRITE_DATA( 0, GLenum, SWAP32(target) );
-        WRITE_DATA( 4, GLint, SWAP32(level) );
-        WRITE_DATA( 8, GLint, SWAP32(xoffset) );
-        WRITE_DATA( 12, GLint, SWAP32(yoffset) );
-        WRITE_DATA( 16, GLint, SWAP32(zoffset) );
-        WRITE_DATA( 20, GLsizei, SWAP32(width) );
-        WRITE_DATA( 24, GLsizei, SWAP32(height) );
-        WRITE_DATA( 28, GLsizei, SWAP32(depth) );
-        WRITE_DATA( 32, GLenum, SWAP32(format) );
-        WRITE_DATA( 36, GLenum, SWAP32(type) );
-
-        crPixelCopy3D( width, height, depth,
-                                                                 (GLvoid *) (data_ptr + 36), format, type, NULL,  /* dst */
-                                                                 pixels, format, type, unpackstate );  /* src */
-
-        crHugePacket( CR_TEXSUBIMAGE3D_OPCODE, data_ptr );
-        crPackFree( data_ptr );
-}
-#endif /* CR_OPENGL_VERSION_1_2 */
-
-void PACK_APIENTRY crPackTexSubImage2DSWAP (GLenum target, GLint level, 
-        GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, 
-        GLenum format, GLenum type, const GLvoid *pixels,
-        const CRPixelPackState *unpackstate )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-
-    CRPixelPackState tmpUnpackState = *unpackstate;
-
-    packet_length = 
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( xoffset ) +
-        sizeof( yoffset ) +
-        sizeof( width ) +
-        sizeof( height ) +
-        sizeof( format ) +
-        sizeof( type ) +
-        crImageSize( format, type, width, height );
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32(target) );
-    WRITE_DATA( 4, GLint, SWAP32(level) );
-    WRITE_DATA( 8, GLint, SWAP32(xoffset) );
-    WRITE_DATA( 12, GLint, SWAP32(yoffset) );
-    WRITE_DATA( 16, GLsizei, SWAP32(width) );
-    WRITE_DATA( 20, GLsizei, SWAP32(height) );
-    WRITE_DATA( 24, GLenum, SWAP32(format) );
-    WRITE_DATA( 28, GLenum, SWAP32(type) );
-
-    /* flip application-requested swapBytes state */
-    tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
-
-    crPixelCopy2D( width, height,
-                                 (GLvoid *) (data_ptr + 32), format, type, NULL,  /* dst */
-                                 pixels, format, type, &tmpUnpackState );  /* src */
-
-    crHugePacket( CR_TEXSUBIMAGE2D_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackTexSubImage1DSWAP (GLenum target, GLint level, 
-        GLint xoffset, GLsizei width, GLenum format, GLenum type,
-        const GLvoid *pixels, const CRPixelPackState *unpackstate )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    CRPixelPackState tmpUnpackState = *unpackstate;
-
-    packet_length = 
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( xoffset ) +
-        sizeof( width ) +
-        sizeof( format ) +
-        sizeof( type ) +
-        crImageSize( format, type, width, 1 );
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32(target) );
-    WRITE_DATA( 4, GLint, SWAP32(level) );
-    WRITE_DATA( 8, GLint, SWAP32(xoffset) );
-    WRITE_DATA( 12, GLsizei, SWAP32(width) );
-    WRITE_DATA( 16, GLenum, SWAP32(format) );
-    WRITE_DATA( 20, GLenum, SWAP32(type) );
-
-    /* flip application-requested swapBytes state */
-    tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE;
-
-    crPixelCopy1D((GLvoid *) (data_ptr + 24), format, type,
-                                pixels, format, type, width, &tmpUnpackState );
-
-    crHugePacket( CR_TEXSUBIMAGE1D_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackAreTexturesResidentSWAP( GLsizei n, const GLuint *textures, GLboolean *residences, GLboolean *return_val, int *writeback )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    unsigned char *data_ptr;
-    int packet_length;
-    int i;
-
-    packet_length = 
-        sizeof( int ) +            /* packet length */
-        sizeof( GLenum ) +       /* extend-o opcode */
-        sizeof( n ) +            /* num_textures */
-        n*sizeof( *textures ) +  /* textures */
-        8 + 8 + 8;               /* return pointers */
-
-    CR_GET_BUFFERED_POINTER(pc, packet_length);
-    WRITE_DATA( 0, int, SWAP32(packet_length) );
-    WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(CR_ARETEXTURESRESIDENT_EXTEND_OPCODE) );
-    WRITE_DATA( sizeof( int ) + 4, GLsizei, SWAP32(n) );
-    for (i = 0 ; i < n ; i++)
-    {
-        WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAP32(textures[i]) );
-    }
-    WRITE_NETWORK_POINTER( sizeof( int ) + 8 + n*sizeof( *textures ), (void *) residences );
-    WRITE_NETWORK_POINTER( sizeof( int ) + 16 + n*sizeof( *textures ), (void *) return_val );
-    WRITE_NETWORK_POINTER( sizeof( int ) + 24 + n*sizeof( *textures ), (void *) writeback );
-    WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
-    CR_CMDBLOCK_CHECK_FLUSH(pc);
-    CR_UNLOCK_PACKER_CONTEXT(pc);
-}
-
-
-/**********************************************************************
- * Texture compression
- */
-
-void PACK_APIENTRY crPackCompressedTexImage1DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid *data )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    int isnull = (data == NULL);
-
-    /* All extended opcodes have their first 8 bytes predefined:
-     * the first four indicate the packet size, and the next four
-     * indicate the actual extended opcode.
-     */
-    packet_length = 
-        sizeof( GLenum) + /* extended opcode */
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( internalformat ) +
-        sizeof( width ) + 
-        sizeof( border ) +
-        sizeof( imagesize ) +
-        sizeof( int );
-
-    if (data)
-    {
-        packet_length += imagesize;
-    }
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE1DARB_EXTEND_OPCODE) );
-    WRITE_DATA( 4, GLenum, SWAP32(target) );
-    WRITE_DATA( 8, GLint, SWAP32(level) );
-    WRITE_DATA( 12, GLint, SWAP32(internalformat) );
-    WRITE_DATA( 16, GLsizei, SWAP32(width) );
-    WRITE_DATA( 20, GLint, SWAP32(border) );
-    WRITE_DATA( 24, GLsizei, SWAP32(imagesize) );
-    WRITE_DATA( 28, int, SWAP32(isnull) );
-
-    if (data) {
-        crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize);
-    }
-
-    crHugePacket( CR_EXTEND_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackCompressedTexImage2DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    int isnull = (data == NULL);
-
-    /* All extended opcodes have their first 8 bytes predefined:
-     * the first four indicate the packet size, and the next four
-     * indicate the actual extended opcode.
-     */
-    packet_length = 
-        sizeof( GLenum) + /* extended opcode */
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( internalformat ) +
-        sizeof( width ) + 
-        sizeof( height ) + 
-        sizeof( border ) +
-        sizeof( imagesize ) +
-        sizeof( int ); /* isnull */
-
-    if (data)
-    {
-        packet_length += imagesize;
-    }
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE2DARB_EXTEND_OPCODE) );
-    WRITE_DATA( 4, GLenum, SWAP32(target) );
-    WRITE_DATA( 8, GLint, SWAP32(level) );
-    WRITE_DATA( 12, GLint, SWAP32(internalformat) );
-    WRITE_DATA( 16, GLsizei, SWAP32(width) );
-    WRITE_DATA( 20, GLsizei, SWAP32(height) );
-    WRITE_DATA( 24, GLint, SWAP32(border) );
-    WRITE_DATA( 28, GLsizei, SWAP32(imagesize) );
-    WRITE_DATA( 32, int, SWAP32(isnull) );
-
-    if (data) {
-        crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize);
-    }
-
-    crHugePacket( CR_EXTEND_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackCompressedTexImage3DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    int isnull = (data == NULL);
-
-    /* All extended opcodes have their first 8 bytes predefined:
-     * the first four indicate the packet size, and the next four
-     * indicate the actual extended opcode.
-     */
-    packet_length = 
-        sizeof( GLenum) + /* extended opcode */
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( internalformat ) +
-        sizeof( width ) + 
-        sizeof( height ) + 
-        sizeof( depth ) + 
-        sizeof( border ) +
-        sizeof( imagesize ) +
-        sizeof( int ); /* isnull */
-
-    if (data)
-    {
-        packet_length += imagesize;
-    }
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE3DARB_EXTEND_OPCODE) );
-    WRITE_DATA( 4, GLenum, SWAP32(target) );
-    WRITE_DATA( 8, GLint, SWAP32(level) );
-    WRITE_DATA( 12, GLint, SWAP32(internalformat) );
-    WRITE_DATA( 16, GLsizei, SWAP32(width) );
-    WRITE_DATA( 20, GLsizei, SWAP32(height) );
-    WRITE_DATA( 24, GLsizei, SWAP32(depth) );
-    WRITE_DATA( 28, GLint, SWAP32(border) );
-    WRITE_DATA( 32, GLsizei, SWAP32(imagesize) );
-    WRITE_DATA( 36, int, SWAP32(isnull) );
-
-    if (data) {
-        crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize);
-    }
-
-    crHugePacket( CR_EXTEND_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackCompressedTexSubImage1DARBSWAP( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid *data )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    int isnull = (data == NULL);
-
-    /* All extended opcodes have their first 8 bytes predefined:
-     * the first four indicate the packet size, and the next four
-     * indicate the actual extended opcode.
-     */
-    packet_length = 
-        sizeof( GLenum) + /* extended opcode */
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( xoffset ) +
-        sizeof( width ) + 
-        sizeof( format ) +
-        sizeof( imagesize ) +
-        sizeof( int ); /* isnull */
-
-    if (data)
-    {
-        packet_length += imagesize;
-    }
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE1DARB_EXTEND_OPCODE) );
-    WRITE_DATA( 4, GLenum, SWAP32(target) );
-    WRITE_DATA( 8, GLint, SWAP32(level) );
-    WRITE_DATA( 12, GLint, SWAP32(xoffset) );
-    WRITE_DATA( 16, GLsizei, SWAP32(width) );
-    WRITE_DATA( 20, GLenum, SWAP32(format) );
-    WRITE_DATA( 24, GLsizei, SWAP32(imagesize) );
-    WRITE_DATA( 28, int, SWAP32(isnull) );
-
-    if (data) {
-        crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize);
-    }
-
-    crHugePacket( CR_EXTEND_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackCompressedTexSubImage2DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    int isnull = (data == NULL);
-
-    /* All extended opcodes have their first 8 bytes predefined:
-     * the first four indicate the packet size, and the next four
-     * indicate the actual extended opcode.
-     */
-    packet_length = 
-        sizeof( GLenum) + /* extended opcode */
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( xoffset ) +
-        sizeof( yoffset ) +
-        sizeof( width ) + 
-        sizeof( height ) + 
-        sizeof( format ) +
-        sizeof( imagesize ) +
-        sizeof( int ); /* isnull */
-
-    if (data)
-    {
-        packet_length += imagesize;
-    }
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE2DARB_EXTEND_OPCODE) );
-    WRITE_DATA( 4, GLenum, SWAP32(target) );
-    WRITE_DATA( 8, GLint, SWAP32(level) );
-    WRITE_DATA( 12, GLint, SWAP32(xoffset) );
-    WRITE_DATA( 16, GLint, SWAP32(yoffset) );
-    WRITE_DATA( 20, GLsizei, SWAP32(width) );
-    WRITE_DATA( 24, GLsizei, SWAP32(height) );
-    WRITE_DATA( 28, GLenum, SWAP32(format) );
-    WRITE_DATA( 32, GLsizei, SWAP32(imagesize) );
-    WRITE_DATA( 36, int, SWAP32(isnull) );
-
-    if (data) {
-        crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize);
-    }
-
-    crHugePacket( CR_EXTEND_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackCompressedTexSubImage3DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid *data )
-{
-    unsigned char *data_ptr;
-    int packet_length;
-    int isnull = (data == NULL);
-
-    /* All extended opcodes have their first 8 bytes predefined:
-     * the first four indicate the packet size, and the next four
-     * indicate the actual extended opcode.
-     */
-    packet_length = 
-        sizeof( GLenum) + /* extended opcode */
-        sizeof( target ) +
-        sizeof( level ) +
-        sizeof( xoffset ) +
-        sizeof( yoffset ) +
-        sizeof( zoffset ) +
-        sizeof( width ) + 
-        sizeof( height ) + 
-        sizeof( depth ) + 
-        sizeof( format ) +
-        sizeof( imagesize ) +
-        sizeof( int ); /* isnull */
-
-    if (data)
-    {
-        packet_length += imagesize;
-    }
-
-    data_ptr = (unsigned char *) crPackAlloc( packet_length );
-    WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE3DARB_EXTEND_OPCODE) );
-    WRITE_DATA( 4, GLenum, SWAP32(target) );
-    WRITE_DATA( 8, GLint, SWAP32(level) );
-    WRITE_DATA( 12, GLint, SWAP32(xoffset) );
-    WRITE_DATA( 16, GLint, SWAP32(yoffset) );
-    WRITE_DATA( 20, GLint, SWAP32(zoffset) );
-    WRITE_DATA( 24, GLsizei, SWAP32(width) );
-    WRITE_DATA( 28, GLsizei, SWAP32(height) );
-    WRITE_DATA( 32, GLsizei, SWAP32(depth) );
-    WRITE_DATA( 36, GLenum, SWAP32(format) );
-    WRITE_DATA( 40, GLsizei, SWAP32(imagesize) );
-    WRITE_DATA( 44, int, SWAP32(isnull) );
-
-    if (data) {
-        crMemcpy( (void *)(data_ptr + 48), (void *)data, imagesize);
-    }
-
-    crHugePacket( CR_EXTEND_OPCODE, data_ptr );
-    crPackFree( data_ptr );
-}
-
-void PACK_APIENTRY crPackGetCompressedTexImageARBSWAP( GLenum target, GLint level, GLvoid *img, int *writeback )
-{
-    CR_GET_PACKER_CONTEXT(pc);
-    crError ( "GetCompressedTexImageARB needs to be special cased!");
-    (void) pc;
-    (void) target;
-    (void) level;
-    (void) img;
-    (void) writeback;
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/pack_visibleregion.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/pack_visibleregion.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/pack_visibleregion.c	(revision 78190)
@@ -51,8 +51,2 @@
 }
 
-void PACK_APIENTRY crPackWindowVisibleRegionSWAP( CR_PACKER_CONTEXT_ARGDECL  GLint window, GLint cRects, const GLint * pRects )
-{
-    RT_NOREF3(window, cRects, pRects); CR_PACKER_CONTEXT_ARG_NOREF();
-    crError( "crPackWindowVisibleRegionSWAP unimplemented and shouldn't be called" );
-}
-
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/packer.py
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/packer.py	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/packer.py	(revision 78190)
@@ -13,5 +13,5 @@
 
 
-def WriteData( offset, arg_type, arg_name, is_swapped ):
+def WriteData( offset, arg_type, arg_name ):
     """Return a string to write a variable to the packing buffer."""
     retval = 9
@@ -19,20 +19,8 @@
         retval = "\tWRITE_NETWORK_POINTER(%d, (void *) %s);" % (offset, arg_name )
     else:   
-        if is_swapped:
-            if arg_type == "GLfloat" or arg_type == "GLclampf":
-                retval = "\tWRITE_DATA(%d, GLuint, SWAPFLOAT(%s));" % (offset, arg_name)
-            elif arg_type == "GLdouble" or arg_type == "GLclampd":
-                retval = "\tWRITE_SWAPPED_DOUBLE(%d, %s);" % (offset, arg_name)
-            elif apiutil.sizeof(arg_type) == 1:
-                retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
-            elif apiutil.sizeof(arg_type) == 2:
-                retval = "\tWRITE_DATA(%d, %s, SWAP16(%s));" % (offset, arg_type, arg_name)
-            elif apiutil.sizeof(arg_type) == 4:
-                retval = "\tWRITE_DATA(%d, %s, SWAP32(%s));" % (offset, arg_type, arg_name)
+        if arg_type == "GLdouble" or arg_type == "GLclampd":
+            retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name)
         else:
-            if arg_type == "GLdouble" or arg_type == "GLclampd":
-                retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name)
-            else:
-                retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
+            retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
     if retval == 9:
         print >>sys.stderr, "no retval for %s %s" % (arg_name, arg_type)
@@ -113,10 +101,7 @@
 
 
-def PrintFunc( func_name, params, is_swapped, can_have_pointers ):
+def PrintFunc( func_name, params, can_have_pointers ):
     """Emit a packer function."""
-    if is_swapped:
-        print('void PACK_APIENTRY crPack%sSWAP(%s)' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params)))
-    else:
-        print('void PACK_APIENTRY crPack%s(%s)' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params)))
+    print('void PACK_APIENTRY crPack%s(%s)' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params)))
     print('{')
     print('\tCR_GET_PACKER_CONTEXT(pc);')
@@ -184,6 +169,6 @@
     if is_extended:
         counter = 8
-        print(WriteData( 0, 'GLint', packet_length, is_swapped ))
-        print(WriteData( 4, 'GLenum', apiutil.ExtendedOpcodeName( func_name ), is_swapped ))
+        print(WriteData( 0, 'GLint', packet_length ))
+        print(WriteData( 4, 'GLenum', apiutil.ExtendedOpcodeName( func_name )))
     else:
         counter = 0
@@ -197,8 +182,8 @@
             for i in range(0, vecSize):
                 print(WriteData( counter + i * apiutil.sizeof(ptrType),
-                                 ptrType, "%s[%d]" % (name, i), is_swapped ))
+                                 ptrType, "%s[%d]" % (name, i)))
             # XXX increment counter here?
         else:
-            print(WriteData( counter, type, name, is_swapped ))
+            print(WriteData( counter, type, name))
             if apiutil.IsPointer(type):
                 counter += apiutil.PointerSize()
@@ -267,7 +252,6 @@
         print('#ifndef IN_RING0')
         
-    PrintFunc( func_name, params, 0, pointers_ok )
-    PrintFunc( func_name, params, 1, pointers_ok )
-    
+    PrintFunc( func_name, params, pointers_ok )
+
     if not func_name in r0_funcs:
         print('#endif')
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/packer_bbox.py
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/packer_bbox.py	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/packer_bbox.py	(revision 78190)
@@ -66,29 +66,17 @@
 """)
 
-def WriteData( offset, arg_type, arg_name, is_swapped ):
+def WriteData( offset, arg_type, arg_name ):
 	if arg_type.find('*') != -1:
 		retval = "\tWRITE_NETWORK_POINTER(%d, (void *) %s);" % (offset, arg_name )
 	else:	
-		if is_swapped:
-			if arg_type == "GLfloat" or arg_type == "GLclampf":
-				retval = "\tWRITE_DATA(%d, GLuint, SWAPFLOAT(%s));" % (offset, arg_name)
-			elif arg_type == "GLdouble" or arg_type == "GLclampd":
-				retval = "\tWRITE_SWAPPED_DOUBLE(%d, %s);" % (offset, arg_name)
-			elif apiutil.sizeof(arg_type) == 1:
-				retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
-			elif apiutil.sizeof(arg_type) == 2:
-				retval = "\tWRITE_DATA(%d, %s, SWAP16(%s));" % (offset, arg_type, arg_name)
-			elif apiutil.sizeof(arg_type) == 4:
-				retval = "\tWRITE_DATA(%d, %s, SWAP32(%s));" % (offset, arg_type, arg_name)
-		else:
-			if arg_type == "GLdouble" or arg_type == "GLclampd":
-				retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name)
-			else:
-				retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
+		if arg_type == "GLdouble" or arg_type == "GLclampd":
+			retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name)
+		else:
+			retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name)
 	return retval
 
 
 def PrintFunction( func_name, extSuffix, num_coords, argtype,
-				   do_swapped, do_count, do_vector ):
+				   do_count, do_vector ):
 	"""
 	Generate all the functions named crPackVertex[234][dfis][v]BBOX() and
@@ -102,9 +90,4 @@
 	else:
 		countSuffix = ""
-
-	if do_swapped:
-		swapSuffix = "SWAP"
-	else:
-		swapSuffix = ""
 
 	if func_name[0:12] == "VertexAttrib":
@@ -146,6 +129,6 @@
 	params = apiutil.Parameters(func_name + extSuffix)
 
-	print('void PACK_APIENTRY crPack%sBBOX%s%s(%s)' % (func_name + extSuffix, countSuffix,
-			 swapSuffix, apiutil.MakeDeclarationString(params)))
+	print('void PACK_APIENTRY crPack%sBBOX%s(%s)' % (func_name + extSuffix, countSuffix,
+			 apiutil.MakeDeclarationString(params)))
 	print('{')
 
@@ -229,8 +212,5 @@
 	if do_vector:
 		if isVertexAttrib:
-			if do_swapped:
-				print("\tWRITE_DATA(0, GLuint, SWAP32(index));")
-			else:
-				print("\tWRITE_DATA(0, GLuint, index);")
+			print("\tWRITE_DATA(0, GLuint, index);")
 			counter += 4
 			argname = params[1][0]  # skip 'index' parameter
@@ -239,5 +219,5 @@
 
 		for index in range(num_coords):
-			print(WriteData( counter, vector_type, "%s[%d]" % (argname, index), do_swapped ))
+			print(WriteData( counter, vector_type, "%s[%d]" % (argname, index)))
 			counter += apiutil.sizeof(vector_type)
 
@@ -253,5 +233,5 @@
 		for index in range(0,len(params)):
 			(name, type, vecSize) = params[index]
-			print(WriteData( counter, type, name, do_swapped ))
+			print(WriteData( counter, type, name))
 			counter += apiutil.sizeof(type)
 
@@ -272,18 +252,16 @@
 	for argtype in ['d', 'f', 'i', 's']:
 		func_name = 'Vertex%d%s' % (num_coords, argtype)
-		for swap in range(0, 2):
-			for count in range(0, 2):
-				for vec in range(0, 2):
-					PrintFunction( func_name, "", num_coords, argtype, swap,
-								   count, vec )
+		for count in range(0, 2):
+			for vec in range(0, 2):
+				PrintFunction( func_name, "", num_coords, argtype,
+							   count, vec )
 
 for num_coords in [1,2,3,4]:
 	for argtype in ['d', 'f', 's']:
 		func_name = 'VertexAttrib%d%s' % (num_coords, argtype)
-		for swap in range(0, 2):
-			for count in range(0, 2):
-				for vec in range(0, 2):
-					PrintFunction( func_name, "ARB", num_coords, argtype, swap,
-								   count, vec )
+		for count in range(0, 2):
+			for vec in range(0, 2):
+				PrintFunction( func_name, "ARB", num_coords, argtype,
+							   count, vec )
 
 # Special vector functions
@@ -303,7 +281,6 @@
 	vec = 2  # special, hacked value
 	num_coords = 4
-	for swap in range(0, 2):
-		for count in range(0, 2):
-			PrintFunction( func_name, "ARB", num_coords, argtype, swap, count, vec )
+	for count in range(0, 2):
+		PrintFunction( func_name, "ARB", num_coords, argtype, count, vec )
 
 # Special non-vector functions
@@ -312,5 +289,5 @@
 	vec = 0
 	num_coords = 4
-	for swap in range(0, 2):
-		for count in range(0, 2):
-			PrintFunction( func_name, "ARB", num_coords, argtype, swap, count, vec )
+	for count in range(0, 2):
+		PrintFunction( func_name, "ARB", num_coords, argtype, count, vec )
+
Index: /trunk/src/VBox/GuestHost/OpenGL/packer/packer_defs.py
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/packer/packer_defs.py	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/packer/packer_defs.py	(revision 78190)
@@ -21,5 +21,4 @@
 	if apiutil.CanPack(func_name):
 		print "crPack%s" % func_name
-		print "crPack%sSWAP" % func_name
 
 functions = [
@@ -171,5 +170,4 @@
 for func_name in functions:
     print "%s" % func_name
-    print "%sSWAP" % func_name
 
 
Index: /trunk/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py	(revision 78190)
@@ -21,5 +21,6 @@
 #include "cr_string.h"
 #include "cr_error.h"
-#include "cr_environment.h"
+
+#include <iprt/env.h>
 
 #include <stdio.h>
@@ -36,7 +37,4 @@
 #define SYSTEM_GL "libGL.dylib"
 #define SYSTEM_CGL "OpenGL"
-# ifndef VBOX_WITH_COCOA_QT
-#  define SYSTEM_AGL "AGL"
-# endif
 #include <string.h> /* VBOX */
 #elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1)
@@ -59,8 +57,4 @@
 #define SYSTEM_CGL_DIR  "/System/Library/Frameworks/OpenGL.framework"
 static CRDLL *cglDll = NULL;
-# ifndef VBOX_WITH_COCOA_QT
-#  define SYSTEM_AGL_DIR  "/System/Library/Frameworks/AGL.framework"
-static CRDLL *aglDll = NULL;
-# endif
 #endif
 
@@ -263,9 +257,4 @@
 	crDLLClose( cglDll );
 	cglDll = NULL;
-
-# ifndef VBOX_WITH_COCOA_QT
-	crDLLClose( aglDll );
-	aglDll = NULL;
-# endif
 #endif
 }
@@ -294,10 +283,7 @@
 	int i;
 
-	const char *env_syspath = crGetenv( "CR_SYSTEM_GL_PATH" );
-#ifdef DARWIN
-	const char *env_cgl_syspath = crGetenv( "CR_SYSTEM_CGL_PATH" );
-# ifndef VBOX_WITH_COCOA_QT
-	const char *env_agl_syspath = crGetenv( "CR_SYSTEM_AGL_PATH" );
-# endif
+	const char *env_syspath = RTEnvGet( "CR_SYSTEM_GL_PATH" );
+#ifdef DARWIN
+	const char *env_cgl_syspath = RTEnvGet( "CR_SYSTEM_CGL_PATH" );
 #endif
 
@@ -326,16 +312,4 @@
 
 	crDebug( "Found it in %s.", !env_cgl_syspath ? "default path" : env_cgl_syspath );
-
-# ifndef VBOX_WITH_COCOA_QT
-	crDebug( "Looking for the system's AGL library..." );
-	aglDll = __findSystemGL( env_agl_syspath, SYSTEM_AGL_DIR, SYSTEM_AGL );
-	if (!aglDll)
-	{
-		crError("Unable to find system AGL!");
-		return 0;
-	}
-
-	crDebug( "Found it in %s.", !env_agl_syspath ? "default path" : env_agl_syspath );
-# endif
 #endif
 """)
@@ -466,9 +440,4 @@
 
 print('#elif defined(DARWIN)')
-print('# ifndef VBOX_WITH_COCOA_QT')
-for fun in useful_agl_functions:
-	print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(aglDll, "%s");' % (fun,fun,fun))
-print('# endif')
-
 for fun in useful_cgl_functions:
 	print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(cglDll, "%s");' % (fun, fun,fun))
@@ -580,5 +549,5 @@
 	static CRDLL *osMesaDll = NULL;
 
-	const char *env_syspath = crGetenv( "CR_SYSTEM_GL_PATH" );
+	const char *env_syspath = RTEnvGet( "CR_SYSTEM_GL_PATH" );
 
 	crDebug( "Looking for the system's OSMesa library..." );
Index: /trunk/src/VBox/GuestHost/OpenGL/spu_loader/spuinit.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/spu_loader/spuinit.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/spu_loader/spuinit.c	(revision 78190)
@@ -28,198 +28,2 @@
 }
 
-#if 0 /* unused */
-
-static int validate_int( const char *response, 
-             const char *min,
-             const char *max )
-{
-    int i, imin, imax;   
-    if (sscanf(response, "%d", &i) != 1)
-        return 0;
-    if (min && sscanf(min, "%d", &imin) == 1 && imin > i)
-        return 0;
-    if (max && sscanf(max, "%d", &imax) == 1 && imax < i)
-        return 0;
-    return 1;
-}
-
-static int validate_float( const char *response, 
-             const char *min,
-             const char *max )
-{
-    float f, fmin, fmax;
-    if (sscanf(response, "%f", &f) != 1)
-        return 0;
-    if (min && sscanf(min, "%f", &fmin) == 1 && fmin > f)
-        return 0;
-    if (max && sscanf(max, "%f", &fmax) == 1 && fmax < f)
-        return 0;
-    return 1;
-}
-
-static int validate_one_option( const SPUOptions *opt, 
-                const char *response,
-                const char *min,
-                const char *max )
-{
-    switch (opt->type) {
-    case CR_BOOL:
-        return validate_int( response, "0", "1" );
-    case CR_INT:
-        return validate_int( response, min, max );
-    case CR_FLOAT:
-        return validate_float( response, min, max );
-    case CR_ENUM:
-        /* Make sure response string is present in the min string.
-         * For enums, the min string is a comma-separated list of valid values.
-         */
-        CRASSERT(opt->numValues == 1); /* an enum limitation for now */
-        {
-            const char *p = crStrstr(min, response);
-            if (!p)
-                return 0;  /* invalid value! */
-            if (p[-1] != '\'')
-                return 0;  /* right substring */
-            if (p[crStrlen(response)] != '\'')
-                return 0;  /* left substring */
-            return 1;
-        }
-    default:
-        return 0;
-    }
-}
-
-
-/**
- * Make sure the response matches the opt's parameters (right number
- * and type of values, etc.)
- * Return 1 if OK, 0 if error.
- */
-static int validate_option( const SPUOptions *opt, const char *response )
-{
-    const char *min = opt->min;
-    const char *max = opt->max;
-    int i = 0;
-    int retval;
-
-    if (opt->type == CR_STRING)
-        return 1;
-   
-    CRASSERT(opt->numValues > 0);
-
-    /* skip leading [ for multi-value options */
-    if (opt->numValues > 1) {
-        /* multi-valued options must be enclosed in brackets */
-        if (*response != '[')
-            return 0;
-        response++; /* skip [ */
-        /* make sure min and max are bracketed as well */
-        if (min) {
-            CRASSERT(*min == '[');  /* error in <foo>spu_config.c code!!! */
-            min++;
-        }
-        if (max) {
-            CRASSERT(*max == '[');  /* error in <foo>spu_config.c code!!! */
-            max++;
-        }
-    }
-
-    for (;;)
-    {
-        if (!validate_one_option( opt, response, min, max ))
-        {
-            retval = 0;
-            break;
-        }
-        if (++i == opt->numValues)
-        {
-            retval = 1; /* all done! */
-            break;
-        }
-        /* advance pointers to next item */
-        if (min)
-        {
-            while (*min != ' ' && *min)
-                min++;
-            while (*min == ' ')
-                min++;
-        }
-        if (max)
-        {
-            while (*max != ' ' && *max)
-                max++;
-            while (*max == ' ')
-                max++;
-        }
-        if (response)
-        {
-            while (*response != ' ' && *response)
-                response++;
-            while (*response == ' ')
-                response++;
-        }
-    }
-
-    return retval;
-}
-
-#endif /* unused */
-
-/** Use the default values for all the options:
- */
-void crSPUSetDefaultParams( void *spu, SPUOptions *options )
-{
-    int i;
-    
-    for (i = 0 ; options[i].option ; i++)
-    {
-        SPUOptions *opt = &options[i];
-        opt->cb( spu, opt->deflt );
-    }
-}
-
-
-/**
- * Find the index of the given enum value in the SPUOption's list of
- * possible enum values.
- * Return the enum index, or -1 if not found.
- */
-int crSPUGetEnumIndex( const SPUOptions *options, const char *optName, const char *value )
-{
-    const SPUOptions *opt;
-    const int valueLen = crStrlen(value);
-
-    /* first, find the right option */
-    for (opt = options; opt->option; opt++) {
-        if (crStrcmp(opt->option, optName) == 0) {
-            char **values;
-            int i;
-
-            CRASSERT(opt->type == CR_ENUM);
-
-            /* break into array of strings */
-            /* min string should be of form "'enum1', 'enum2', 'enum3', etc" */
-            values = crStrSplit(opt->min, ",");
-
-            /* search the array */
-            for (i = 0; values[i]; i++) {
-                /* find leading quote */
-                const char *e = crStrchr(values[i], '\'');
-                CRASSERT(e);
-                if (e) {
-                    /* test for match */
-                    if (crStrncmp(value, e + 1, valueLen) == 0 &&   e[valueLen + 1] == '\'') {
-                        crFreeStrings(values);
-                        return i;
-                    }
-                }
-            }
-
-            /* enum value not found! */
-            crFreeStrings(values);
-            return -1;
-        }
-    }
-
-    return -1;
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/spu_loader/spuload.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/spu_loader/spuload.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/spu_loader/spuload.c	(revision 78190)
@@ -6,5 +6,4 @@
 
 #include "cr_mem.h"
-#include "cr_environment.h"
 #include "cr_string.h"
 #include "cr_dll.h"
@@ -120,5 +119,4 @@
                                    &(the_spu->init), &(the_spu->self),
                                    &(the_spu->cleanup),
-                                   &(the_spu->options),
                                    &(the_spu->spu_flags)) )
         {
Index: /trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp	(revision 78190)
@@ -20,5 +20,4 @@
 #include "cr_error.h"
 #include "cr_net.h"
-#include "cr_rand.h"
 #include "cr_mem.h"
 #include "cr_string.h"
Index: /trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py	(revision 78190)
@@ -40,5 +40,4 @@
 #include "cr_error.h"
 #include "cr_net.h"
-#include "cr_rand.h"
 #include "cr_mem.h"
 #include "cr_string.h"
Index: /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_error.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_error.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_error.c	(revision 78190)
@@ -9,7 +9,8 @@
 #include "state.h"
 #include "cr_error.h"
-#include "cr_environment.h"
 #include <stdarg.h>
 #include <stdio.h>
+
+#include <iprt/env.h>
 
 void crStateError( int line, const char *file, GLenum error, const char *format, ... )
@@ -25,5 +26,5 @@
 
 #ifndef DEBUG_misha
-	if (crGetenv("CR_DEBUG"))
+	if (RTEnvExist("CR_DEBUG"))
 #endif
 	{
Index: /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c	(revision 78190)
@@ -23,4 +23,6 @@
 #include "cr_mem.h"
 #include "cr_string.h"
+
+#include <stdio.h> /*sprintf*/
 
 static CRGLSLShader* crStateGetShaderObj(GLuint id)
Index: /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_limits.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_limits.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_limits.c	(revision 78190)
@@ -174,10 +174,17 @@
  * compute the version number supported by Chromium.
  */
-GLfloat crStateComputeVersion(float minVersion)
-{
-	const GLfloat crVersion = crStrToFloat(CR_OPENGL_VERSION_STRING);
-	if (crVersion < minVersion)
-		minVersion = crVersion;
-	return minVersion;
+void crStateComputeVersion(uint32_t *puMajorMin, uint32_t *puMinorMin)
+{
+	if (*puMajorMin > CR_OPENGL_VERSION_MAJOR)
+	{
+		*puMajorMin = CR_OPENGL_VERSION_MAJOR;
+		*puMinorMin = CR_OPENGL_VERSION_MINOR;
+		return;
+	}
+
+	if (*puMinorMin > CR_OPENGL_VERSION_MINOR)
+		*puMinorMin = CR_OPENGL_VERSION_MINOR;
+
+	return;
 }
 
Index: /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_occlude.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_occlude.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_occlude.c	(revision 78190)
@@ -10,8 +10,4 @@
 #include "state_internals.h"
 #include "cr_mem.h"
-
-#if !defined(IN_GUEST)
-#include "cr_unpack.h"
-#endif
 
 void
@@ -63,19 +59,4 @@
 		return;
 	}
-
-    if (n <= 0 || n >= (GLsizei)(INT32_MAX / sizeof(GLuint)))
-    {
-        crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
-                     "glDeleteQueriesARB: parameter 'n' is out of range");
-        return;
-    }
-
-#if !defined(IN_GUEST)
-    if (!DATA_POINTER_CHECK(n * sizeof(GLuint)))
-    {
-        crError("glDeleteQueriesARB: parameter 'n' is out of range");
-        return;
-    }
-#endif
 
     for (i = 0; i < n; i++) {
Index: unk/src/VBox/GuestHost/OpenGL/util/bbox.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/bbox.c	(revision 78189)
+++ 	(revision )
@@ -1,229 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include <float.h>
-#include "cr_bbox.h"
-
-/**
- * \mainpage Util 
- *
- * \section UtilIntroduction Introduction
- *
- * Chromium consists of all the top-level files in the cr
- * directory.  The util module basically takes care of API dispatch,
- * and OpenGL state management.
- *
- */
-static float _vmult(const float *m, float x, float y, float z) 
-{
-	return m[0]*x + m[4]*y + m[8]*z + m[12];
-}
-
-void
-crTransformBBox( float xmin, float ymin, float zmin,
-                 float xmax, float ymax, float zmax,
-                 const CRmatrix *m,
-                 float *out_xmin, float *out_ymin, float *out_zmin,
-                 float *out_xmax, float *out_ymax, float *out_zmax )
-{
-	float x[8], y[8], z[8], w[8];
-	int i,j;
-    
-	/*  Here is the arrangement of the bounding box
-	 *  
-	 *           0 --- 1
-	 *           |\    .\
-	 *           | 2 --- 3 
-	 *           | |   . |
-	 *           | |   . |
-	 *           4.|...5 |
-	 *            \|    .|
-	 *             6 --- 7
-	 *  
-	 *  c array contains the edge connectivity list
-	 */
-
-	static const int c[8][3] = {	
-		{1, 2, 4}, 
-		{0, 3, 5}, 
-		{0, 3, 6}, 
-		{1, 2, 7},
-		{0, 5, 6}, 
-		{1, 4, 7}, 
-		{2, 4, 7}, 
-		{3, 5, 6} 
-	};
-
-	x[0] = _vmult(&(m->m00), xmin, ymin, zmin);
-	x[1] = _vmult(&(m->m00), xmax, ymin, zmin);
-	x[2] = _vmult(&(m->m00), xmin, ymax, zmin);
-	x[3] = _vmult(&(m->m00), xmax, ymax, zmin);
-	x[4] = _vmult(&(m->m00), xmin, ymin, zmax);
-	x[5] = _vmult(&(m->m00), xmax, ymin, zmax);
-	x[6] = _vmult(&(m->m00), xmin, ymax, zmax);
-	x[7] = _vmult(&(m->m00), xmax, ymax, zmax);
-
-	y[0] = _vmult(&(m->m01), xmin, ymin, zmin);
-	y[1] = _vmult(&(m->m01), xmax, ymin, zmin);
-	y[2] = _vmult(&(m->m01), xmin, ymax, zmin);
-	y[3] = _vmult(&(m->m01), xmax, ymax, zmin);
-	y[4] = _vmult(&(m->m01), xmin, ymin, zmax);
-	y[5] = _vmult(&(m->m01), xmax, ymin, zmax);
-	y[6] = _vmult(&(m->m01), xmin, ymax, zmax);
-	y[7] = _vmult(&(m->m01), xmax, ymax, zmax);
-
-	z[0] = _vmult(&(m->m02), xmin, ymin, zmin);
-	z[1] = _vmult(&(m->m02), xmax, ymin, zmin);
-	z[2] = _vmult(&(m->m02), xmin, ymax, zmin);
-	z[3] = _vmult(&(m->m02), xmax, ymax, zmin);
-	z[4] = _vmult(&(m->m02), xmin, ymin, zmax);
-	z[5] = _vmult(&(m->m02), xmax, ymin, zmax);
-	z[6] = _vmult(&(m->m02), xmin, ymax, zmax);
-	z[7] = _vmult(&(m->m02), xmax, ymax, zmax);
-
-	w[0] = _vmult(&(m->m03), xmin, ymin, zmin);
-	w[1] = _vmult(&(m->m03), xmax, ymin, zmin);
-	w[2] = _vmult(&(m->m03), xmin, ymax, zmin);
-	w[3] = _vmult(&(m->m03), xmax, ymax, zmin);
-	w[4] = _vmult(&(m->m03), xmin, ymin, zmax);
-	w[5] = _vmult(&(m->m03), xmax, ymin, zmax);
-	w[6] = _vmult(&(m->m03), xmin, ymax, zmax);
-	w[7] = _vmult(&(m->m03), xmax, ymax, zmax);
-
-	/* Now, the object-space bbox has been transformed into 
-	 * clip-space. */
-
-	/* Find the 2D bounding box of the 3D bounding box */
-	xmin = ymin = zmin = FLT_MAX;
-	xmax = ymax = zmax = -FLT_MAX;
-
-	for (i=0; i<8; i++) 
-	{
-		float xp = x[i];
-		float yp = y[i];
-		float zp = z[i];
-		float wp = w[i];
-
-		/* If corner is to be clipped... */
-		if (zp < -wp) 
-		{
-
-			/* Point has three edges */
-			for (j=0; j<3; j++) 
-			{
-				/* Handle the clipping... */
-				int k = c[i][j];
-				float xk = x[k];
-				float yk = y[k];
-				float zk = z[k];
-				float wk = w[k];
-				float t;
-
-				if (zp+wp-zk-wk == 0.0)
-					continue; /* avoid divide by zero */
-				else 
-					t = (wp + zp) / (zp+wp-zk-wk);
-
-				if (t < 0.0f || t > 1.0f)
-				{
-					continue;
-				}
-				wp = wp + (wk-wp) * t;
-				xp = xp + (xk-xp) * t;
-				yp = yp + (yk-yp) * t;
-				zp = -wp;
-
-				xp /= wp;
-				yp /= wp;
-				zp /= wp;
-
-				if (xp < xmin) xmin = xp;
-				if (xp > xmax) xmax = xp;
-				if (yp < ymin) ymin = yp;
-				if (yp > ymax) ymax = yp;
-				if (zp < zmin) zmin = zp;
-				if (zp > zmax) zmax = zp;
-			}
-		} 
-		else 
-		{
-			/* corner was not clipped.. */
-			xp /= wp;
-			yp /= wp;
-			zp /= wp;
-			if (xp < xmin) xmin = xp;
-			if (xp > xmax) xmax = xp;
-			if (yp < ymin) ymin = yp;
-			if (yp > ymax) ymax = yp;
-			if (zp < zmin) zmin = zp;
-			if (zp > zmax) zmax = zp;
-		}
-	}
-
-	/* Copy for export */
-	if (out_xmin) *out_xmin = xmin;
-	if (out_ymin) *out_ymin = ymin;
-	if (out_zmin) *out_zmin = zmin;
-	if (out_xmax) *out_xmax = xmax;
-	if (out_ymax) *out_ymax = ymax;
-	if (out_zmax) *out_zmax = zmax;
-}
-
-/**
- * Given the coordinates of the two opposite corners of a bounding box
- * in object space (x1,y1,z1) and (x2,y2,z2), use the given modelview
- * and projection matrices to transform the coordinates to NDC space.
- * Find the 3D bounding bounding box of those eight coordinates and
- * return the min/max in (x1,y1,x1) and (x2,y2,z2).
- */
-void
-crProjectBBox(const GLfloat modl[16], const GLfloat proj[16], 
-              GLfloat *x1, GLfloat *y1, GLfloat *z1,
-              GLfloat *x2, GLfloat *y2, GLfloat *z2) 
-{
-	CRmatrix m;
-	
-	/* compute product of modl and proj matrices */
-	m.m00  = proj[0] * modl[0]  + proj[4] * modl[1]  + proj[8]  * modl[2]  + proj[12] * modl[3];	
-	m.m01  = proj[1] * modl[0]  + proj[5] * modl[1]  + proj[9]  * modl[2]  + proj[13] * modl[3];	
-	m.m02  = proj[2] * modl[0]  + proj[6] * modl[1]  + proj[10] * modl[2]  + proj[14] * modl[3];	
-	m.m03  = proj[3] * modl[0]  + proj[7] * modl[1]  + proj[11] * modl[2]  + proj[15] * modl[3];	
-	m.m10  = proj[0] * modl[4]  + proj[4] * modl[5]  + proj[8]  * modl[6]  + proj[12] * modl[7];	
-	m.m11  = proj[1] * modl[4]  + proj[5] * modl[5]  + proj[9]  * modl[6]  + proj[13] * modl[7];	
-	m.m12  = proj[2] * modl[4]  + proj[6] * modl[5]  + proj[10] * modl[6]  + proj[14] * modl[7];	
-	m.m13  = proj[3] * modl[4]  + proj[7] * modl[5]  + proj[11] * modl[6]  + proj[15] * modl[7];	
-	m.m20  = proj[0] * modl[8]  + proj[4] * modl[9]  + proj[8]  * modl[10] + proj[12] * modl[11];	
-	m.m21  = proj[1] * modl[8]  + proj[5] * modl[9]  + proj[9]  * modl[10] + proj[13] * modl[11];
-	m.m22  = proj[2] * modl[8]  + proj[6] * modl[9]  + proj[10] * modl[10] + proj[14] * modl[11];	
-	m.m23  = proj[3] * modl[8]  + proj[7] * modl[9]  + proj[11] * modl[10] + proj[15] * modl[11];	
-	m.m30  = proj[0] * modl[12] + proj[4] * modl[13] + proj[8]  * modl[14] + proj[12] * modl[15];	
-	m.m31  = proj[1] * modl[12] + proj[5] * modl[13] + proj[9]  * modl[14] + proj[13] * modl[15];	
-	m.m32  = proj[2] * modl[12] + proj[6] * modl[13] + proj[10] * modl[14] + proj[14] * modl[15];	
-	m.m33  = proj[3] * modl[12] + proj[7] * modl[13] + proj[11] * modl[14] + proj[15] * modl[15]; 
-	
-    crTransformBBox( *x1, *y1, *z1,
-                     *x2, *y2, *z2,
-                     &m,
-                     x1, y1, z1,
-                     x2, y2, z2 );
-}
-
-
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-
-
-/**
- * Compute union of a and b and put in result.
- */
-void
-crRectiUnion(CRrecti *result, const CRrecti *a, const CRrecti *b)
-{
-	result->x1 = MIN(a->x1, b->x1);
-	result->x2 = MAX(a->x2, b->x2);
-	result->y1 = MIN(a->y1, b->y1);
-	result->y2 = MAX(a->y2, b->y2);
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp	(revision 78190)
@@ -34,5 +34,4 @@
 # include "cr_error.h"
 # include "cr_net.h"
-# include "cr_rand.h"
 # include "cr_mem.h"
 # include "cr_string.h"
Index: unk/src/VBox/GuestHost/OpenGL/util/calllists.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/calllists.c	(revision 78189)
+++ 	(revision )
@@ -1,81 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "chromium.h"
-#include "cr_calllists.h"
-
-#define EXPAND(typeEnum, typeCast, increment, value)     \
-    case typeEnum:                                       \
-      {                                                  \
-        const typeCast *array = (const typeCast *) lists; \
-        for (i = 0; i < (GLuint)n; i++, array increment) {        \
-          (*callListFunc)(base + (GLuint) value); 	 \
-        }                                                \
-      }                                                  \
-      break
-
-#define EXPAND_WITH_DATA(typeEnum, typeCast, increment, value)     \
-    case typeEnum:                                       	\
-      {                                                  \
-        const typeCast *array = (const typeCast *) lists; \
-        for (i = 0; i < (GLuint)n; i++, array increment) {\
-          (*callListFunc)(base + (GLuint) value, i, data); \
-        }                                                 \
-      }                                                    \
-      break
-
-
-int
-crExpandCallLists(GLsizei n, GLenum type, const GLvoid *lists, 
-    GLuint base, void (*callListFunc)(GLuint list))
-{
-	GLuint i;
-
-	switch (type) {
-		EXPAND(GL_BYTE, GLbyte,++,*array);
-		EXPAND(GL_UNSIGNED_BYTE, GLubyte,++,*array);
-		EXPAND(GL_SHORT, GLshort,++,*array);
-		EXPAND(GL_UNSIGNED_SHORT, GLushort,++,*array);
-		EXPAND(GL_INT, GLint,++,*array);
-		EXPAND(GL_UNSIGNED_INT, GLuint,++,*array);
-		EXPAND(GL_FLOAT, GLfloat,++,*array);
-
-		EXPAND(GL_2_BYTES, GLubyte, +=2, 256*array[0] + array[1]);
-		EXPAND(GL_3_BYTES, GLubyte, +=3, 256 * (256 * array[0] + array[1]) + array[2]);
-		EXPAND(GL_4_BYTES, GLubyte, +=4, 256 * (256 * (256 * array[0] + array[1]) + array[2]) + array[3]);
-
-		default:
-			return GL_INVALID_ENUM;
-	}
-
-	return GL_NO_ERROR;
-}
-
-int
-crExpandCallListsWithData(GLsizei n, GLenum type, const GLvoid *lists, 
-    GLuint base, void (*callListFunc)(GLuint list, GLuint index, GLvoid *data), GLvoid *data)
-{
-	GLuint i;
-
-	switch (type) {
-		EXPAND_WITH_DATA(GL_BYTE, GLbyte,++,*array);
-		EXPAND_WITH_DATA(GL_UNSIGNED_BYTE, GLubyte,++,*array);
-		EXPAND_WITH_DATA(GL_SHORT, GLshort,++,*array);
-		EXPAND_WITH_DATA(GL_UNSIGNED_SHORT, GLushort,++,*array);
-		EXPAND_WITH_DATA(GL_INT, GLint,++,*array);
-		EXPAND_WITH_DATA(GL_UNSIGNED_INT, GLuint,++,*array);
-		EXPAND_WITH_DATA(GL_FLOAT, GLfloat,++,*array);
-
-		EXPAND_WITH_DATA(GL_2_BYTES, GLubyte, +=2, 256*array[0] + array[1]);
-		EXPAND_WITH_DATA(GL_3_BYTES, GLubyte, +=3, 256 * (256 * array[0] + array[1]) + array[2]);
-		EXPAND_WITH_DATA(GL_4_BYTES, GLubyte, +=4, 256 * (256 * (256 * array[0] + array[1]) + array[2]) + array[3]);
-
-		default:
-			return GL_INVALID_ENUM;
-	}
-
-	return GL_NO_ERROR;
-}
Index: unk/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py	(revision 78189)
+++ 	(revision )
@@ -1,42 +1,0 @@
-# Copyright (c) 2001, Stanford University
-# All rights reserved.
-#
-# See the file LICENSE.txt for information on redistributing this software.
-
-from __future__ import print_function
-import sys;
-import string;
-import re;
-
-import apiutil
-
-apiutil.CopyrightC()
-
-print("""
-#include "cr_debugopcodes.h"
-#include <stdio.h>
-""")
-
-print("""void crDebugOpcodes( FILE *fp, unsigned char *ptr, unsigned int num_opcodes )
-{
-\tunsigned int i;
-\tfor (i = 0; i < num_opcodes; i++)
-\t{
-\t\tswitch(*(ptr--))
-\t\t{
-""")
-
-keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
-keys.sort()
-
-for func_name in keys:
-	if "pack" in apiutil.ChromiumProps(func_name):
-		print('\t\tcase %s:' % apiutil.OpcodeName( func_name ))
-		print('\t\t\tfprintf(fp, "%s\\n"); ' % apiutil.OpcodeName( func_name ))
-		print( '\t\t\tbreak;')
-
-print("""
-\t\t}
-\t}
-}
-""")
Index: unk/src/VBox/GuestHost/OpenGL/util/devnull.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/devnull.c	(revision 78189)
+++ 	(revision )
@@ -1,118 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_net.h"
-#include "cr_mem.h"
-#include "cr_error.h"
-#include "net_internals.h"
-
-static void
-crDevnullWriteExact( CRConnection *conn, const void *buf, unsigned int len )
-{
-	(void) conn;
-	(void) buf;
-	(void) len;
-}
-
-static void *
-crDevnullAlloc( CRConnection *conn )
-{
-	return crAlloc( conn->buffer_size );
-}
-
-static void
-crDevnullSingleRecv( CRConnection *conn, void *buf, unsigned int len )
-{
-	crError( "You can't receive data on a devnull connection!" );
-	(void) conn;
-	(void) buf;
-	(void) len;
-}
-
-static void
-crDevnullFree( CRConnection *conn, void *buf )
-{
-	crFree( buf );
-	(void) conn;
-}
-
-static void
-crDevnullSend( CRConnection *conn, void **bufp,
-				 const void *start, unsigned int len )
-{
-	
-	if (bufp)
-	{
-		/* We're sending something we've allocated.  It's now ours. 
-		 * If the callers wants to send something else, he'll allocate 
-		 * something else. 
-		 * 
-		 * ENFORCE IT! */
-
-		crDevnullFree( conn, *bufp );
-	}
-	(void) conn;
-	(void) bufp;
-	(void) start;
-	(void) len;
-}
-
-int
-crDevnullRecv( void )
-{
-	crError( "You can't receive data on a DevNull network, stupid." );
-	return 0;
-}
-
-void
-crDevnullInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu )
-{
-	(void) rfl;
-	(void) cfl;
-	(void) mtu;
-}
-
-static void
-crDevnullAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-	crError( "Well, you *could* accept a devnull client, but you'd be disappointed. ");
-	(void) conn;
-	(void) port;
-        (void) hostname;
-}
-
-static int
-crDevnullDoConnect( CRConnection *conn )
-{
-	(void) conn; 
-	return 1;
-}
-
-static void
-crDevnullDoDisconnect( CRConnection *conn )
-{
-	(void) conn;
-}
-
-void crDevnullConnection( CRConnection *conn )
-{
-	conn->type  = CR_DROP_PACKETS;
-	conn->Alloc = crDevnullAlloc;
-	conn->Send  = crDevnullSend;
-	conn->SendExact  = crDevnullWriteExact;
-	conn->Recv  = crDevnullSingleRecv;
-	conn->Free  = crDevnullFree;
-	conn->Accept = crDevnullAccept;
-	conn->Connect = crDevnullDoConnect;
-	conn->Disconnect = crDevnullDoDisconnect;
-	conn->actual_network = 0;
-}
-
-CRConnection** crDevnullDump( int * num )
-{
-	*num = 0;
-	return NULL;
-}
Index: unk/src/VBox/GuestHost/OpenGL/util/endian.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/endian.c	(revision 78189)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#include "chromium.h"
-#include "cr_endian.h"
-
-char crDetermineEndianness( void )
-{
-	union {
-		struct {
-			char c1;
-			char c2;
-			char c3;
-			char c4;
-		} c;
-		unsigned int i;
-	} e_test;
-
-	e_test.c.c1 = 1;
-	e_test.c.c2 = 2;
-	e_test.c.c3 = 3;
-	e_test.c.c4 = 4;
-
-	if (e_test.i == 0x01020304)
-	{
-		return CR_BIG_ENDIAN;
-	}
-	return CR_LITTLE_ENDIAN;
-}  
-
-double SWAPDOUBLE( double d )
-{
-	CR64BitType *ptr = (CR64BitType *) (&d);
-#ifdef __STDC__
-	CR64BitType swapped;
-	SWAP64( *ptr );
-	swapped = *ptr;
-#else
-	CR64BitType swapped = SWAP64( *ptr );
-#endif
-	return *((double *) (&swapped));
-}
Index: unk/src/VBox/GuestHost/OpenGL/util/environment.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/environment.c	(revision 78189)
+++ 	(revision )
@@ -1,34 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_environment.h"
-#include "cr_string.h"
-#include "cr_mem.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-void crSetenv( const char *var, const char *value )
-{
-#if defined(LINUX) || defined(FREEBSD) || defined(DARWIN)
-	setenv( var, value, 1 /* replace */ );
-#else
-	unsigned long len;
-	char *buf;
-
-	len = crStrlen(var) + 1 + crStrlen(value) + 1;
-	buf = (char *) crAlloc( len );
-	sprintf( buf, "%s=%s", var, value );
-	putenv( buf );
-
-	/* don't free the buf, the string is *part* of the environment,
-	 * and can't be reclaimed */
-#endif
-}
-
-const char *crGetenv( const char *var )
-{
-	return getenv( var );
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/util/error.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/error.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/util/error.c	(revision 78190)
@@ -25,9 +25,10 @@
 #include <iprt/buildconfig.h>
 
+
 #include <VBox/log.h>
+#include <iprt/env.h>
 
 #ifdef RT_OS_WINDOWS
 # include <iprt/win/windows.h>
-# include "cr_environment.h"
 # include "cr_error.h"
 # include "VBox/VBoxGuestLib.h"
@@ -100,5 +101,5 @@
     /* Log last error on windows. */
     dwLastErr = GetLastError();
-    if (dwLastErr != 0 && crGetenv("CR_WINDOWS_ERRORS") != NULL)
+    if (dwLastErr != 0 && RTEnvGet("CR_WINDOWS_ERRORS") != NULL)
     {
         LPTSTR pszWindowsMessage;
Index: unk/src/VBox/GuestHost/OpenGL/util/filenet.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/filenet.c	(revision 78189)
+++ 	(revision )
@@ -1,385 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#ifdef WINDOWS
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-#include "cr_bufpool.h"
-#include "cr_net.h"
-#include "cr_endian.h"
-#include "cr_threads.h"
-#include "net_internals.h"
-
-typedef enum {
-	CRFileMemory,
-	CRFileMemoryBig
-} CRFileBufferKind;
-
-#define CR_FILE_BUFFER_MAGIC 0x89134539
-
-#ifndef WINDOWS
-#define O_BINARY 0
-#endif
-
-typedef struct CRFileBuffer {
-	unsigned int          magic;
-	CRFileBufferKind     kind;
-	unsigned int          len;
-	unsigned int          allocated;
-	unsigned int          pad;
-} CRFileBuffer;
-
-static struct {
-	int                  initialized;
-	int                  num_conns;
-	CRConnection         **conns;
-	CRBufferPool         *bufpool;
-#ifdef CHROMIUM_THREADSAFE
-	CRmutex              mutex;
-#endif
-	CRNetReceiveFuncList *recv_list;
-	CRNetCloseFuncList   *close_list;
-} cr_file;
-
-static void
-crFileReadExact( CRConnection *conn, void *buf, unsigned int len )
-{
-	char *dst = (char *) buf;
-
-	while ( len > 0 )
-	{
-		int num_read = read( conn->fd, buf, len );
-
-		if ( num_read < 0 )
-		{
-			crError( "Bad bad bad file error!" );
-		}
-		if (num_read == 0)
-		{
-			crError( "END OF FILE!" );
-		}
-
-		dst += num_read;
-		len -= num_read;
-	}
-}
-
-static void
-crFileWriteExact( CRConnection *conn, const void *buf, unsigned int len )
-{
-	int retval = write( conn->fd, buf, len );
-	if ( retval < (int) len )
-	{
-		crError( "crFileWriteExact: %s (tried to write %d bytes, actually wrote %d)", conn->filename, len, retval );
-	}
-}
-
-static void
-crFileAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-	(void)hostname;
-	conn->file_direction = CR_FILE_READ;
-	conn->fd = open( conn->filename, O_RDONLY | O_BINARY );
-	if (conn->fd < 0)
-	{
-		crError( "Couldn't open %s for reading!", conn->filename );
-	}
-	(void) port;
-}
-
-static void
-*crFileAlloc( CRConnection *conn )
-{
-	CRFileBuffer *buf;
-
-#ifdef CHROMIUM_THREADSAFE
-	crLockMutex(&cr_file.mutex);
-#endif
-
-	buf  = (CRFileBuffer *) crBufferPoolPop( cr_file.bufpool, conn->buffer_size );
-
-	if ( buf == NULL )
-	{
-		crDebug( "Buffer pool was empty, so I allocated %d bytes", 
-			(int)(sizeof(CRFileBuffer) + conn->buffer_size) );
-		buf = (CRFileBuffer *) 
-			crAlloc( sizeof(CRFileBuffer) + conn->buffer_size );
-		buf->magic = CR_FILE_BUFFER_MAGIC;
-		buf->kind  = CRFileMemory;
-		buf->pad   = 0;
-		buf->allocated = conn->buffer_size;
-	}
-
-#ifdef CHROMIUM_THREADSAFE
-	crUnlockMutex(&cr_file.mutex);
-#endif
-
-	return (void *)( buf + 1 );
-}
-
-static void
-crFileSingleRecv( CRConnection *conn, void *buf, unsigned int len )
-{
-	crFileReadExact( conn, buf, len );
-}
-
-static void
-crFileSend( CRConnection *conn, void **bufp, const void *start, unsigned int len )
-{
-	CRFileBuffer *file_buffer;
-	unsigned int      *lenp;
-
-	if ( bufp == NULL )
-	{
-		/* we are doing synchronous sends from user memory, so no need
-		 * to get fancy.  Simply write the length & the payload and
-		 * return. */
-		if (conn->swap)
-		{
-			len = SWAP32(len);
-		}
-		crFileWriteExact( conn, &len, sizeof(len) );
-		crFileWriteExact( conn, start, len );
-		return;
-	}
-
-	file_buffer = (CRFileBuffer *)(*bufp) - 1;
-
-	CRASSERT( file_buffer->magic == CR_FILE_BUFFER_MAGIC );
-
-	/* All of the buffers passed to the send function were allocated
-	 * with crFileAlloc(), which includes a header with a 4 byte
-	 * length field, to insure that we always have a place to write
-	 * the length field, even when start == *bufp. */
-	lenp = (unsigned int *) start - 1;
-	*lenp = len;
-
-	crFileWriteExact(conn, lenp, len + sizeof(int) );
-
-	/* reclaim this pointer for reuse and try to keep the client from
-		 accidentally reusing it directly */
-#ifdef CHROMIUM_THREADSAFE
-	crLockMutex(&cr_file.mutex);
-#endif
-	crBufferPoolPush( cr_file.bufpool, file_buffer, conn->buffer_size );
-#ifdef CHROMIUM_THREADSAFE
-	crUnlockMutex(&cr_file.mutex);
-#endif
-	*bufp = NULL;
-}
-
-static void
-crFileFree( CRConnection *conn, void *buf )
-{
-	CRFileBuffer *file_buffer = (CRFileBuffer *) buf - 1;
-
-	CRASSERT( file_buffer->magic == CR_FILE_BUFFER_MAGIC );
-	conn->recv_credits += file_buffer->len;
-
-	switch ( file_buffer->kind )
-	{
-		case CRFileMemory:
-#ifdef CHROMIUM_THREADSAFE
-			crLockMutex(&cr_file.mutex);
-#endif
-			crBufferPoolPush( cr_file.bufpool, file_buffer, conn->buffer_size );
-#ifdef CHROMIUM_THREADSAFE
-			crUnlockMutex(&cr_file.mutex);
-#endif
-			break;
-
-		case CRFileMemoryBig:
-			crFree( file_buffer );
-			break;
-
-		default:
-			crError( "Weird buffer kind trying to free in crFileFree: %d", file_buffer->kind );
-	}
-}
-
-int
-crFileRecv( void )
-{
-	CRMessage *msg;
-	int i;
-
-	if (!cr_file.num_conns)
-	{
-		return 0;
-	}
-	for ( i = 0; i < cr_file.num_conns; i++ )
-	{
-		CRFileBuffer *file_buffer;
-		unsigned int   len;
-		CRConnection  *conn = cr_file.conns[i];
-
-		crFileReadExact( conn, &len, sizeof( len ) );
-
-		CRASSERT( len > 0 );
-
-		if ( len <= conn->buffer_size )
-		{
-			file_buffer = (CRFileBuffer *) crFileAlloc( conn ) - 1;
-		}
-		else
-		{
-			file_buffer = (CRFileBuffer *) 
-				crAlloc( sizeof(*file_buffer) + len );
-			file_buffer->magic = CR_FILE_BUFFER_MAGIC;
-			file_buffer->kind  = CRFileMemoryBig;
-			file_buffer->pad   = 0;
-		}
-
-		file_buffer->len = len;
-
-		crFileReadExact( conn, file_buffer + 1, len );
-
-		conn->recv_credits -= len;
-
-		msg = (CRMessage *) (file_buffer + 1);
-		crNetDispatchMessage( cr_file.recv_list, conn, msg, len );
-
-		/* CR_MESSAGE_OPCODES is freed in
-		 * crserverlib/server_stream.c 
-		 *
-		 * OOB messages are the programmer's problem.  -- Humper 12/17/01 */
-		if (msg->header.type != CR_MESSAGE_OPCODES && msg->header.type != CR_MESSAGE_OOB)
-		{
-			crFileFree( conn, file_buffer + 1 );
-		}
-	}
-
-	return 1;
-}
-
-static void
-crFileHandleNewMessage( CRConnection *conn, CRMessage *msg,
-		unsigned int len )
-{
-	CRFileBuffer *buf = ((CRFileBuffer *) msg) - 1;
-
-	/* build a header so we can delete the message later */
-	buf->magic = CR_FILE_BUFFER_MAGIC;
-	buf->kind  = CRFileMemory;
-	buf->len   = len;
-	buf->pad   = 0;
-
-	crNetDispatchMessage( cr_file.recv_list, conn, msg, len );
-}
-
-static void
-crFileInstantReclaim( CRConnection *conn, CRMessage *mess )
-{
-	crFileFree( conn, mess );
-}
-
-void
-crFileInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu )
-{
-	(void) mtu;
-
-	cr_file.recv_list = rfl;
-	cr_file.close_list = cfl;
-
-	if (cr_file.initialized)
-	{
-		return;
-	}
-
-	cr_file.num_conns = 0;
-	cr_file.conns     = NULL;
-	
-#ifdef CHROMIUM_THREADSAFE
-	crInitMutex(&cr_file.mutex);
-#endif
-	cr_file.bufpool = crBufferPoolInit(16);
-
-
-	cr_file.initialized = 1;
-}
-
-static int
-crFileDoConnect( CRConnection *conn )
-{
-	conn->file_direction = CR_FILE_WRITE;
-	/* NOTE: the third parameter (file permissions) is only used/required when
-	 * we specify O_CREAT as part of the flags.  The permissions will be
-	 * masked according to the effective user's umask setting.
-	 */
-#ifdef WINDOWS
-	conn->fd = open( conn->filename, O_CREAT | O_WRONLY | O_BINARY |
-									 S_IREAD | S_IWRITE);
-#else
-	conn->fd = open( conn->filename, O_CREAT | O_WRONLY | O_BINARY,
-								     S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
-#endif
-	if (conn->fd < 0)
-	{
-		crWarning( "Couldn't open %s for writing!", conn->filename );
-		return 0;
-	}
-	return 1;
-}
-
-static void
-crFileDoDisconnect( CRConnection *conn )
-{
-	close( conn->fd );
-	conn->type = CR_NO_CONNECTION;
-	crMemcpy( cr_file.conns + conn->index, cr_file.conns + conn->index+1, 
-		(cr_file.num_conns - conn->index - 1)*sizeof(*(cr_file.conns)) );
-	cr_file.num_conns--;
-}
-
-void
-crFileConnection( CRConnection *conn )
-{
-	int n_bytes;
-
-	CRASSERT( cr_file.initialized );
-
-	conn->type  = CR_FILE;
-	conn->Alloc = crFileAlloc;
-	conn->Send  = crFileSend;
-	conn->SendExact  = crFileWriteExact;
-	conn->Recv  = crFileSingleRecv;
-	conn->Free  = crFileFree;
-	conn->Accept = crFileAccept;
-	conn->Connect = crFileDoConnect;
-	conn->Disconnect = crFileDoDisconnect;
-	conn->InstantReclaim = crFileInstantReclaim;
-	conn->HandleNewMessage = crFileHandleNewMessage;
-	conn->index = cr_file.num_conns;
-	conn->sizeof_buffer_header = sizeof( CRFileBuffer );
-	conn->actual_network = 0;
-
-	conn->filename = crStrdup( conn->hostname );
-
-	n_bytes = ( cr_file.num_conns + 1 ) * sizeof(*cr_file.conns);
-	crRealloc( (void **) &cr_file.conns, n_bytes );
-
-	cr_file.conns[cr_file.num_conns++] = conn;
-}
-
-CRConnection**
-crFileDump( int* num )
-{
-	*num = cr_file.num_conns;
-
-	return cr_file.conns;
-}
-
Index: /trunk/src/VBox/GuestHost/OpenGL/util/htable.cpp
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/htable.cpp	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/util/htable.cpp	(revision 78190)
@@ -28,5 +28,4 @@
 #include "cr_error.h"
 #include "cr_net.h"
-#include "cr_rand.h"
 #include "cr_mem.h"
 #include "cr_string.h"
Index: unk/src/VBox/GuestHost/OpenGL/util/hull.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/hull.c	(revision 78189)
+++ 	(revision )
@@ -1,315 +1,0 @@
-
-#include <stdlib.h>
-#include <math.h>
-
-#include "cr_mem.h"
-#include "cr_hull.h"
-#include "cr_error.h"
-
-#ifdef WINDOWS
-/* I know while(1) is constant */
-#pragma warning( disable: 4127 )
-#endif
-
-/*==================================================
- *
- * Do S1 & S2 intersect? if so, return t for s1
- */
-static double
-_segment_segment_intersection(const double *s1a, const double *s1b,
-															const double *s2a, const double *s2b)
-{
-	double r1[2], r2[2];
-	double A, B, s, t;
-	double epsilon = .0000000001;
-
-	r1[0] = s1b[0] - s1a[0];
-	r1[1] = s1b[1] - s1a[1];
-	r2[0] = s2b[0] - s2a[0];
-	r2[1] = s2b[1] - s2a[1];
-
-	if (r1[0] == 0)
-		return -1;
-
-	A = s1a[1] - s2a[1] + (r1[1] / r1[0]) * (s2a[0] - s1a[0]);
-	B = r2[1] - (r1[1] / r1[0]) * r2[0];
-
-	if (B == 0)
-		return -1;
-	s = A / B;
-
-	if ((s <= epsilon) || (s > 1. + epsilon))
-		return -1;
-
-	t = (s2a[0] - s1a[0] + s * r2[0]) / r1[0];
-	if ((t < epsilon) || (t > 1. + epsilon))
-		return -1;
-
-	return t;
-}
-
-static int
-_segment_hull_intersect(double *sa, double *sb, const double *pnts,
-												int *hull, int hull_len, double *hits)
-{
-	int a, hitnum;
-	double result;
-	double d[2];
-
-	hitnum = 0;
-	for (a = 0; a < hull_len - 1; a++)
-	{
-		result = _segment_segment_intersection(sa, sb, pnts + 2 * hull[a],
-																					 pnts + 2 * hull[a + 1]);
-
-		if (result >= 0)
-		{
-			d[0] = sb[0] - sa[0];
-			d[1] = sb[1] - sa[1];
-			hits[2 * hitnum] = sa[0] + result * d[0];
-			hits[2 * hitnum + 1] = sa[1] + result * d[1];
-			hitnum++;
-		}
-	}
-
-	return hitnum;
-}
-
-/* 
- * given 4 points, find a rectangle that lays w/i the quad
- */
-static void
-_four_point_box(double *points, double *min, double *max)
-{
-	int a, b, tmp, sort[4];
-	double npnts[8], pnt[2], retval, d[2];
-
-	for (a = 0; a < 4; a++)
-		sort[a] = a;
-
-	for (a = 0; a < 4; a++)
-		for (b = a + 1; b < 4; b++)
-		{
-			if (points[2 * sort[a] + 1] > points[2 * sort[b] + 1])
-			{
-				tmp = sort[a];
-				sort[a] = sort[b];
-				sort[b] = tmp;
-			}
-		}
-
-	npnts[0] = points[2 * sort[1]];
-	npnts[1] = points[2 * sort[1] + 1];
-	npnts[2] = points[2 * sort[2]];
-	npnts[3] = points[2 * sort[2] + 1];
-
-	/* now, intersect a horizontal ray from sort[1] with the quad */
-	for (b = 0; b < 2; b++)
-	{
-		for (a = 0; a < 4; a++)
-		{
-			pnt[0] = points[2 * sort[b + 1]] + 10;
-			pnt[1] = points[2 * sort[b + 1] + 1];
-
-			retval = _segment_segment_intersection(points + 2 * sort[b + 1], pnt,
-																						 points + 2 * a,
-																						 points + 2 * ((a + 1) % 4));
-			if (retval <= 0.001)
-			{
-				pnt[0] = points[2 * sort[b + 1]] - 10;
-				retval = _segment_segment_intersection(points + 2 * sort[b + 1], pnt,
-																							 points + 2 * a,
-																							 points + 2 * ((a + 1) % 4));
-			}
-
-			if (retval > 0.001)
-			{
-				d[0] = pnt[0] - points[2 * sort[b + 1]];
-				d[1] = pnt[1] - points[2 * sort[b + 1] + 1];
-				npnts[2 * b + 4] = points[2 * sort[b + 1]] + retval * d[0];
-				npnts[2 * b + 5] = points[2 * sort[b + 1] + 1] + retval * d[1];
-			}
-		}
-	}
-
-	min[1] = points[2 * sort[1] + 1];
-	max[1] = points[2 * sort[2] + 1];
-
-	/* finally, sort npnts by x */
-	for (a = 0; a < 4; a++)
-		sort[a] = a;
-
-	for (a = 0; a < 4; a++)
-		for (b = a + 1; b < 4; b++)
-		{
-			if (npnts[2 * sort[a]] > npnts[2 * sort[b]])
-			{
-				tmp = sort[a];
-				sort[a] = sort[b];
-				sort[b] = tmp;
-			}
-		}
-
-	/* and grab the x coord of the box */
-	min[0] = npnts[2 * sort[1]];
-	max[0] = npnts[2 * sort[2]];
-
-}
-
-/* 
- * Given the convex hull, find a rectangle w/i it. 
- *
- * Finding the rect from 4 pnts isn't too bad. Find the bbox
- * of the CH, then intersect the diagonals of the bbox with
- * the CH. Use those 4 points to compute the box
- */
-static void
-_bound(const double *pnts, int npnts, int *hull, int hull_len, double *bbox)
-{
-	double max[2], min[2], cent[2], dir[2], pnt[2];
-	double x, y, intr_pnts[8];
-	int a, retval;
-
-	(void) npnts;
-
-	max[0] = max[1] = -9999;
-	min[0] = min[1] = 9999;
-	for (a = 0; a < hull_len; a++)
-	{
-		x = pnts[2 * hull[a]];
-		y = pnts[2 * hull[a] + 1];
-		if (x < min[0])
-			min[0] = x;
-		if (x > max[0])
-			max[0] = x;
-		if (y < min[1])
-			min[1] = y;
-		if (y > max[1])
-			max[1] = y;
-	}
-
-	/* push the bbox out just a hair to make intersection
-	 * a bit more sane */
-	cent[0] = (min[0] + max[0]) / 2.;
-	cent[1] = (min[1] + max[1]) / 2.;
-	dir[0] = max[0] - cent[0];
-	dir[1] = max[1] - cent[1];
-	max[0] = cent[0] + 1.01 * dir[0];
-	max[1] = cent[1] + 1.01 * dir[1];
-	dir[0] = min[0] - cent[0];
-	dir[1] = min[1] - cent[1];
-	min[0] = cent[0] + 1.01 * dir[0];
-	min[1] = cent[1] + 1.01 * dir[1];
-
-	retval = _segment_hull_intersect(min, max, pnts, hull, hull_len, intr_pnts);
-	if (retval != 2)
-		crError("Bad hull intersection");
-
-	dir[0] = min[0];
-	dir[1] = max[1];
-	pnt[0] = max[0];
-	pnt[1] = min[1];
-	retval =
-		_segment_hull_intersect(dir, pnt, pnts, hull, hull_len, intr_pnts + 4);
-	if (retval != 2)
-		crError("Bad hull intersection");
-
-	/* swap points to get them in some order */
-	cent[0] = intr_pnts[2];
-	cent[1] = intr_pnts[3];
-	intr_pnts[2] = intr_pnts[4];
-	intr_pnts[3] = intr_pnts[5];
-	intr_pnts[4] = cent[0];
-	intr_pnts[5] = cent[1];
-
-	_four_point_box(intr_pnts, bbox, bbox + 2);
-}
-
-/*==================================================*/
-void
-crHullInteriorBox(const double *pnts, int npnts, double *bbox)
-{
-	int lowest, a;
-	int *hull, idx, low_idx = 0;
-	double low_dot;
-	const double *p0, *p1;
-	double v[2], A, B, vnew[2], vlow[2];
-
-	vlow[0] = vlow[1] = 0.0;
-
-	hull = (int *) crAlloc((npnts + 1) * sizeof(int));
-
-	/* find the lowest */
-	lowest = 0;
-	for (a = 0; a < 2 * npnts; a += 2)
-	{
-		if (pnts[a + 1] < pnts[2 * lowest + 1])
-			lowest = a / 2;
-	}
-
-	hull[0] = lowest;
-	p0 = pnts + 2 * lowest;
-	idx = 1;
-
-	v[0] = 1;
-	v[1] = 0;
-
-	while (1)
-	{
-		low_dot = -10;
-
-		for (a = 0; a < npnts; a++)
-		{
-			if (a == hull[idx - 1])
-				continue;
-
-			p1 = pnts + 2 * a;
-			if (v[0] == 0.0)
-				A = 0.0;
-			else
-				A = p0[1] - p1[1] + (v[1] / v[0]) * (p1[0] - p0[0]);
-			if (v[0] == 0.0)
-				B = 0.0;
-			else
-				B = v[1] * v[1] / v[0] + v[0];
-
-			if (B != 0.0 && A / B > 0)
-			{
-				continue;
-			}
-
-			vnew[0] = p1[0] - p0[0];
-			vnew[1] = p1[1] - p0[1];
-			B = sqrt(vnew[0] * vnew[0] + vnew[1] * vnew[1]);
-
-			vnew[0] /= B;
-			vnew[1] /= B;
-
-			A = vnew[0] * v[0] + vnew[1] * v[1];
-
-			if (A > low_dot)
-			{
-				low_dot = A;
-				low_idx = a;
-				vlow[0] = vnew[0];
-				vlow[1] = vnew[1];
-			}
-		}
-
-		p0 = pnts + 2 * low_idx;
-		hull[idx] = low_idx;
-		idx++;
-
-		v[0] = vlow[0];
-		v[1] = vlow[1];
-
-		if (low_idx == lowest)
-		{
-			break;
-		}
-	} 
-
-	_bound(pnts, npnts, hull, idx, bbox);
-
-	crFree(hull);
-}
Index: unk/src/VBox/GuestHost/OpenGL/util/idpool.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/idpool.c	(revision 78189)
+++ 	(revision )
@@ -1,288 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "chromium.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_idpool.h"
-
-
-#define CR_MAXUINT             ((GLuint) 0xFFFFFFFF)
-
-typedef struct FreeElemRec {
-	GLuint min;
-	GLuint max;
-	struct FreeElemRec *next;
-	struct FreeElemRec *prev;
-} FreeElem;
-
-struct CRIdPoolRec {
-	FreeElem *freeList;
-};
-
-
-
-CRIdPool *crAllocIdPool( void )
-{
-	CRIdPool *pool = (CRIdPool *) crCalloc(sizeof(CRIdPool));
-	pool->freeList = (FreeElem *) crCalloc(sizeof(FreeElem));
-	pool->freeList->min = 1;
-	pool->freeList->max = CR_MAXUINT;
-	pool->freeList->next = NULL;
-	pool->freeList->prev = NULL;
-	return pool;
-}
-
-void crFreeIdPool( CRIdPool *pool )
-{
-	FreeElem *i, *next;
-	for (i = pool->freeList; i; i = next)
-	{
-		next = i->next;
-		crFree(i);
-	}
-	crFree(pool);
-}
-
-/*
- * Allocate a block of <count> IDs.  Return index of first one.
- * Return 0 if we fail.
- */
-GLuint crIdPoolAllocBlock( CRIdPool *pool, GLuint count )
-{
-	FreeElem *f;
-	GLuint ret;
-
-	CRASSERT(count > 0);
-
-	f = pool->freeList;
-	while (f)
-	{
-		if (f->max - f->min + 1 >= (GLuint) count)
-		{
-			/* found a sufficiently large enough block */
-			ret = f->min;
-			f->min += count;
-
-			if (f->min == f->max)
-			{
-				/* remove this block from linked list */
-				if (f == pool->freeList) 
-				{
-					/* remove from head */
-					pool->freeList = pool->freeList->next;
-					pool->freeList->prev = NULL;
-				}
-				else 
-				{
-					/* remove from elsewhere */
-					f->prev->next = f->next;
-					f->next->prev = f->prev;
-				}
-				crFree(f);
-			}
-
-#ifdef DEBUG
-			/* make sure the IDs really are allocated */
-			{
-				GLuint i;
-				for (i = 0; i < count; i++)
-				{
-					CRASSERT(crIdPoolIsIdUsed(pool, ret + i));
-				}
-			}
-#endif
-
-			return ret;
-		}
-		else {
-			f = f->next;
-		}
-	}
-
-	/* failed to find free block */
-	return 0;
-}
-
-
-/*
- * Free a block of <count> IDs starting at <first>.
- */
-void crIdPoolFreeBlock( CRIdPool *pool, GLuint first, GLuint count )
-{
-	FreeElem *i;
-	FreeElem *newelem;
-
-	/*********************************/
-	/* Add the name to the freeList  */
-	/* Find the bracketing sequences */
-
-	for (i = pool->freeList; i && i->next && i->next->min < first; i = i->next)
-	{
-		/* EMPTY BODY */
-	}
-
-	/* j will always be valid */
-	if (!i)
-		return;
-	if (!i->next && i->max == first)
-		return;
-
-	/* Case:  j:(~,first-1) */
-	if (i->max + 1 == first) 
-	{
-		i->max += count;
-		if (i->next && i->max+1 >= i->next->min) 
-		{
-			/* Collapse */
-			i->next->min = i->min;
-			i->next->prev = i->prev;
-			if (i->prev)
-			{
-				i->prev->next = i->next;
-			}
-			if (i == pool->freeList)
-			{
-				pool->freeList = i->next;
-			}
-			crFree(i);
-		}
-		return;
-	}
-
-	/* Case: j->next: (first+1, ~) */
-	if (i->next && i->next->min - count == first) 
-	{
-		i->next->min -= count;
-		if (i->max + 1 >= i->next->min) 
-		{
-			/* Collapse */
-			i->next->min = i->min;
-			i->next->prev = i->prev;
-			if (i->prev)
-			{
-				i->prev->next = i->next;
-			}
-			if (i == pool->freeList) 
-			{
-				pool->freeList = i->next;
-			}
-			crFree(i);
-		}
-		return;
-	}
-
-	/* Case: j: (first+1, ~) j->next: null */
-	if (!i->next && i->min - count == first) 
-	{
-		i->min -= count;
-		return;
-	}
-
-	/* allocate a new FreeElem node */
-	newelem = (FreeElem *) crCalloc(sizeof(FreeElem));
-	newelem->min = first;
-	newelem->max = first + count - 1;
-
-	/* Case: j: (~,first-(2+))  j->next: (first+(2+), ~) or null */
-	if (first > i->max) 
-	{
-		newelem->prev = i;
-		newelem->next = i->next;
-		if (i->next)
-		{
-			i->next->prev = newelem;
-		}
-		i->next = newelem;
-		return;
-	}
-
-	/* Case: j: (first+(2+), ~) */
-	/* Can only happen if j = t->freeList! */
-	if (i == pool->freeList && i->min > first) 
-	{
-		newelem->next = i;
-		newelem->prev = i->prev;
-		i->prev = newelem;
-		pool->freeList = newelem;
-		return;
-	}
-}
-
-
-
-/*
- * Mark the given Id as being allocated.
- */
-void crIdPoolAllocId( CRIdPool *pool, GLuint id )
-{
-	FreeElem *f;
-
-	CRASSERT(id > 0);
-
-	f = pool->freeList;
-	while (f)
-	{
-		if (id >= f->min && id <= f->max)
-		{
-			/* found the block */
-			if (id == f->min)
-			{
-				f->min++;
-			}
-			else if (id == f->max)
-			{
-				f->max--;
-			}
-			else
-			{
-				/* somewhere in the middle - split the block */
-				FreeElem *newelem = (FreeElem *) crCalloc(sizeof(FreeElem));
-				newelem->min = id + 1;
-				newelem->max = f->max;
-				f->max = id - 1;
-				newelem->next = f->next;
-				if (f->next)
-				   f->next->prev = newelem;
-				newelem->prev = f;
-				f->next = newelem;
-			}
-			return;
-		}
-		f = f->next;
-	}
-
-	/* if we get here, the ID was already allocated - that's OK */
-}
-
-
-/*
- * Determine if the given id is free.  Return GL_TRUE if so.
- */
-GLboolean crIdPoolIsIdFree( const CRIdPool *pool, GLuint id )
-{
-	FreeElem *i;
-
-	/* First find which region it fits in */
-	for (i = pool->freeList; i && !(i->min <= id && id <= i->max); i=i->next)
-	{
-		/* EMPTY BODY */
-	}
-
-	if (i)
-		return GL_TRUE;
-	else
-		return GL_FALSE;
-}
-
-
-/*
- * Determine if the given id is used.  Return GL_TRUE if so.
- */
-GLboolean crIdPoolIsIdUsed( const CRIdPool *pool, GLuint id )
-{
-	return (GLboolean) !crIdPoolIsIdFree( pool, id);
-}
Index: unk/src/VBox/GuestHost/OpenGL/util/libteac.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/libteac.c	(revision 78189)
+++ 	(revision )
@@ -1,1213 +1,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/fcntl.h>
-#include <string.h>
-#include <time.h>
-
-#include "teac.h"
-
-/* Notes-
- * -Why is elan3_fini dropping core?  It's intermittent, and seems to
- *  depend on relative timing of multiple calls.
- */
-
-#ifdef CHROMIUM
-#include <cr_string.h>
-#include <cr_mem.h>
-#include <cr_error.h>
-#else
-#define crAlloc(sz) malloc(sz)
-#define crStrncpy(out,in,sz) strncpy(out,in,sz)
-#define crMemcpy(out,in,bytes) memcpy(out,in,bytes)
-#define crStrchr(instr,inchr) strchr(instr,inchr)
-#define crFree(ptr) free(ptr)
-#define crRealloc( pp, size ) { \
-  if (!(*pp=realloc(*pp,size))) { \
-    fprintf(stderr,"failed to reallocate %d bytes!\n",size); \
-    abort(); \
-  } \
-}
-#include <stdarg.h>
-static void crDebug( const char* fmt, ... ) { 
-  va_list ap;
-  va_start(ap,fmt);
-  vfprintf(stderr, fmt, ap); 
-  va_end(ap);
-}
-#endif
-
-#define EADDR_ALLOC_ELAN            0x200000
-#define ALLOC_ELAN_SIZE	            0x200000
-#define EADDR_ALLOC_MAIN            0x400000
-#define ALLOC_MAIN_SIZE	            0x2000000
-
-/* We need some defs to handle changes in structures between software
- * revisions.  
- */
-/* Capability shape is the same between KITE and pre-KITE */
-#ifdef ELAN_PRE_KITE
-
-/* software level is PRE_KITE */
-#define TEAC_DEVINFO_TYPE 0
-#define TEAC_CAP_TYPE 0
-
-#else
-#ifdef ELAN_PRE_EAGLE
-
-/* software level is KITE */
-
-#ifdef LINUX
-#define TEAC_DEVINFO_TYPE 1
-#define TEAC_CREATE_TYPE 1
-#else
-#define TEAC_DEVINFO_TYPE 0
-#define TEAC_CREATE_TYPE 0
-#endif
-#define TEAC_CAP_TYPE 1
-
-#else
-/* software level is EAGLE */
-#define TEAC_DEVINFO_TYPE 2
-#define TEAC_CAP_TYPE 2
-#define TEAC_CREATE_TYPE 2
-
-#endif
-#endif
-
-#if (TEAC_CAP_TYPE == 2)
-#define TEAC_CAP_ENTRIES(cap) ELAN_CAP_ENTRIES(cap)
-#else
-#define TEAC_CAP_ENTRIES(cap) (cap->Entries)
-#endif
-
-/* In the future we will use the bitwise AND of the rail masks */
-#define RAIL 0
-
-#ifndef HOST_TABLE_FILENAME
-#define HOST_TABLE_FILENAME "/usr/users/8/welling/elanstuff/teac/teac_host_map.t"
-#endif
-
-#define INITIAL_HOST_TABLE_SIZE 256
-
-static host_t* hosts= NULL; /* this one ends up sorted by host name */
-static int* hostsIndex= NULL; /* this is sorted by node ID */
-static sdramaddr_t* sdramAddrBase= NULL;
-static E3_Addr* elanAddrBase= NULL;
-
-static int nodeTablesInitialized= 0;
-static int nodeTableSize= 0;
-static int nodeCount= 0;
-
-static int read_node_map()
-{
-  FILE* f= NULL;
-  int i;
-  int iLine;
-  char buf[256];
-
-  if (hosts) crFree(hosts);
-  if (!(hosts= (host_t*)crAlloc(INITIAL_HOST_TABLE_SIZE*sizeof(host_t)))) {
-    fprintf(stderr,"libteac: read_node_map: unable to allocate %d bytes!\n",
-	    INITIAL_HOST_TABLE_SIZE*sizeof(host_t));
-    abort();
-  }
-  nodeTableSize= INITIAL_HOST_TABLE_SIZE;
-
-  if (!(f=fopen(HOST_TABLE_FILENAME,"r"))) {
-    fprintf(stderr,"libteac: read_node_map: cannot open <%s> for reading!\n",
-	    HOST_TABLE_FILENAME);
-    abort();
-  }
-
-  i= 0;
-  iLine= 0;
-  buf[sizeof(buf)-1]= '\0';
-  while (!feof(f) && !ferror(f)) {
-    char* tmp;
-    char* string;
-    if (!fgets(buf, sizeof(buf)-1, f)) break;
-    iLine++;
-    if (buf[0]=='#' || buf[0]=='\n' || buf[0]=='\0') continue;
-    if (i>=nodeTableSize) {
-      /* We need to grow the table */
-      int newSize= 2*nodeTableSize;
-      crRealloc((void**)&hosts,newSize*sizeof(host_t));
-      nodeTableSize= newSize;      
-    }
-    if (!(string=strtok_r(buf," ,;\t\n",&tmp))) {
-      fprintf(stderr,"libteac: read_node_map: Bad machine name at line %d of %s!\n",
-	      iLine, HOST_TABLE_FILENAME);
-      abort();
-    }
-    if (strlen(string)==0) continue; /* blank line */
-    hosts[i].name= strdup(string);
-
-    if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) {
-      fprintf(stderr,"libteac: read_node_map: bad integer string at line %d of %s!\n",
-	      iLine, HOST_TABLE_FILENAME);
-      abort();
-    }
-    errno= 0;
-    hosts[i].railMask= atoi(string);
-    if (errno != 0) {
-      fprintf(stderr,"libteac: read_node_map: bad integer %s at %s line %d!\n",
-	      string, HOST_TABLE_FILENAME, iLine);
-      abort();
-    }
-
-    if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) {
-      fprintf(stderr,"libteac: read_node_map: bad integer string at line %d of %s!\n",
-	      iLine, HOST_TABLE_FILENAME);
-      abort();
-    }
-    errno= 0;
-    hosts[i].id= atoi(string);
-    if (errno != 0) {
-      fprintf(stderr,"libteac: read_node_map: bad integer %s at %s line %d!\n",
-	      string, HOST_TABLE_FILENAME, iLine);
-      abort();
-    }
-
-    if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) {
-      fprintf(stderr,"libteac: read_node_map: bad hex value at line %d of %s!\n",
-	      iLine, HOST_TABLE_FILENAME);
-      abort();
-    }
-    errno= 0;
-    hosts[i].sdramAddrBase= (sdramaddr_t)strtol(string, (char**)NULL, 0);
-    if (errno != 0) {
-      fprintf(stderr,"libteac: read_node_map: bad hex address %s at %s line %d!\n",
-	      string, HOST_TABLE_FILENAME, iLine);
-      abort();
-    }
-
-    if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) {
-      fprintf(stderr,"libteac: read_node_map: bad hex value at line %d of %s!\n",
-	      iLine, HOST_TABLE_FILENAME);
-      abort();
-    }
-    errno= 0;
-    hosts[i].elanAddrBase= (E3_Addr)strtol(string, (char**)NULL, 0);
-    if (errno != 0) {
-      fprintf(stderr,"libteac: read_node_map: bad hex address %s at %s line %d!\n",
-	      string, HOST_TABLE_FILENAME, iLine);
-      abort();
-    }
-
-#if 0
-    crDebug("line %d: %d: got <%s> %d %d 0x%x 0x%x\n",
-	    iLine, i, hosts[i].name, hosts[i].railMask, hosts[i].id, 
-	    hosts[i].sdramAddrBase, hosts[i].elanAddrBase);
-#endif
-
-    i++;
-  }
-  if (ferror(f)) {
-    perror("Error reading host table");
-    fprintf(stderr,"libteac: read_node_map: error reading <%s>!\n",
-	    HOST_TABLE_FILENAME);
-    abort();
-  }
-
-  (void)fclose(f);
-  return i;
-}
-
-static int hostnameCompare(const void* h1, const void* h2)
-{
-  return strcmp(((host_t*)h1)->name, ((host_t*)h2)->name);
-}
-
-static int hostnameLookup(const void* h1, const void* h2)
-{
-  return strcmp((const char*)h1, ((host_t*)h2)->name);
-}
-
-static void initialize_node_tables()
-{
-  if (!nodeTablesInitialized) {
-    int nodeMin;
-    int nodeMax;
-    int nodeRange;
-    int i;
-
-    crDebug("Loading Quadrics network map from <%s>\n",HOST_TABLE_FILENAME);
-
-    /* Load information about Quadrics network */
-    nodeCount= read_node_map();
-    if (nodeCount==0) {
-      fprintf(stderr,
-	      "libteac: initialize_node_tables: no valid nodes in %s!\n",
-	      HOST_TABLE_FILENAME);
-      abort();
-    }
-
-    /* 
-     * Build the offset tables.  Offsets are looked up by node ID, so we
-     * have to avoid redundant IDs and order the tables correctly.
-     */
-    nodeMin= nodeMax= hosts[0].id;
-    for (i=1; i<nodeCount; i++) {
-      if (hosts[i].id<nodeMin) nodeMin= hosts[i].id;
-      if (hosts[i].id>nodeMax) nodeMax= hosts[i].id;
-    }
-    nodeRange= (nodeMax-nodeMin) + 1;
-    if (!(sdramAddrBase=(sdramaddr_t*)crAlloc(nodeRange*sizeof(sdramaddr_t)))) {
-      fprintf(stderr,
-	    "libteac: initialize_node_tables: unable to allocate %d bytes!\n",
-	      nodeRange*sizeof(sdramaddr_t));
-      abort();
-    }
-    if (!(elanAddrBase=(E3_Addr*)crAlloc(nodeRange*sizeof(E3_Addr)))) {
-      fprintf(stderr,
-	    "libteac: initialize_node_tables: unable to allocate %d bytes!\n",
-	      nodeRange*sizeof(E3_Addr));
-      abort();
-    }
-    for (i=0; i<nodeRange; i++) {
-      sdramAddrBase[i]= (sdramaddr_t)0;
-      elanAddrBase[i]= (E3_Addr)0;
-    }
-    for (i=0; i<nodeCount; i++) {
-      sdramAddrBase[hosts[i].id]= hosts[i].sdramAddrBase;
-      elanAddrBase[hosts[i].id]= hosts[i].elanAddrBase;
-    }
-
-    /* Sort the host table alphabetically by host name for faster lookup */
-    qsort( hosts, nodeCount, sizeof(host_t), hostnameCompare );
-
-    /* Build an ordered index into the hosts table */
-    if (hostsIndex) crFree(hostsIndex);
-    if (!(hostsIndex= (int*)crAlloc(nodeRange*sizeof(int)))) {
-      fprintf(stderr,"libteac: read_node_map: unable to allocate %d bytes!\n",
-	      nodeCount*sizeof(int));
-      abort();
-    }
-    for (i=0; i<nodeRange; i++) hostsIndex[i]= 0;
-    for (i=0; i<nodeCount; i++) hostsIndex[hosts[i].id]= i;
-
-    nodeTablesInitialized= 1;
-  }
-}
-
-static int trans_host(const char *hn)  {
-  host_t* h= NULL;
-
-  if (!nodeTablesInitialized) initialize_node_tables();
-
-#if 0
-  char buf[128];
-  int i;
-  i= 0;
-  while (i<sizeof(buf)-1 && hn[i] && hn[i]!='.') { buf[i]= hn[i]; i++; };
-  buf[i]= '\0';
-#endif
-
-  h=(host_t*)bsearch(hn, hosts, nodeCount, sizeof(host_t), hostnameLookup);
-#if 0
-  if (h) {
-    crDebug("Lookup <%s> got <%s> <%d> <%x> <%x>\n",
-	    hn,h->name,h->id,(int)h->sdramAddrBase,(int)h->elanAddrBase);
-  }
-  else fprintf(stderr,"Lookup <%s> returned NULL!\n",hn);
-#endif
-  if (h) return h->id;
-  else return -1;
-}
-
-/*
- * A version of address translation with some safety checks
- */
-static E3_Addr teac_main2elan( ELAN3_CTX *ctx, void* main_addr )
-{
-  E3_Addr result= elan3_main2elan(ctx,main_addr);
-  /*
-  crDebug("mapping %0lx -> %d; addressable %d\n",
-	  main_addr,result,elan3_addressable(ctx,main_addr,64));
-  */
-  if (result==ELAN_BAD_ADDR) {
-    fprintf(stderr,"Address translation error: %0x has no elan equivalent\n",
-	    (int)main_addr);
-    abort();
-  }
-  return result;
-}
-
-Tcomm *teac_Init(char *lh, char *hh, int lctx, int hctx, int myrank, 
-		 const unsigned char key[TEAC_KEY_SIZE])
-{
-#if (TEAC_DEVINFO_TYPE == 2)
-  ELAN_DEVINFO info;
-  ELAN_POSITION position;
-#else
-  ELAN3_DEVINFO	info;
-#endif
-  ELAN_CAPABILITY *cap;
-  Tcomm* result= NULL;
-  int i;
-  int j;
-  int a;
-  int b;
-  char buf[256];
-  char* here;
-#if ( TEAC_CREATE_TYPE == 0 )
-  void* control;
-#endif
-
-  if (!nodeTablesInitialized) initialize_node_tables();
-
-  if (!(result= (Tcomm*)crAlloc(sizeof(Tcomm)))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    sizeof(Tcomm));
-    return(NULL);
-  }
-  result->ctx = NULL;
-  result->dma = NULL;
-  result->e_dma = 0;
-  result->s_event = 0;
-  result->r_event = NULL;
-  for (i=0; i<NUM_SEND_BUFFERS; i++) result->sbuf_pull_event[i] = 0;
-  result->rbuf_pull_event = 0;
-  result->m_snd = NULL;
-  result->m_rcv = NULL;
-  for (i=0; i<NUM_SEND_BUFFERS; i++) result->sbuf_ready[i]= NULL;
-  result->rbuf_ready = NULL;
-  result->mbuff= NULL;
-  for (i=0; i<NUM_SEND_BUFFERS; i++) result->sendWrappers[i]= NULL;
-  result->vp = -1;
-  result->hhost = result->lhost = -1;
-  result->hctx = result->lctx = -1;
-  result->msgnum = 0;
-  result->poll_shift = 0;
-  result->totalSendBufferBytesAllocated= 0;
-  result->totalRecvBufferBytesAllocated= 0;
-      
-  a = trans_host(lh);
-  b = trans_host(hh);
-  result->lhost = (a < b)? a : b;
-  result->hhost = (a > b) ? a : b;
-  
-  result->lctx = (lctx<hctx) ? lctx : hctx;
-  result->hctx = (hctx>lctx) ? hctx : lctx;
-  
-  cap = &(result->cap);
-#if (TEAC_CAP_TYPE == 2)
-  elan_nullcap(cap);
-  /* Initialize the UserKey to the given value */
-  crMemcpy((void*)&(cap->cap_userkey.key_values),key,TEAC_KEY_SIZE);
-  cap->cap_lowcontext = lctx;
-  cap->cap_mycontext = lctx + (myrank%4);
-  cap->cap_highcontext = hctx;
-  cap->cap_lownode = result->lhost;
-  cap->cap_highnode = result->hhost;
-  cap->cap_type = 
-    ELAN_CAP_TYPE_BLOCK | ELAN_CAP_TYPE_NO_BITMAP | ELAN_CAP_TYPE_MULTI_RAIL;
-#else
-  elan3_nullcap(cap);
-  /* Initialize the UserKey to the given value */
-  crMemcpy((void*)&(cap->UserKey),key,TEAC_KEY_SIZE);
-  cap->LowContext = lctx;
-  cap->MyContext = lctx + (myrank%4);
-  cap->HighContext = hctx;
-  cap->LowNode = result->lhost;
-  cap->HighNode = result->hhost;
-  cap->Entries = (hctx - lctx + 1) * (cap->HighNode - cap->LowNode + 1);
-  cap->Type = 
-    ELAN_CAP_TYPE_BLOCK | ELAN_CAP_TYPE_NO_BITMAP | ELAN_CAP_TYPE_MULTI_RAIL;
-#endif
-  
-  if ((result->ctx = elan3_init( 0, EADDR_ALLOC_MAIN, ALLOC_MAIN_SIZE, 
-				 EADDR_ALLOC_ELAN, ALLOC_ELAN_SIZE))
-      == NULL)  {
-    fprintf(stderr, "teac_Init: elan3_init returned NULL context\n");
-    return(NULL);
-  }
-  elan3_block_inputter (result->ctx, 1);
-  
-#if ( TEAC_CREATE_TYPE == 0 )
-  if ((control = elan3_control_open (RAIL)) != NULL)  {
-    if (elan3_create(control, &(result->cap)))  {
-      crDebug("elan3_create failed with <%s>, but that's OK!\n",
-	      strerror(errno));
-      errno= 0;
-    }
-  }  
-  else  {
-    perror("elan3_control_open failed");
-    teac_Close(result);
-    return NULL;
-  }                                                                       
-#elif ( TEAC_CREATE_TYPE == 1 )
-  if (elan3_create(result->ctx, &(result->cap)))  {
-    crDebug("elan3_create failed with <%s>, but that's OK!\n",
-	    strerror(errno));
-    errno= 0;
-  }
-#else
-  /* I don't think we have to do anything here! */
-#endif
-
-#if (TEAC_DEVINFO_TYPE == 2)
-  (void)elan3_get_devinfo(result->ctx, &info);
-  (void)elan3_get_position(result->ctx, &position);
-  crDebug("Position mode %d, NodeID %d, NumNodes %d, NumLevels %d\n",
-	  position.pos_mode,position.pos_nodeid, position.pos_nodes,
-	  position.pos_levels);
-  if (position.pos_mode != ELAN_POS_MODE_SWITCHED)
-    crDebug("WARNING: position mode is not %d!\n",ELAN_POS_MODE_SWITCHED);
-  crDebug("Rail %d\n",info.dev_rail);
-#elif (TEAC_DEVINFO_TYPE == 1)
-  elan3_devinfo(0, &info);
-  crDebug("NodeId: %d, NumNodes: %d, NumLevels: %d, NodeLevel: %d\n",
-	  info.Position.NodeId, info.Position.NumNodes, 
-	  info.Position.NumLevels, info.Position.NodeLevel);
-#else
-  elan3_devinfo(0, &info);
-  crDebug("NodeId: %d, NumLevels: %d, NodeLevel: %d\n",
-	  info.NodeId, info.NumLevels, info.NodeLevel);
-#endif
-
-#if 0
-  {
-    static char junkString[256];
-#if (TEAC_CAP_TYPE == 2)
-    crDebug("Capability: <%s>\n",
-	    elan_capability_string(&(result->cap),junkString));
-    crDebug("railmask is %d\n",result->cap.cap_railmask);
-    crDebug("bitmap is %x\n",result->cap.cap_bitmap[0]);
-#else
-  crDebug("Capability: <%s>\n",
-	  elan3_capability_string(&(result->cap),junkString));
-  crDebug("railmask is %d\n",result->cap.RailMask);
-  crDebug("bitmap is %x\n",result->cap.Bitmap[0]);
-#endif
-  }
-#endif
-
-  /* Reality check. */
-  if (gethostname(buf,sizeof(buf)-1)) {
-    perror("Can't get my own host name");
-    teac_Close(result);
-    return NULL;
-  }
-  if ((here= crStrchr(buf,'.')) != NULL) *here= '\0';
-
-#if (TEAC_DEVINFO_TYPE == 2)
-  if (trans_host(buf) != (int)position.pos_nodeid) {
-    fprintf(stderr,
- "teac_Init: Expected Quadrics port id %d does not match real value %d!\n",
-	    trans_host(buf), position.pos_nodeid);
-    teac_Close(result);
-    return NULL;
-  }
-#elif (TEAC_DEVINFO_TYPE == 1)
-  if (trans_host(buf) != info.Position.NodeId) {
-    fprintf(stderr,
- "teac_Init: Expected Quadrics port id %d does not match real value %d!\n",
-	    trans_host(buf), info.Position.NodeId);
-    teac_Close(result);
-    return NULL;
-  }
-#else
-  if (trans_host(buf) != info.NodeId) {
-    fprintf(stderr,
- "teac_Init: Expected Quadrics port id %d does not match real value %d!\n",
-	    trans_host(buf), info.NodeId);
-    teac_Close(result);
-    return NULL;
-  }
-#endif
-
-  if (elan3_attach(result->ctx, &(result->cap)))  {
-    fprintf(stderr, "teac_Init: elan3_attach failed\n");
-    teac_Close(result);
-    return(NULL);
-  }
-
-  if (elan3_addvp(result->ctx, 0, &(result->cap)))  {
-    fprintf(stderr, "teac_Init: elan3_addvp failed\n");
-    teac_Close(result);
-    return(NULL);
-  }
-  
-  result->vp = elan3_process(result->ctx);
-  
-  if (! elan3_set_required_mappings (result->ctx))  {
-    fprintf(stderr, "teac_Init: elan3_set_required_mappings failed\n");
-    teac_Close(result);
-    return(NULL);
-  }
-  
-  if (!(result->r_event= 
-	(sdramaddr_t**)crAlloc( TEAC_CAP_ENTRIES(cap)*sizeof(sdramaddr_t*) ))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    TEAC_CAP_ENTRIES(cap)*sizeof(sdramaddr_t*));
-    teac_Close(result);
-    return(NULL);
-  }
-  if (!(result->r_event[0]=
-	(sdramaddr_t*)crAlloc( TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS
-			      * sizeof(sdramaddr_t) ))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(sdramaddr_t));
-    teac_Close(result);
-    return(NULL);
-  }
-  if (!(result->r_event[0][0]=
-	elan3_allocElan(result->ctx, E3_EVENT_ALIGN, 
-		TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(E3_BlockCopyEvent)))) {
-    perror("teac_Init: elan3_allocElan failed for r_event block");
-    teac_Close(result);
-    return(NULL);
-  }
-  for (j=1; j<TEAC_CAP_ENTRIES(cap); j++) {
-    result->r_event[j]= result->r_event[0] + j*NUM_SEND_BUFFERS;
-    result->r_event[j][0]= 
-      result->r_event[0][0]+j*NUM_SEND_BUFFERS*sizeof(E3_BlockCopyEvent);
-  }
-  for (j=0; j<TEAC_CAP_ENTRIES(cap); j++) 
-    for (i=1; i<NUM_SEND_BUFFERS; i++) {
-      result->r_event[j][i]= 
-	result->r_event[j][0] + i*sizeof(E3_BlockCopyEvent);
-    }
-#if 0
-  crDebug("r_event[0][0] is %x\n",(int)result->r_event[0][0]);
-#endif
-
-  if (!(result->m_rcv= 
-	(volatile E3_uint32**)crAlloc( TEAC_CAP_ENTRIES(cap)*sizeof(E3_uint32*) ))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    TEAC_CAP_ENTRIES(cap)*sizeof(E3_uint32*));
-    teac_Close(result);
-    return(NULL);
-  }
-  if (!(result->m_rcv[0]= (volatile E3_uint32*)
-	elan3_allocMain(result->ctx, 0, 
-			TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(E3_uint32)))) {
-    perror("teac_Init: elan3_allocMain failed for m_rcv block");
-    teac_Close(result);
-    return(NULL);
-  }
-  for (i=1; i<TEAC_CAP_ENTRIES(cap); i++)
-    result->m_rcv[i]= result->m_rcv[0] + i*NUM_SEND_BUFFERS;
-#if 0
-  crDebug("Base of m_rcv is %lx -> %lx\n",
-	  (long)(result->m_rcv[0]),
-	  (long)teac_main2elan(result->ctx,(void*)(result->m_rcv[0])));
-#endif
-  
-  if (!(result->mbuff= (teacMsg**)crAlloc( TEAC_CAP_ENTRIES(cap)*sizeof(teacMsg*) ))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    TEAC_CAP_ENTRIES(cap)*sizeof(teacMsg*));
-    teac_Close(result);
-    return(NULL);
-  }
-  if (!(result->mbuff[0]= (teacMsg*)
-	elan3_allocMain(result->ctx, 8, 
-			TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(teacMsg)))) {
-    perror("teac_Init: elan3_allocMain failed for mbuff block");
-    teac_Close(result);
-    return(NULL);
-  }
-  for (i=1; i<TEAC_CAP_ENTRIES(cap); i++)
-    result->mbuff[i]= result->mbuff[0] + i*NUM_SEND_BUFFERS;
-#if 0
-  crDebug("Base of mbuff is %lx -> %lx\n",
-	  (long)(result->mbuff[0]), 
-	  (long)teac_main2elan(result->ctx,result->mbuff[0]));
-#endif
-  
-  if (!(result->dma= (E3_DMA_MAIN *)
-	elan3_allocMain(result->ctx, 
-			E3_DMA_ALIGN, sizeof(E3_DMA_MAIN)))) {
-    perror("teac_Init: elan3_allocMain failed for dma");
-    teac_Close(result);
-    return(NULL);
-  }
-  
-  if (!(result->e_dma= 
-	elan3_allocElan(result->ctx, E3_DMA_ALIGN, sizeof(E3_DMA)))) {
-    perror("teac_Init: elan3_allocElan failed for e_dma");
-    teac_Close(result);
-    return(NULL);
-  }
-  
-  if (!(result->s_event= 
-	elan3_allocElan(result->ctx, E3_EVENT_ALIGN, 
-			sizeof(E3_BlockCopyEvent)))) {
-    perror("teac_Init: elan3_allocElan failed for s_event");
-    teac_Close(result);
-    return(NULL);
-  }
-#if 0
-  crDebug("s_event is %x\n",(int)result->s_event);
-#endif
-  
-  if (!(result->sbuf_pull_event[0]= 
-	elan3_allocElan(result->ctx, E3_EVENT_ALIGN, 
-			NUM_SEND_BUFFERS*sizeof(E3_BlockCopyEvent)))) {
-    perror("teac_Init: elan3_allocElan failed for sbuf_pull_event block");
-    teac_Close(result);
-    return(NULL);
-  }
-  for (i=1; i<NUM_SEND_BUFFERS; i++) 
-    result->sbuf_pull_event[i]= 
-      result->sbuf_pull_event[0]+i*sizeof(E3_BlockCopyEvent);
-  
-  if (!(result->rbuf_pull_event= 
-	elan3_allocElan(result->ctx, E3_EVENT_ALIGN, 
-			sizeof(E3_BlockCopyEvent)))) {
-    perror("teac_Init: elan3_allocElan failed for rbuf_pull_event");
-    teac_Close(result);
-    return(NULL);
-  }
-  
-  if (!(result->m_snd= (E3_uint32 *)
-	elan3_allocMain(result->ctx, 0, 
-			sizeof(E3_uint32)))) {
-    perror("teac_Init: elan3_allocMain failed for m_snd");
-    teac_Close(result);
-    return(NULL);
-  }
-
-  if (!(result->sbuf_ready[0]= (E3_uint32 *)
-	elan3_allocMain(result->ctx, 0, 
-			NUM_SEND_BUFFERS*sizeof(E3_uint32)))) {
-    perror("teac_Init: elan3_allocMain failed for sbuf_ready block");
-    teac_Close(result);
-    return(NULL);
-  }
-  for (i=1; i<NUM_SEND_BUFFERS; i++)
-    result->sbuf_ready[i]= result->sbuf_ready[0] + i;
-  
-  if (!(result->sendWrappers[0]= 
-	(SBuffer*)crAlloc(NUM_SEND_BUFFERS*sizeof(SBuffer)))) {
-    fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n",
-	    NUM_SEND_BUFFERS*sizeof(SBuffer));
-    teac_Close(result);
-    return(NULL);
-  }
-  for (i=1; i<NUM_SEND_BUFFERS; i++)
-    result->sendWrappers[i]= result->sendWrappers[0] + i;
-
-  if (!(result->rbuf_ready= (E3_uint32 *)
-	elan3_allocMain(result->ctx, 0, 
-			sizeof(E3_uint32)))) {
-    perror("teac_Init: elan3_allocMain failed for rbuf_ready");
-    teac_Close(result);
-    return(NULL);
-  }
-
-  for (i=0; i<NUM_SEND_BUFFERS; i++) {
-    char* buf;
-    if (!(buf= (char*)elan3_allocMain(result->ctx, 8, 
-				      E_BUFFER_INITIAL_SIZE))) {
-      perror("teac_Init: elan3_allocMain failed for buffer block");
-      teac_Close(result);
-      return(NULL);
-    }
-    result->sendWrappers[i]->bufId= i;
-    result->sendWrappers[i]->totSize= E_BUFFER_INITIAL_SIZE;
-    result->sendWrappers[i]->validSize= 0;
-    result->sendWrappers[i]->buf= buf;
-    result->totalSendBufferBytesAllocated += result->sendWrappers[i]->totSize; 
-  }
-  
-  elan3_initevent_word (result->ctx, 
-			result->s_event, result->m_snd);
-  elan3_initevent_word (result->ctx, 
-			result->rbuf_pull_event, result->rbuf_ready);
-  
-  for (i=0; i<NUM_SEND_BUFFERS; i++) {
-    elan3_initevent_word (result->ctx, 
-			  result->sbuf_pull_event[i], result->sbuf_ready[i]);
-  }
-
-  for (j=0; j<TEAC_CAP_ENTRIES(cap); j++) 
-    for (i=0; i<NUM_SEND_BUFFERS; i++) {
-      elan3_initevent_word (result->ctx, 
-			    result->r_event[j][i], &(result->m_rcv[j][i]));
-    }
-  
-  /* Get the message receive events ready to fire, in case something
-   * comes in before receive gets called.
-   */
-  for (j=0; j<TEAC_CAP_ENTRIES(cap); j++)
-    for (i=0; i<NUM_SEND_BUFFERS; i++) {
-      elan3_primeevent(result->ctx, result->r_event[j][i], 1);
-    }
-
-  /* Fire the sbuffer free events, so that the buffers look free when 
-   * the first call to send happens.
-   */
-  for (i=0; i<NUM_SEND_BUFFERS; i++) {
-    elan3_primeevent(result->ctx, result->sbuf_pull_event[i], 1);
-    elan3_setevent( result->ctx, result->sbuf_pull_event[i] );
-  }
-  
-  /* And now we're ready to face the world. */
-  elan3_block_inputter (result->ctx, 0);
-  
-  return(result);
-}
-  
-void teac_Close(Tcomm *tcomm)
-{
-  int i;
-
-  if (tcomm) {
-    /* First we have to wait until all pending messages have been
-     * pulled (assuming they got initialized in the first place).
-     */
-    if ((tcomm->sbuf_pull_event[0] != 0) && (tcomm->sbuf_ready[0] != NULL)) {
-      for (i=0; i<NUM_SEND_BUFFERS; i++) {
-	elan3_waitevent_word(tcomm->ctx, tcomm->sbuf_pull_event[i],
-			     tcomm->sbuf_ready[i], 10);
-      }
-      crDebug("All TEAC messages have reported home!\n");
-    }
-    elan3_block_inputter (tcomm->ctx, 1);
-
-    if (tcomm->e_dma != 0) elan3_freeElan(tcomm->ctx, tcomm->e_dma);
-    if (tcomm->s_event != 0) elan3_freeElan(tcomm->ctx, tcomm->s_event);
-    if (tcomm->r_event != NULL) {
-      if (tcomm->r_event[0] != NULL) {
-	if (tcomm->r_event[0][0] != 0) elan3_freeElan(tcomm->ctx, 
-						      tcomm->r_event[0][0]);
-	crFree(tcomm->r_event[0]);
-      }
-      crFree(tcomm->r_event);
-    }
-    if (tcomm->sbuf_pull_event[0] != 0) 
-      elan3_freeElan(tcomm->ctx, tcomm->sbuf_pull_event[0]);
-    if (tcomm->sendWrappers[0] != NULL) {
-      for (i=0; i<NUM_SEND_BUFFERS; i++) {
-	if (tcomm->sendWrappers[i]->buf != NULL) {
-	  elan3_free(tcomm->ctx, tcomm->sendWrappers[i]->buf);
-	  tcomm->totalSendBufferBytesAllocated -= 
-	    tcomm->sendWrappers[i]->totSize;
-	}
-      }
-      crFree(tcomm->sendWrappers[0]);
-    }
-    if (tcomm->rbuf_pull_event != 0) 
-      elan3_freeElan(tcomm->ctx, tcomm->rbuf_pull_event);
-    if (tcomm->m_snd != NULL) elan3_free(tcomm->ctx, 
-					 (E3_uint32*)tcomm->m_snd);
-    if (tcomm->m_rcv != NULL) {
-      if (tcomm->m_rcv[0] != NULL) elan3_free(tcomm->ctx,
-					      (E3_uint32*)tcomm->m_rcv[0]);
-      crFree(tcomm->m_rcv);
-    }
-    if (tcomm->sbuf_ready[0] != NULL) 
-      elan3_free(tcomm->ctx, (E3_uint32*)tcomm->sbuf_ready[0]);
-    if (tcomm->rbuf_ready != NULL) elan3_free(tcomm->ctx, 
-					    (E3_uint32*)tcomm->rbuf_ready);
-    if (tcomm->mbuff != NULL) {
-      if (tcomm->mbuff[0] != NULL) elan3_free(tcomm->ctx, tcomm->mbuff[0]);
-      crFree(tcomm->mbuff);
-    }
-#if (TEAC_CREATE_TYPE==2)
-    elan3_detach(tcomm->ctx);
-    elan3_fini(tcomm->ctx);
-#else
-    /* elan3_detach and elan3_destroy seem to crash sometimes in 
-     * these versions. 
-     */
-#endif
-  }
-}
-
-int teac_Select(Tcomm* tcomm, int *ids, int num_ids, int timeout)
-{
-  int id;
-  while (timeout-- > 0) {
-    if ((id= teac_Poll(tcomm, ids, num_ids)) >= 0) return id;
-  }
-
-  return -1;
-}
-
-int teac_Poll(Tcomm* tcomm, int *ids, int num_ids)
-{
-  int i;
-  int j;
-
-  for (j=0; j<num_ids; j++) {
-    int index= (j+tcomm->poll_shift) % num_ids;
-    int thisId= ids[index];
-    for (i=0; i<NUM_SEND_BUFFERS; i++) {
-      if (elan3_pollevent_word(tcomm->ctx, &(tcomm->m_rcv[thisId][i]), 1)) {
-#ifdef never
-	tcomm->poll_shift= index;
-#endif
-	return thisId;
-      }
-    }
-  }
-  
-  return -1;
-}
-
-int teac_sendBufferAvailable(Tcomm* tcomm)
-{
-  int i;
-  for (i=0; i<NUM_SEND_BUFFERS; i++) {
-    if (elan3_pollevent_word(tcomm->ctx, tcomm->sbuf_ready[i], 1))
-      return 1;
-  }
-  return 0;
-}
-
-SBuffer* teac_getSendBuffer( Tcomm* tcomm, long size )
-{
-  /* Find a free send buffer.  We'll busy wait in this poll loop
-   * if necessary.
-   */
-  int i= 0;
-  while (1) {
-    if (elan3_pollevent_word(tcomm->ctx, tcomm->sbuf_ready[i],
-			     1)) break;
-    if (++i == NUM_SEND_BUFFERS) i= 0;
-  }
-  /* We will use this buffer! */
-#if 0
-  crDebug("Allocated message buffer %d\n",i);
-#endif
-  *(tcomm->sbuf_ready[i])= 0; /* mark it busy */
-
-  /* If the associated chunk of memory is smaller than that requested,
-   * replace it with something larger.
-   */
-  if (tcomm->sendWrappers[i]->totSize < size) {
-    tcomm->totalSendBufferBytesAllocated -= tcomm->sendWrappers[i]->totSize;
-    elan3_free( tcomm->ctx, tcomm->sendWrappers[i]->buf );
-    if (!(tcomm->sendWrappers[i]->buf= 
-	  (char*)elan3_allocMain(tcomm->ctx, 8, size))) {
-      perror("teac_getSendBuffer: failed to grow send buffer");
-      exit(-1);
-    }
-    tcomm->totalSendBufferBytesAllocated += size;
-  }
-  tcomm->sendWrappers[i]->totSize= size;
-  tcomm->sendWrappers[i]->validSize= 0;
-  return tcomm->sendWrappers[i];
-}
-
-SBuffer* teac_getUnreadySendBuffer( Tcomm* tcomm, long size )
-{
-  SBuffer* result= NULL;
-  if (!(result= (SBuffer*)crAlloc(sizeof(SBuffer)))) {
-    fprintf(stderr,"libteac: read_node_map: unable to allocate %d bytes!\n",
-	    sizeof(SBuffer));
-    abort();
-  }
-  result->bufId= -1; /* this marks it unready */
-#if 0
-  crDebug("Allocated an unready message buffer!\n");
-#endif
-  
-  /* Allocate some DMA-able memory */
-  if (!(result->buf= (char*)elan3_allocMain(tcomm->ctx, 8, size))) {
-    perror("teac_getUnreadySendBuffer: failed to allocate elan3 memory");
-    exit(-1);
-  }
-  result->totSize= size;
-  result->validSize= 0;
-  tcomm->totalSendBufferBytesAllocated += result->totSize;
-
-  return result;
-}
-
-SBuffer* teac_makeSendBufferReady( Tcomm* tcomm, SBuffer* buf )
-{
-  int i= 0;
-  /* If the input buffer is already ready, just return it */
-  if (buf->bufId >= 0 && buf->bufId<NUM_SEND_BUFFERS) return buf;
-
-  /* Find a free send buffer.  We'll busy wait in this poll loop
-   * if necessary.
-   */
-  while (1) {
-    if (elan3_pollevent_word(tcomm->ctx, tcomm->sbuf_ready[i],
-			     1)) break;
-    if (++i == NUM_SEND_BUFFERS) i= 0;
-  }
-  /* We will use this buffer! */
-#if 0
-  crDebug("Allocated message buffer %d in makeSendBufferReady\n",i);
-#endif
-  *(tcomm->sbuf_ready[i])= 0; /* mark it busy */
-
-  /* Substitute the unready payload for the old payload */
-  tcomm->totalSendBufferBytesAllocated -= tcomm->sendWrappers[i]->totSize;
-  elan3_free( tcomm->ctx, tcomm->sendWrappers[i]->buf );
-  tcomm->sendWrappers[i]->buf= buf->buf;
-  
-  tcomm->sendWrappers[i]->totSize= buf->totSize;
-  tcomm->sendWrappers[i]->validSize= buf->validSize;
-  crFree(buf);
-  return tcomm->sendWrappers[i];
-  
-}
-
-int teac_Send( Tcomm* tcomm, int* ids, int num_ids, SBuffer* buf, void *start )
-{
-  int	vp = tcomm->vp;
-  int	iBuf;
-  int   iDest;
-  teacMsg *msg;
-
-  /* Complain loudly if this is an unready buffer */
-  if (buf->bufId==-1) {
-    fprintf(stderr,"teac_Send: tried to send an unready buffer!\n");
-    return 0;
-  }
-
-  /* Reality check: is this one of my buffers? */
-  if (buf->bufId<0 || buf->bufId>=NUM_SEND_BUFFERS) {
-    fprintf(stderr,"teac_Send: I don't know this buffer!\n");
-    return 0;
-  }
-
-  /* Reality check: did they write too much into the message? */
-  if (buf->validSize > buf->totSize) {
-    fprintf(stderr,"teac_Send: message too large! (%ld vs %ld)\n",
-	    buf->validSize, buf->totSize);
-    abort();
-    return 0;
-  }
-
-  iBuf= buf->bufId;
-  msg = &(tcomm->mbuff[vp][iBuf]);
-  msg->msgnum = tcomm->msgnum++;
-  msg->size = buf->validSize;
-  msg->host = vp;
-  if ( start != NULL )
-	  msg->mptr = teac_main2elan( tcomm->ctx, start );
-  else
-  	msg->mptr = teac_main2elan(tcomm->ctx, buf->buf);
-  msg->clr_event = elan3_sdram2elan(tcomm->ctx, tcomm->ctx->sdram,
-				    tcomm->sbuf_pull_event[iBuf]);
-  msg->new= 1;
-  
-  /* Set up the parts of the DMA that are not specific to destination */
-  tcomm->dma->dma_type = E3_DMA_TYPE(DMA_BYTE,DMA_WRITE,DMA_NORMAL,0);
-  tcomm->dma->dma_size = sizeof(teacMsg);
-  tcomm->dma->dma_srcEvent = 
-    elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram,tcomm->s_event);
-  tcomm->dma->dma_source = teac_main2elan(tcomm->ctx, msg);
-  elan3_primeevent(tcomm->ctx, tcomm->sbuf_pull_event[buf->bufId], num_ids);
-
-  /* Send this message off to each destination */
-  for (iDest=0; iDest<num_ids; iDest++) {
-    tcomm->dma->dma_srcCookieVProc = 
-      elan3_local_cookie(tcomm->ctx, vp, ids[iDest]);
-    tcomm->dma->dma_destCookieVProc = ids[iDest];
-    tcomm->dma->dma_destEvent = 
-      elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram,
-		       tcomm->r_event[vp][iBuf])
-      + sdramAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost] 
-      - sdramAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost];
-    tcomm->dma->dma_dest = teac_main2elan(tcomm->ctx, msg)
-      + elanAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost] 
-      - elanAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost];
-    elan3_primeevent(tcomm->ctx, tcomm->s_event, 1);
-    *(tcomm->m_snd)= 0;
-    elan3_putdma_main(tcomm->ctx, tcomm->dma, tcomm->e_dma);
-#if 0
-    crDebug("DMA dest event %x, dest mem %lx\n",
-	    tcomm->dma->dma_destEvent, 
-	    (long)tcomm->dma->dma_dest);
-    crDebug("Mem shifts are %x %x based on %d %d\n",
-	    elanAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost],
-	    elanAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost],
-	    ids[iDest],vp);
-    crDebug("Send msg %d in buffer %d to %d (list index %d)...",
-	    msg->msgnum,iBuf, ids[iDest],iDest);
-#endif
-    elan3_waitevent_word(tcomm->ctx,
-			 tcomm->s_event, tcomm->m_snd, ELAN_WAIT_EVENT);
-#if 0
-    crDebug("message away!\n");
-#endif
-  }
-  return 1;
-}
-
-RBuffer* teac_Recv(Tcomm* tcomm, int id)
-{
-  int	vp = tcomm->vp;
-  RBuffer* result= NULL;
-  int iEvent= 0;
-  int iBuf= 0;
-  int i;
-  int lowestMsgnum;
-  
-  /* poll until we get an incoming message from the given sender */
-  while (1) {
-    if (elan3_pollevent_word(tcomm->ctx, &(tcomm->m_rcv[id][iEvent]), 1)) 
-      break;
-    if (++iEvent == NUM_SEND_BUFFERS) iEvent= 0;
-  }
-
-  /* This may not be the earliest event, however. */
-  lowestMsgnum= -1;
-  for (i=0; i<NUM_SEND_BUFFERS; i++) {
-#if 0
-    crDebug("Testing for new msg at %lx -> %lx\n",
-	    (long)&(tcomm->mbuff[id][i]), 
-	    (long)teac_main2elan(tcomm->ctx,(void*)(&tcomm->mbuff[id][i])));
-#endif
-    if (tcomm->mbuff[id][i].new) {
-      if ((lowestMsgnum < 0) 
-	  || (tcomm->mbuff[id][i].msgnum < (E3_uint32)lowestMsgnum)) {
-	lowestMsgnum= tcomm->mbuff[id][i].msgnum;
-	iBuf= i;
-      }
-    }
-  }
-  if (lowestMsgnum<0) {
-    fprintf(stderr,
-	    "teac_Recv: internal error: can't find message I just got!\n");
-    return NULL;
-  }
-  tcomm->mbuff[id][iBuf].new= 0; 
-  tcomm->m_rcv[id][iBuf]= 0;
-  elan3_primeevent(tcomm->ctx, tcomm->r_event[id][iBuf],1);
-#if 0
-  crDebug("got msg %d in buffer %d from %d!\n",
-	  tcomm->mbuff[id][iBuf].msgnum, iBuf, id);
-#endif
-
-  /* Make some space to put the message when it arrives */
-  if (!(result= (RBuffer*)crAlloc(sizeof(RBuffer)))) {
-    fprintf(stderr,"teac_Recv: unable to allocate %d bytes!\n",
-	    sizeof(RBuffer));
-    return NULL;
-  }
-#if 0
-  if (!(result->buf= (void*)elan3_allocMain(tcomm->ctx, 8,E_BUFFER_SIZE))) {
-    perror("teac_Recv: elan3_allocMain failed for buffer");
-    return(NULL);
-  }
-  result->totSize= E_BUFFER_SIZE;
-#endif
-  if (!(result->buf= (void*)elan3_allocMain(tcomm->ctx, 8, 
-					    tcomm->mbuff[id][iBuf].size))) {
-    perror("teac_Recv: elan3_allocMain failed for buffer");
-    return(NULL);
-  }
-  result->totSize= tcomm->mbuff[id][iBuf].size;
-  tcomm->totalRecvBufferBytesAllocated+= result->totSize;
-  result->validSize= tcomm->mbuff[id][iBuf].size;
-  result->from= tcomm->mbuff[id][iBuf].host;
-  result->senderMsgnum= tcomm->mbuff[id][iBuf].msgnum;
-		
-  /* Set up the DMA to pull the message */
-  tcomm->dma->dma_type = E3_DMA_TYPE(DMA_BYTE,DMA_READ,DMA_NORMAL,0);
-  tcomm->dma->dma_size = tcomm->mbuff[id][iBuf].size;
-  tcomm->dma->dma_source = tcomm->mbuff[id][iBuf].mptr;
-  tcomm->dma->dma_dest = teac_main2elan(tcomm->ctx,result->buf);
-  tcomm->dma->dma_srcCookieVProc = 
-    elan3_remote_cookie(tcomm->ctx, vp, tcomm->mbuff[id][iBuf].host);
-  tcomm->dma->dma_destCookieVProc = 
-    elan3_local_cookie(tcomm->ctx, vp, tcomm->mbuff[id][iBuf].host);
-  tcomm->dma->dma_srcEvent = tcomm->mbuff[id][iBuf].clr_event; 
-  tcomm->dma->dma_destEvent = 
-    elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram,
-		     tcomm->rbuf_pull_event);
-
-  
-  elan3_primeevent(tcomm->ctx, tcomm->rbuf_pull_event,1);
-  *(tcomm->rbuf_ready)= 0;
-  elan3_getdma_main(tcomm->ctx, tcomm->dma, tcomm->e_dma);
-  elan3_waitevent_word(tcomm->ctx,
-		       tcomm->rbuf_pull_event, 
-		       tcomm->rbuf_ready, ELAN_WAIT_EVENT);
-
-  return(result);
-}
-
-int teac_Dispose( Tcomm* tcomm, RBuffer* buf )
-{
-  tcomm->totalRecvBufferBytesAllocated -= buf->totSize;
-  elan3_free(tcomm->ctx, buf->buf);
-  crFree(buf);
-  return 0;
-}
-
-char* teac_getTcommString(Tcomm *c, char* buf, int buflen)
-{
-  snprintf(buf,buflen-1,
-	   "<vp= %d, host range %d-%d, ctxnum range %d-%d, msg %d>",
-	   c->vp,c->lhost,c->hhost,c->lctx,c->hctx,c->msgnum);
-  buf[buflen-1]= '\0';
-  return buf;
-}
-
-char* teac_getConnString(Tcomm *c, int id, char* buf, int buflen)
-{
-  int rel_rank= id%4;
-  int node= ((id-rel_rank)/4) + c->lhost;
-  snprintf(buf,buflen-1,"vp %d, <%s>:%d",id,
-	   hosts[hostsIndex[node]].name,rel_rank);
-  buf[buflen-1]= '\0';
-#if 0
-  crDebug("getConnString: lookup id %d -> %d %d -> %s\n",id,rel_rank,node,buf);
-#endif
-  return buf;
-}
-
-int teac_getConnId(Tcomm *c, const char* host, int rank)
-{
-  int node= trans_host(host);
-#if 0
-  crDebug("getConnId: <%s> %d %d maps to %d %d\n",
-	  host, rank, c->lhost, node, (4*(node - c->lhost) + (rank%4)));
-#endif
-  return (4*(node - c->lhost) + (rank%4));
-}
-
-int teac_getHostInfo(Tcomm *c, char* host, const int hostLength,
-		     int* railMask, int *nodeId, 
-		     long* sdramBaseAddr, long* elanBaseAddr)
-{
-#if (TEAC_DEVINFO_TYPE == 2)
-  ELAN_DEVINFO info;
-  ELAN_POSITION position;
-#else
-  ELAN3_DEVINFO	info;
-#endif
-  char* here;
-
-  if (gethostname(host,hostLength-1)) {
-    perror("Can't get my own host name");
-    return 0;
-  }
-  host[hostLength-1]= '\0';
-  if ((here= crStrchr(host,'.')) != NULL) *here= '\0';
-
-#if (TEAC_DEVINFO_TYPE == 2)
-  (void)elan3_get_devinfo(c->ctx, &info);
-  (void)elan3_get_position(c->ctx, &position);
-  *nodeId= position.pos_nodeid;
-#elif (TEAC_DEVINFO_TYPE == 1)
-  elan3_devinfo(0, &info);
-  *nodeId= info.Position.NodeId;
-#else
-  elan3_devinfo(0, &info);
-  *nodeId= info.NodeId;
-#endif
-
-#if (TEAC_CAP_TYPE == 2)
-  *railMask= c->cap.cap_railmask;
-#else
-  *railMask= c->cap.RailMask;
-#endif
-
-  *sdramBaseAddr= (int)c->r_event[0][0];
-	  
-  *elanBaseAddr= (long)teac_main2elan(c->ctx,(void*)c->m_rcv[0]);
-  return 1;
-}
Index: unk/src/VBox/GuestHost/OpenGL/util/list.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/list.c	(revision 78189)
+++ 	(revision )
@@ -1,314 +1,0 @@
-#include "cr_list.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-
-#ifndef CR_TESTING_LIST			/* vbox */
-# define CR_TESTING_LIST 0      	/* vbox */
-#endif  				/* vbox */
-#if CR_TESTING_LIST
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#endif
-
-struct CRListIterator {
-	void *element;
-	CRListIterator *prev;
-	CRListIterator *next;
-};
-
-struct CRList {
-	CRListIterator *head;
-	CRListIterator *tail;
-	unsigned size;
-};
-
-CRList *crAllocList( void )
-{
-	CRList *l = crAlloc( sizeof( CRList ) );
-	CRASSERT( l );
-
-	l->head = crAlloc( sizeof( CRListIterator ) );
-	CRASSERT( l->head );
-
-	l->tail = crAlloc( sizeof( CRListIterator ) );
-	CRASSERT( l->tail );
-
-	l->head->prev = NULL;
-	l->head->next = l->tail;
-
-	l->tail->prev = l->head;
-	l->tail->next = NULL;
-
-	l->size = 0;
-
-	return l;
-}
-
-void crFreeList( CRList *l )
-{
-	CRListIterator *t1;
-
-	CRASSERT( l != NULL );
-	t1 = l->head;
-	while ( t1 != NULL )
-	{
-		CRListIterator *t2 = t1;
-		t1 = t1->next;
-		t2->prev = NULL;
-		t2->next = NULL;
-		t2->element = NULL;
-		crFree( t2 );
-	}
-	l->size = 0;
-	crFree( l );
-}
-
-unsigned crListSize( const CRList *l )
-{
-	return l->size;
-}
-
-int crListIsEmpty( const CRList *l )
-{
-	CRASSERT( l != NULL );
-	return l->size == 0;
-}
-
-void crListInsert( CRList *l, CRListIterator *iter, void *elem )
-{
-	CRListIterator *p;
-
-	CRASSERT( l != NULL );
-	CRASSERT( iter != NULL );
-	CRASSERT( iter != l->head );
-
-	p = crAlloc( sizeof( CRListIterator ) );
-	CRASSERT( p != NULL );
-	p->prev = iter->prev;
-	p->next = iter;
-	p->prev->next = p;
-	iter->prev = p;
-
-	p->element = elem;
-	l->size++;
-}
-
-void crListErase( CRList *l, CRListIterator *iter )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( iter != NULL );
-	CRASSERT( iter != l->head );
-	CRASSERT( iter != l->tail );
-	CRASSERT( l->size > 0 );
-
-	iter->next->prev = iter->prev;
-	iter->prev->next = iter->next;
-
-	iter->prev = NULL;
-	iter->next = NULL;
-	iter->element = NULL;
-	crFree( iter );
-
-	l->size--;
-}
-
-void crListClear( CRList *l )
-{
-	CRASSERT( l != NULL );
-	while ( !crListIsEmpty( l ) )
-	{
-		crListPopFront( l );
-	}
-}
-
-void crListPushBack( CRList *l, void *elem )
-{
-	CRASSERT( l != NULL );
-	crListInsert( l, l->tail, elem );
-}
-
-void crListPushFront( CRList *l, void *elem )
-{
-	CRASSERT( l != NULL );
-	crListInsert( l, l->head->next, elem );
-}
-
-void crListPopBack( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->size > 0 );
-	crListErase( l, l->tail->prev );
-}
-
-void crListPopFront( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->size > 0 );
-	crListErase( l, l->head->next );
-}
-
-void *crListFront( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->size > 0 );
-	CRASSERT( l->head != NULL );
-	CRASSERT( l->head->next != NULL );
-	return l->head->next->element;
-}
-
-void *crListBack( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->size > 0 );
-	CRASSERT( l->tail != NULL );
-	CRASSERT( l->tail->prev != NULL );
-	return l->tail->prev->element;
-}
-
-CRListIterator *crListBegin( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->head != NULL );
-	CRASSERT( l->head->next != NULL );
-	return l->head->next;
-}
-
-CRListIterator *crListEnd( CRList *l )
-{
-	CRASSERT( l != NULL );
-	CRASSERT( l->tail != NULL );
-	return l->tail;
-}
-
-CRListIterator *crListNext( CRListIterator *iter )
-{
-	CRASSERT( iter != NULL );
-	CRASSERT( iter->next != NULL );
-	return iter->next;
-}
-
-CRListIterator *crListPrev( CRListIterator *iter )
-{
-	CRASSERT( iter != NULL );
-	CRASSERT( iter->prev != NULL );
-	return iter->prev;
-}
-
-void *crListElement( CRListIterator *iter )
-{
-	CRASSERT( iter != NULL );
-	return iter->element;
-}
-
-CRListIterator *crListFind( CRList *l, void *element, CRListCompareFunc compare )
-{
-	CRListIterator *iter;
-
-	CRASSERT( l != NULL );
-	CRASSERT( compare );
-
-	for ( iter = crListBegin( l ); iter != crListEnd( l ); iter = crListNext( iter ) )
-	{
-		if ( compare( element, iter->element ) == 0 )
-		{
-			return iter;
-		}
-	}
-	return NULL;
-}
-
-void crListApply( CRList *l, CRListApplyFunc apply, void *arg )
-{
-	CRListIterator *iter;
-
-	CRASSERT( l != NULL );
-	for ( iter = crListBegin( l ); iter != crListEnd( l ); iter = crListNext( iter ) )
-	{
-		apply( iter->element, arg );
-	}
-}
-
-#if CR_TESTING_LIST
-
-static void printElement( void *elem, void *arg )
-{
-	char *s = elem;
-	FILE *fp = arg;
-
-	CRASSERT( s != NULL );
-	CRASSERT( fp != NULL );
-	fprintf( fp, "%s ", s );
-}
-
-static void printList( CRList *l )
-{
-	CRASSERT( l != NULL );
-	crListApply( l, printElement, stderr );
-	fprintf( stderr, "\n" );
-}
-
-static int elementCompare( void *a, void *b )
-{
-	return strcmp( a, b );
-}
-
-int main( void )
-{
-	char *names[] = { "a", "b", "c", "d", "e", "f" };
-	CRList *l;
-	CRListIterator *iter;
-	int i, n;
-
-	n = sizeof( names ) / sizeof( names[0] );
-	fprintf( stderr, "n=%d\n", n );
-
-	l = crAllocList(  );
-	for ( i = 0; i < n; ++i )
-	{
-		crListPushBack( l, names[i] );
-	}
-	printList( l );
-
-	crListPushFront( l, "x" );
-	printList( l );
-
-	crListPushBack( l, "y" );
-	printList( l );
-
-	crListPopFront( l );
-	printList( l );
-
-	crListPopBack( l );
-	printList( l );
-
-	iter = crListFind( l, "c", elementCompare );
-	CRASSERT( iter != NULL );
-	crListInsert( l, iter, "z" );
-	printList( l );
-
-	iter = crListFind( l, "d", elementCompare );
-	CRASSERT( iter != NULL );
-	crListErase( l, iter );
-	printList( l );
-
-	crListClear( l );
-	printList( l );
-	fprintf( stderr, "size: %u\n", crListSize( l ) );
-	fprintf( stderr, "is empty: %d\n", crListIsEmpty( l ) );
-
-	crListPushBack( l, "w" );
-	crListPushBack( l, "t" );
-	crListPushBack( l, "c" );
-	printList( l );
-
-	fprintf( stderr, "front: %s\n", ( char * ) crListFront( l ) );
-	fprintf( stderr, "back: %s\n", ( char * ) crListBack( l ) );
-	fprintf( stderr, "size: %u\n", crListSize( l ) );
-	fprintf( stderr, "is empty: %d\n", crListIsEmpty( l ) );
-
-	crFreeList( l );
-	return 0;
-}
-
-#endif /* CR_TESTING_LIST */
Index: unk/src/VBox/GuestHost/OpenGL/util/lowercase.py
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/lowercase.py	(revision 78189)
+++ 	(revision )
@@ -1,27 +1,0 @@
-# Copyright (c) 2001, Stanford University
-# All rights reserved.
-#
-# See the file LICENSE.txt for information on redistributing this software.
-
-import sys,string
-
-stub_common.CopyrightC()
-
-print "char lowercase[256] = {"
-
-NUM_COLS = 8
-
-count = 0
-for num in range(256):
-	if count%NUM_COLS == 0:
-		sys.stdout.write( '\t' )
-	the_char = chr(num);
-	if num != 255:
-		print ("'\%03o'," % ord(string.lower(the_char))),
-	else:
-		print ("'\%03o'" % ord(string.lower(the_char))),
-	count += 1
-	if count%NUM_COLS == 0:
-		print ""
-
-print "};"
Index: /trunk/src/VBox/GuestHost/OpenGL/util/mem.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/mem.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/util/mem.c	(revision 78190)
@@ -8,46 +8,11 @@
 #include "cr_error.h"
 
-#include <stdlib.h>
-#include <memory.h>
-
 #include <iprt/types.h>
 #include <iprt/mem.h>
 
-#if DEBUG_MEM
-#include <stdio.h>
-#define THRESHOLD 100 * 1024
 
-#undef crAlloc
-#undef crCalloc
-
-/* Need these stubs because util.def says we're always exporting crAlloc
- * and crCalloc.
- */
-extern void *crAlloc( unsigned int bytes );
-void *crAlloc( unsigned int bytes )
+DECLEXPORT(void) *crAlloc( unsigned int nbytes )
 {
-   return NULL;
-}
-
-extern void *crCalloc( unsigned int bytes );
-void *crCalloc( unsigned int bytes )
-{
-   return NULL;
-}
-#endif /* DEBUG_MEM */
-
-
-
-#if DEBUG_MEM
-static void *_crAlloc( unsigned int nbytes )
-#else
-DECLEXPORT(void) *crAlloc( unsigned int nbytes )
-#endif
-{
-#ifdef VBOX
 	void *ret = RTMemAlloc( nbytes );
-#else
-	void *ret = malloc( nbytes );
-#endif
 	if (!ret) {
 		crError( "Out of memory trying to allocate %d bytes!", nbytes );
@@ -57,27 +22,7 @@
 }
 
-void *crAllocDebug( unsigned int nbytes, const char *file, int line )
+DECLEXPORT(void) *crCalloc( unsigned int nbytes )
 {
-#if DEBUG_MEM
-	if (nbytes >= THRESHOLD)
-		fprintf(stderr, "crAllocDebug(%d bytes) in %s at %d\n", nbytes, file, line);
-	return _crAlloc(nbytes);
-#else
-	RT_NOREF2(file, line);
-	return crAlloc(nbytes);
-#endif
-}
-
-#if DEBUG_MEM
-static void *_crCalloc( unsigned int nbytes )
-#else
-DECLEXPORT(void) *crCalloc( unsigned int nbytes )
-#endif
-{
-#ifdef VBOX
 	void *ret = RTMemAlloc( nbytes );
-#else
-	void *ret = malloc( nbytes );
-#endif
 	if (!ret) {
 		crError( "Out of memory trying to (c)allocate %d bytes!", nbytes );
@@ -88,33 +33,11 @@
 }
 
-void *crCallocDebug( unsigned int nbytes, const char *file, int line )
-{
-#if DEBUG_MEM
-	if (nbytes >= THRESHOLD)
-		fprintf(stderr, "crCallocDebug(%d bytes) in %s at %d\n", nbytes, file, line);
-	return _crCalloc(nbytes);
-#else
-	RT_NOREF2(file, line);
-	return crCalloc(nbytes);
-#endif
-}
-
 DECLEXPORT(void) crRealloc( void **ptr, unsigned int nbytes )
 {
 	if ( *ptr == NULL )
-	{
-#if DEBUG_MEM
-		*ptr = _crAlloc( nbytes );
-#else
 		*ptr = crAlloc( nbytes );
-#endif
-	}
 	else
 	{
-#ifdef VBOX
 		*ptr = RTMemRealloc( *ptr, nbytes );
-#else
-		*ptr = realloc( *ptr, nbytes );
-#endif
 		if (*ptr == NULL)
 			crError( "Couldn't realloc %d bytes!", nbytes );
@@ -124,37 +47,5 @@
 DECLEXPORT(void) crFree( void *ptr )
 {
-#ifdef VBOX
 	if (ptr)
 		RTMemFree(ptr);
-#else
-	if (ptr)
-		free(ptr);
-#endif
 }
-
-DECLEXPORT(void) crMemcpy( void *dst, const void *src, unsigned int bytes )
-{
-	CRASSERT(dst || 0==bytes);
-	CRASSERT(src || 0==bytes);
-	(void) memcpy( dst, src, bytes );
-}
-
-DECLEXPORT(void) crMemset( void *ptr, int value, unsigned int bytes )
-{
-	CRASSERT(ptr);
-	memset( ptr, value, bytes );
-}
-
-DECLEXPORT(void) crMemZero( void *ptr, unsigned int bytes )
-{
-	CRASSERT(ptr);
-	memset( ptr, 0, bytes );
-}
-
-DECLEXPORT(int) crMemcmp( const void *p1, const void *p2, unsigned int bytes )
-{
-	CRASSERT(p1);
-	CRASSERT(p2);
-	return memcmp( p1, p2, bytes );
-}
-
Index: /trunk/src/VBox/GuestHost/OpenGL/util/net.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/net.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/util/net.c	(revision 78190)
@@ -22,10 +22,7 @@
 #include "cr_error.h"
 #include "cr_string.h"
-#include "cr_url.h"
 #include "cr_net.h"
 #include "cr_netserver.h"
 #include "cr_pixeldata.h"
-#include "cr_environment.h"
-#include "cr_endian.h"
 #include "cr_bufpool.h"
 #include "cr_threads.h"
@@ -47,12 +44,4 @@
 
     /* Number of connections using each type of interface: */
-    int                  use_tcpip;
-    int                  use_ib;
-    int                  use_file;
-    int                  use_udp;
-    int                  use_gm;
-    int                  use_sdp;
-    int                  use_teac;
-    int                  use_tcscomm;
     int                  use_hgcm;
 
@@ -60,7 +49,6 @@
 
 #ifdef CHROMIUM_THREADSAFE
-    CRmutex          mutex;
-#endif
-    int                  my_rank;  /* Teac/TSComm only */
+    CRmutex              mutex;
+#endif
 } cr_net;
 
@@ -73,5 +61,5 @@
  */
 static void
-InitConnection(CRConnection *conn, const char *protocol, unsigned int mtu
+InitConnection(CRConnection *conn
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
                 , struct VBOXUHGSMI *pHgsmi
@@ -79,101 +67,13 @@
         )
 {
-    if (!crStrcmp(protocol, "devnull"))
-    {
-        crDevnullInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crDevnullConnection(conn);
-    }
-    else if (!crStrcmp(protocol, "file"))
-    {
-        cr_net.use_file++;
-        crFileInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crFileConnection(conn);
-    }
-    else if (!crStrcmp(protocol, "swapfile"))
-    {
-        /* file with byte-swapping */
-        cr_net.use_file++;
-        crFileInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crFileConnection(conn);
-        conn->swap = 1;
-    }
-    else if (!crStrcmp(protocol, "tcpip"))
-    {
-        cr_net.use_tcpip++;
-        crTCPIPInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crTCPIPConnection(conn);
-    }
-    else if (!crStrcmp(protocol, "udptcpip"))
-    {
-        cr_net.use_udp++;
-        crUDPTCPIPInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crUDPTCPIPConnection(conn);
-    }
 #ifdef VBOX_WITH_HGCM
-    else if (!crStrcmp(protocol, "vboxhgcm"))
-    {
-        cr_net.use_hgcm++;
-        crVBoxHGCMInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crVBoxHGCMConnection(conn
-#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
-                    , pHgsmi
-#endif
-                );
-    }
-#endif
-#ifdef GM_SUPPORT
-    else if (!crStrcmp(protocol, "gm"))
-    {
-        cr_net.use_gm++;
-        crGmInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crGmConnection(conn);
-    }
-#endif
-#ifdef TEAC_SUPPORT
-    else if (!crStrcmp(protocol, "quadrics"))
-    {
-        cr_net.use_teac++;
-        crTeacInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crTeacConnection(conn);
-    }
-#endif
-#ifdef TCSCOMM_SUPPORT
-    else if (!crStrcmp(protocol, "quadrics-tcscomm"))
-    {
-        cr_net.use_tcscomm++;
-        crTcscommInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crTcscommConnection(conn);
-    }
-#endif
-#ifdef SDP_SUPPORT
-    else if (!crStrcmp(protocol, "sdp"))
-    {
-        cr_net.use_sdp++;
-        crSDPInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crSDPConnection(conn);
-    }
-#endif
-#ifdef IB_SUPPORT
-    else if (!crStrcmp(protocol, "ib"))
-    {
-        cr_net.use_ib++;
-        crDebug("Calling crIBInit()");
-        crIBInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crIBConnection(conn);
-        crDebug("Done Calling crIBInit()");
-    }
-#endif
-#ifdef HP_MULTICAST_SUPPORT
-    else if (!crStrcmp(protocol, "hpmc"))
-    {
-        cr_net.use_hpmc++;
-        crHPMCInit(cr_net.recv_list, cr_net.close_list, mtu);
-        crHPMCConnection(conn);
-    }
-#endif
-    else
-    {
-        crError("Unknown protocol: \"%s\"", protocol);
-    }
+    cr_net.use_hgcm++;
+    crVBoxHGCMInit(cr_net.recv_list, cr_net.close_list);
+    crVBoxHGCMConnection(conn
+#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
+                         , pHgsmi
+#endif
+                         );
+#endif
 }
 
@@ -192,5 +92,5 @@
  *                the mothership
  */
-CRConnection * crNetConnectToServer( const char *server, unsigned short default_port, int mtu, int broker
+CRConnection * crNetConnectToServer( const char *server, int mtu, int broker
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
                 , struct VBOXUHGSMI *pHgsmi
@@ -198,10 +98,8 @@
 )
 {
-    char hostname[4096], protocol[4096];
-    unsigned short port;
     CRConnection *conn;
 
-    crDebug( "In crNetConnectToServer( \"%s\", port=%d, mtu=%d, broker=%d )",
-                     server, default_port, mtu, broker );
+    crDebug( "In crNetConnectToServer( \"%s\", mtu=%d, broker=%d )",
+                     server, mtu, broker );
 
     CRASSERT( cr_net.initialized );
@@ -212,47 +110,4 @@
                          "but the minimum MTU is %d", server, mtu, CR_MINIMUM_MTU );
     }
-
-    /* Tear the URL apart into relevant portions. */
-    if ( !crParseURL( server, protocol, hostname, &port, default_port ) ) {
-         crError( "Malformed URL: \"%s\"", server );
-    }
-
-    /* If the host name is "localhost" replace it with the _real_ name
-     * of the localhost.  If we don't do this, there seems to be
-     * confusion in the mothership as to whether or not "localhost" and
-     * "foo.bar.com" are the same machine.
-     */
-    if (crStrcmp(hostname, "localhost") == 0) {
-        int rv = crGetHostname(hostname, 4096);
-        CRASSERT(rv == 0);
-        (void) rv;
-    }
-
-    /* XXX why is this here???  I think it could be moved into the
-     * crTeacConnection() function with no problem. I.e. change the
-     * connection's port, teac_rank and tcscomm_rank there.  (BrianP)
-     */
-    if ( !crStrcmp( protocol, "quadrics" ) ||
-         !crStrcmp( protocol, "quadrics-tcscomm" ) ) {
-      /* For Quadrics protocols, treat "port" as "rank" */
-      if ( port > CR_QUADRICS_HIGHEST_RANK ) {
-        crWarning( "Invalid crserver rank, %d, defaulting to %d\n",
-               port, CR_QUADRICS_LOWEST_RANK );
-        port = CR_QUADRICS_LOWEST_RANK;
-      }
-    }
-    crDebug( "Connecting to %s on port %d, with protocol %s",
-                     hostname, port, protocol );
-
-#ifdef SDP_SUPPORT
-    /* This makes me ill, but we need to "fix" the hostname for sdp. MCH */
-    if (!crStrcmp(protocol, "sdp")) {
-        char* temp;
-        temp = strtok(hostname, ".");
-        crStrcat(temp, crGetSDPHostnameSuffix());
-        crStrcpy(hostname, temp);
-        crDebug("SDP rename hostname: %s", hostname);    
-    }
-#endif
 
     conn = (CRConnection *) crCalloc( sizeof(*conn) );
@@ -263,22 +118,12 @@
     conn->type               = CR_NO_CONNECTION; /* we don't know yet */
     conn->recv_credits       = CR_INITIAL_RECV_CREDITS;
-    conn->hostname           = crStrdup( hostname );
-    conn->port               = port;
     conn->mtu                = mtu;
     conn->buffer_size        = mtu;
     conn->broker             = broker;
-    conn->endianness         = crDetermineEndianness();
-    /* XXX why are these here??? Move them into the crTeacConnection()
-     * and crTcscommConnection() functions.
-     */
-    conn->teac_id            = -1;
-    conn->teac_rank          = port;
-    conn->tcscomm_id         = -1;
-    conn->tcscomm_rank       = port;
 
     crInitMessageList(&conn->messageList);
 
     /* now, just dispatch to the appropriate protocol's initialization functions. */
-    InitConnection(conn, protocol, mtu
+    InitConnection(conn
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
                 , pHgsmi
@@ -311,18 +156,4 @@
 )
 {
-    /*
-    unsigned int len = sizeof(CRMessageNewClient);
-    CRMessageNewClient msg;
-
-    CRASSERT( conn );
-
-    if (conn->swap)
-        msg.header.type = (CRMessageType) SWAP32(CR_MESSAGE_NEWCLIENT);
-    else
-        msg.header.type = CR_MESSAGE_NEWCLIENT;
-
-    crNetSend( conn, NULL, &msg, len );
-    */
-
     crNetServerConnect( ns
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
@@ -349,4 +180,5 @@
     CRConnection *conn;
 
+    RT_NOREF(hostname);
     CRASSERT( cr_net.initialized );
 
@@ -358,13 +190,7 @@
     conn->type               = CR_NO_CONNECTION; /* we don't know yet */
     conn->recv_credits       = CR_INITIAL_RECV_CREDITS;
-    conn->port               = port;
     conn->mtu                = mtu;
     conn->buffer_size        = mtu;
     conn->broker             = broker;
-    conn->endianness         = crDetermineEndianness();
-    conn->teac_id            = -1;
-    conn->teac_rank          = -1;
-    conn->tcscomm_id         = -1;
-    conn->tcscomm_rank       = -1;
 
     crInitMessageList(&conn->messageList);
@@ -374,35 +200,12 @@
                     protocol, (int) port, (int) mtu);
 
-    /* special case */
-    if ( !crStrncmp( protocol, "file", crStrlen( "file" ) ) ||
-             !crStrncmp( protocol, "swapfile", crStrlen( "swapfile" ) ) )
-    {
-        char filename[4096];
-    char protocol_only[4096];
-
-        cr_net.use_file++;
-        if (!crParseURL(protocol, protocol_only, filename, NULL, 0))
-        {
-            crError( "Malformed URL: \"%s\"", protocol );
-        }
-        conn->hostname = crStrdup( filename );
-
-    /* call the protocol-specific init routines */  /* ktd (add) */
-    InitConnection(conn, protocol_only, mtu
+    /* call the protocol-specific init routines */
+      InitConnection(conn
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
                 , NULL
 #endif
-            );       /* ktd (add) */
-    }
-    else {
-    /* call the protocol-specific init routines */
-      InitConnection(conn, protocol, mtu
-#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
-                , NULL
-#endif
               );
-    }
-
-    crNetAccept( conn, hostname, port );
+
+    crNetAccept(conn);
     return conn;
 }
@@ -416,5 +219,4 @@
 {
     conn->Disconnect(conn);
-    crFree( conn->hostname );
     #ifdef CHROMIUM_THREADSAFE
         crFreeMutex( &conn->messageList.lock );
@@ -440,22 +242,4 @@
     else
     {
-#ifdef WINDOWS
-        /** @todo do we actually need that WSA stuff with VBox at all? */
-        WORD wVersionRequested = MAKEWORD(2, 0);
-        WSADATA wsaData;
-        int err;
-
-        err = WSAStartup(wVersionRequested, &wsaData);
-        if (err != 0)
-            crError("Couldn't initialize sockets on WINDOWS");
-#endif
-
-        cr_net.use_gm      = 0;
-        cr_net.use_udp     = 0;
-        cr_net.use_tcpip   = 0;
-        cr_net.use_sdp     = 0;
-        cr_net.use_tcscomm = 0;
-        cr_net.use_teac    = 0;
-        cr_net.use_file    = 0;
         cr_net.use_hgcm    = 0;
         cr_net.num_clients = 0;
@@ -555,27 +339,6 @@
     CRConnection **c;
 
-    c = crTCPIPDump( num );
-    if ( c ) return c;
-
-    c = crDevnullDump( num );
-    if ( c ) return c;
-
-    c = crFileDump( num );
-    if ( c ) return c;
-
 #ifdef VBOX_WITH_HGCM
     c = crVBoxHGCMDump( num );
-    if ( c ) return c;
-#endif
-#ifdef GM_SUPPORT
-    c = crGmDump( num );
-    if ( c ) return c;
-#endif
-#ifdef IB_SUPPORT
-    c = crIBDump( num );
-    if ( c ) return c;
-#endif
-#ifdef SDP_SUPPORT
-    c = crSDPDump( num );
     if ( c ) return c;
 #endif
@@ -866,5 +629,5 @@
 )
 {
-    ns->conn = crNetConnectToServer( ns->name, DEFAULT_SERVER_PORT,
+    ns->conn = crNetConnectToServer( ns->name,
                                      ns->buffer_size, 0
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
@@ -890,5 +653,4 @@
 {
     conn->Disconnect( conn );
-    crFree( conn->hostname );
 #ifdef CHROMIUM_THREADSAFE
     crFreeMutex( &conn->messageList.lock );
@@ -902,7 +664,7 @@
  * Apparently, this is only called from the crNetConnectToServer function.
  */
-void crNetAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-    conn->Accept( conn, hostname, port );
+void crNetAccept( CRConnection *conn)
+{
+    conn->Accept( conn);
 }
 
@@ -916,8 +678,6 @@
 void crNetSingleRecv( CRConnection *conn, void *buf, unsigned int len )
 {
-    if (conn->type != CR_TCPIP)
-    {
-        crError( "Can't do a crNetSingleReceive on anything other than TCPIP." );
-    }
+    /** @todo Remove after users have been identified and eliminated .*/
+    crError( "Can't do a crNetSingleReceive on anything other than TCPIP." );
     conn->Recv( conn, buf, len );
 }
@@ -987,5 +747,5 @@
 {
     CRASSERT( len == sizeof(CRMessageFlowControl) );
-    conn->send_credits += (conn->swap ? SWAP32(msg->credits) : msg->credits);
+    conn->send_credits += msg->credits;
     conn->InstantReclaim( conn, (CRMessage *) msg );
 }
@@ -1095,9 +855,4 @@
         case CR_MESSAGE_OPCODES:
         case CR_MESSAGE_OOB:
-            {
-                /*CRMessageOpcodes *ops = (CRMessageOpcodes *) msg;
-                 *unsigned char *data_ptr = (unsigned char *) ops + sizeof( *ops) + ((ops->numOpcodes + 3 ) & ~0x03);
-                 *crDebugOpcodes( stdout, data_ptr-1, ops->numOpcodes ); */
-            }
             break;
         case CR_MESSAGE_READ_PIXELS:
@@ -1251,24 +1006,11 @@
 void crNetReadline( CRConnection *conn, void *buf )
 {
-    char *temp, c;
+    RT_NOREF(buf);
 
     if (!conn || conn->type == CR_NO_CONNECTION)
         return;
 
-    if (conn->type != CR_TCPIP)
-    {
-        crError( "Can't do a crNetReadline on anything other than TCPIP (%d).",conn->type );
-    }
-    temp = (char*)buf;
-    for (;;)
-    {
-        conn->Recv( conn, &c, 1 );
-        if (c == '\n')
-        {
-            *temp = '\0';
-            return;
-        }
-        *(temp++) = c;
-    }
+    /** @todo Remove after users have been found and eliminated. */
+    crError( "Can't do a crNetReadline on anything other than TCPIP (%d).",conn->type );
 }
 
@@ -1301,6 +1043,4 @@
     int found_work = 0;
 
-    if ( cr_net.use_tcpip )
-        found_work += crTCPIPRecv();
 #ifdef VBOX_WITH_HGCM
     if ( cr_net.use_hgcm )
@@ -1311,96 +1051,6 @@
                 );
 #endif
-#ifdef SDP_SUPPORT
-    if ( cr_net.use_sdp )
-        found_work += crSDPRecv();
-#endif
-#ifdef IB_SUPPORT
-    if ( cr_net.use_ib )
-        found_work += crIBRecv();
-#endif
-    if ( cr_net.use_udp )
-        found_work += crUDPTCPIPRecv();
-    
-    if ( cr_net.use_file )
-        found_work += crFileRecv();
-
-#ifdef GM_SUPPORT
-    if ( cr_net.use_gm )
-        found_work += crGmRecv();
-#endif
-
-#ifdef TEAC_SUPPORT
-    if ( cr_net.use_teac )
-        found_work += crTeacRecv();
-#endif
-
-#ifdef TCSCOMM_SUPPORT
-    if ( cr_net.use_tcscomm )
-        found_work += crTcscommRecv();
-#endif
 
     return found_work;
 }
 
-
-/**
- * Teac/TSComm only
- */
-void
-crNetSetRank( int my_rank )
-{
-    cr_net.my_rank = my_rank;
-#ifdef TEAC_SUPPORT
-    crTeacSetRank( cr_net.my_rank );
-#endif
-#ifdef TCSCOMM_SUPPORT
-    crTcscommSetRank( cr_net.my_rank );
-#endif
-}
-
-/**
- * Teac/TSComm only
- */
-void
-crNetSetContextRange( int low_context, int high_context )
-{
-#if !defined(TEAC_SUPPORT) && !defined(TCSCOMM_SUPPORT)
-    (void)low_context; (void)high_context;
-#endif
-#ifdef TEAC_SUPPORT
-    crTeacSetContextRange( low_context, high_context );
-#endif
-#ifdef TCSCOMM_SUPPORT
-    crTcscommSetContextRange( low_context, high_context );
-#endif
-}
-
-/**
- * Teac/TSComm only
- */
-void
-crNetSetNodeRange( const char *low_node, const char *high_node )
-{
-#if !defined(TEAC_SUPPORT) && !defined(TCSCOMM_SUPPORT)
-    (void)low_node; (void)high_node;
-#endif
-#ifdef TEAC_SUPPORT
-    crTeacSetNodeRange( low_node, high_node );
-#endif
-#ifdef TCSCOMM_SUPPORT
-    crTcscommSetNodeRange( low_node, high_node );
-#endif
-}
-
-/**
- * Teac/TSComm only
- */
-void
-crNetSetKey( const unsigned char* key, const int keyLength )
-{
-#ifdef TEAC_SUPPORT
-    crTeacSetKey( key, keyLength );
-#else
-    (void)key; (void)keyLength;
-#endif
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/util/net_internals.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/net_internals.h	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/util/net_internals.h	(revision 78190)
@@ -10,86 +10,8 @@
 
 /*
- * DevNull network interface
- */
-extern void crDevnullInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crDevnullConnection( CRConnection *conn );
-extern int crDevnullRecv( void );
-extern CRConnection** crDevnullDump( int *num );
-
-
-/*
- * File network interface
- */
-extern void crFileInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crFileConnection( CRConnection *conn );
-extern int crFileRecv( void );
-extern CRConnection** crFileDump( int *num );
-
-
-/*
- * TCP/IP network interface
- */
-typedef enum {
-    CRTCPIPMemory,
-    CRTCPIPMemoryBig
-} CRTCPIPBufferKind;
-
-#define CR_TCPIP_BUFFER_MAGIC 0x89134532
-
-typedef struct CRTCPIPBuffer {
-    unsigned int          magic;
-    CRTCPIPBufferKind     kind;
-    unsigned int          len;
-    unsigned int          allocated;
-    unsigned int          pad;  /* may be clobbered by crTCPIPSend() */
-} CRTCPIPBuffer;
-
-typedef struct {
-    int                  initialized;
-    int                  num_conns;
-    CRConnection         **conns;
-    CRBufferPool         *bufpool;
-#ifdef CHROMIUM_THREADSAFE
-    CRmutex              mutex;
-    CRmutex              recvmutex;
-#endif
-    CRNetReceiveFuncList *recv_list;
-    CRNetCloseFuncList *close_list;
-    CRSocket             server_sock;
-} cr_tcpip_data;
-
-extern cr_tcpip_data cr_tcpip;
-
-extern void crTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crTCPIPConnection( CRConnection *conn );
-extern int crTCPIPRecv( void );
-extern CRConnection** crTCPIPDump( int *num );
-extern int crTCPIPDoConnect( CRConnection *conn );
-extern void crTCPIPDoDisconnect( CRConnection *conn );
-extern int crTCPIPErrno( void );
-extern char *crTCPIPErrorString( int err );
-extern void crTCPIPAccept( CRConnection *conn, const char *hostname, unsigned short port );
-extern void crTCPIPWriteExact( CRConnection *conn, const void *buf, unsigned int len );
-extern void crTCPIPFree( CRConnection *conn, void *buf );
-extern void *crTCPIPAlloc( CRConnection *conn );
-extern void crTCPIPReadExact( CRConnection *conn, void *buf, unsigned int len );
-extern int __tcpip_write_exact( CRSocket sock, const void *buf, unsigned int len );
-extern int __tcpip_read_exact( CRSocket sock, void *buf, unsigned int len );
-extern void __tcpip_dead_connection( CRConnection *conn );
-extern int __crSelect( int n, fd_set *readfds, int sec, int usec );
-
-
-/*
- * UDP network interface
- */
-extern void crUDPTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crUDPTCPIPConnection( CRConnection *conn );
-extern int crUDPTCPIPRecv( void );
-
-/*
  * VirtualBox HGCM
  */
 #ifdef VBOX_WITH_HGCM
-extern void crVBoxHGCMInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
+extern void crVBoxHGCMInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl);
 extern void crVBoxHGCMConnection( CRConnection *conn
 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
@@ -111,78 +33,4 @@
 #endif
 
-/*
- * TEAC network interface
- */
-#ifdef TEAC_SUPPORT
-extern void crTeacInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl,
-            unsigned int mtu );
-extern void crTeacConnection( CRConnection *conn );
-extern int crTeacRecv( void );
-extern void crTeacSetRank( int );
-extern void crTeacSetContextRange( int, int );
-extern void crTeacSetNodeRange( const char *, const char * );
-extern void crTeacSetKey( const unsigned char *key, const int keyLength );
-#endif /* TEAC_SUPPORT */
-
-
-/*
- * Tcscomm network interface
- */
-#ifdef TCSCOMM_SUPPORT
-extern void crTcscommInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl,
-                           unsigned int mtu );
-extern void crTcscommConnection( CRConnection *conn );
-extern int crTcscommRecv( void );
-#endif /* TCSCOMM_SUPPORT */
-
-
-/*
- * SDP network interface
- */
-#ifdef SDP_SUPPORT
-extern const char *crGetSDPHostnameSuffix(void);
-extern void crSDPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crSDPConnection( CRConnection *conn );
-extern int crSDPRecv( void );
-extern CRConnection** crSDPDump( int *num );
-#endif /* SDP_SUPPORT */
-
-
-/*
- * Infiniband network interface
- */
-#ifdef IB_SUPPORT
-extern void crIBInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crIBConnection( CRConnection *conn );
-extern int crIBRecv( void );
-extern CRConnection** crIBDump( int *num );
-#endif /* IB_SUPPORT */
-
-
-/*
- * GM network interface
- */
-#ifdef GM_SUPPORT
-extern void crGmInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu );
-extern void crGmConnection( CRConnection *conn );
-extern int crGmRecv( void );
-extern CRConnection** crGmDump( int *num );
-extern int crGmDoConnect( CRConnection *conn );
-extern void crGmDoDisconnect( CRConnection *conn );
-extern int crGmErrno( void );
-extern char *crGmErrorString( int err );
-extern void crGmAccept( CRConnection *conn, const char *hostname, unsigned short port );
-extern void crGmSendExact( CRConnection *conn, const void *buf, unsigned int len );
-extern void crGmFree( CRConnection *conn, void *buf );
-extern void *crGmAlloc( CRConnection *conn );
-extern void crGmReadExact( CRConnection *conn, void *buf, unsigned int len );
-extern void crGmBogusRecv( CRConnection *conn, void *buf, unsigned int len );
-extern void crGmHandleNewMessage( CRConnection *conn, CRMessage *msg, unsigned int len );
-extern void crGmInstantReclaim( CRConnection *conn, CRMessage *msg );
-extern unsigned int crGmNodeId( void );
-extern unsigned int crGmPortNum( void );
-#endif /* GM_SUPPORT */
-
-
 extern CRConnection** crNetDump( int *num );
 
Index: /trunk/src/VBox/GuestHost/OpenGL/util/process.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/process.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/util/process.c	(revision 78190)
@@ -22,86 +22,4 @@
 #define snprintf _snprintf
 #endif
-
-/**
- * Sleep/pause for the given number of seconds.
- */
-void crSleep( unsigned int seconds )
-{
-#ifdef WINDOWS
-  Sleep(seconds*1000); /* milliseconds */
-#else
-  sleep(seconds);
-#endif
-}
-
-/**
- * Sleep/pause for the given number of milliseconds.
- */
-void crMsleep( unsigned int msec )
-{
-#ifdef WINDOWS
-     Sleep(msec); 
-#else
-     usleep(msec*1000); /* usecs */
-#endif
-}
-
-
-/*
- * Spawn (i.e. fork/exec) a new process.
- */
-CRpid crSpawn( const char *command, const char *argv[] )
-{
-#ifdef WINDOWS
-	char newargv[1000];
-	int i;
-	STARTUPINFO si;
-	PROCESS_INFORMATION pi;
-
-	(void) command;
-
-	ZeroMemory( &si, sizeof(si) );
-	si.cb = sizeof(si);
-	ZeroMemory( &pi, sizeof(pi) );
-
-	crStrncpy(newargv, argv[0], 1000 );
-	for (i = 1; argv[i]; i++) {
-		crStrcat(newargv, " ");
-		crStrcat(newargv, argv[i]);
-	}
-
-	if ( !CreateProcess(NULL, newargv, NULL, NULL, FALSE, 0, NULL,
-				NULL, &si, &pi) )
-	{
-		crWarning("crSpawn failed, %d", GetLastError());
-		return 0;
-	}
-	return pi.hProcess;
-#else
-	pid_t pid;
-	if ((pid = fork()) == 0)
-	{
-		/* I'm the child */
-		int err = execvp(command, (char * const *) argv);
-		crWarning("crSpawn failed (return code: %d)", err);
-		return 0;
-	}
-	return (unsigned long) pid;
-#endif
-}
-
-
-/*
- * Kill the named process.
- */
-void crKill( CRpid pid )
-{
-#ifdef WINDOWS
-	TerminateProcess( pid, 0 );
-#else
-	kill((pid_t) pid, SIGKILL);
-#endif
-}
-
 
 /*
@@ -208,19 +126,4 @@
 
 
-/*
- * Return current directory string.
- */
-void crGetCurrentDir( char *dir, int maxLen )
-{
-#ifdef WINDOWS
-  if (!GetCurrentDirectory(maxLen, dir))
-	dir[0] = 0;
-#else
-  if (!getcwd(dir, maxLen))
-	dir[0] = 0;
-#endif
-}
-
-
 /**
  * Return current process ID number.
Index: unk/src/VBox/GuestHost/OpenGL/util/rand.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/rand.c	(revision 78189)
+++ 	(revision )
@@ -1,115 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_rand.h"
-
-#ifdef WINDOWS
-#define WIN32_LEAN_AND_MEAN
-# ifdef VBOX
-#  include <iprt/win/windows.h>
-# else
-#include <windows.h>
-# endif
-#else
-#include <sys/time.h>
-#endif
-
-
-/* Period parameters */
-#define N 624
-#define M 397
-#define MATRIX_A 0x9908b0df   /* constant vector a */
-#define UPPER_MASK 0x80000000 /* most significant w-r bits */
-#define LOWER_MASK 0x7fffffff /* least significant r bits */
-
-/* Tempering parameters */
-#define TEMPERING_MASK_B 0x9d2c5680
-#define TEMPERING_MASK_C 0xefc60000
-#define TEMPERING_SHIFT_U(y)  (y >> 11)
-#define TEMPERING_SHIFT_S(y)  (y << 7)
-#define TEMPERING_SHIFT_T(y)  (y << 15)
-#define TEMPERING_SHIFT_L(y)  (y >> 18)
-
-static unsigned long mt[N]; /* the array for the state vector  */
-static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
-
-void crRandSeed(unsigned long seed)
-{
-	/* setting initial seeds to mt[N] using the generator Line 25 of Table 1
-	   in [KNUTH 1981, The Art of Computer Programming Vol. 2 (2nd Ed.),
-	   pp102
-	*/
-	if (seed == 0)
-		seed = 4357;   /* pick default seed if seed=0 (Guy Zadickario) */
-	mt[0]= seed & 0xffffffff;
-	for (mti=1; mti<N; mti++)
-		mt[mti] = (69069 * mt[mti-1]) & 0xffffffff;
-}
-
-
-/*
- * Seed the generator based on time of day or a system counter.
- */
-void crRandAutoSeed(void)
-{
-#if defined(WINDOWS)
-	LARGE_INTEGER counter;
-	QueryPerformanceCounter( &counter );
-	crRandSeed((unsigned long) counter.QuadPart);
-#else
-	struct timeval timeofday;
-	gettimeofday( &timeofday, 0 );	
-	crRandSeed((unsigned long) timeofday.tv_usec);
-#endif
-}
-
-
-static double genrand( void ) 
-{
-	unsigned long y;
-	static unsigned long mag01[2]={0x0, MATRIX_A};
-	/* mag01[x] = x * MATRIX_A  for x=0,1 */
-
-	if (mti >= N) { /* generate N words at one time */
-		int kk;
-		if (mti == N+1)   /* if sgenrand() has not been called, */
-			crRandSeed(4357); /* a default initial seed is used   */
-
-		for (kk=0;kk<N-M;kk++) {
-			y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
-			mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1];
-		}
-		for (;kk<N-1;kk++) {
-			y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
-			mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1];
-		}
-		y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
-		mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1];
-		mti = 0;
-	}
-
-	y = mt[mti++];
-	y ^= TEMPERING_SHIFT_U(y);
-	y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B;
-	y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C;
-	y ^= TEMPERING_SHIFT_L(y);
-
-	return ( (double)y / (unsigned long)0xffffffff ); /* reals */
-	/* return y; */ /* for integer generation */
-}
-
-float crRandFloat(float min, float max) 
-{
-	double t = genrand();
-	return (float) (t*min + (1-t)*max);
-}
-
-/* return a random integer in [min, max] (inclusive). */
-int crRandInt(int min, int max)
-{
-	double t = genrand();
-	return min + (int) (t * (max - min + 1));
-}
Index: unk/src/VBox/GuestHost/OpenGL/util/sortarray.cpp
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/sortarray.cpp	(revision 78189)
+++ 	(revision )
@@ -1,414 +1,0 @@
-/* $Id$ */
-
-/** @file
- * Sorted array impl
- */
-
-/*
- * Copyright (C) 2014-2019 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#include <cr_sortarray.h>
-#include <cr_error.h>
-#include <iprt/err.h>
-#include <iprt/mem.h>
-
-#include <memory.h>
-
-VBOXSADECL(int) CrSaInit(CR_SORTARRAY *pArray, uint32_t cInitBuffer)
-{
-    pArray->cBufferSize = cInitBuffer;
-    pArray->cSize = 0;
-    if (cInitBuffer)
-    {
-        pArray->pElements = (uint64_t*)RTMemAlloc(cInitBuffer * sizeof (pArray->pElements[0]));
-        if (!pArray->pElements)
-        {
-            WARN(("no memory"));
-            /* sanity */
-            pArray->cBufferSize = 0;
-            return VERR_NO_MEMORY;
-        }
-    }
-    else
-        pArray->pElements = NULL;
-
-    return VINF_SUCCESS;
-}
-
-VBOXSADECL(void) CrSaCleanup(CR_SORTARRAY *pArray)
-{
-    if (pArray->pElements)
-        RTMemFree(pArray->pElements);
-
-    CrSaInit(pArray, 0);
-}
-
-static int crSaSearch(const CR_SORTARRAY *pArray, uint64_t element)
-{
-    int iMin = 0;
-    int iMax = pArray->cSize;
-    int i = 0;
-
-    while (iMin < iMax)
-    {
-        i = (iMax + iMin) / 2;
-
-        uint64_t el = pArray->pElements[i];
-        if (el == element)
-            return i;
-        else if (el < element)
-            iMin = i + 1;
-        else
-            iMax = i;
-    }
-
-    return -1;
-}
-
-static void crSaDbgValidate(const CR_SORTARRAY *pArray)
-{
-    Assert(pArray->cSize <= pArray->cBufferSize);
-    Assert(!pArray->pElements == !pArray->cBufferSize);
-    if (!pArray->cSize)
-        return;
-    uint64_t cur = pArray->pElements[0];
-    for (uint32_t i = 1; i < pArray->cSize; ++i)
-    {
-        Assert(pArray->pElements[i] > cur);
-        cur = pArray->pElements[i];
-    }
-}
-
-#ifdef DEBUG
-# define crSaValidate crSaDbgValidate
-#else
-# define crSaValidate(_a) do {} while (0)
-#endif
-
-static int crSaInsAt(CR_SORTARRAY *pArray, uint32_t iPos, uint64_t element)
-{
-    if (pArray->cSize == pArray->cBufferSize)
-    {
-        uint32_t cNewBufferSize = pArray->cBufferSize + 16;
-        uint64_t *pNew;
-        if (pArray->pElements)
-            pNew = (uint64_t*)RTMemRealloc(pArray->pElements, cNewBufferSize * sizeof (pArray->pElements[0]));
-        else
-            pNew = (uint64_t*)RTMemAlloc(cNewBufferSize * sizeof (pArray->pElements[0]));
-        if (!pNew)
-        {
-            WARN(("no memory"));
-            return VERR_NO_MEMORY;
-        }
-
-        pArray->pElements = pNew;
-        pArray->cBufferSize = cNewBufferSize;
-        crSaValidate(pArray);
-    }
-
-    for (int32_t i = (int32_t)pArray->cSize - 1; i >= (int32_t)iPos; --i)
-    {
-        pArray->pElements[i+1] = pArray->pElements[i];
-    }
-
-    pArray->pElements[iPos] = element;
-    ++pArray->cSize;
-
-    crSaValidate(pArray);
-
-    return VINF_SUCCESS;
-}
-
-static void crSaDelAt(CR_SORTARRAY *pArray, uint32_t iPos)
-{
-    Assert(pArray->cSize > iPos);
-
-    for (uint32_t i = iPos; i < pArray->cSize - 1; ++i)
-    {
-        pArray->pElements[i] = pArray->pElements[i+1];
-    }
-
-    --pArray->cSize;
-}
-
-static int crSaAdd(CR_SORTARRAY *pArray, uint64_t element)
-{
-    int iMin = 0;
-    int iMax = pArray->cSize;
-    int i = 0;
-    uint64_t el;
-
-    if (!iMax)
-        return crSaInsAt(pArray, 0, element);
-
-    el = element; /* Shup up MSC. */
-    while (iMin < iMax)
-    {
-        i = (iMax + iMin) / 2;
-
-        el = pArray->pElements[i];
-        if (el == element)
-            return VINF_ALREADY_INITIALIZED;
-        else if (el < element)
-            iMin = i + 1;
-        else
-            iMax = i;
-    }
-
-    if (el < element)
-        return crSaInsAt(pArray, i+1, element);
-    return crSaInsAt(pArray, i, element);
-}
-
-static int crSaRemove(CR_SORTARRAY *pArray, uint64_t element)
-{
-    int i = crSaSearch(pArray, element);
-    if (i >= 0)
-    {
-        crSaDelAt(pArray, i);
-        return VINF_SUCCESS;
-    }
-    return VINF_ALREADY_INITIALIZED;
-}
-
-/*
- *  * @return true if element is found */
-VBOXSADECL(bool) CrSaContains(const CR_SORTARRAY *pArray, uint64_t element)
-{
-    return crSaSearch(pArray, element) >= 0;
-}
-
-VBOXSADECL(int) CrSaAdd(CR_SORTARRAY *pArray, uint64_t element)
-{
-    return crSaAdd(pArray, element);
-}
-
-VBOXSADECL(int) CrSaRemove(CR_SORTARRAY *pArray, uint64_t element)
-{
-    return crSaRemove(pArray, element);
-}
-
-static int crSaIntersected(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
-{
-    int rc = VINF_SUCCESS;
-    CrSaClear(pResult);
-
-    for (uint32_t i = 0, j = 0; i < pArray1->cSize && j < pArray2->cSize; )
-    {
-        if (pArray1->pElements[i] == pArray2->pElements[j])
-        {
-            rc = CrSaAdd(pResult, pArray1->pElements[i]);
-            if (rc < 0)
-            {
-                WARN(("CrSaAdd failed"));
-                return rc;
-            }
-
-            ++i;
-            ++j;
-        }
-        else if (pArray1->pElements[i] < pArray2->pElements[j])
-        {
-            ++i;
-        }
-        else
-        {
-            ++j;
-        }
-    }
-
-    return VINF_SUCCESS;
-}
-
-static void crSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    for (uint32_t i = 0, j = 0; i < pArray1->cSize && j < pArray2->cSize; )
-    {
-        if (pArray1->pElements[i] == pArray2->pElements[j])
-        {
-            ++i;
-            ++j;
-        }
-        else if (pArray1->pElements[i] < pArray2->pElements[j])
-            crSaDelAt(pArray1, i);
-        else
-            ++j;
-    }
-}
-
-/*
- * @return >= 0 success
- * < 0 - no memory
- *  */
-VBOXSADECL(void) CrSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    crSaIntersect(pArray1, pArray2);
-}
-
-VBOXSADECL(int) CrSaIntersected(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
-{
-    return crSaIntersected(pArray1, pArray2, pResult);
-}
-
-static int crSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
-{
-    int rc = VINF_SUCCESS;
-    CrSaClear(pResult);
-
-    uint32_t i = 0, j = 0;
-    uint32_t cResult = 0;
-    while (i < pArray1->cSize && j < pArray2->cSize)
-    {
-        uint64_t element;
-        if (pArray1->pElements[i] == pArray2->pElements[j])
-        {
-            element = pArray1->pElements[i];
-            ++i;
-            ++j;
-        }
-        else if (pArray1->pElements[i] < pArray2->pElements[j])
-        {
-            element = pArray1->pElements[i];
-            ++i;
-        }
-        else
-        {
-            element = pArray1->pElements[j];
-            ++j;
-        }
-
-        rc = crSaInsAt(pResult, cResult++, element);
-        if (rc < 0)
-        {
-            WARN(("crSaInsAt failed"));
-            return rc;
-        }
-    }
-
-    uint32_t iTail;
-    const CR_SORTARRAY *pTail;
-
-    if (i < pArray1->cSize)
-    {
-        iTail = i;
-        pTail = pArray1;
-    }
-    else if (j < pArray2->cSize)
-    {
-        iTail = j;
-        pTail = pArray2;
-    }
-    else
-    {
-        iTail = 0;
-        pTail = 0;
-    }
-
-    if (pTail)
-    {
-        for (;iTail < pTail->cSize; ++iTail)
-        {
-            rc = crSaInsAt(pResult, cResult++, pTail->pElements[iTail]);
-            if (rc < 0)
-            {
-                WARN(("crSaInsAt failed"));
-                return rc;
-            }
-        }
-    }
-
-    return VINF_SUCCESS;
-}
-
-VBOXSADECL(int) CrSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult)
-{
-    return crSaUnited(pArray1, pArray2, pResult);
-}
-
-static int crSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult)
-{
-    CrSaClear(pResult);
-
-    if (pArray1->cSize > pResult->cBufferSize)
-    {
-        CrSaCleanup(pResult);
-        uint32_t cNewBufferSize = pArray1->cSize;
-        uint64_t *pNew = (uint64_t*)RTMemAlloc(cNewBufferSize * sizeof (pResult->pElements[0]));
-        if (!pNew)
-        {
-            WARN(("no memory"));
-            return VERR_NO_MEMORY;
-        }
-
-        pResult->pElements = pNew;
-        pResult->cBufferSize = cNewBufferSize;
-        crSaValidate(pResult);
-    }
-
-    pResult->cSize = pArray1->cSize;
-    memcpy(pResult->pElements, pArray1->pElements, pArray1->cSize * sizeof (pArray1->pElements[0]));
-    return VINF_SUCCESS;
-}
-
-/*
- * @return VINF_SUCCESS on success
- * VERR_NO_MEMORY - no memory
- *  */
-VBOXSADECL(int) CrSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult)
-{
-    return crSaClone(pArray1, pResult);
-}
-
-static int crSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    int diff = CrSaGetSize(pArray1) - CrSaGetSize(pArray2);
-    if (diff)
-        return diff;
-
-    return memcmp(pArray1->pElements, pArray2->pElements, pArray1->cSize * sizeof (pArray1->pElements[0]));
-}
-
-VBOXSADECL(int) CrSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    return crSaCmp(pArray1, pArray2);
-}
-
-static bool crSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    if (CrSaGetSize(pArray1) < CrSaGetSize(pArray2))
-        return false;
-
-    uint32_t i = 0, j = 0;
-    while (j < pArray2->cSize)
-    {
-        if (i == pArray1->cSize)
-            return false;
-
-        if (pArray1->pElements[i] == pArray2->pElements[j])
-        {
-            ++i;
-            ++j;
-        }
-        else if (pArray1->pElements[i] < pArray2->pElements[j])
-            ++i;
-        else
-            return false;
-    }
-
-    return true;
-}
-
-VBOXSADECL(bool) CrSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2)
-{
-    return crSaCovers(pArray1, pArray2);
-}
-
Index: unk/src/VBox/GuestHost/OpenGL/util/tcpip.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/tcpip.c	(revision 78189)
+++ 	(revision )
@@ -1,1472 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifdef WINDOWS
-#define WIN32_LEAN_AND_MEAN
-# ifdef VBOX
-#  include <iprt/win/winsock2.h>
-# else /* !VBOX */
-#pragma warning( push, 3 )
-#include <winsock2.h>
-#pragma warning( pop )
-#pragma warning( disable : 4514 )
-#pragma warning( disable : 4127 )
-typedef int ssize_t;
-# endif /* !VBOX */
-#else
-#include <sys/types.h>
-#include <sys/wait.h>
-#ifdef OSF1
-typedef int socklen_t;
-#endif
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#endif
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-#ifdef AIX
-#include <strings.h>
-#endif
-
-#ifdef LINUX
-#include <sys/ioctl.h>
-#include <unistd.h>
-#endif
-
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-#include "cr_bufpool.h"
-#include "cr_net.h"
-#include "cr_endian.h"
-#include "cr_threads.h"
-#include "cr_environment.h"
-#include "net_internals.h"
-
-#ifdef ADDRINFO
-#define PF PF_UNSPEC
-#endif
-
-#ifdef WINDOWS
-# undef EADDRINUSE
-#define EADDRINUSE   WSAEADDRINUSE
-# undef ECONNREFUSED
-#define ECONNREFUSED WSAECONNREFUSED
-#endif
-
-#ifdef WINDOWS
-
-#undef  ECONNRESET
-#define ECONNRESET  WSAECONNRESET
-#undef  EINTR
-#define EINTR       WSAEINTR
-
-int crTCPIPErrno( void )
-{
-    return WSAGetLastError( );
-}
-
-char *crTCPIPErrorString( int err )
-{
-    static char buf[512], *temp;
-    
-    sprintf( buf, "err=%d", err );
-    
-#define X(x)    crStrcpy(buf,x); break
-
-    switch ( err )
-    {
-        case WSAECONNREFUSED: X( "connection refused" );
-        case WSAECONNRESET:   X( "connection reset" );
-        default:
-            FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                           FORMAT_MESSAGE_FROM_SYSTEM |
-                           FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, err,
-                           MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
-                           (LPTSTR) &temp, 0, NULL );
-            if ( temp )
-            {
-                crStrncpy( buf, temp, sizeof(buf)-1 );
-                buf[sizeof(buf)-1] = 0;
-            }
-    }
-
-#undef X
-
-    temp = buf + crStrlen(buf) - 1;
-    while ( temp > buf && isspace( *temp ) )
-    {
-        *temp = '\0';
-        temp--;
-    }
-
-    return buf;
-}
-
-#else /* WINDOWS */
-
-int crTCPIPErrno( void )
-{
-    int err = errno;
-    errno = 0;
-    return err;
-}
-
-char *crTCPIPErrorString( int err )
-{
-    static char buf[512], *temp;
-    
-    temp = strerror( err );
-    if ( temp )
-    {
-        crStrncpy( buf, temp, sizeof(buf)-1 );
-        buf[sizeof(buf)-1] = 0;
-    }
-    else
-    {
-        sprintf( buf, "err=%d", err );
-    }
-
-    return buf;
-}
-
-#endif /* WINDOWS */
-
-
-/*
- * Socket callbacks.  When a socket is created or destroyed we will
- * call these callback functions.
- * XXX Currently only implemented for TCP/IP.
- * XXX Maybe have lists of callbacks?
- */
-static CRSocketCallbackProc SocketCreateCallback = NULL;
-static CRSocketCallbackProc SocketDestroyCallback = NULL;
-
-void
-crRegisterSocketCallback(int mode, CRSocketCallbackProc proc)
-{
-    if (mode == CR_SOCKET_CREATE) {
-        SocketCreateCallback = proc;
-    }
-    else if (mode == CR_SOCKET_DESTROY) {
-        SocketDestroyCallback = proc;
-    }
-    else {
-        crError("Invalid crRegisterSocketCallbac mode=%d", mode);
-    }
-}
-
-
-
-void crCloseSocket( CRSocket sock )
-{
-    int fail;
-
-    if (sock <= 0)
-        return;
-
-    if (SocketDestroyCallback) {
-        SocketDestroyCallback(CR_SOCKET_DESTROY, sock);
-    }
-
-#ifdef WINDOWS
-    fail = ( closesocket( sock ) != 0 );
-#else
-    shutdown( sock, 2 /* RDWR */ );
-    fail = ( close( sock ) != 0 );
-#endif
-    if ( fail )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "crCloseSocket( sock=%d ): %s",
-                             sock, crTCPIPErrorString( err ) );
-    }
-}
-
-cr_tcpip_data cr_tcpip;
-
-/**
- * Read len bytes from socket, and store in buffer.
- * \return 1 if success, -1 if error, 0 if sender exited.
- */
-int
-__tcpip_read_exact( CRSocket sock, void *buf, unsigned int len )
-{
-    char *dst = (char *) buf;
-    /* 
-     * Shouldn't write to a non-existent socket, ie when 
-     * crTCPIPDoDisconnect has removed it from the pool
-     */
-    if ( sock <= 0 )
-        return 1;
-
-    while ( len > 0 )
-    {
-        const int num_read = recv( sock, dst, (int) len, 0 );
-
-#ifdef WINDOWS_XXXX
-        /* MWE: why is this necessary for windows???  Does it return a
-             "good" value for num_bytes despite having a reset
-             connection? */
-        if ( crTCPIPErrno( ) == ECONNRESET )
-            return -1;
-#endif
-
-        if ( num_read < 0 )
-        {
-            int error = crTCPIPErrno();
-            switch( error )
-            {
-                case EINTR:
-                    crWarning( "__tcpip_read_exact(TCPIP): "
-                            "caught an EINTR, looping for more data" );
-                    continue;
-                case EFAULT:
-                    crWarning( "EFAULT" );
-                    break;
-                case EINVAL:
-                    crWarning( "EINVAL" );
-                    break;
-                default:
-                    break;
-            }
-            crWarning( "Bad bad bad socket error: %s", crTCPIPErrorString( error ) );
-            return -1;
-        }
-
-        if ( num_read == 0 ) 
-        {
-            /* client exited gracefully */
-            return 0;
-        }
-
-        dst += num_read;
-        len -= num_read;
-    }
-
-    return 1;
-}
-
-void
-crTCPIPReadExact( CRConnection *conn, void *buf, unsigned int len )
-{
-    if ( __tcpip_read_exact( conn->tcp_socket, buf, len ) <= 0 )
-    {
-        __tcpip_dead_connection( conn );
-    }
-}
-
-/**
- * Write the given buffer of len bytes on the socket.
- * \return 1 if OK, negative value if error.
- */
-int
-__tcpip_write_exact( CRSocket sock, const void *buf, unsigned int len )
-{
-    const char *src = (const char *) buf;
-
-    /* 
-     * Shouldn't write to a non-existent socket, ie when 
-     * crTCPIPDoDisconnect has removed it from the pool
-     */
-    if ( sock <= 0 )
-        return 1;
-
-    while ( len > 0 )
-    {
-        const int num_written = send( sock, src, len, 0 );
-        if ( num_written <= 0 )
-        {
-            int err;
-          if ( (err = crTCPIPErrno( )) == EINTR )
-          {
-                crWarning("__tcpip_write_exact(TCPIP): caught an EINTR, continuing");
-                continue;
-          }
-          
-          return -err;
-        }
-         
-        len -= num_written;
-        src += num_written;
-    }
-         
-    return 1;
-}
-
-void
-crTCPIPWriteExact( CRConnection *conn, const void *buf, unsigned int len )
-{
-    if ( __tcpip_write_exact( conn->tcp_socket, buf, len) <= 0 )
-    {
-        __tcpip_dead_connection( conn );
-    }
-}
-
-
-/**
- * Make sockets do what we want: 
- * 
- * 1) Change the size of the send/receive buffers to 64K 
- * 2) Turn off Nagle's algorithm
- */
-static void
-spankSocket( CRSocket sock )
-{
-    /* why do we do 1) ? things work much better for me to push the
-     * the buffer size way up -- karl
-     */
-#ifdef LINUX
-    int sndbuf = 1*1024*1024;
-#else
-    int sndbuf = 64*1024;
-#endif  
-
-    int rcvbuf = sndbuf;
-    int so_reuseaddr = 1;
-    int tcp_nodelay = 1;
-
-    if ( setsockopt( sock, SOL_SOCKET, SO_SNDBUF, 
-             (char *) &sndbuf, sizeof(sndbuf) ) )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "setsockopt( SO_SNDBUF=%d ) : %s",
-               sndbuf, crTCPIPErrorString( err ) );
-    }
-    
-    if ( setsockopt( sock, SOL_SOCKET, SO_RCVBUF,
-             (char *) &rcvbuf, sizeof(rcvbuf) ) )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "setsockopt( SO_RCVBUF=%d ) : %s",
-               rcvbuf, crTCPIPErrorString( err ) );
-    }
-    
-    
-    if ( setsockopt( sock, SOL_SOCKET, SO_REUSEADDR,
-             (char *) &so_reuseaddr, sizeof(so_reuseaddr) ) )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "setsockopt( SO_REUSEADDR=%d ) : %s",
-               so_reuseaddr, crTCPIPErrorString( err ) );
-    }
-    
-    if ( setsockopt( sock, IPPROTO_TCP, TCP_NODELAY,
-             (char *) &tcp_nodelay, sizeof(tcp_nodelay) ) )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "setsockopt( TCP_NODELAY=%d )"
-               " : %s", tcp_nodelay, crTCPIPErrorString( err ) );
-    }
-}
-
-
-#if defined( WINDOWS ) || defined( IRIX ) || defined( IRIX64 )
-typedef int socklen_t;
-#endif
-
-
-/**
- * Create a listening socket using the given port.
- * Caller can then pass the socket to accept().
- * If the port is one that's been seen before, we'll reuse/return the
- * previously create socket.
- */
-static int
-CreateListeningSocket(int port)
-{
-    /* XXX should use an unbounded list here instead of parallel arrays... */
-#define MAX_PORTS 100
-    static int ports[MAX_PORTS];
-    static int sockets[MAX_PORTS];
-    static int count = 0;
-    int i, sock = -1;
-
-    /* search to see if we've seen this port before */
-    for (i = 0; i < count; i++) {
-        if (ports[i] == port) {
-            return sockets[i];
-        }
-    }
-
-    /* new port so create new socket */
-    {
-        int err;
-#ifndef ADDRINFO
-        struct sockaddr_in  servaddr;
-#endif
-
-        /* with the new OOB stuff, we can have multiple ports being 
-         * accepted on, so we need to redo the server socket every time.
-         */
-#ifndef ADDRINFO
-        sock = socket( AF_INET, SOCK_STREAM, 0 );
-        if ( sock == -1 )
-        {
-            err = crTCPIPErrno( );
-            crError( "Couldn't create socket: %s", crTCPIPErrorString( err ) );
-        }
-        spankSocket( sock );
-
-        servaddr.sin_family = AF_INET;
-        servaddr.sin_addr.s_addr = INADDR_ANY;
-        servaddr.sin_port = htons( (short) port );
-
-        if ( bind( sock, (struct sockaddr *) &servaddr, sizeof(servaddr) ) )
-        {
-            err = crTCPIPErrno( );
-            crError( "Couldn't bind to socket (port=%d): %s",
-                             port, crTCPIPErrorString( err ) );
-        }
-
-        if ( listen( sock, 100 /* max pending connections */ ) )
-        {
-            err = crTCPIPErrno( );
-            crError( "Couldn't listen on socket: %s", crTCPIPErrorString( err ) );
-        }
-#else
-        char port_s[NI_MAXSERV];
-        struct addrinfo *res,*cur;
-        struct addrinfo hints;
-
-        sprintf(port_s, "%u", (short unsigned) port);
-
-        crMemset(&hints, 0, sizeof(hints));
-        hints.ai_flags = AI_PASSIVE;
-        hints.ai_family = PF;
-        hints.ai_socktype = SOCK_STREAM;
-
-        err = getaddrinfo( NULL, port_s, &hints, &res );
-        if ( err )
-            crError( "Couldn't find local TCP port %s: %s",
-                             port_s, gai_strerror(err) );
-
-        for (cur=res;cur;cur=cur->ai_next)
-        {
-            sock = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol );
-            if ( sock == -1 )
-            {
-                err = crTCPIPErrno( );
-                if (err != EAFNOSUPPORT)
-                    crWarning("Couldn't create socket of family %i: %s, trying another", 
-                                        cur->ai_family, crTCPIPErrorString( err ) );
-                continue;
-            }
-            spankSocket( sock );
-
-            if ( bind( sock, cur->ai_addr, cur->ai_addrlen ) )
-            {
-                err = crTCPIPErrno( );
-                crWarning( "Couldn't bind to socket (port=%d): %s", 
-                       port, crTCPIPErrorString( err ) );
-                crCloseSocket( sock );
-                continue;
-            }
-
-            if ( listen( sock, 100 /* max pending connections */ ) )
-            {
-                err = crTCPIPErrno( );
-                crWarning("Couldn't listen on socket: %s", crTCPIPErrorString(err));
-                crCloseSocket( sock );
-                continue;
-            }
-            break;
-        }
-        freeaddrinfo(res);
-        if (!cur)
-            crError( "Couldn't find/bind local TCP port %s", port_s);
-#endif
-    }
-    
-    /* save the new port/socket */
-    if (count == MAX_PORTS) {
-        crError("Fatal error in tcpip layer: too many listening ports/sockets");
-    }
-    ports[count] = port;
-    sockets[count] = sock;
-    count++;
-
-    return sock;
-}
-
-
-
-
-void
-crTCPIPAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-    int err;
-    socklen_t       addr_length;
-#ifndef ADDRINFO
-    struct hostent      *host;
-    struct in_addr      sin_addr;
-    struct sockaddr     addr;
-#else
-    struct sockaddr_storage addr;
-    char            host[NI_MAXHOST];
-#endif
-    (void)hostname;
-
-    cr_tcpip.server_sock = CreateListeningSocket(port);
-
-    /* If brokered, we'll contact the mothership to broker the network
-     * connection.  We'll send the mothership our hostname, the port and
-     * our endianness and will get in return a connection ID number.
-     */
-    if (conn->broker) {
-        crError("There shouldn't be any brokered connections in VirtualBox");
-    }
-    
-    addr_length =   sizeof( addr );
-    conn->tcp_socket = accept( cr_tcpip.server_sock, (struct sockaddr *) &addr, &addr_length );
-    if (conn->tcp_socket == -1)
-    {
-        err = crTCPIPErrno( );
-        crError( "Couldn't accept client: %s", crTCPIPErrorString( err ) );
-    }
-    
-    if (SocketCreateCallback) {
-        SocketCreateCallback(CR_SOCKET_CREATE, conn->tcp_socket);
-    }
-
-#ifndef ADDRINFO
-    sin_addr = ((struct sockaddr_in *) &addr)->sin_addr;
-    host = gethostbyaddr( (char *) &sin_addr, sizeof( sin_addr), AF_INET );
-    if (host == NULL )
-    {
-        char *temp = inet_ntoa( sin_addr );
-        conn->hostname = crStrdup( temp );
-    }
-#else
-    err = getnameinfo ( (struct sockaddr *) &addr, addr_length,
-                host, sizeof( host),
-                NULL, 0, NI_NAMEREQD);
-    if ( err )
-    {
-        err = getnameinfo ( (struct sockaddr *) &addr, addr_length,
-                    host, sizeof( host),
-                    NULL, 0, NI_NUMERICHOST);
-        if ( err )  /* shouldn't ever happen */
-            conn->hostname = crStrdup("unknown ?!");
-        else
-            conn->hostname = crStrdup( host );
-    }
-#endif
-    else
-    {
-        char *temp;
-#ifndef ADDRINFO
-        conn->hostname = crStrdup( host->h_name );
-#else
-        conn->hostname = crStrdup( host );
-#endif
-
-        temp = conn->hostname;
-        while (*temp && *temp != '.' )
-            temp++;
-        *temp = '\0';
-    }
-
-#ifdef RECV_BAIL_OUT 
-    err = sizeof(unsigned int);
-    if ( getsockopt( conn->tcp_socket, SOL_SOCKET, SO_RCVBUF,
-            (char *) &conn->krecv_buf_size, &err ) )
-    {
-        conn->krecv_buf_size = 0;   
-    }
-#endif
-
-    crDebug( "Accepted connection from \"%s\".", conn->hostname );
-}
-
-
-void *
-crTCPIPAlloc( CRConnection *conn )
-{
-    CRTCPIPBuffer *buf;
-
-#ifdef CHROMIUM_THREADSAFE
-    crLockMutex(&cr_tcpip.mutex);
-#endif
-
-    buf = (CRTCPIPBuffer *) crBufferPoolPop( cr_tcpip.bufpool, conn->buffer_size );
-
-    if ( buf == NULL )
-    {
-        crDebug("Buffer pool %p was empty; allocated new %d byte buffer.", 
-                        cr_tcpip.bufpool,
-                        (unsigned int)sizeof(CRTCPIPBuffer) + conn->buffer_size);
-        buf = (CRTCPIPBuffer *) 
-            crAlloc( sizeof(CRTCPIPBuffer) + conn->buffer_size );
-        buf->magic = CR_TCPIP_BUFFER_MAGIC;
-        buf->kind  = CRTCPIPMemory;
-        buf->pad   = 0;
-        buf->allocated = conn->buffer_size;
-    }
-    
-#ifdef CHROMIUM_THREADSAFE
-    crUnlockMutex(&cr_tcpip.mutex);
-#endif
-
-    return (void *)( buf + 1 );
-}
-
-
-static void
-crTCPIPSingleRecv( CRConnection *conn, void *buf, unsigned int len )
-{
-    crTCPIPReadExact( conn, buf, len );
-}
-
-
-static void
-crTCPIPSend( CRConnection *conn, void **bufp,
-                         const void *start, unsigned int len )
-{
-    if ( !conn || conn->type == CR_NO_CONNECTION )
-        return;
-
-    if (!bufp) {
-        /* We're sending a user-allocated buffer.
-         * Simply write the length & the payload and return.
-         */
-        const int sendable_len = conn->swap ? SWAP32(len) : len;
-        crTCPIPWriteExact( conn, &sendable_len, sizeof(len) );
-        if (conn->type == CR_NO_CONNECTION)
-            return;
-        crTCPIPWriteExact( conn, start, len );
-    }
-    else {
-        /* The region [start .. start + len + 1] lies within a buffer that
-         * was allocated with crTCPIPAlloc() and can be put into the free
-         * buffer pool when we're done sending it.
-         */
-        CRTCPIPBuffer *tcpip_buffer;
-        unsigned int *lenp;
-
-        tcpip_buffer = (CRTCPIPBuffer *)(*bufp) - 1;
-
-        CRASSERT( tcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC );
-
-        /* All of the buffers passed to the send function were allocated
-         * with crTCPIPAlloc(), which includes a header with a 4 byte
-         * pad field, to insure that we always have a place to write
-         * the length field, even when start == *bufp.
-         */
-        lenp = (unsigned int *) start - 1;
-        *lenp = conn->swap ? SWAP32(len) : len;
-
-        crTCPIPWriteExact(conn, lenp, len + sizeof(unsigned int));
-
-        /* Reclaim this pointer for reuse */
-#ifdef CHROMIUM_THREADSAFE
-        crLockMutex(&cr_tcpip.mutex);
-#endif
-        crBufferPoolPush(cr_tcpip.bufpool, tcpip_buffer, tcpip_buffer->allocated);
-#ifdef CHROMIUM_THREADSAFE
-        crUnlockMutex(&cr_tcpip.mutex);
-#endif
-        /* Since the buffer's now in the 'free' buffer pool, the caller can't
-         * use it any more.  Setting bufp to NULL will make sure the caller
-         * doesn't try to re-use the buffer.
-         */
-        *bufp = NULL;
-    }
-}
-
-
-void
-__tcpip_dead_connection( CRConnection *conn )
-{
-    crDebug( "Dead connection (sock=%d, host=%s), removing from pool",
-                   conn->tcp_socket, conn->hostname );
-    /* remove from connection pool */
-    crTCPIPDoDisconnect( conn );
-}
-
-
-int
-__crSelect( int n, fd_set *readfds, int sec, int usec )
-{
-    for ( ; ; ) 
-    { 
-        int err, num_ready;
-
-        if (sec || usec)
-        {
-            /* We re-init everytime for Linux, as it corrupts
-             * the timeout structure, but other OS's
-             * don't have a problem with it.
-             */
-            struct timeval timeout;
-            timeout.tv_sec = sec;
-            timeout.tv_usec = usec;
-            num_ready = select( n, readfds, NULL, NULL, &timeout );
-        } 
-        else
-            num_ready = select( n, readfds, NULL, NULL, NULL );
-
-        if ( num_ready >= 0 )
-        {
-            return num_ready;
-        }
-
-        err = crTCPIPErrno( );
-        if ( err == EINTR )
-        {
-            crWarning( "select interrupted by an unblocked signal, trying again" );
-        }
-        else
-        {
-            crError( "select failed: %s", crTCPIPErrorString( err ) );
-        }
-    }
-}
-
-
-void
-crTCPIPFree( CRConnection *conn, void *buf )
-{
-    CRTCPIPBuffer *tcpip_buffer = (CRTCPIPBuffer *) buf - 1;
-
-    CRASSERT( tcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC );
-    conn->recv_credits += tcpip_buffer->len;
-
-    switch ( tcpip_buffer->kind )
-    {
-        case CRTCPIPMemory:
-#ifdef CHROMIUM_THREADSAFE
-            crLockMutex(&cr_tcpip.mutex);
-#endif
-            if (cr_tcpip.bufpool) {
-                /* pool may have been deallocated just a bit earlier in response
-                 * to a SIGPIPE (Broken Pipe) signal.
-                 */
-                crBufferPoolPush( cr_tcpip.bufpool, tcpip_buffer, tcpip_buffer->allocated );
-            }
-#ifdef CHROMIUM_THREADSAFE
-            crUnlockMutex(&cr_tcpip.mutex);
-#endif
-            break;
-
-        case CRTCPIPMemoryBig:
-            crFree( tcpip_buffer );
-            break;
-
-        default:
-            crError( "Weird buffer kind trying to free in crTCPIPFree: %d", tcpip_buffer->kind );
-    }
-}
-
-
-/**
- * Check if message type is GATHER.  If so, process it specially.
- * \return number of bytes which were consumed
- */ 
-static int
-crTCPIPUserbufRecv(CRConnection *conn, CRMessage *msg)
-{
-    if (msg->header.type == CR_MESSAGE_GATHER) {
-        /* grab the offset and the length */
-        const int len = 2 * sizeof(unsigned int); /* was unsigned long!!!! */
-        unsigned int buf[2];
-
-        if (__tcpip_read_exact(conn->tcp_socket, buf, len) <= 0)
-        {
-            __tcpip_dead_connection( conn );
-        }
-        msg->gather.offset = buf[0];
-        msg->gather.len = buf[1];
-
-        /* read the rest into the userbuf */
-        if (buf[0] + buf[1] > (unsigned int) conn->userbuf_len)
-        {
-            crDebug("userbuf for Gather Message is too small!");
-            return len;
-        }
-
-        if (__tcpip_read_exact(conn->tcp_socket,
-                                                     conn->userbuf + buf[0], buf[1]) <= 0)
-        {
-            __tcpip_dead_connection( conn );
-        }
-        return len + buf[1];
-    }
-    else {
-        return 0;
-    }
-}
-
-
-/**
- * Receive the next message on the given connection.
- * If we're being called by crTCPIPRecv(), we already know there's
- * something to receive.
- */
-static void
-crTCPIPReceiveMessage(CRConnection *conn)
-{
-    CRMessage *msg;
-    CRMessageType cached_type;
-    CRTCPIPBuffer *tcpip_buffer;
-    unsigned int len, total, leftover;
-    const int sock = conn->tcp_socket;
-
-    /* Our gigE board is acting odd. If we recv() an amount
-     * less than what is already in the RECVBUF, performance
-     * goes into the toilet (somewhere around a factor of 3).
-     * This is an ugly hack, but seems to get around whatever
-     * funk is being produced  
-     *
-     * Remember to set your kernel recv buffers to be bigger
-     * than the framebuffer 'chunk' you are sending (see
-     * sysctl -a | grep rmem) , or this will really have no
-     * effect.   --karl 
-     */      
-#ifdef RECV_BAIL_OUT 
-    {
-        int inbuf;
-        (void) recv(sock, &len, sizeof(len), MSG_PEEK);
-        ioctl(conn->tcp_socket, FIONREAD, &inbuf);
-
-        if ((conn->krecv_buf_size > len) && (inbuf < len))
-            return;
-    }
-#endif
-
-    /* this reads the length of the message */
-    if ( __tcpip_read_exact( sock, &len, sizeof(len)) <= 0 )
-    {
-        __tcpip_dead_connection( conn );
-        return;
-    }
-
-    if (conn->swap)
-        len = SWAP32(len);
-
-    CRASSERT( len > 0 );
-
-    if ( len <= conn->buffer_size )
-    {
-        /* put in pre-allocated buffer */
-        tcpip_buffer = (CRTCPIPBuffer *) crTCPIPAlloc( conn ) - 1;
-    }
-    else
-    {
-        /* allocate new buffer */
-        tcpip_buffer = (CRTCPIPBuffer *) crAlloc( sizeof(*tcpip_buffer) + len );
-        tcpip_buffer->magic = CR_TCPIP_BUFFER_MAGIC;
-        tcpip_buffer->kind  = CRTCPIPMemoryBig;
-        tcpip_buffer->pad   = 0;
-    }
-
-    tcpip_buffer->len = len;
-
-    /* if we have set a userbuf, and there is room in it, we probably 
-     * want to stick the message into that, instead of our allocated
-     * buffer.
-     */
-    leftover = 0;
-    total = len;
-    if ((conn->userbuf != NULL)
-            && (conn->userbuf_len >= (int) sizeof(CRMessageHeader)))
-    {
-        leftover = len - sizeof(CRMessageHeader);
-        total = sizeof(CRMessageHeader);
-    }
-
-    if ( __tcpip_read_exact( sock, tcpip_buffer + 1, total) <= 0 )
-    {
-        crWarning( "Bad juju: %d %d on socket 0x%x", tcpip_buffer->allocated,
-                             total, sock );
-        crFree( tcpip_buffer );
-        __tcpip_dead_connection( conn );
-        return;
-    }
-
-    conn->recv_credits -= total;
-    conn->total_bytes_recv +=  total;
-
-    msg = (CRMessage *) (tcpip_buffer + 1);
-    cached_type = msg->header.type;
-    if (conn->swap)
-    {
-        msg->header.type = (CRMessageType) SWAP32( msg->header.type );
-        msg->header.conn_id = (CRMessageType) SWAP32( msg->header.conn_id );
-    }
-    
-    /* if there is still data pending, it should go into the user buffer */
-    if (leftover)
-    {
-        const unsigned int handled = crTCPIPUserbufRecv(conn, msg);
-
-        /* if there is anything left, plop it into the recv_buffer */
-        if (leftover - handled)
-        {
-            if ( __tcpip_read_exact( sock, tcpip_buffer + 1 + total, leftover-handled) <= 0 )
-            {
-                crWarning( "Bad juju: %d %d", tcpip_buffer->allocated, leftover-handled);
-                crFree( tcpip_buffer );
-                __tcpip_dead_connection( conn );
-                return;
-            }
-        }
-
-        conn->recv_credits -= handled;
-        conn->total_bytes_recv +=  handled;
-    }
-
-    crNetDispatchMessage( cr_tcpip.recv_list, conn, msg, len );
-#if 0
-    crLogRead( len );
-#endif
-
-    /* CR_MESSAGE_OPCODES is freed in crserverlib/server_stream.c with crNetFree.
-     * OOB messages are the programmer's problem.  -- Humper 12/17/01
-     */
-    if (cached_type != CR_MESSAGE_OPCODES
-            && cached_type != CR_MESSAGE_OOB
-            && cached_type != CR_MESSAGE_GATHER) 
-    {
-        crTCPIPFree( conn, tcpip_buffer + 1 );
-    }
-}
-
-
-/**
- * Loop over all TCP/IP connections, reading incoming data on those
- * that are ready.
- */
-int
-crTCPIPRecv( void )
-{
-    /* ensure we don't get caught with a new thread connecting */
-    const int num_conns = cr_tcpip.num_conns;
-    int num_ready, max_fd, i;
-    fd_set read_fds;
-    int msock = -1; /* assumed mothership socket */
-#if CRAPPFAKER_SHOULD_DIE
-    int none_left = 1;
-#endif
-
-#ifdef CHROMIUM_THREADSAFE
-    crLockMutex(&cr_tcpip.recvmutex);
-#endif
-
-    /*
-     * Loop over all connections and determine which are TCP/IP connections
-     * that are ready to be read.
-     */
-    max_fd = 0;
-    FD_ZERO( &read_fds );
-    for ( i = 0; i < num_conns; i++ )
-    {
-        CRConnection *conn = cr_tcpip.conns[i];
-        if ( !conn || conn->type == CR_NO_CONNECTION )
-            continue;
-
-#if CRAPPFAKER_SHOULD_DIE
-        none_left = 0;
-#endif
-
-        if ( conn->recv_credits > 0 || conn->type != CR_TCPIP )
-        {
-            /* 
-             * NOTE: may want to always put the FD in the descriptor
-             * set so we'll notice broken connections.  Down in the
-             * loop that iterates over the ready sockets only peek
-             * (MSG_PEEK flag to recv()?) if the connection isn't
-             * enabled. 
-             */
-#if 0 /* not used - see below */
-#ifndef ADDRINFO
-            struct sockaddr s;
-#else
-            struct sockaddr_storage s;
-#endif
-            socklen_t slen;
-#endif
-            fd_set only_fd; /* testing single fd */
-            CRSocket sock = conn->tcp_socket;
-
-            if ( (int) sock + 1 > max_fd )
-                max_fd = (int) sock + 1;
-            FD_SET( sock, &read_fds );
-
-            /* KLUDGE CITY......
-             *
-             * With threads there's a race condition between
-             * TCPIPRecv and TCPIPSingleRecv when new
-             * clients are connecting, thus new mothership
-             * connections are also being established.
-             * This code below is to check that we're not
-             * in a state of accepting the socket without
-             * connecting to it otherwise we fail with
-             * ENOTCONN later. But, this is really a side
-             * effect of this routine catching a motherships
-             * socket connection and reading data that wasn't
-             * really meant for us. It was really meant for
-             * TCPIPSingleRecv. So, if we detect an
-             * in-progress connection we set the msock id
-             * so that we can assume the motherships socket
-             * and skip over them.
-             */
-            
-            FD_ZERO(&only_fd);
-            FD_SET( sock, &only_fd );
-
-#if 0 /* Disabled on Dec 13 2005 by BrianP - seems to cause trouble */
-            slen = sizeof( s );
-            /* Check that the socket is REALLY connected */
-            /* Doesn't this call introduce some inefficiency??? (BP) */
-            if (getpeername(sock, (struct sockaddr *) &s, &slen) < 0) {
-                /* Another kludge.....
-                 * If we disconnect a socket without writing
-                 * anything to it, we end up here. Detect
-                 * the disconnected socket by checking if
-                 * we've ever sent something and then
-                 * disconnect it.
-                 * 
-                 * I think the networking layer needs
-                 * a bit of a re-write.... Alan.
-                 */
-                if (conn->total_bytes_sent > 0) {
-                    crTCPIPDoDisconnect( conn );
-                }
-                FD_CLR(sock, &read_fds);
-                msock = sock;
-            }
-#endif
-            /* 
-             * Nope, that last socket we've just caught in
-             * the connecting phase. We've probably found
-             * a mothership connection here, and we shouldn't
-             * process it 
-             */
-            if ((int)sock == msock+1)
-                FD_CLR(sock, &read_fds);
-        }
-    }
-
-#if CRAPPFAKER_SHOULD_DIE
-    if (none_left) {
-        /*
-         * Caught no more connections.
-         * Review this if we want to try 
-         * restarting crserver's dynamically.
-         */
-#ifdef CHROMIUM_THREADSAFE
-        crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-        crError("No more connections to process, terminating...\n");
-        exit(0); /* shouldn't get here */
-    }
-#endif
-
-    if (!max_fd) {
-#ifdef CHROMIUM_THREADSAFE
-        crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-        return 0;
-    }
-
-    if ( num_conns ) {
-        num_ready = __crSelect( max_fd, &read_fds, 0, 500 );
-    }
-    else {
-        crWarning( "Waiting for first connection..." );
-        num_ready = __crSelect( max_fd, &read_fds, 0, 0 );
-    }
-
-    if ( num_ready == 0 ) {
-#ifdef CHROMIUM_THREADSAFE
-        crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-        return 0;
-    }
-
-    /*
-     * Loop over connections, receive data on the TCP/IP connections that
-     * we determined are ready above.
-     */
-    for ( i = 0; i < num_conns; i++ )
-    {
-        CRConnection *conn = cr_tcpip.conns[i];
-        CRSocket sock;
-
-        if ( !conn || conn->type == CR_NO_CONNECTION )
-            continue;
-
-        /* Added by Samuel Thibault during TCP/IP / UDP code factorization */
-        if ( conn->type != CR_TCPIP )
-            continue;
-
-        sock = conn->tcp_socket;
-        if ( !FD_ISSET( sock, &read_fds ) )
-            continue;
-
-        if (conn->threaded)
-            continue;
-
-        crTCPIPReceiveMessage(conn);
-    }
-
-#ifdef CHROMIUM_THREADSAFE
-    crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-
-    return 1;
-}
-
-
-static void
-crTCPIPHandleNewMessage( CRConnection *conn, CRMessage *msg, unsigned int len )
-{
-    CRTCPIPBuffer *buf = ((CRTCPIPBuffer *) msg) - 1;
-
-    /* build a header so we can delete the message later */
-    buf->magic = CR_TCPIP_BUFFER_MAGIC;
-    buf->kind  = CRTCPIPMemory;
-    buf->len   = len;
-    buf->pad   = 0;
-
-    crNetDispatchMessage( cr_tcpip.recv_list, conn, msg, len );
-}
-
-
-static void
-crTCPIPInstantReclaim( CRConnection *conn, CRMessage *mess )
-{
-    crTCPIPFree( conn, mess );
-}
-
-
-void
-crTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl,
-                         unsigned int mtu )
-{
-    (void) mtu;
-
-    cr_tcpip.recv_list = rfl;
-    cr_tcpip.close_list = cfl;
-    if ( cr_tcpip.initialized )
-    {
-        return;
-    }
-
-    cr_tcpip.initialized = 1;
-
-    cr_tcpip.num_conns = 0;
-    cr_tcpip.conns     = NULL;
-    
-    cr_tcpip.server_sock    = -1;
-
-#ifdef CHROMIUM_THREADSAFE
-    crInitMutex(&cr_tcpip.mutex);
-    crInitMutex(&cr_tcpip.recvmutex);
-#endif
-    cr_tcpip.bufpool = crBufferPoolInit(16);
-}
-
-
-/**
- * The function that actually connects.  This should only be called by clients 
- * Servers have another way to set up the socket.
- */
-int
-crTCPIPDoConnect( CRConnection *conn )
-{
-    int err;
-#ifndef ADDRINFO
-    struct sockaddr_in servaddr;
-    struct hostent *hp;
-    int i;
-
-    conn->tcp_socket = socket( AF_INET, SOCK_STREAM, 0 );
-    if ( conn->tcp_socket < 0 )
-    {
-        int err = crTCPIPErrno( );
-        crWarning( "socket error: %s", crTCPIPErrorString( err ) );
-        cr_tcpip.conns[conn->index] = NULL; /* remove from table */
-        return 0;
-    }
-
-    if (SocketCreateCallback) {
-        SocketCreateCallback(CR_SOCKET_CREATE, conn->tcp_socket);
-    }
-
-    /* Set up the socket the way *we* want. */
-    spankSocket( conn->tcp_socket );
-
-    /* Standard Berkeley sockets mumbo jumbo */
-    hp = gethostbyname( conn->hostname );
-    if ( !hp )
-    {
-        crWarning( "Unknown host: \"%s\"", conn->hostname );
-        cr_tcpip.conns[conn->index] = NULL; /* remove from table */
-        return 0;
-    }
-
-    crMemset( &servaddr, 0, sizeof(servaddr) );
-    servaddr.sin_family = AF_INET;
-    servaddr.sin_port = htons( (short) conn->port );
-
-    crMemcpy((char *) &servaddr.sin_addr, hp->h_addr, sizeof(servaddr.sin_addr));
-#else
-    char port_s[NI_MAXSERV];
-    struct addrinfo *res,*cur;
-    struct addrinfo hints;
-
-    sprintf(port_s, "%u", (short unsigned) conn->port);
-
-    crMemset(&hints, 0, sizeof(hints));
-    hints.ai_family = PF;
-    hints.ai_socktype = SOCK_STREAM;
-
-    err = getaddrinfo( conn->hostname, port_s, &hints, &res);
-    if ( err )
-    {
-        crWarning( "Unknown host: \"%s\": %s", conn->hostname, gai_strerror(err) );
-        cr_tcpip.conns[conn->index] = NULL; /* remove from table */
-        return 0;
-    }
-#endif
-
-    /* If brokered, we'll contact the mothership to broker the network
-     * connection.  We'll send the mothership our hostname, the port and
-     * our endianness and will get in return a connection ID number.
-     */
-    if (conn->broker)
-    {
-        crError("There shouldn't be any brokered connections in VirtualBox");
-    }
-
-#ifndef ADDRINFO
-    for (i=1;i;)
-#else
-    for (cur=res;cur;)
-#endif
-    {
-#ifndef ADDRINFO
-
-#ifdef RECV_BAIL_OUT        
-        err = sizeof(unsigned int);
-        if ( getsockopt( conn->tcp_socket, SOL_SOCKET, SO_RCVBUF,
-                (char *) &conn->krecv_buf_size, &err ) )
-        {
-            conn->krecv_buf_size = 0;   
-        }
-#endif
-        if ( !connect( conn->tcp_socket, (struct sockaddr *) &servaddr,
-                    sizeof(servaddr) ) )
-            return 1;
-#else
-
-        conn->tcp_socket = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol );
-        if ( conn->tcp_socket < 0 )
-        {
-            int err2 = crTCPIPErrno( );
-            if (err2 != EAFNOSUPPORT)
-                crWarning( "socket error: %s, trying another way", crTCPIPErrorString( err2 ) );
-            cur=cur->ai_next;
-            continue;
-        }
-
-        if (SocketCreateCallback) {
-            SocketCreateCallback(CR_SOCKET_CREATE, conn->tcp_socket);
-        }
-
-        err = 1;
-        setsockopt(conn->tcp_socket, SOL_SOCKET, SO_REUSEADDR,  &err, sizeof(int));
-
-        /* Set up the socket the way *we* want. */
-        spankSocket( conn->tcp_socket );
-
-#if RECV_BAIL_OUT       
-        err = sizeof(unsigned int);
-        if ( getsockopt( conn->tcp_socket, SOL_SOCKET, SO_RCVBUF,
-                (char *) &conn->krecv_buf_size, &err ) )
-        {
-            conn->krecv_buf_size = 0;   
-        }
-#endif
-
-        if ( !connect( conn->tcp_socket, cur->ai_addr, cur->ai_addrlen ) ) {
-            freeaddrinfo(res);
-            return 1;
-        }
-#endif
-
-        err = crTCPIPErrno( );
-        if ( err == EADDRINUSE || err == ECONNREFUSED )
-            crWarning( "Connection refused to %s:%d, %s",
-                    conn->hostname, conn->port, crTCPIPErrorString( err ) );
-
-        else if ( err == EINTR )
-        {
-            crWarning( "connection to %s:%d "
-                    "interrupted, trying again", conn->hostname, conn->port );
-            continue;
-        }
-        else
-            crWarning( "Couldn't connect to %s:%d, %s",
-                    conn->hostname, conn->port, crTCPIPErrorString( err ) );
-        crCloseSocket( conn->tcp_socket );
-#ifndef ADDRINFO
-        i=0;
-#else
-        cur=cur->ai_next;
-#endif
-    }
-#ifdef ADDRINFO
-    freeaddrinfo(res);
-    crWarning( "Couldn't find any suitable way to connect to %s", conn->hostname );
-#endif
-    cr_tcpip.conns[conn->index] = NULL; /* remove from table */
-    return 0;
-}
-
-
-/**
- * Disconnect this connection, but don't free(conn).
- */
-void
-crTCPIPDoDisconnect( CRConnection *conn )
-{
-    int num_conns = cr_tcpip.num_conns;
-    int none_left = 1;
-    int i;
-
-    /* If this connection has already been disconnected (e.g.
-     * if the connection has been lost and disabled through
-     * a call to __tcpip_dead_connection(), which will then
-     * call this routine), don't disconnect it again; if we
-     * do, and if a new valid connection appears in the same
-     * slot (conn->index), we'll effectively disable the
-     * valid connection by mistake, leaving us unable to
-     * receive inbound data on that connection.
-     */
-    if (conn->type == CR_NO_CONNECTION) return;
-
-    crCloseSocket( conn->tcp_socket );
-    if (conn->hostname) {
-        crFree(conn->hostname);
-        conn->hostname = NULL;
-    }
-    conn->tcp_socket = 0;
-    conn->type = CR_NO_CONNECTION;
-    cr_tcpip.conns[conn->index] = NULL;
-
-    /* see if any connections remain */
-    for (i = 0; i < num_conns; i++) 
-    {
-        if ( cr_tcpip.conns[i] && cr_tcpip.conns[i]->type != CR_NO_CONNECTION )
-            none_left = 0; /* found a live connection */
-    }
-
-#if 0 /* disabled on 13 Dec 2005 by BrianP - this prevents future client
-             * connections after the last one goes away.
-             */
-    if (none_left && cr_tcpip.server_sock != -1)
-    {
-        crDebug("Closing master socket (probably quitting).");
-        crCloseSocket( cr_tcpip.server_sock );
-        cr_tcpip.server_sock = -1;
-#ifdef CHROMIUM_THREADSAFE
-        crFreeMutex(&cr_tcpip.mutex);
-        crFreeMutex(&cr_tcpip.recvmutex);
-#endif
-        crBufferPoolFree( cr_tcpip.bufpool );
-        cr_tcpip.bufpool = NULL;
-        last_port = 0;
-        cr_tcpip.initialized = 0;
-    }
-#endif
-}
-
-
-/**
- * Initialize a CRConnection for tcp/ip.  This is called via the
- * InitConnection() function (and from the UDP module).
- */
-void
-crTCPIPConnection( CRConnection *conn )
-{
-    int i, found = 0;
-    int n_bytes;
-
-    CRASSERT( cr_tcpip.initialized );
-
-    conn->type = CR_TCPIP;
-    conn->Alloc = crTCPIPAlloc;
-    conn->Send = crTCPIPSend;
-    conn->SendExact = crTCPIPWriteExact;
-    conn->Recv = crTCPIPSingleRecv;
-    conn->RecvMsg = crTCPIPReceiveMessage;
-    conn->Free = crTCPIPFree;
-    conn->Accept = crTCPIPAccept;
-    conn->Connect = crTCPIPDoConnect;
-    conn->Disconnect = crTCPIPDoDisconnect;
-    conn->InstantReclaim = crTCPIPInstantReclaim;
-    conn->HandleNewMessage = crTCPIPHandleNewMessage;
-    conn->index = cr_tcpip.num_conns;
-    conn->sizeof_buffer_header = sizeof( CRTCPIPBuffer );
-    conn->actual_network = 1;
-
-    conn->krecv_buf_size = 0;
-
-    /* Find a free slot */
-    for (i = 0; i < cr_tcpip.num_conns; i++) {
-        if (cr_tcpip.conns[i] == NULL) {
-            conn->index = i;
-            cr_tcpip.conns[i] = conn;
-            found = 1;
-            break;
-        }
-    }
-    
-    /* Realloc connection stack if we couldn't find a free slot */
-    if (found == 0) {
-        n_bytes = ( cr_tcpip.num_conns + 1 ) * sizeof(*cr_tcpip.conns);
-        crRealloc( (void **) &cr_tcpip.conns, n_bytes );
-        cr_tcpip.conns[cr_tcpip.num_conns++] = conn;
-    }
-}
-
-
-int crGetHostname( char *buf, unsigned int len )
-{
-    const char *override;
-    int ret;
-
-    override = crGetenv("CR_HOSTNAME");
-    if (override)
-    {
-        crStrncpy(buf, override, len);
-        ret = 0;    
-    }
-    else
-        ret = gethostname( buf, len );
-    return ret;
-}
-
-
-CRConnection** crTCPIPDump( int *num )
-{
-    *num = cr_tcpip.num_conns;
-
-    return cr_tcpip.conns;
-}
Index: unk/src/VBox/GuestHost/OpenGL/util/timer.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/timer.c	(revision 78189)
+++ 	(revision )
@@ -1,129 +1,0 @@
-
-#ifndef WINDOWS
-#include <stddef.h>
-#include <fcntl.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#if defined( IRIX ) || defined( IRIX64 )
-#include <sys/syssgi.h>
-#endif
-#include <sys/errno.h>
-#include <unistd.h>
-#else
-#define WIN32_LEAN_AND_MEAN
-# ifdef VBOX
-#  include <iprt/win/windows.h>
-# else
-#include <windows.h>
-# endif
-#endif
-
-#include "cr_timer.h"
-#include "cr_mem.h"
-#include "cr_error.h"
-
-static double crTimerGetTime( CRTimer *t )
-{
-#if defined( IRIX ) || defined( IRIX64 )
-	if (t->iotimer_addr64) {
-		volatile iotimer64_t counter_value;
-		counter_value = *(t->iotimer_addr64);
-		return ((double) counter_value * .000000000001) * (double) t->cycleval;
-	}
-	else {
-		volatile iotimer32_t counter_value;
-		counter_value = *(t->iotimer_addr32);
-		return ((double) counter_value * .000000000001) * (double) t->cycleval;
-	}
-#elif defined( WINDOWS )
-	QueryPerformanceCounter( &t->performance_counter );
-	return ((double) t->performance_counter.QuadPart)*t->one_over_frequency;
-#elif defined( Linux ) || defined( FreeBSD ) || defined(DARWIN) || defined(AIX) || defined(SunOS) || defined(OSF1)
-	gettimeofday( &t->timeofday, NULL );	
-	return t->timeofday.tv_sec + t->timeofday.tv_usec / 1000000.0;
-#else
-#error TIMERS
-#endif
-}
-
-CRTimer *crTimerNewTimer( void )
-{
-	CRTimer *t = (CRTimer *) crAlloc( sizeof(*t) );
-#if defined(IRIX) || defined( IRIX64 )
-	__psunsigned_t phys_addr, raddr;
-	int poffmask = getpagesize() - 1;
-	int counterSize = syssgi(SGI_CYCLECNTR_SIZE);
-
-	phys_addr = syssgi(SGI_QUERY_CYCLECNTR, &(t->cycleval));
-	if (phys_addr == ENODEV) {
-		crError( "Sorry, this SGI doesn't support timers." );
-	}
-
-	raddr = phys_addr & ~poffmask;
-	t->fd = open("/dev/mmem", O_RDONLY);
-
-	if (counterSize == 64) {
-		t->iotimer_addr64 =
-			(volatile iotimer64_t *)mmap(0, poffmask, PROT_READ,
-																	 MAP_PRIVATE, t->fd, (off_t)raddr);
-		t->unmapLocation = (void *)t->iotimer_addr64;
-		t->unmapSize = poffmask;
-		t->iotimer_addr64 = (iotimer64_t *)((__psunsigned_t)t->iotimer_addr64 +
-				(phys_addr & poffmask));
-	}
-	else if (counterSize == 32) {
-		t->iotimer_addr32 = (volatile iotimer32_t *)mmap(0, poffmask, PROT_READ,
-				MAP_PRIVATE, t->fd,
-				(off_t)raddr);
-		t->unmapLocation = (void *)t->iotimer_addr32;
-		t->unmapSize = poffmask;
-		t->iotimer_addr32 = (iotimer32_t *)((__psunsigned_t)t->iotimer_addr32 +
-				(phys_addr & poffmask));
-	}
-	else {
-		crError( "Fatal timer init error" );
-	}
-#elif defined( WINDOWS )
-	QueryPerformanceFrequency( &t->performance_frequency );
-	t->one_over_frequency = 1.0/((double)t->performance_frequency.QuadPart);
-#endif
-	t->time0 = t->elapsed = 0;
-	t->running = 0;
-	return t;
-}
-
-void crDestroyTimer( CRTimer *t )
-{
-#if defined( IRIX ) || defined( IRIX64 )
-	close( t->fd );
-#endif
-	crFree( t );
-}
-
-void crStartTimer( CRTimer *t )
-{
-    t->running = 1;
-    t->time0 = crTimerGetTime( t );
-}
-
-void crStopTimer( CRTimer *t )
-{
-    t->running = 0;
-    t->elapsed += crTimerGetTime( t ) - t->time0;
-}
-
-void crResetTimer( CRTimer *t )
-{
-    t->running = 0;
-    t->elapsed = 0;
-}
-
-double crTimerTime( CRTimer *t )
-{
-	if (t->running) {
-		crStopTimer( t );
-		crStartTimer( t );
-	}
-	return t->elapsed;
-}
Index: unk/src/VBox/GuestHost/OpenGL/util/udptcpip.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/udptcpip.c	(revision 78189)
+++ 	(revision )
@@ -1,753 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#ifdef WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#pragma warning( push, 3 )
-#include <winsock2.h>
-#include <ws2tcpip.h> /* for ipv6 */
-#include <time.h>
-#pragma warning( pop )
-#pragma warning( disable : 4514 )
-#pragma warning( disable : 4127 )
-# ifndef VBOX
-typedef int ssize_t;
-# endif
-#define write(a,b,c) send(a,b,c,0)
-#else
-#include <sys/types.h>
-#if defined(OSF1)
-typedef int socklen_t;
-#endif
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#ifdef LINUX
-#define IP_MTU	14
-#endif
-#include <netinet/in.h>
-#if !defined(IRIX) /* ip6.h might not be present on other unix variants either */
-#include <netinet/ip6.h>
-#endif
-#include <netinet/udp.h>
-#ifndef DARWIN
-#include <netinet/tcp.h>
-#endif
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#endif
-
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-#ifdef AIX
-#include <strings.h>
-#endif
-
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-#include "cr_bufpool.h"
-#include "cr_net.h"
-#include "cr_endian.h"
-#include "cr_threads.h"
-#include "net_internals.h"
-
-#ifdef ADDRINFO
-#define PF PF_UNSPEC
-#endif
-
-#ifndef MSG_TRUNC
-#define MSG_TRUNC 0
-#endif
-
-#ifdef IRIX
-/* IRIX defines this token, but appears to be missing the related types
- * and functions.  Turn it off.
- */
-#undef AF_INET6
-#endif
-
-#if defined( WINDOWS ) || defined( IRIX ) || defined( IRIX64 )
-typedef int socklen_t;
-#endif
-
-static void
-crUDPIPWriteExact( CRConnection *conn, const void *buf, unsigned int len )
-{
-	int retval;
-	if ( len > conn->mtu + sizeof(conn->seq) )
-	{
-		crWarning( "crUDPIPWriteExact(%d): too big a packet for mtu %d, dropping !", len, (int)(conn->mtu + sizeof(conn->seq)) );
-		return;
-	}
-	retval = sendto( conn->udp_socket, buf, len, 0,
-		(struct sockaddr *) &(conn->remoteaddr), sizeof(conn->remoteaddr));
-	if ( retval <= 0 )
-	{
-		int err = crTCPIPErrno( );
-		crWarning( "crUDPIPWriteExact(%d): %s", len, crTCPIPErrorString( err ) );
-#ifdef LINUX
-		if ( err == EMSGSIZE )
-		{
-			int opt;
-			socklen_t leno = sizeof(opt);
-			crDebug( "Too big a UDP packet(%d), looking at new MTU...", len );
-			if ( getsockopt( conn->udp_socket, SOL_IP, IP_MTU_DISCOVER, &opt, &leno) == -1)
-			{
-				err = crTCPIPErrno( );
-				crWarning( "Couldn't determine whether PMTU discovery is used : %s", crTCPIPErrorString( err ) );
-				return;
-			}
-			if ( leno != sizeof(opt) )
-			{
-				crWarning( "Unexpected length %d for PMTU_DISCOVERY option length", leno );
-				return;
-			}
-			if ( opt == IP_PMTUDISC_DONT )
-			{
-				crWarning( "Uh, PMTU discovery isn't enabled ?!" );
-				return;
-			}
-			if ( getsockopt( conn->udp_socket, SOL_IP, IP_MTU, &opt, &leno) == -1 )
-			{
-				err = crTCPIPErrno( );
-				crWarning( "Couldn't determine the MTU : %s", crTCPIPErrorString( err ) );
-				return;
-			}
-			if ( leno != sizeof(opt) )
-			{
-				crWarning( "Unexpected length %d for MTU option length", leno );
-				return;
-			}
-			opt -= sizeof(conn->seq) + sizeof(struct udphdr) + sizeof(struct ip6_hdr);
-			if (opt >= (int) conn->mtu)
-			{
-				crWarning( "But MTU discovery is still bigger ! Narrowing it by hand to %d", conn->mtu = (conn->mtu * 2 / 3) & ~0x3 );
-			}
-			else
-			{
-				crDebug( "new MTU is %d", opt );
-				conn->mtu = opt & ~0x3;
-			}
-		}
-#endif
-	}
-}
-
-static void
-crUDPTCPIPAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-	int err;
-	socklen_t		addr_length;
-#ifndef ADDRINFO
-	struct sockaddr		addr;
-	struct sockaddr_in	udpaddr;
-#else
-	struct sockaddr_storage addr;
-	struct addrinfo         *res,*cur;
-	struct addrinfo         hints;
-#endif
-
-	crTCPIPAccept( conn, hostname, port );
-
-#ifndef ADDRINFO
-	conn->udp_socket = socket( AF_INET, SOCK_DGRAM, 0 );
-	if ( conn->udp_socket >= 0 )
-	{
-		memset(&udpaddr, 0, sizeof(udpaddr));
-		udpaddr.sin_family = AF_INET;
-		udpaddr.sin_addr.s_addr = INADDR_ANY;
-		udpaddr.sin_port = htons(0);
-		if ( bind( conn->udp_socket, (struct sockaddr *) &udpaddr, sizeof(udpaddr) ) )
-		{
-			err = crTCPIPErrno( );
-			crWarning( "Couldn't bind socket: %s", crTCPIPErrorString( err ) );
-			crCloseSocket( conn->udp_socket );
-			conn->udp_socket = -1;
-		}
-	}
-#else
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_flags = AI_PASSIVE;
-	hints.ai_family = PF;
-	hints.ai_socktype = SOCK_DGRAM;
-
-	err = getaddrinfo( NULL, "0", &hints, &res);
-	if ( err )
-		crError( "Couldn't find local UDP port: %s", gai_strerror(err));
-
-	conn->udp_socket = -1;
-
-	for (cur=res;cur;cur=cur->ai_next)
-	{
-		conn->udp_socket = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol );
-		if ( conn->udp_socket == -1 )
-		{
-			err = crTCPIPErrno( );
-			if (err != EAFNOSUPPORT)
-				crWarning( "Couldn't create socket of family %i: %s, trying another one", cur->ai_family, crTCPIPErrorString( err ) );
-			continue;
-		}
-		if ( bind( conn->udp_socket, cur->ai_addr, cur->ai_addrlen ) )
-		{
-			err = crTCPIPErrno( );
-			crWarning( "Couldn't bind socket: %s", crTCPIPErrorString( err ) );
-			crCloseSocket( conn->udp_socket );
-			conn->udp_socket = -1;
-			continue;
-		}
-		break;
-
-	}
-	freeaddrinfo(res);
-#endif
-
-	if ( conn->udp_socket < 0 )
-		crError( "Couldn't find local UDP port" );
-	
-	addr_length = sizeof(addr);
-	err = getsockname( conn->udp_socket, (struct sockaddr *) &addr, &addr_length );
-
-	if ( err == -1 )
-		crError( "Couldn't get our local UDP port: %s", crTCPIPErrorString( crTCPIPErrno( ) ) );
-
-	switch (((struct sockaddr *) &addr)->sa_family) {
-	case AF_INET:
-		crTCPIPWriteExact( conn, &((struct sockaddr_in *)&addr)->sin_port,
-				sizeof(((struct sockaddr_in *)&addr)->sin_port));
-		break;
-#ifdef AF_INET6
-	case AF_INET6:
-		crTCPIPWriteExact( conn, &((struct sockaddr_in6 *)&addr)->sin6_port,
-				sizeof(((struct sockaddr_in6 *)&addr)->sin6_port));
-		break;
-#endif
-	default:
-		crError( "Unknown address family: %d", ((struct sockaddr *) &addr)->sa_family);
-	}
-}
-
-
-static unsigned int safelen=0;
-static void crUDPTCPIPSend( CRConnection *conn, void **bufp,
-				const void *start, unsigned int len )
-{
-	static unsigned int safedone=0;
-	CRTCPIPBuffer *udptcpip_buffer;
-	unsigned int      *lenp;
-
-	if ( !conn || conn->type == CR_NO_CONNECTION )
-		return;
-
-	if ( safelen+len > safelen )
-	{
-		safelen+=len;
-		if (safelen-safedone>100000)
-		{
-			safedone=safelen;
-			crDebug( "%dKo safe", safelen/1024 );
-		}
-	}
-
-	conn->seq++;
-	if ( bufp == NULL )
-	{
-		unsigned int len_swap = conn->swap ? SWAP32(len) : len;
-		/* we are doing synchronous sends from user memory, so no need
-		 * to get fancy.  Simply write the length & the payload and
-		 * return. */
-		crTCPIPWriteExact( conn, &len_swap, sizeof(len_swap) );
-		if ( conn->type == CR_NO_CONNECTION ) return;
-		crTCPIPWriteExact( conn, start, len );
-		return;
-	}
-
-	udptcpip_buffer = (CRTCPIPBuffer *)(*bufp) - 1;
-
-	CRASSERT( udptcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC );
-
-	/* All of the buffers passed to the send function were allocated
-	 * with crTCPIPAlloc(), which includes a header with a 4 byte
-	 * length field, to insure that we always have a place to write
-	 * the length field, even when start == *bufp. */
-	lenp = (unsigned int *) start - 1;
-	if (conn->swap)
-	{
-		*lenp = SWAP32(len);
-	}
-	else
-	{
-		*lenp = len;
-	}
-
-	if ( __tcpip_write_exact( conn->tcp_socket, lenp, len + sizeof(*lenp) ) < 0 )
-	{
-		__tcpip_dead_connection( conn );
-	}
-
-	/* reclaim this pointer for reuse and try to keep the client from
-		 accidentally reusing it directly */
-#ifdef CHROMIUM_THREADSAFE
-	crLockMutex(&cr_tcpip.mutex);
-#endif
-	crBufferPoolPush( cr_tcpip.bufpool, udptcpip_buffer, conn->buffer_size );
-	/* Since the buffer's now in the 'free' buffer pool, the caller can't
-	 * use it any more.  Setting bufp to NULL will make sure the caller
-	 * doesn't try to re-use the buffer.
-	 */
-	*bufp = NULL;
-#ifdef CHROMIUM_THREADSAFE
-	crUnlockMutex(&cr_tcpip.mutex);
-#endif
-}
-
-static unsigned int barflen=0;
-static void crUDPTCPIPBarf( CRConnection *conn, void **bufp,
-				const void *start, unsigned int len)
-{
-	static unsigned int barfdone=0;
-	static const unsigned int sizes[]={
-		0,10,50,100,500,1000,5000,10000,UINT_MAX
-	};
-	static unsigned int nbs[sizeof(sizes)/sizeof(int)] = {
-		0, 0, 0,  0,  0,   0,   0,    0,       0
-	};
-	static unsigned int nb;
-	unsigned int      *seqp;
-	CRTCPIPBuffer *udptcpip_buffer;
-	int i;
-
-	if (!bufp) {
-		crDebug("writing safely %d bytes because from user memory",len);
-		crUDPTCPIPSend( conn, bufp, start, len);
-		return;
-	}
-	if (len > conn->mtu) {
-		crDebug("writing safely %d bytes because that is too much for MTU %d", len, conn->mtu);
-		crUDPTCPIPSend( conn, bufp, start, len);
-		return;
-	}
-
-	if ( barflen+len > barflen )
-	{
-		barflen+=len;
-		nb++;
-		for(i=0;;i++)
-			if (len > sizes[i] && len <= sizes[i+1]) {
-				nbs[i]++;
-				break;
-			}
-		if (barflen-barfdone>1<<22) {
-			barfdone=barflen;
-			crDebug( "send traffic: %d%sMo barfed %dKo safe", barflen/(1024*1024), barflen?"":".0", safelen/1024 );
-			if (nb) {
-				for (i=0; i < (int) (sizeof(sizes)/sizeof(int)-1); i++)
-					fprintf(stderr,"%u:%u%s%% ",sizes[i],(nbs[i]*100)/nb,nbs[i]==0?".0":"");
-				fprintf(stderr,"\n");
-			}
-		}
-	}
-
-	udptcpip_buffer = (CRTCPIPBuffer *)(*bufp) - 1;
-
-	CRASSERT( udptcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC );
-
-	seqp = (unsigned int *) start - 1;
-	if (conn->swap)
-	{
-		*seqp = SWAP32(conn->seq);
-	}
-	else
-	{
-		*seqp = conn->seq;
-	}
-	crUDPIPWriteExact( conn, seqp, len + sizeof(*seqp) );
-
-	/* reclaim this pointer for reuse and try to keep the client from
-		 accidentally reusing it directly */
-#ifdef CHROMIUM_THREADSAFE
-	crLockMutex(&cr_tcpip.mutex);
-#endif
-	crBufferPoolPush( cr_tcpip.bufpool, udptcpip_buffer, conn->buffer_size );
-#ifdef CHROMIUM_THREADSAFE
-	crUnlockMutex(&cr_tcpip.mutex);
-#endif
-	*bufp = NULL;
-}
-
-static void
-crUDPTCPIPReceive( CRConnection *conn, CRTCPIPBuffer *buf, int len )
-{
-	CRMessage *msg;
-	CRMessageType cached_type;
-#if 0
-	crLogRead( len );
-#endif
-
-	conn->recv_credits -= len;
-
-	conn->total_bytes_recv +=  len;
-
-	msg = (CRMessage *) (buf + 1);
-	cached_type = msg->header.type;
-	if (conn->swap)
-	{
-		msg->header.type = (CRMessageType) SWAP32( msg->header.type );
-		msg->header.conn_id = (CRMessageType) SWAP32( msg->header.conn_id );
-	}
-
-	crNetDispatchMessage( cr_tcpip.recv_list, conn, msg, len );
-
-	/* CR_MESSAGE_OPCODES is freed in
-	 * crserverlib/server_stream.c 
-	 *
-	 * OOB messages are the programmer's problem.  -- Humper 12/17/01 */
-	if (cached_type != CR_MESSAGE_OPCODES && cached_type != CR_MESSAGE_OOB)
-	{
-		crTCPIPFree( conn, buf + 1 );
-	}
-}
-
-int
-crUDPTCPIPRecv( void )
-{
-	int    num_ready, max_fd;
-	fd_set read_fds;
-	int i;
-	/* ensure we don't get caught with a new thread connecting */
-	int num_conns = cr_tcpip.num_conns;
-
-#ifdef CHROMIUM_THREADSAFE
-	crLockMutex(&cr_tcpip.recvmutex);
-#endif
-
-	max_fd = 0;
-	FD_ZERO( &read_fds );
-	for ( i = 0; i < num_conns; i++ )
-	{
-		CRConnection *conn = cr_tcpip.conns[i];
-		if ( !conn || conn->type == CR_NO_CONNECTION ) continue;
-		if ( conn->recv_credits > 0 || conn->type != CR_UDPTCPIP )
-		{
-			/* 
-			 * NOTE: may want to always put the FD in the descriptor
-               		 * set so we'll notice broken connections.  Down in the
-               		 * loop that iterates over the ready sockets only peek
-               		 * (MSG_PEEK flag to recv()?) if the connection isn't
-               		 * enabled. 
-			 */
-			CRSocket sock = conn->tcp_socket;
-
-			if (conn->type != CR_UDPTCPIP)
-				continue;
-
-			if ( (int) sock + 1 > max_fd )
-				max_fd = (int) sock + 1;
-			FD_SET( sock, &read_fds );
-
-			sock = conn->udp_socket;
-			if ( (int) sock + 1 > max_fd )
-				max_fd = (int) sock + 1;
-			FD_SET( sock, &read_fds );
-		}
-	}
-
-	if (!max_fd) {
-#ifdef CHROMIUM_THREADSAFE
-		crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-		return 0;
-	}
-
-	if ( num_conns )
-	{
-		num_ready = __crSelect( max_fd, &read_fds, 0, 500 );
-	}
-	else
-	{
-		crWarning( "Waiting for first connection..." );
-		num_ready = __crSelect( max_fd, &read_fds, 0, 0 );
-	}
-
-	if ( num_ready == 0 ) {
-#ifdef CHROMIUM_THREADSAFE
-		crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-		return 0;
-	}
-
-	for ( i = 0; i < num_conns; i++ )
-	{
-		CRConnection     *conn = cr_tcpip.conns[i];
-		CRTCPIPBuffer *buf;
-		int len;
-		int sock;
-
-		if ( !conn || conn->type == CR_NO_CONNECTION ) continue;
-
-		if ( conn->type != CR_UDPTCPIP )
-			continue;
-
-		if ( conn->udp_packet ) {
-			unsigned int *seq;
-			buf = conn->udp_packet;
-			seq = (unsigned int *)(buf + 1) - 1;
-			if ( *seq == conn->ack )
-			{
-				crUDPTCPIPReceive( conn, buf,
-						conn->udp_packetlen );
-				conn->udp_packet = NULL;
-				i--;	/* can now read other packets */
-				continue;
-			}
-			if ( *seq - conn->ack > (~(0U)) >> 1 )
-			{
-				crError( "%u is older than %u ?!", *seq, conn->ack );
-				crTCPIPFree( conn, buf + 1 );
-				conn->udp_packet = NULL;
-				i--;	/* can now read other packets */
-				continue;
-			}
-			/* still too early, wait for TCP data */
-		}
-		else if ( FD_ISSET(conn->udp_socket, &read_fds ) )
-		{
-			unsigned int *seq;
-			buf = ((CRTCPIPBuffer *) crTCPIPAlloc( conn )) - 1;
-			seq = ((unsigned int *) (buf + 1)) - 1;
-
-			len = recv( conn->udp_socket, (void *)seq,
-				buf->allocated + sizeof(*seq), MSG_TRUNC );
-
-			CRASSERT( len > 0 );
-			CRASSERT( (unsigned int)len <= buf->allocated + sizeof(*seq) );
-			if ( len < (int) sizeof(*seq) )
-			{
-				crWarning( "too short a UDP packet : %d", len);
-				crTCPIPFree( conn, buf + 1 );
-				continue;
-			}
-
-			buf->len = len;
-
-			if ( *seq == conn->ack)
-			{
-				crUDPTCPIPReceive( conn, buf, len );
-				continue;
-			}
-
-			if ( *seq - conn->ack > (~(0U)) >> 1 )
-			{
-				crWarning( "%u is older than %u, dropping", *seq, conn->ack );
-				crTCPIPFree( conn, buf + 1 );
-				continue;
-			}
-			conn->udp_packet = buf;
-			conn->udp_packetlen = len;
-		}
-
-		sock = conn->tcp_socket;
-		if ( !FD_ISSET( sock, &read_fds ) )
-			continue;
-
-		if ( __tcpip_read_exact( sock, &len, sizeof(len)) <= 0 )
-		{
-			__tcpip_dead_connection( conn );
-			i--;
-			continue;
-		}
-
-		if (conn->swap)
-		{
-			len = SWAP32(len);
-		}
-
-		CRASSERT( len > 0 );
-
-		if ( (unsigned int)len <= conn->buffer_size )
-		{
-			buf = (CRTCPIPBuffer *) crTCPIPAlloc( conn ) - 1;
-		}
-		else
-		{
-			buf = (CRTCPIPBuffer *) 
-				crAlloc( sizeof(*buf) + len );
-			buf->magic = CR_TCPIP_BUFFER_MAGIC;
-			buf->kind  = CRTCPIPMemoryBig;
-			buf->pad   = 0;
-		}
-
-		buf->len = len;
-
-		if ( __tcpip_read_exact( sock, buf + 1, len ) <= 0 )
-		{
-			crWarning( "Bad juju: %d %d", buf->allocated, len );
-			crFree( buf );
-			__tcpip_dead_connection( conn );
-			i--;
-			continue;
-		}
-
-		crUDPTCPIPReceive( conn, buf, len );
-		conn->ack++;
-	}
-
-#ifdef CHROMIUM_THREADSAFE
-	crUnlockMutex(&cr_tcpip.recvmutex);
-#endif
-
-	return 1;
-}
-
-void crUDPTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu )
-{
-	crTCPIPInit( rfl, cfl, mtu );
-}
-
-/* The function that actually connects.  This should only be called by clients 
- * Servers have another way to set up the socket. */
-
-static int crUDPTCPIPDoConnect( CRConnection *conn )
-{
-#ifdef WINDOWS
-	unsigned short port;
-#else
-	in_port_t port;
-#endif
-#ifdef LINUX
-	int opt = IP_PMTUDISC_DO;
-#endif
-#ifndef ADDRINFO
-	struct hostent *hp;
-#else
-	int err;
-	char port_s[NI_MAXSERV];
-	struct addrinfo *res,*cur;
-	struct addrinfo hints;
-#endif
-	
-	/* first connect to its tcp port */
-	if ( !crTCPIPDoConnect( conn ) )
-		return 0;
-
-	/* read its UDP port */
-	crTCPIPReadExact( conn, &port, sizeof( port ) );
-	port = ntohs(port);
-
-	crDebug( "Server's UDP port is %d", port);
-
-	/* and connect to it */
-#ifndef ADDRINFO
-	hp = gethostbyname( conn->hostname );
-	if ( !hp )
-	{
-		crWarning( "Unknown host: \"%s\"", conn->hostname );
-		return 0;
-	}
-	conn->udp_socket = socket( AF_INET, SOCK_DGRAM, 0 );
-	memset(&conn->remoteaddr, 0, sizeof(conn->remoteaddr));
-	conn->remoteaddr.sin_family = AF_INET;
-	conn->remoteaddr.sin_port = htons( (short) port );
-
-	memcpy( (char *) &conn->remoteaddr.sin_addr, hp->h_addr,
-			sizeof(conn->remoteaddr.sin_addr) );
-	if ( conn->udp_socket >= 0 ) {
-		if ( connect( conn->udp_socket, (struct sockaddr *) &conn->remoteaddr,
-					sizeof(conn->remoteaddr) ) == -1 )
-			crWarning( "Couldn't connect UDP socket : %s", crTCPIPErrorString( crTCPIPErrno( ) ) );
-	} else {
-#else
-	sprintf(port_s, "%u", port);
-
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = PF;
-	hints.ai_socktype = SOCK_DGRAM;
-
-	err = getaddrinfo( conn->hostname, port_s, &hints, &res);
-	if ( err )
-	{
-		crWarning( "Unknown host: \"%s\": %s", conn->hostname, gai_strerror(err) );
-		return 0;
-	}
-
-	for (cur=res;cur;)
-	{
-		conn->udp_socket = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol );
-		if ( conn->udp_socket >= 0 )
-		{
-			if ( connect( conn->udp_socket, cur->ai_addr, cur->ai_addrlen ) == -1 )
-				crWarning( "Couldn't connect UDP socket : %s", crTCPIPErrorString( crTCPIPErrno( ) ) );
-			break;
-		}
-		err = crTCPIPErrno( );
-		if (err != EAFNOSUPPORT)
-			crWarning( "socket error: %s, trying another way", crTCPIPErrorString( err ) );
-		cur=cur->ai_next;
-	}
-	if (!cur) {
-		freeaddrinfo(res);
-#endif
-		crWarning( "Couldn't find any suitable way to connect to %s:%d", conn->hostname, port );
-		return 0;
-	}
-
-#ifdef LINUX
-	if ( setsockopt(conn->udp_socket, SOL_IP, IP_MTU_DISCOVER, &opt, sizeof(opt)) == -1 )
-	{
-		err = crTCPIPErrno( );
-		crWarning( "MTU discovery can't be activated : %s", crTCPIPErrorString( err ) );
-	}
-	else
-	{
-		socklen_t len = sizeof(opt);
-		if ( getsockopt(conn->udp_socket, SOL_IP, IP_MTU, &opt, &len) == -1 )
-			crWarning( "MTU couldn't be got : %s", crTCPIPErrorString( crTCPIPErrno ( ) ) );
-		else
-			if ( len != sizeof(opt) )
-				crWarning( "Unexpected length %d for MTU option length", len );
-			else
-			{
-				opt -= sizeof(conn->seq) + sizeof(struct udphdr) + sizeof(struct ip6_hdr);
-				crDebug( "MTU is (for now) %d", opt );
-				conn->mtu = opt;
-			}
-	}
-#endif
-#ifdef ADDRINFO
-	crMemcpy(&conn->remoteaddr, cur->ai_addr, cur->ai_addrlen);
-	freeaddrinfo(res);
-#endif
-	return 1;
-}
-
-static void crUDPTCPIPDoDisconnect( CRConnection *conn )
-{
-	crCloseSocket( conn->udp_socket );
-	crTCPIPDoDisconnect( conn );
-}
-
-void crUDPTCPIPConnection( CRConnection *conn )
-{
-	crTCPIPConnection( conn );
-
-	conn->type  = CR_UDPTCPIP;
-	conn->Send  = crUDPTCPIPSend;
-	conn->Barf  = crUDPTCPIPBarf;
-	conn->SendExact  = NULL;
-	conn->Recv  = NULL;	/* none for UDP : *must* multiplex ! */
-	conn->Accept = crUDPTCPIPAccept;
-	conn->Connect = crUDPTCPIPDoConnect;
-	conn->Disconnect = crUDPTCPIPDoDisconnect;
-	conn->seq   = 0;
-	conn->ack   = 0;
-	conn->udp_packet = NULL;
-	conn->mtu  -= sizeof(conn->seq); /* some room for seq */
-}
Index: unk/src/VBox/GuestHost/OpenGL/util/url.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/url.c	(revision 78189)
+++ 	(revision )
@@ -1,94 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#include "cr_string.h"
-#include "cr_url.h"
-#include "cr_error.h"
-
-static int is_digit_string( const char *s )
-{
-     if (!isdigit( (int) *s))
-	{
-		return 0;
-	}
-
-     while (*s && isdigit ( (int) *s))
-	{
-		s++;
-	}
-
-	return ( *s == 0 );
-}
-
-int crParseURL( const char *url, char *protocol, char *hostname,
-				unsigned short *port, unsigned short default_port )
-{
-	const char *temp, *temp2;
-
-	/* pull off the protocol */
-	temp = crStrstr( url, "://" );
-	if ( temp == NULL && protocol != NULL )
-	{
-		crStrcpy( protocol, "tcpip" );
-		temp = url;
-	}
-	else 
-	{
-		if (protocol != NULL) {
-			int len = temp - url;
-			crStrncpy( protocol, url, len );
-			protocol[len] = 0;
-		}
-		temp += 3;
-	}
-
-	/* handle a trailing :<digits> to specify the port */
-
-	/* there might be a filename here */
-	temp2 = crStrrchr( temp, '/' );
-	if ( temp2 == NULL )
-	{
-		temp2 = crStrrchr( temp, '\\' );
-	}
-	if ( temp2 == NULL )
-	{
-		temp2 = temp;
-	}
-
-	temp2 = crStrrchr( temp2, ':' );
-	if ( temp2 )
-	{
-		if (hostname != NULL) {
-			int len = temp2 - temp;
-			crStrncpy( hostname, temp, len );
-			hostname[len] = 0;
-		}
-		temp2++;
-		if ( !is_digit_string( temp2 ) )
-			goto bad_url;
-
-		if (port != NULL)
-			*port = (unsigned short) atoi( temp2 );
-	}
-	else
-	{
-		if (hostname != NULL)
-			crStrcpy( hostname, temp );
-		if (port != NULL)
-		*port = default_port;
-	}
-
-	return 1;
-
- bad_url:
-	crWarning( "URL: expected <protocol>://"
-				   "<destination>[:<port>], what is \"%s\"?", url );
-	return 0;
-}
Index: /trunk/src/VBox/GuestHost/OpenGL/util/util.def
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/util.def	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/util/util.def	(revision 78190)
@@ -12,12 +12,4 @@
 crDebug
 crInfo
-crParseURL
-crAlloc
-crCalloc
-crAllocDebug
-crCallocDebug
-crRealloc
-crMemset
-crFree
 crStrSplit
 crStrSplitn
@@ -43,5 +35,4 @@
 crBytesToString
 crWordsToString
-crGetHostname
 crGetPID
 crNetAcceptClient
@@ -74,6 +65,4 @@
 crImageSize
 crTextureSize
-crGetenv
-crSetenv
 crHashtableAdd
 crHashtableDelete
@@ -90,22 +79,10 @@
 crFreeHashtableEx
 crHashtableGetDataKey
-crDetermineEndianness
-SWAPDOUBLE
 crBufferPoolInit
 crBufferPoolPush
 crBufferPoolPop
 crBufferPoolFree
-crTimerNewTimer
 crBufferPoolGetNumBuffers
 crBufferPoolGetMaxBuffers
-crDestroyTimer
-crStartTimer
-crStopTimer
-crResetTimer
-crTimerTime
-crMemcpy
-crMemcmp
-crMemZero
-crCalloc
 crSetTSD
 crGetTSD
@@ -129,22 +106,5 @@
 crGetTSD
 crFreeTSD
-crRandFloat
-crRandInt
-crRandSeed
-crRandAutoSeed
-crTransformBBox
-crProjectBBox
-crRectiUnion
-crWarpPoint
-crHullInteriorBox
-crNetSetNodeRange
-crNetSetContextRange
-crNetSetRank
-crNetSetKey
-crSleep
-crSpawn
-crKill
 crGetProcName
-crGetCurrentDir
 crHashtableAllocKeys
 crHashtableDeleteBlock
Index: /trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c	(revision 78189)
+++ /trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c	(revision 78190)
@@ -32,5 +32,4 @@
 #include "cr_mem.h"
 #include "cr_string.h"
-#include "cr_endian.h"
 #include "cr_threads.h"
 #include "net_internals.h"
@@ -1185,7 +1184,6 @@
  * Called on host side only, to "accept" client connection
  */
-static void crVBoxHGCMAccept( CRConnection *conn, const char *hostname, unsigned short port )
-{
-    RT_NOREF(hostname, port);
+static void crVBoxHGCMAccept( CRConnection *conn)
+{
     VBOXCRHGSMIPROFILE_FUNC_PROLOGUE();
     CRASSERT(conn && conn->pHostBuffer);
@@ -2067,5 +2065,5 @@
  * Called on host side only, to "accept" client connection
  */
-static void crVBoxHGSMIAccept( CRConnection *conn, const char *hostname, unsigned short port )
+static void crVBoxHGSMIAccept( CRConnection *conn)
 {
     VBOXCRHGSMIPROFILE_FUNC_PROLOGUE();
@@ -2186,8 +2184,6 @@
 #endif
 
-void crVBoxHGCMInit(CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu)
-{
-    (void) mtu;
-
+void crVBoxHGCMInit(CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl)
+{
     g_crvboxhgcm.recv_list = rfl;
     g_crvboxhgcm.close_list = cfl;
Index: unk/src/VBox/GuestHost/OpenGL/util/warp.c
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/warp.c	(revision 78189)
+++ 	(revision )
@@ -1,24 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_error.h"
-#include "cr_warp.h"
-
-void
-crWarpPoint(const float *align, const float *point, float *result)
-{
-	float w, x, y;
-
-	x = align[0] * point[0] + align[1] * point[1] + align[2];
-	y = align[3] * point[0] + align[4] * point[1] + align[5];
-	w = align[6] * point[0] + align[7] * point[1] + align[8];
-
-	if (w == 0)
-		crError("Crud in alignment matrix --> w == 0. bleh!");
-
-	result[0] = x / w;
-	result[1] = y / w;
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/Makefile.kmk	(revision 78190)
@@ -29,9 +29,4 @@
 	$(VBOX_PATH_CROGL_GENFILES)/
 endif
-
-ifdef VBOX_WITH_CR_DISPLAY_LISTS
- LIBRARIES += VBoxOGLcrdlm
- DLLS      += VBoxOGLexpandospu
-endif # VBOX_WITH_CR_DISPLAY_LISTS
 
 ifeq ($(KBUILD_TARGET),darwin)
@@ -97,7 +92,4 @@
 VBoxSharedCrOpenGL_DEFS += VBOX_WITH_CRHGSMI
 endif
-ifdef VBOX_WITH_CR_DISPLAY_LISTS
-VBoxSharedCrOpenGL_LIBS += $(PATH_STAGE_LIB)/VBoxOGLcrdlm$(VBOX_SUFF_LIB)
-endif
 
 #
@@ -116,38 +108,34 @@
 	$(VBOX_PATH_CROGL_GENFILES)/state/cr_statefuncs.h
 
-ifdef VBOX_WITH_CR_DISPLAY_LISTS
-VBoxOGLcrserverlib_INTERMEDIATES += $(VBOX_PATH_CROGL_GENFILES)/cr_dlm.h
-endif
-
 VBoxOGLcrserverlib_SOURCES := \
-	crserverlib/server_main.c \
-	crserverlib/server_boundsinfo.c \
-	crserverlib/server_bufferobject.c \
-	crserverlib/server_clear.c \
-	crserverlib/server_clip.c \
-	crserverlib/server_config.c \
-	crserverlib/server_context.c \
-	crserverlib/server_gentextures.c \
-	crserverlib/server_getmap.c \
-	crserverlib/server_getstring.c \
-	crserverlib/server_getpointer.c \
-	crserverlib/server_getpixelmap.c \
-	crserverlib/server_getteximage.c \
-	crserverlib/server_lists.c \
-	crserverlib/server_misc.c \
-	crserverlib/server_occlude.c \
-	crserverlib/server_papi.c \
-	crserverlib/server_projmatrix.c \
-	crserverlib/server_readpixels.c \
-	crserverlib/server_stream.c \
-	crserverlib/server_viewport.c \
-	crserverlib/server_window.c \
-	crserverlib/server_winpos.c \
-	crserverlib/server_writeback.c \
-	crserverlib/server_getshaders.c \
-	crserverlib/server_framebuffer.c \
-	crserverlib/server_glsl.c \
+	crserverlib/server_main.cpp \
+	crserverlib/server_boundsinfo.cpp \
+	crserverlib/server_bufferobject.cpp \
+	crserverlib/server_clear.cpp \
+	crserverlib/server_clip.cpp \
+	crserverlib/server_config.cpp \
+	crserverlib/server_context.cpp \
+	crserverlib/server_gentextures.cpp \
+	crserverlib/server_getmap.cpp \
+	crserverlib/server_getstring.cpp \
+	crserverlib/server_getpointer.cpp \
+	crserverlib/server_getpixelmap.cpp \
+	crserverlib/server_getteximage.cpp \
+	crserverlib/server_lists.cpp \
+	crserverlib/server_misc.cpp \
+	crserverlib/server_occlude.cpp \
+	crserverlib/server_papi.cpp \
+	crserverlib/server_projmatrix.cpp \
+	crserverlib/server_readpixels.cpp \
+	crserverlib/server_stream.cpp \
+	crserverlib/server_viewport.cpp \
+	crserverlib/server_window.cpp \
+	crserverlib/server_winpos.cpp \
+	crserverlib/server_writeback.cpp \
+	crserverlib/server_getshaders.cpp \
+	crserverlib/server_framebuffer.cpp \
+	crserverlib/server_glsl.cpp \
 	crserverlib/server_muralfbo.cpp \
-	crserverlib/server_texture.c \
+	crserverlib/server_texture.cpp \
 	crserverlib/presenter/server_presenter.cpp \
 	crserverlib/presenter/display_base.cpp \
@@ -158,17 +146,14 @@
 	crserverlib/presenter/display_vrdp.cpp \
 	crserverlib/server_rpw.cpp \
-	$(VBOX_PATH_CROGL_GENFILES)/server_dispatch.c \
-	$(VBOX_PATH_CROGL_GENFILES)/server_retval.c \
-	$(VBOX_PATH_CROGL_GENFILES)/server_get.c \
-	$(VBOX_PATH_CROGL_GENFILES)/server_simpleget.c
+	$(VBOX_PATH_CROGL_GENFILES)/server_dispatch.cpp \
+	$(VBOX_PATH_CROGL_GENFILES)/server_retval.cpp \
+	$(VBOX_PATH_CROGL_GENFILES)/server_get.cpp \
+	$(VBOX_PATH_CROGL_GENFILES)/server_simpleget.cpp
 VBoxOGLcrserverlib_CLEAN = \
-	$(VBOX_PATH_CROGL_GENFILES)/server_dispatch.c \
-	$(VBOX_PATH_CROGL_GENFILES)/server_retval.c \
-	$(VBOX_PATH_CROGL_GENFILES)/server_get.c \
-	$(VBOX_PATH_CROGL_GENFILES)/server_simpleget.c \
+	$(VBOX_PATH_CROGL_GENFILES)/server_dispatch.cpp \
+	$(VBOX_PATH_CROGL_GENFILES)/server_retval.cpp \
+	$(VBOX_PATH_CROGL_GENFILES)/server_get.cpp \
+	$(VBOX_PATH_CROGL_GENFILES)/server_simpleget.cpp \
 	$(VBOX_PATH_CROGL_GENFILES)/server_dispatch.h
-ifdef VBOX_WITH_CR_DISPLAY_LISTS
-VBoxOGLcrserverlib_DEFS += VBOX_WITH_CR_DISPLAY_LISTS
-endif
 ifdef VBOXCR_LOGFPS
 VBoxOGLcrserverlib_DEFS += VBOXCR_LOGFPS
@@ -192,17 +177,17 @@
 	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D)
 
-$(VBOX_PATH_CROGL_GENFILES)/server_dispatch.c: $(addprefix $(PATH_SUB_CURRENT)/crserverlib/, server_dispatch.py server_special) $(VBOX_CROGL_API_FILES) $(PATH_ROOT)/src/VBox/GuestHost/OpenGL/state_tracker/state_special | $$(dir $$@)
-	$(call MSG_GENERATE,python,$@,$<)
-	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D)
-
-$(VBOX_PATH_CROGL_GENFILES)/server_retval.c: $(addprefix $(PATH_SUB_CURRENT)/crserverlib/, server_retval.py server_special) $(VBOX_CROGL_API_FILES) | $$(dir $$@)
-	$(call MSG_GENERATE,python,$@,$<)
-	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D)
-
-$(VBOX_PATH_CROGL_GENFILES)/server_get.c: $(addprefix $(PATH_SUB_CURRENT)/crserverlib/, server_get.py server_special) $(VBOX_CROGL_API_FILES) | $$(dir $$@)
-	$(call MSG_GENERATE,python,$@,$<)
-	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D)
-
-$(VBOX_PATH_CROGL_GENFILES)/server_simpleget.c: $(addprefix $(PATH_SUB_CURRENT)/crserverlib/, server_simpleget.py get_sizes.py) $(VBOX_CROGL_API_FILES) | $$(dir $$@)
+$(VBOX_PATH_CROGL_GENFILES)/server_dispatch.cpp: $(addprefix $(PATH_SUB_CURRENT)/crserverlib/, server_dispatch.py server_special) $(VBOX_CROGL_API_FILES) $(PATH_ROOT)/src/VBox/GuestHost/OpenGL/state_tracker/state_special | $$(dir $$@)
+	$(call MSG_GENERATE,python,$@,$<)
+	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D)
+
+$(VBOX_PATH_CROGL_GENFILES)/server_retval.cpp: $(addprefix $(PATH_SUB_CURRENT)/crserverlib/, server_retval.py server_special) $(VBOX_CROGL_API_FILES) | $$(dir $$@)
+	$(call MSG_GENERATE,python,$@,$<)
+	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D)
+
+$(VBOX_PATH_CROGL_GENFILES)/server_get.cpp: $(addprefix $(PATH_SUB_CURRENT)/crserverlib/, server_get.py server_special) $(VBOX_CROGL_API_FILES) | $$(dir $$@)
+	$(call MSG_GENERATE,python,$@,$<)
+	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D)
+
+$(VBOX_PATH_CROGL_GENFILES)/server_simpleget.cpp: $(addprefix $(PATH_SUB_CURRENT)/crserverlib/, server_simpleget.py get_sizes.py) $(VBOX_CROGL_API_FILES) | $$(dir $$@)
 	$(call MSG_GENERATE,python,$@,$<)
 	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D)
@@ -223,29 +208,29 @@
 	$(VBOX_PATH_CROGL_GENFILES)/state/cr_statefuncs.h
 VBoxOGLcrunpacker_SOURCES  = \
-	unpacker/unpack_arrays.c \
-	unpacker/unpack_bounds.c \
-	unpacker/unpack_bufferobject.c \
-	unpacker/unpack_calllists.c \
-	unpacker/unpack_clipplane.c \
-	unpacker/unpack_context.c \
-	unpacker/unpack_drawpixels.c \
-	unpacker/unpack_fence.c \
-	unpacker/unpack_fog.c \
-	unpacker/unpack_lights.c \
-	unpacker/unpack_map.c \
-	unpacker/unpack_materials.c \
-	unpacker/unpack_matrices.c \
-	unpacker/unpack_misc.c \
-	unpacker/unpack_pixelmap.c \
-	unpacker/unpack_point.c \
-	unpacker/unpack_program.c \
-	unpacker/unpack_readpixels.c \
-	unpacker/unpack_regcombiner.c \
-	unpacker/unpack_stipple.c \
-	unpacker/unpack_texture.c \
-	unpacker/unpack_writeback.c \
-	unpacker/unpack_visibleregion.c \
-	unpacker/unpack_shaders.c \
-	unpacker/unpack_framebuffer.c \
+	unpacker/unpack_arrays.cpp \
+	unpacker/unpack_bounds.cpp \
+	unpacker/unpack_bufferobject.cpp \
+	unpacker/unpack_calllists.cpp \
+	unpacker/unpack_clipplane.cpp \
+	unpacker/unpack_context.cpp \
+	unpacker/unpack_drawpixels.cpp \
+	unpacker/unpack_fence.cpp \
+	unpacker/unpack_fog.cpp \
+	unpacker/unpack_lights.cpp \
+	unpacker/unpack_map.cpp \
+	unpacker/unpack_materials.cpp \
+	unpacker/unpack_matrices.cpp \
+	unpacker/unpack_misc.cpp \
+	unpacker/unpack_pixelmap.cpp \
+	unpacker/unpack_point.cpp \
+	unpacker/unpack_program.cpp \
+	unpacker/unpack_readpixels.cpp \
+	unpacker/unpack_regcombiner.cpp \
+	unpacker/unpack_stipple.cpp \
+	unpacker/unpack_texture.cpp \
+	unpacker/unpack_writeback.cpp \
+	unpacker/unpack_visibleregion.cpp \
+	unpacker/unpack_shaders.cpp \
+	unpacker/unpack_framebuffer.cpp \
 	$(VBOX_PATH_CROGL_GENFILES)/unpack.cpp
 VBoxOGLcrunpacker_CLEAN = \
@@ -270,92 +255,4 @@
 	$(call MSG_GENERATE,python,$@,$<)
 	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D)
-
-
-ifdef VBOX_WITH_CR_DISPLAY_LISTS
-#
-# VBoxOGLcrdlm
-#
-
-VBoxOGLcrdlm_TEMPLATE       = VBOXCROGLR3HOSTLIB
-VBoxOGLcrdlm_INCS           = \
-	dlm
-VBoxOGLcrdlm_INTERMEDIATES  = \
-	$(VBOX_PATH_CROGL_GENFILES)/cr_dlm.h \
-	$(VBOX_PATH_CROGL_GENFILES)/dlm_generated.h
-
-VBoxOGLcrdlm_SOURCES  = \
-	dlm/dlm.c \
-	dlm/dlm_arrays.c \
-	dlm/dlm_state.c \
-	dlm/dlm_checklist.c \
-	dlm/dlm_error.c \
-	dlm/dlm_lists.c \
-	dlm/dlm_pointers.c \
-	$(VBOX_PATH_CROGL_GENFILES)/dlm_generated.c
-
-VBoxOGLcrdlm_CLEAN = \
-	$(VBOX_PATH_CROGL_GENFILES)/dlm_generated.c \
-	$(VBOX_PATH_CROGL_GENFILES)/cr_dlm.h \
-	$(VBOX_PATH_CROGL_GENFILES)/dlm_generated.h
-#
-# Generate files for VBoxOGLcrdlm.
-#
-$(VBOX_PATH_CROGL_GENFILES)/cr_dlm.h: \
-		$(addprefix $(PATH_SUB_CURRENT)/dlm/, dlm_header.py) \
-		$(VBOX_CROGL_API_FILES) \
-		| $$(dir $$@)
-	$(call MSG_GENERATE,python,$@,$<)
-	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< header $(<D) $(VBOX_PATH_CROGL_GLAPI) > $@
-
-$(VBOX_PATH_CROGL_GENFILES)/dlm_generated.h: \
-		$(addprefix $(PATH_SUB_CURRENT)/dlm/, dlm_generated.py dlm_special) \
-		$(VBOX_PATH_CROGL_GENFILES)/cr_dlm.h \
-		$(VBOX_CROGL_API_FILES) \
-		| $$(dir $$@)
-	$(call MSG_GENERATE,python,$@,$<)
-	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< headers $(<D) $(VBOX_PATH_CROGL_GLAPI) > $@
-
-$(VBOX_PATH_CROGL_GENFILES)/dlm_generated.c: \
-		$(addprefix $(PATH_SUB_CURRENT)/dlm/, dlm_generated.py dlm_special) \
-		$(VBOX_PATH_CROGL_GENFILES)/dlm_generated.h \
-		$(VBOX_CROGL_API_FILES) \
-		| $$(dir $$@)
-	$(call MSG_GENERATE,python,$@,$<)
-	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< source $(<D) $(VBOX_PATH_CROGL_GLAPI) > $@
-
-
-#
-# VBoxOGLexpandospu
-#
-VBoxOGLexpandospu_TEMPLATE       = VBOXCROGLR3HOSTDLL
-VBoxOGLexpandospu_INCS           = \
-	expando
-VBoxOGLexpandospu_SOURCES  = \
-	expando/expandospu.c \
-	expando/expandospu_config.c \
-	expando/expandospu_init.c \
-	$(VBOX_PATH_CROGL_GENFILES)/expando.c
-VBoxOGLexpandospu_CLEAN = \
-	$(VBOX_PATH_CROGL_GENFILES)/expando.c
-VBoxOGLexpandospu_CLEAN = \
-	$(VBOX_PATH_CROGL_GENFILES)/expando.c
-VBoxOGLexpandospu_LDFLAGS.darwin += -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxOGLexpandospu.dylib
-VBoxOGLexpandospu_LIBS = \
-	$(PATH_STAGE_LIB)/VBoxOGLcrdlm$(VBOX_SUFF_LIB) \
-	$(PATH_STAGE_LIB)/VBoxOGLhostcrstate$(VBOX_SUFF_LIB) \
-	$(PATH_STAGE_LIB)/VBoxOGLhostspuload$(VBOX_SUFF_LIB) \
-	$(VBOX_LIB_OGL_HOSTCRUTIL) \
-	$(LIB_RUNTIME) \
-	$(LIB_VMM)
-#
-# Generate files for VBoxOGLexpandospu.
-#
-$(VBOX_PATH_CROGL_GENFILES)/expando.c: \
-		$(addprefix $(PATH_SUB_CURRENT)/expando/, expando.py expando_special) \
-		$(VBOX_CROGL_API_FILES) \
-		| $$(dir $$@)
-	$(call MSG_GENERATE,python,$@,$<)
-	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $(<D) > $@
-endif
 
 
Index: /trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp	(revision 78190)
@@ -26,7 +26,5 @@
 #include <ApplicationServices/ApplicationServices.h>
 #include <OpenGL/gl.h>
-#ifdef VBOX_WITH_COCOA_QT
-# include <OpenGL/glu.h>
-#endif
+#include <OpenGL/glu.h>
 
 #include <iprt/env.h>
@@ -143,5 +141,4 @@
             GLboolean isSupported = GL_TRUE;
 
-#ifdef VBOX_WITH_COCOA_QT
             /*
              * In the Cocoa port we depend on the GL_EXT_framebuffer_object &
@@ -160,5 +157,4 @@
             else
                 LogRel(("OpenGL Info: 3D test found that GL_EXT_framebuffer_object extension not supported.\n"));
-#endif /* VBOX_WITH_COCOA_QT */
 
             CGLDestroyContext(pCglContext);
Index: unk/src/VBox/HostServices/SharedOpenGL/crserver/main.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserver/main.c	(revision 78189)
+++ 	(revision )
@@ -1,23 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_server.h"
-
-/**
- * \mainpage Crserver 
- *
- * \section CrserverIntroduction Introduction
- *
- * Chromium consists of all the top-level files in the cr
- * directory.  The crserver module basically takes care of API dispatch,
- * and OpenGL state management.
- *
- */
-
-int main( int argc, char *argv[] )
-{
-	return CRServerMain( argc, argv );
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.h
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.h	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/presenter/server_presenter.h	(revision 78190)
@@ -24,5 +24,4 @@
 #include "cr_error.h"
 #include "cr_net.h"
-#include "cr_rand.h"
 #include "server_dispatch.h"
 #include "server.h"
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h	(revision 78190)
@@ -92,5 +92,4 @@
 } CRServerProgram;
 
-void crServerSetVBoxConfiguration();
 void crServerSetVBoxConfigurationHGCM();
 void crServerInitDispatch(void);
@@ -107,6 +106,4 @@
 void crServerSetOutputBounds( const CRMuralInfo *mural, int extNum );
 void crServerComputeViewportBounds( const CRViewportState *v, CRMuralInfo *mural );
-
-GLboolean crServerInitializeBucketing(CRMuralInfo *mural);
 
 void crComputeOverlapGeom(double *quads, int nquad, CRPoly ***res);
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_boundsinfo.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_boundsinfo.c	(revision 78189)
+++ 	(revision )
@@ -1,329 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_error.h"
-#include "cr_unpack.h"
-#include "cr_mem.h"
-#include "state/cr_statetypes.h"
-
-/* This code copied from the tilesorter (fooey) */
-
-typedef struct BucketRegion *BucketRegion_ptr;
-typedef struct BucketRegion {
-	CRbitvalue       id;
-	CRrecti          extents;
-	BucketRegion_ptr right;
-	BucketRegion_ptr up;
-} BucketRegion;
-
-#define HASHRANGE 256
-
-#define BKT_DOWNHASH(a, range) ((a)*HASHRANGE/(range))
-#define BKT_UPHASH(a, range) ((a)*HASHRANGE/(range) + ((a)*HASHRANGE%(range)?1:0))
-
-struct BucketingInfo {
-	BucketRegion *rhash[HASHRANGE][HASHRANGE];
-	BucketRegion *rlist;
-};
-
-
-/*
- * At this point we know that the tiles are uniformly sized so we can use
- * a hash-based bucketing method.  Setup the hash table now.
- */
-static GLboolean
-fillBucketingHash(CRMuralInfo *mural)
-{
-#if 0
-	int i, j, k, m;
-	int r_len = 0;
-	int xinc, yinc;
-	int rlist_alloc = 64 * 128;
-	BucketRegion *rptr;
-	struct BucketingInfo *bucketInfo;
-
-	if (mural->bucketInfo) {
-		crFree(mural->bucketInfo->rlist);
-		crFree(mural->bucketInfo);
-		mural->bucketInfo = NULL;
-	}
-
-	bucketInfo = (struct BucketingInfo *) crCalloc(sizeof(struct BucketingInfo));
-	if (!bucketInfo)
-		return GL_FALSE;
-
-	/* Allocate rlist (don't free it!!!) */
-	bucketInfo->rlist = (BucketRegion *) crAlloc(rlist_alloc * sizeof(BucketRegion));
-
-	for ( i = 0; i < HASHRANGE; i++ )
-	{
-		for ( j = 0; j < HASHRANGE; j++ )
-		{
-			bucketInfo->rhash[i][j] = NULL;
-		}
-	}
-
-	/* Fill the rlist */
-	xinc = mural->extents[0].imagewindow.x2 - mural->extents[0].imagewindow.x1;
-	yinc = mural->extents[0].imagewindow.y2 - mural->extents[0].imagewindow.y1;
-	CRASSERT(xinc > 0 || mural->width == 0);
-	CRASSERT(yinc > 0 || mural->height == 0);
-
-	rptr = bucketInfo->rlist;
-	for (i=0; i < (int) mural->width; i+=xinc) 
-	{
-		for (j=0; j < (int) mural->height; j+=yinc) 
-		{
-			for (k=0; k < mural->numExtents; k++) 
-			{
-				if (mural->extents[k].imagewindow.x1 == i &&
-						mural->extents[k].imagewindow.y1 == j) 
-				{
-					rptr->extents = mural->extents[k].imagewindow; /* x1,y1,x2,y2 */
-					rptr->id = k;
-					break;
-				}
-			}
-			if (k == mural->numExtents) 
-			{
-				rptr->extents.x1 = i;
-				rptr->extents.y1 = j;
-				rptr->extents.x2 = i + xinc;
-				rptr->extents.y2 = j + yinc;
-				rptr->id = -1;
-			}
-			rptr++;
-		}
-	}
-	r_len = rptr - bucketInfo->rlist;
-
-	/* Fill hash table */
-	for (i = 0; i < r_len; i++)
-	{
-		BucketRegion *r = &bucketInfo->rlist[i];
-
-		for (k=BKT_DOWNHASH(r->extents.x1, (int)mural->width);
-		     k<=BKT_UPHASH(r->extents.x2, (int)mural->width) &&
-			     k < HASHRANGE;
-		     k++) 
-		{
-			for (m=BKT_DOWNHASH(r->extents.y1, (int)mural->height);
-			     m<=BKT_UPHASH(r->extents.y2, (int)mural->height) &&
-				     m < HASHRANGE;
-			     m++) 
-			{
-				if ( bucketInfo->rhash[m][k] == NULL ||
-				     (bucketInfo->rhash[m][k]->extents.x1 > r->extents.x1 &&
-				      bucketInfo->rhash[m][k]->extents.y1 > r->extents.y1))
-				{
-					bucketInfo->rhash[m][k] = r;
-				}
-			}
-		}
-	}
-
-	/* Initialize links */
-	for (i=0; i<r_len; i++) 
-	{
-		BucketRegion *r = &bucketInfo->rlist[i];
-		r->right = NULL;
-		r->up    = NULL;
-	}
-
-	/* Build links */
-	for (i=0; i<r_len; i++) 
-	{
-		BucketRegion *r = &bucketInfo->rlist[i];
-		for (j=0; j<r_len; j++) 
-		{
-			BucketRegion *q = &bucketInfo->rlist[j];
-			if (r==q)
-				continue;
-
-			/* Right Edge */
-			if (r->extents.x2 == q->extents.x1 &&
-			    r->extents.y1 == q->extents.y1 &&
-			    r->extents.y2 == q->extents.y2) 
-			{
-				r->right = q;
-			}
-
-			/* Upper Edge */
-			if (r->extents.y2 == q->extents.y1 &&
-			    r->extents.x1 == q->extents.x1 &&
-			    r->extents.x2 == q->extents.x2) 
-			{
-				r->up = q;
-			}
-		}
-	}
-
-	mural->bucketInfo = bucketInfo;
-#endif
-	return GL_TRUE;
-}
-
-
-/*
- * Check if the tiles are the same size.  If so, initialize hash-based
- * bucketing.
- */
-GLboolean
-crServerInitializeBucketing(CRMuralInfo *mural)
-{
-#if 0
-	int optTileWidth = 0, optTileHeight = 0;
-	int i;
-
-	for (i = 0; i < mural->numExtents; i++)
-	{
-		const int w = mural->extents[i].imagewindow.x2 -
-			mural->extents[i].imagewindow.x1;
-		const int h = mural->extents[i].imagewindow.y2 -
-			mural->extents[i].imagewindow.y1;
-
-		if (optTileWidth == 0 && optTileHeight == 0) {
-			/* First tile */
-			optTileWidth = w;
-			optTileHeight = h;
-		}
-		else
-		{
-			/* Subsequent tile - make sure it's the same size as first and
-			 * falls on the expected x/y location.
-			 */
-			if (w != optTileWidth || h != optTileHeight) {
-				crWarning("Tile %d, %d .. %d, %d is not the right size!",
-									mural->extents[i].imagewindow.x1, mural->extents[i].imagewindow.y1,
-									mural->extents[i].imagewindow.x2, mural->extents[i].imagewindow.y2);
-				crWarning("All tiles must be same size with optimize_bucket.");
-				crWarning("Turning off optimize_bucket for this mural.");
-				return GL_FALSE;
-			}
-			else if ((mural->extents[i].imagewindow.x1 % optTileWidth) != 0 ||
-							 (mural->extents[i].imagewindow.x2 % optTileWidth) != 0 ||
-							 (mural->extents[i].imagewindow.y1 % optTileHeight) != 0 ||
-							 (mural->extents[i].imagewindow.y2 % optTileHeight) != 0)
-			{
-				crWarning("Tile %d, %d .. %d, %d is not positioned correctly "
-									"to use optimize_bucket.",
-									mural->extents[i].imagewindow.x1, mural->extents[i].imagewindow.y1,
-									mural->extents[i].imagewindow.x2, mural->extents[i].imagewindow.y2);
-				crWarning("Turning off optimize_bucket for this mural.");
-				return GL_FALSE;
-			}
-		}
-	}
-#endif
-	return fillBucketingHash(mural);
-}
-
-
-/**
- * Process a crBoundsInfoCR message/function.  This is a bounding box
- * followed by a payload of arbitrary Chromium rendering commands.
- * The tilesort SPU will send this.
- * Note: the bounding box is in mural pixel coordinates (y=0=bottom)
- */
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchBoundsInfoCR( const CRrecti *bounds, const GLbyte *payload,
-															GLint len, GLint num_opcodes )
-{
-#if 0
-	CRMuralInfo *mural = cr_server.curClient->currentMural;
-	char *data_ptr = (char*)(payload + ((num_opcodes + 3 ) & ~0x03));
-	unsigned int bx, by;
-#endif
-
-	/* Save current unpacker state */
-	crUnpackPush();
-#if 0
-	/* pass bounds info to first SPU */
-	{
-		/* bias bounds to extent/window coords */
-		CRrecti bounds2;
-		const int dx = mural->extents[0].imagewindow.x1;
-		const int dy = mural->extents[0].imagewindow.y1;
-		if (bounds->x1 == -CR_MAXINT) {
-			/* "infinite" bounds: convert to full image bounds */
-			bounds2.x1 = 0;
-			bounds2.y1 = 0;
-			bounds2.x2 = mural->extents[0].imagewindow.x2 - dx; /* width */
-			bounds2.y2 = mural->extents[0].imagewindow.y2 - dy; /* height */
-		}
-		else {
-			bounds2.x1 = bounds->x1 - dx;
-			bounds2.y1 = bounds->y1 - dy;
-			bounds2.x2 = bounds->x2 - dx;
-			bounds2.y2 = bounds->y2 - dy;
-		}
-		cr_server.head_spu->dispatch_table.BoundsInfoCR(&bounds2, NULL, 0, 0);
-	}
-
-	if (!mural->viewportValidated) {
-		crServerComputeViewportBounds(&(cr_server.curClient->currentCtxInfo->pContext->viewport),
-																	mural);
-	}
-
-	bx = BKT_DOWNHASH(bounds->x1, mural->width);
-	by = BKT_DOWNHASH(bounds->y1, mural->height);
-
-	/* Check for out of bounds, and optimizeBucket to enable */
-	if (mural->optimizeBucket && (bx <= HASHRANGE) && (by <= HASHRANGE))
-	{
-		const struct BucketingInfo *bucketInfo = mural->bucketInfo;
-		const BucketRegion *r;
-		const BucketRegion *p;
-
-		CRASSERT(bucketInfo);
-
-		for (r = bucketInfo->rhash[by][bx]; r && bounds->y2 >= r->extents.y1;
-		     r = r->up)
-		{
-			for (p=r; p && bounds->x2 >= p->extents.x1; p = p->right)
-			{
-				if ( p->id != (unsigned int) -1 &&
-					bounds->x1 < p->extents.x2  &&
-					bounds->y1 < p->extents.y2 &&
-					bounds->y2 >= p->extents.y1 )
-				{
-					mural->curExtent = p->id;
-					if (cr_server.run_queue->client->currentCtxInfo && cr_server.run_queue->client->currentCtxInfo->pContext) {
-						crServerSetOutputBounds( mural, mural->curExtent );
-					}
-                    crUnpack( data_ptr, NULL, data_ptr-1, num_opcodes, &(cr_server.dispatch) );
-				}
-			}
-		}
-	} 
-	else 
-	{
-		/* non-optimized bucketing - unpack/render for each tile/extent */
-		int i;
-		for ( i = 0; i < mural->numExtents; i++ )
-		{
-			CRExtent *extent = &mural->extents[i];
-
-			if (cr_server.localTileSpec ||
-			    (extent->imagewindow.x2 > bounds->x1 &&
-					 extent->imagewindow.x1 < bounds->x2 &&
-					 extent->imagewindow.y2 > bounds->y1 &&
-					 extent->imagewindow.y1 < bounds->y2))
-			{
-				mural->curExtent = i;
-				if (cr_server.run_queue->client->currentCtxInfo && cr_server.run_queue->client->currentCtxInfo->pContext) {
-					crServerSetOutputBounds( mural, i );
-				}
-                crUnpack( data_ptr, NULL, data_ptr-1, num_opcodes, &(cr_server.dispatch) );
-			}
-		}
-	}
-#endif
-	/* Restore previous unpacker state */
-	crUnpackPop();
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_boundsinfo.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_boundsinfo.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_boundsinfo.cpp	(revision 78190)
@@ -0,0 +1,27 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_error.h"
+#include "cr_unpack.h"
+#include "cr_mem.h"
+#include "state/cr_statetypes.h"
+
+
+
+/**
+ * Process a crBoundsInfoCR message/function.  This is a bounding box
+ * followed by a payload of arbitrary Chromium rendering commands.
+ * The tilesort SPU will send this.
+ * Note: the bounding box is in mural pixel coordinates (y=0=bottom)
+ */
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchBoundsInfoCR( const CRrecti *bounds, const GLbyte *payload,
+															GLint len, GLint num_opcodes )
+{
+
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_bufferobject.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_bufferobject.c	(revision 78189)
+++ 	(revision )
@@ -1,111 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "chromium.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_unpack.h"
-
-void * SERVER_DISPATCH_APIENTRY
-crServerDispatchMapBufferARB( GLenum target, GLenum access )
-{
-	return NULL;
-}
-
-GLboolean SERVER_DISPATCH_APIENTRY
-crServerDispatchUnmapBufferARB( GLenum target )
-{
-	return GL_FALSE;
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGenBuffersARB(GLsizei n, GLuint *buffers)
-{
-    GLuint *local_buffers;
-    (void) buffers;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchGenBuffersARB: parameter 'n' is out of range");
-        return;
-    }
-
-    local_buffers = (GLuint *)crCalloc(n * sizeof(*local_buffers));
-
-    if (!local_buffers)
-    {
-        crError("crServerDispatchGenBuffersARB: out of memory");
-        return;
-    }
-
-    crStateGenBuffersARB(n, local_buffers);
-
-    crServerReturnValue( local_buffers, n * sizeof(*local_buffers) );
-    crFree( local_buffers );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteBuffersARB( GLsizei n, const GLuint * buffer )
-{
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint) || !DATA_POINTER_CHECK(n * sizeof(GLuint)))
-    {
-        crError("glDeleteBuffersARB: parameter 'n' is out of range");
-        return;
-    }
-
-    crStateDeleteBuffersARB( n, buffer );
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
-{
-	crError( "glGetBufferPointervARB isn't *ever* allowed to be on the wire!" );
-	(void) target;
-	(void) pname;
-	(void) params;
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data)
-{
-    void *b;
-
-    if (size <= 0 || size >= INT32_MAX / 2)
-    {
-        crError("crServerDispatchGetBufferSubDataARB: size is out of range");
-        return;
-    }
-
-    b = crCalloc(size);
-
-    if (b) {
-        cr_server.head_spu->dispatch_table.GetBufferSubDataARB( target, offset, size, b );
-
-        crServerReturnValue( b, size );
-        crFree( b );
-    }
-    else {
-        crError("Out of memory in crServerDispatchGetBufferSubDataARB");
-    }
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchBindBufferARB(GLenum target, GLuint buffer)
-{
-    crStateBindBufferARB(target, buffer);
-    cr_server.head_spu->dispatch_table.BindBufferARB(target, crStateGetBufferHWID(buffer));
-}
-
-GLboolean SERVER_DISPATCH_APIENTRY
-crServerDispatchIsBufferARB(GLuint buffer)
-{
-    /* since GenBuffersARB issued to host ogl only on bind + some other ops, the host drivers may not know about them
-     * so use state data*/
-    GLboolean retval = crStateIsBufferARB(buffer);
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_bufferobject.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_bufferobject.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_bufferobject.cpp	(revision 78190)
@@ -0,0 +1,111 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "chromium.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_unpack.h"
+
+void * SERVER_DISPATCH_APIENTRY
+crServerDispatchMapBufferARB( GLenum target, GLenum access )
+{
+	return NULL;
+}
+
+GLboolean SERVER_DISPATCH_APIENTRY
+crServerDispatchUnmapBufferARB( GLenum target )
+{
+	return GL_FALSE;
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGenBuffersARB(GLsizei n, GLuint *buffers)
+{
+    GLuint *local_buffers;
+    (void) buffers;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchGenBuffersARB: parameter 'n' is out of range");
+        return;
+    }
+
+    local_buffers = (GLuint *)crCalloc(n * sizeof(*local_buffers));
+
+    if (!local_buffers)
+    {
+        crError("crServerDispatchGenBuffersARB: out of memory");
+        return;
+    }
+
+    crStateGenBuffersARB(n, local_buffers);
+
+    crServerReturnValue( local_buffers, n * sizeof(*local_buffers) );
+    crFree( local_buffers );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteBuffersARB( GLsizei n, const GLuint * buffer )
+{
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("glDeleteBuffersARB: parameter 'n' is out of range");
+        return;
+    }
+
+    crStateDeleteBuffersARB( n, buffer );
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
+{
+	crError( "glGetBufferPointervARB isn't *ever* allowed to be on the wire!" );
+	(void) target;
+	(void) pname;
+	(void) params;
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data)
+{
+    void *b;
+
+    if (size <= 0 || size >= INT32_MAX / 2)
+    {
+        crError("crServerDispatchGetBufferSubDataARB: size is out of range");
+        return;
+    }
+
+    b = crCalloc(size);
+
+    if (b) {
+        cr_server.head_spu->dispatch_table.GetBufferSubDataARB( target, offset, size, b );
+
+        crServerReturnValue( b, size );
+        crFree( b );
+    }
+    else {
+        crError("Out of memory in crServerDispatchGetBufferSubDataARB");
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchBindBufferARB(GLenum target, GLuint buffer)
+{
+    crStateBindBufferARB(target, buffer);
+    cr_server.head_spu->dispatch_table.BindBufferARB(target, crStateGetBufferHWID(buffer));
+}
+
+GLboolean SERVER_DISPATCH_APIENTRY
+crServerDispatchIsBufferARB(GLuint buffer)
+{
+    /* since GenBuffersARB issued to host ogl only on bind + some other ops, the host drivers may not know about them
+     * so use state data*/
+    GLboolean retval = crStateIsBufferARB(buffer);
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clear.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clear.c	(revision 78189)
+++ 	(revision )
@@ -1,492 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_spu.h"
-#include "chromium.h"
-#include "cr_mem.h"
-#include "cr_net.h"
-#include "server_dispatch.h"
-#include "server.h"
-
-#ifdef VBOXCR_LOGFPS
-#include <iprt/timer.h>
-#include <iprt/ctype.h>
-typedef struct VBOXCRFPS
-{
-    uint64_t mPeriodSum;
-    uint64_t *mpaPeriods;
-    uint64_t mPrevTime;
-    uint64_t mcFrames;
-    uint32_t mcPeriods;
-    uint32_t miPeriod;
-
-    uint64_t mBytesSum;
-    uint32_t *mpaBytes;
-
-    uint64_t mBytesSentSum;
-    uint32_t *mpaBytesSent;
-
-    uint64_t mCallsSum;
-    uint32_t *mpaCalls;
-
-    uint64_t mOpsSum;
-    uint32_t *mpaOps;
-
-    uint64_t mTimeUsedSum;
-    uint64_t *mpaTimes;
-} VBOXCRFPS, *PVBOXCRFPS;
-
-void vboxCrFpsInit(PVBOXCRFPS pFps, uint32_t cPeriods)
-{
-    crMemset(pFps, 0, sizeof (*pFps));
-    pFps->mcPeriods = cPeriods;
-    pFps->mpaPeriods = crCalloc(sizeof (pFps->mpaPeriods[0]) * cPeriods);
-    pFps->mpaBytes = crCalloc(sizeof (pFps->mpaBytes[0]) * cPeriods);
-    pFps->mpaBytesSent = crCalloc(sizeof (pFps->mpaBytesSent[0]) * cPeriods);
-    pFps->mpaCalls = crCalloc(sizeof (pFps->mpaCalls[0]) * cPeriods);
-    pFps->mpaOps = crCalloc(sizeof (pFps->mpaOps[0]) * cPeriods);
-    pFps->mpaTimes = crCalloc(sizeof (pFps->mpaTimes[0]) * cPeriods);
-}
-
-void vboxCrFpsTerm(PVBOXCRFPS pFps)
-{
-    crFree(pFps->mpaPeriods);
-    crFree(pFps->mpaBytes);
-    crFree(pFps->mpaCalls);
-}
-
-void vboxCrFpsReportFrame(PVBOXCRFPS pFps)
-{
-    uint64_t cur = RTTimeNanoTS();
-    uint64_t curBytes, curBytesSent, curCalls, curOps, curTimeUsed;
-    int i;
-
-    curBytes = 0;
-    curBytesSent = 0;
-    curCalls = 0;
-    curOps = 0;
-    curTimeUsed = 0;
-
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        if (cr_server.clients[i] && cr_server.clients[i]->conn)
-        {
-            curBytes += cr_server.clients[i]->conn->total_bytes_recv;
-            curBytesSent += cr_server.clients[i]->conn->total_bytes_sent;
-            curCalls += cr_server.clients[i]->conn->recv_count;
-            curOps += cr_server.clients[i]->conn->opcodes_count;
-            curTimeUsed += cr_server.clients[i]->timeUsed;
-            cr_server.clients[i]->conn->total_bytes_recv = 0;
-            cr_server.clients[i]->conn->total_bytes_sent = 0;
-            cr_server.clients[i]->conn->recv_count = 0;
-            cr_server.clients[i]->conn->opcodes_count = 0;
-            cr_server.clients[i]->timeUsed = 0;
-        }
-    }
-
-    if(pFps->mPrevTime)
-    {
-        uint64_t curPeriod = cur - pFps->mPrevTime;
-
-        pFps->mPeriodSum += curPeriod - pFps->mpaPeriods[pFps->miPeriod];
-        pFps->mpaPeriods[pFps->miPeriod] = curPeriod;
-
-        pFps->mBytesSum += curBytes - pFps->mpaBytes[pFps->miPeriod];
-        pFps->mpaBytes[pFps->miPeriod] = curBytes;
-
-        pFps->mBytesSentSum += curBytesSent - pFps->mpaBytesSent[pFps->miPeriod];
-        pFps->mpaBytesSent[pFps->miPeriod] = curBytesSent;
-
-        pFps->mCallsSum += curCalls - pFps->mpaCalls[pFps->miPeriod];
-        pFps->mpaCalls[pFps->miPeriod] = curCalls;
-
-        pFps->mOpsSum += curOps - pFps->mpaOps[pFps->miPeriod];
-        pFps->mpaOps[pFps->miPeriod] = curOps;
-
-        pFps->mTimeUsedSum += curTimeUsed - pFps->mpaTimes[pFps->miPeriod];
-        pFps->mpaTimes[pFps->miPeriod] = curTimeUsed;
-
-        ++pFps->miPeriod;
-        pFps->miPeriod %= pFps->mcPeriods;
-    }
-    pFps->mPrevTime = cur;
-    ++pFps->mcFrames;
-}
-
-uint64_t vboxCrFpsGetEveragePeriod(PVBOXCRFPS pFps)
-{
-    return pFps->mPeriodSum / pFps->mcPeriods;
-}
-
-double vboxCrFpsGetFps(PVBOXCRFPS pFps)
-{
-    return ((double)1000000000.0) / vboxCrFpsGetEveragePeriod(pFps);
-}
-
-double vboxCrFpsGetBps(PVBOXCRFPS pFps)
-{
-    return vboxCrFpsGetFps(pFps) * pFps->mBytesSum / pFps->mcPeriods;
-}
-
-double vboxCrFpsGetBpsSent(PVBOXCRFPS pFps)
-{
-    return vboxCrFpsGetFps(pFps) * pFps->mBytesSentSum / pFps->mcPeriods;
-}
-
-double vboxCrFpsGetCps(PVBOXCRFPS pFps)
-{
-    return vboxCrFpsGetFps(pFps) * pFps->mCallsSum / pFps->mcPeriods;
-}
-
-double vboxCrFpsGetOps(PVBOXCRFPS pFps)
-{
-    return vboxCrFpsGetFps(pFps) * pFps->mOpsSum / pFps->mcPeriods;
-}
-
-double vboxCrFpsGetTimeProcPercent(PVBOXCRFPS pFps)
-{
-    return 100.0*pFps->mTimeUsedSum/pFps->mPeriodSum;
-}
-
-uint64_t vboxCrFpsGetNumFrames(PVBOXCRFPS pFps)
-{
-    return pFps->mcFrames;
-}
-
-#endif
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchClear( GLenum mask )
-{
-	CRMuralInfo *mural = cr_server.curClient->currentMural;
-	const RunQueue *q = cr_server.run_queue;
-
-	if (cr_server.only_swap_once)
-	{
-		/* NOTE: we only do the clear for the _last_ client in the list.
-		 * This is because in multi-threaded apps the zeroeth client may
-		 * be idle and never call glClear at all.  See threadtest.c
-		 * It's pretty likely that the last client will be active.
-		 */
-		if ((mask & GL_COLOR_BUFFER_BIT) &&
-			(cr_server.curClient != cr_server.clients[cr_server.numClients - 1]))
-		   return;
-	}
-
-	cr_server.head_spu->dispatch_table.Clear( mask );
-}
-
-static void __draw_poly(CRPoly *p)
-{
-	int b;
-
-	cr_server.head_spu->dispatch_table.Begin(GL_POLYGON);
-	for (b=0; b<p->npoints; b++)
-		cr_server.head_spu->dispatch_table.Vertex2dv(p->points+2*b);
-	cr_server.head_spu->dispatch_table.End();
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchSwapBuffers( GLint window, GLint flags )
-{
-  CRMuralInfo *mural;
-  CRContext *ctx;
-
-#ifdef VBOXCR_LOGFPS
-  static VBOXCRFPS Fps;
-  static bool bFpsInited = false;
-
-  if (!bFpsInited)
-  {
-      vboxCrFpsInit(&Fps, 64 /* cPeriods */);
-      bFpsInited = true;
-  }
-  vboxCrFpsReportFrame(&Fps);
-  if(!(vboxCrFpsGetNumFrames(&Fps) % 31))
-  {
-      double fps = vboxCrFpsGetFps(&Fps);
-      double bps = vboxCrFpsGetBps(&Fps);
-      double bpsSent = vboxCrFpsGetBpsSent(&Fps);
-      double cps = vboxCrFpsGetCps(&Fps);
-      double ops = vboxCrFpsGetOps(&Fps);
-      double tup = vboxCrFpsGetTimeProcPercent(&Fps);
-      crDebug("fps: %f, rec Mbps: %.1f, send Mbps: %.1f, cps: %.1f, ops: %.0f, host %.1f%%", 
-              fps, bps/(1024.0*1024.0), bpsSent/(1024.0*1024.0), cps, ops, tup);
-  }
-#endif
-	mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
-	if (!mural) {
-		 return;
-	}
-
-
-	if (cr_server.only_swap_once)
-	{
-		/* NOTE: we only do the clear for the _last_ client in the list.
-		 * This is because in multi-threaded apps the zeroeth client may
-		 * be idle and never call glClear at all.  See threadtest.c
-		 * It's pretty likely that the last client will be active.
-		 */
-		if (cr_server.curClient != cr_server.clients[cr_server.numClients - 1])
-		{
-			return;
-		}
-	}
-
-#if 0
-	if (cr_server.overlapBlending)
-	{
-		int a;
-		CRPoly *p;
-		GLboolean lighting, fog, blend, cull, tex[3];
-		GLenum mm, blendSrc, blendDst;
-		GLcolorf col;
-		CRContext *ctx = crStateGetCurrent();
-		const CRmatrix *baseProj;
-
-		/* 
-		 * I've probably missed some state here, or it
-	 	 * might be easier just to push/pop it....
-		 */
-		lighting = ctx->lighting.lighting;
-		fog		 = ctx->fog.enable;
-		tex[0] = 0;
-		for (a=0; a<CR_MAX_TEXTURE_UNITS; a++)
-		{
-			if (!ctx->texture.unit[a].enabled1D) continue;
-	
-			tex[0] 	 = 1;
-			break;
-		}
-		tex[1] = 0;
-		for	(a=0; a<CR_MAX_TEXTURE_UNITS; a++)
-		{
-			if (!ctx->texture.unit[a].enabled2D) continue;
-
-			tex[1] 	 = 1;
-			break;
-		}
-		tex[2] = 0;
-		for (a=0; a<CR_MAX_TEXTURE_UNITS; a++)
-		{	
-			if (!ctx->texture.unit[a].enabled3D) continue;
-	
-			tex[2] 	 = 1;
-			break;
-		}
-
-		cull	 = ctx->polygon.cullFace;
-		blend	 = ctx->buffer.blend;
-		blendSrc = ctx->buffer.blendSrcRGB;
-		blendDst = ctx->buffer.blendDstRGB;
-		mm = ctx->transform.matrixMode;
-		col.r = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][0];
-		col.g = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][1];
-		col.b = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][2];
-		col.a = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][3];
-
-		baseProj = &(cr_server.curClient->currentMural->extents[0].baseProjection);
-	
-		switch(mm)
-		{
-				case GL_PROJECTION:
-					cr_server.head_spu->dispatch_table.PushMatrix();
-					cr_server.head_spu->dispatch_table.LoadMatrixf((GLfloat *) baseProj);
-					cr_server.head_spu->dispatch_table.MultMatrixf(cr_server.unnormalized_alignment_matrix);
-					cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
-					cr_server.head_spu->dispatch_table.PushMatrix();
-					cr_server.head_spu->dispatch_table.LoadIdentity();
-					break;
-				
-				default:
-					cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
-					/* fall through */
-	
-				case GL_MODELVIEW:
-					cr_server.head_spu->dispatch_table.PushMatrix();
-					cr_server.head_spu->dispatch_table.LoadIdentity();
-					cr_server.head_spu->dispatch_table.MatrixMode(GL_PROJECTION);
-					cr_server.head_spu->dispatch_table.PushMatrix();
-					cr_server.head_spu->dispatch_table.LoadMatrixf((GLfloat *) baseProj);
-					cr_server.head_spu->dispatch_table.MultMatrixf(cr_server.unnormalized_alignment_matrix);
-					break;	
-		}
-	
-		/* fix state */
-		if (lighting)
-			cr_server.head_spu->dispatch_table.Disable(GL_LIGHTING);
-		if (fog)
-			cr_server.head_spu->dispatch_table.Disable(GL_FOG);
-		if (tex[0])
-			cr_server.head_spu->dispatch_table.Disable(GL_TEXTURE_1D);
-		if (tex[1])
-			cr_server.head_spu->dispatch_table.Disable(GL_TEXTURE_2D);
-		if (tex[2])
-			cr_server.head_spu->dispatch_table.Disable(GL_TEXTURE_3D);
-		if (cull)
-			cr_server.head_spu->dispatch_table.Disable(GL_CULL_FACE);
-
-		/* Regular Blending */
-		if (cr_server.overlapBlending == 1)
-		{
-			if (!blend)
-				cr_server.head_spu->dispatch_table.Enable(GL_BLEND);
-			if ((blendSrc != GL_ZERO) && (blendDst != GL_SRC_ALPHA))
-				cr_server.head_spu->dispatch_table.BlendFunc(GL_ZERO, GL_SRC_ALPHA);
-
-			/* draw the blends */
-			for (a=1; a<cr_server.num_overlap_levels; a++)
-			{
-				if (a-1 < cr_server.num_overlap_intens)
-				{
-					cr_server.head_spu->dispatch_table.Color4f(0, 0, 0, 
-											cr_server.overlap_intens[a-1]);
-				}
-				else
-				{
-					cr_server.head_spu->dispatch_table.Color4f(0, 0, 0, 1);
-				}
-		
-				p = cr_server.overlap_geom[a];
-				while (p)
-				{
-					/* hopefully this isnt concave... */
-					__draw_poly(p);
-					p = p->next;
-				}	
-			}
-
-			if (!blend)
-				cr_server.head_spu->dispatch_table.Disable(GL_BLEND);
-			if ((blendSrc != GL_ZERO) && (blendDst != GL_SRC_ALPHA))
-				cr_server.head_spu->dispatch_table.BlendFunc(blendSrc, blendDst);
-		}
-		else
-		/* Knockout Blending */
-		{
-			cr_server.head_spu->dispatch_table.Color4f(0, 0, 0, 1);
-
-			if (blend)
-				cr_server.head_spu->dispatch_table.Disable(GL_BLEND);
-			p = cr_server.overlap_knockout;
-			while (p)
-			{
-				__draw_poly(p);
-				p = p->next;
-			}	
-			if (blend)
-				cr_server.head_spu->dispatch_table.Enable(GL_BLEND);
-		}
-
-
-		/* return things to normal */
-		switch (mm)
-		{
-			case GL_PROJECTION:
-				cr_server.head_spu->dispatch_table.PopMatrix();
-				cr_server.head_spu->dispatch_table.MatrixMode(GL_PROJECTION);
-				cr_server.head_spu->dispatch_table.PopMatrix();
-				break;
-			case GL_MODELVIEW:
-				cr_server.head_spu->dispatch_table.PopMatrix();
-				cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
-				cr_server.head_spu->dispatch_table.PopMatrix();
-				break;
-			default:
-				cr_server.head_spu->dispatch_table.PopMatrix();
-				cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
-				cr_server.head_spu->dispatch_table.PopMatrix();
-				cr_server.head_spu->dispatch_table.MatrixMode(mm);
-				break;
-		}
-
-		if (lighting)
-			cr_server.head_spu->dispatch_table.Enable(GL_LIGHTING);
-		if (fog)
-			cr_server.head_spu->dispatch_table.Enable(GL_FOG);
-		if (tex[0])
-			cr_server.head_spu->dispatch_table.Enable(GL_TEXTURE_1D);
-		if (tex[1])
-			cr_server.head_spu->dispatch_table.Enable(GL_TEXTURE_2D);
-		if (tex[2])
-			cr_server.head_spu->dispatch_table.Enable(GL_TEXTURE_3D);
-		if (cull)
-			cr_server.head_spu->dispatch_table.Enable(GL_CULL_FACE);
-	
-		cr_server.head_spu->dispatch_table.Color4f(col.r, col.g, col.b, col.a);
-	}
-#endif
-
-	/* Check if using a file network */
-	if (!cr_server.clients[0]->conn->actual_network && window == MAGIC_OFFSET)
-		window = 0;
-
-	ctx = crStateGetCurrent();
-
-	CRASSERT(cr_server.curClient && cr_server.curClient->currentMural == mural);
-
-    if (ctx->framebufferobject.drawFB
-            || (ctx->buffer.drawBuffer != GL_FRONT && ctx->buffer.drawBuffer != GL_FRONT_LEFT))
-        mural->bFbDraw = GL_FALSE;
-
-    CR_SERVER_DUMP_SWAPBUFFERS_ENTER();
-
-    if (crServerIsRedirectedToFBO())
-    {
-        crServerMuralFBOSwapBuffers(mural);
-        crServerPresentFBO(mural);
-    }
-    else
-    {
-        cr_server.head_spu->dispatch_table.SwapBuffers( mural->spuWindow, flags );
-    }
-
-    CR_SERVER_DUMP_SWAPBUFFERS_LEAVE();
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchFlush(void)
-{
-    CRContext *ctx = crStateGetCurrent();
-    cr_server.head_spu->dispatch_table.Flush();
-
-    if (cr_server.curClient && cr_server.curClient->currentMural)
-    {
-        CRMuralInfo *mural = cr_server.curClient->currentMural;
-        if (mural->bFbDraw)
-        {
-            if (crServerIsRedirectedToFBO())
-                crServerPresentFBO(mural);
-        }
-
-        if (ctx->framebufferobject.drawFB
-                || (ctx->buffer.drawBuffer != GL_FRONT && ctx->buffer.drawBuffer != GL_FRONT_LEFT))
-            mural->bFbDraw = GL_FALSE;
-    }
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchFinish(void)
-{
-    CRContext *ctx = crStateGetCurrent();
-
-    cr_server.head_spu->dispatch_table.Finish();
-
-    if (cr_server.curClient && cr_server.curClient->currentMural)
-    {
-        CRMuralInfo *mural = cr_server.curClient->currentMural;
-        if (mural->bFbDraw)
-        {
-            if (crServerIsRedirectedToFBO())
-                crServerPresentFBO(mural);
-        }
-
-        if (ctx->framebufferobject.drawFB
-                || (ctx->buffer.drawBuffer != GL_FRONT && ctx->buffer.drawBuffer != GL_FRONT_LEFT))
-            mural->bFbDraw = GL_FALSE;
-    }
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clear.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clear.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clear.cpp	(revision 78190)
@@ -0,0 +1,492 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "cr_spu.h"
+#include "chromium.h"
+#include "cr_mem.h"
+#include "cr_net.h"
+#include "server_dispatch.h"
+#include "server.h"
+
+#ifdef VBOXCR_LOGFPS
+#include <iprt/timer.h>
+#include <iprt/ctype.h>
+typedef struct VBOXCRFPS
+{
+    uint64_t mPeriodSum;
+    uint64_t *mpaPeriods;
+    uint64_t mPrevTime;
+    uint64_t mcFrames;
+    uint32_t mcPeriods;
+    uint32_t miPeriod;
+
+    uint64_t mBytesSum;
+    uint32_t *mpaBytes;
+
+    uint64_t mBytesSentSum;
+    uint32_t *mpaBytesSent;
+
+    uint64_t mCallsSum;
+    uint32_t *mpaCalls;
+
+    uint64_t mOpsSum;
+    uint32_t *mpaOps;
+
+    uint64_t mTimeUsedSum;
+    uint64_t *mpaTimes;
+} VBOXCRFPS, *PVBOXCRFPS;
+
+void vboxCrFpsInit(PVBOXCRFPS pFps, uint32_t cPeriods)
+{
+    crMemset(pFps, 0, sizeof (*pFps));
+    pFps->mcPeriods = cPeriods;
+    pFps->mpaPeriods = crCalloc(sizeof (pFps->mpaPeriods[0]) * cPeriods);
+    pFps->mpaBytes = crCalloc(sizeof (pFps->mpaBytes[0]) * cPeriods);
+    pFps->mpaBytesSent = crCalloc(sizeof (pFps->mpaBytesSent[0]) * cPeriods);
+    pFps->mpaCalls = crCalloc(sizeof (pFps->mpaCalls[0]) * cPeriods);
+    pFps->mpaOps = crCalloc(sizeof (pFps->mpaOps[0]) * cPeriods);
+    pFps->mpaTimes = crCalloc(sizeof (pFps->mpaTimes[0]) * cPeriods);
+}
+
+void vboxCrFpsTerm(PVBOXCRFPS pFps)
+{
+    crFree(pFps->mpaPeriods);
+    crFree(pFps->mpaBytes);
+    crFree(pFps->mpaCalls);
+}
+
+void vboxCrFpsReportFrame(PVBOXCRFPS pFps)
+{
+    uint64_t cur = RTTimeNanoTS();
+    uint64_t curBytes, curBytesSent, curCalls, curOps, curTimeUsed;
+    int i;
+
+    curBytes = 0;
+    curBytesSent = 0;
+    curCalls = 0;
+    curOps = 0;
+    curTimeUsed = 0;
+
+    for (i = 0; i < cr_server.numClients; i++)
+    {
+        if (cr_server.clients[i] && cr_server.clients[i]->conn)
+        {
+            curBytes += cr_server.clients[i]->conn->total_bytes_recv;
+            curBytesSent += cr_server.clients[i]->conn->total_bytes_sent;
+            curCalls += cr_server.clients[i]->conn->recv_count;
+            curOps += cr_server.clients[i]->conn->opcodes_count;
+            curTimeUsed += cr_server.clients[i]->timeUsed;
+            cr_server.clients[i]->conn->total_bytes_recv = 0;
+            cr_server.clients[i]->conn->total_bytes_sent = 0;
+            cr_server.clients[i]->conn->recv_count = 0;
+            cr_server.clients[i]->conn->opcodes_count = 0;
+            cr_server.clients[i]->timeUsed = 0;
+        }
+    }
+
+    if(pFps->mPrevTime)
+    {
+        uint64_t curPeriod = cur - pFps->mPrevTime;
+
+        pFps->mPeriodSum += curPeriod - pFps->mpaPeriods[pFps->miPeriod];
+        pFps->mpaPeriods[pFps->miPeriod] = curPeriod;
+
+        pFps->mBytesSum += curBytes - pFps->mpaBytes[pFps->miPeriod];
+        pFps->mpaBytes[pFps->miPeriod] = curBytes;
+
+        pFps->mBytesSentSum += curBytesSent - pFps->mpaBytesSent[pFps->miPeriod];
+        pFps->mpaBytesSent[pFps->miPeriod] = curBytesSent;
+
+        pFps->mCallsSum += curCalls - pFps->mpaCalls[pFps->miPeriod];
+        pFps->mpaCalls[pFps->miPeriod] = curCalls;
+
+        pFps->mOpsSum += curOps - pFps->mpaOps[pFps->miPeriod];
+        pFps->mpaOps[pFps->miPeriod] = curOps;
+
+        pFps->mTimeUsedSum += curTimeUsed - pFps->mpaTimes[pFps->miPeriod];
+        pFps->mpaTimes[pFps->miPeriod] = curTimeUsed;
+
+        ++pFps->miPeriod;
+        pFps->miPeriod %= pFps->mcPeriods;
+    }
+    pFps->mPrevTime = cur;
+    ++pFps->mcFrames;
+}
+
+uint64_t vboxCrFpsGetEveragePeriod(PVBOXCRFPS pFps)
+{
+    return pFps->mPeriodSum / pFps->mcPeriods;
+}
+
+double vboxCrFpsGetFps(PVBOXCRFPS pFps)
+{
+    return ((double)1000000000.0) / vboxCrFpsGetEveragePeriod(pFps);
+}
+
+double vboxCrFpsGetBps(PVBOXCRFPS pFps)
+{
+    return vboxCrFpsGetFps(pFps) * pFps->mBytesSum / pFps->mcPeriods;
+}
+
+double vboxCrFpsGetBpsSent(PVBOXCRFPS pFps)
+{
+    return vboxCrFpsGetFps(pFps) * pFps->mBytesSentSum / pFps->mcPeriods;
+}
+
+double vboxCrFpsGetCps(PVBOXCRFPS pFps)
+{
+    return vboxCrFpsGetFps(pFps) * pFps->mCallsSum / pFps->mcPeriods;
+}
+
+double vboxCrFpsGetOps(PVBOXCRFPS pFps)
+{
+    return vboxCrFpsGetFps(pFps) * pFps->mOpsSum / pFps->mcPeriods;
+}
+
+double vboxCrFpsGetTimeProcPercent(PVBOXCRFPS pFps)
+{
+    return 100.0*pFps->mTimeUsedSum/pFps->mPeriodSum;
+}
+
+uint64_t vboxCrFpsGetNumFrames(PVBOXCRFPS pFps)
+{
+    return pFps->mcFrames;
+}
+
+#endif
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchClear( GLenum mask )
+{
+	CRMuralInfo *mural = cr_server.curClient->currentMural;
+	const RunQueue *q = cr_server.run_queue;
+
+	if (cr_server.only_swap_once)
+	{
+		/* NOTE: we only do the clear for the _last_ client in the list.
+		 * This is because in multi-threaded apps the zeroeth client may
+		 * be idle and never call glClear at all.  See threadtest.c
+		 * It's pretty likely that the last client will be active.
+		 */
+		if ((mask & GL_COLOR_BUFFER_BIT) &&
+			(cr_server.curClient != cr_server.clients[cr_server.numClients - 1]))
+		   return;
+	}
+
+	cr_server.head_spu->dispatch_table.Clear( mask );
+}
+
+static void __draw_poly(CRPoly *p)
+{
+	int b;
+
+	cr_server.head_spu->dispatch_table.Begin(GL_POLYGON);
+	for (b=0; b<p->npoints; b++)
+		cr_server.head_spu->dispatch_table.Vertex2dv(p->points+2*b);
+	cr_server.head_spu->dispatch_table.End();
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchSwapBuffers( GLint window, GLint flags )
+{
+  CRMuralInfo *mural;
+  CRContext *ctx;
+
+#ifdef VBOXCR_LOGFPS
+  static VBOXCRFPS Fps;
+  static bool bFpsInited = false;
+
+  if (!bFpsInited)
+  {
+      vboxCrFpsInit(&Fps, 64 /* cPeriods */);
+      bFpsInited = true;
+  }
+  vboxCrFpsReportFrame(&Fps);
+  if(!(vboxCrFpsGetNumFrames(&Fps) % 31))
+  {
+      double fps = vboxCrFpsGetFps(&Fps);
+      double bps = vboxCrFpsGetBps(&Fps);
+      double bpsSent = vboxCrFpsGetBpsSent(&Fps);
+      double cps = vboxCrFpsGetCps(&Fps);
+      double ops = vboxCrFpsGetOps(&Fps);
+      double tup = vboxCrFpsGetTimeProcPercent(&Fps);
+      crDebug("fps: %f, rec Mbps: %.1f, send Mbps: %.1f, cps: %.1f, ops: %.0f, host %.1f%%", 
+              fps, bps/(1024.0*1024.0), bpsSent/(1024.0*1024.0), cps, ops, tup);
+  }
+#endif
+	mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
+	if (!mural) {
+		 return;
+	}
+
+
+	if (cr_server.only_swap_once)
+	{
+		/* NOTE: we only do the clear for the _last_ client in the list.
+		 * This is because in multi-threaded apps the zeroeth client may
+		 * be idle and never call glClear at all.  See threadtest.c
+		 * It's pretty likely that the last client will be active.
+		 */
+		if (cr_server.curClient != cr_server.clients[cr_server.numClients - 1])
+		{
+			return;
+		}
+	}
+
+#if 0
+	if (cr_server.overlapBlending)
+	{
+		int a;
+		CRPoly *p;
+		GLboolean lighting, fog, blend, cull, tex[3];
+		GLenum mm, blendSrc, blendDst;
+		GLcolorf col;
+		CRContext *ctx = crStateGetCurrent();
+		const CRmatrix *baseProj;
+
+		/* 
+		 * I've probably missed some state here, or it
+	 	 * might be easier just to push/pop it....
+		 */
+		lighting = ctx->lighting.lighting;
+		fog		 = ctx->fog.enable;
+		tex[0] = 0;
+		for (a=0; a<CR_MAX_TEXTURE_UNITS; a++)
+		{
+			if (!ctx->texture.unit[a].enabled1D) continue;
+	
+			tex[0] 	 = 1;
+			break;
+		}
+		tex[1] = 0;
+		for	(a=0; a<CR_MAX_TEXTURE_UNITS; a++)
+		{
+			if (!ctx->texture.unit[a].enabled2D) continue;
+
+			tex[1] 	 = 1;
+			break;
+		}
+		tex[2] = 0;
+		for (a=0; a<CR_MAX_TEXTURE_UNITS; a++)
+		{	
+			if (!ctx->texture.unit[a].enabled3D) continue;
+	
+			tex[2] 	 = 1;
+			break;
+		}
+
+		cull	 = ctx->polygon.cullFace;
+		blend	 = ctx->buffer.blend;
+		blendSrc = ctx->buffer.blendSrcRGB;
+		blendDst = ctx->buffer.blendDstRGB;
+		mm = ctx->transform.matrixMode;
+		col.r = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][0];
+		col.g = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][1];
+		col.b = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][2];
+		col.a = ctx->current.vertexAttrib[VERT_ATTRIB_COLOR0][3];
+
+		baseProj = &(cr_server.curClient->currentMural->extents[0].baseProjection);
+	
+		switch(mm)
+		{
+				case GL_PROJECTION:
+					cr_server.head_spu->dispatch_table.PushMatrix();
+					cr_server.head_spu->dispatch_table.LoadMatrixf((GLfloat *) baseProj);
+					cr_server.head_spu->dispatch_table.MultMatrixf(cr_server.unnormalized_alignment_matrix);
+					cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
+					cr_server.head_spu->dispatch_table.PushMatrix();
+					cr_server.head_spu->dispatch_table.LoadIdentity();
+					break;
+				
+				default:
+					cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
+					/* fall through */
+	
+				case GL_MODELVIEW:
+					cr_server.head_spu->dispatch_table.PushMatrix();
+					cr_server.head_spu->dispatch_table.LoadIdentity();
+					cr_server.head_spu->dispatch_table.MatrixMode(GL_PROJECTION);
+					cr_server.head_spu->dispatch_table.PushMatrix();
+					cr_server.head_spu->dispatch_table.LoadMatrixf((GLfloat *) baseProj);
+					cr_server.head_spu->dispatch_table.MultMatrixf(cr_server.unnormalized_alignment_matrix);
+					break;	
+		}
+	
+		/* fix state */
+		if (lighting)
+			cr_server.head_spu->dispatch_table.Disable(GL_LIGHTING);
+		if (fog)
+			cr_server.head_spu->dispatch_table.Disable(GL_FOG);
+		if (tex[0])
+			cr_server.head_spu->dispatch_table.Disable(GL_TEXTURE_1D);
+		if (tex[1])
+			cr_server.head_spu->dispatch_table.Disable(GL_TEXTURE_2D);
+		if (tex[2])
+			cr_server.head_spu->dispatch_table.Disable(GL_TEXTURE_3D);
+		if (cull)
+			cr_server.head_spu->dispatch_table.Disable(GL_CULL_FACE);
+
+		/* Regular Blending */
+		if (cr_server.overlapBlending == 1)
+		{
+			if (!blend)
+				cr_server.head_spu->dispatch_table.Enable(GL_BLEND);
+			if ((blendSrc != GL_ZERO) && (blendDst != GL_SRC_ALPHA))
+				cr_server.head_spu->dispatch_table.BlendFunc(GL_ZERO, GL_SRC_ALPHA);
+
+			/* draw the blends */
+			for (a=1; a<cr_server.num_overlap_levels; a++)
+			{
+				if (a-1 < cr_server.num_overlap_intens)
+				{
+					cr_server.head_spu->dispatch_table.Color4f(0, 0, 0, 
+											cr_server.overlap_intens[a-1]);
+				}
+				else
+				{
+					cr_server.head_spu->dispatch_table.Color4f(0, 0, 0, 1);
+				}
+		
+				p = cr_server.overlap_geom[a];
+				while (p)
+				{
+					/* hopefully this isnt concave... */
+					__draw_poly(p);
+					p = p->next;
+				}	
+			}
+
+			if (!blend)
+				cr_server.head_spu->dispatch_table.Disable(GL_BLEND);
+			if ((blendSrc != GL_ZERO) && (blendDst != GL_SRC_ALPHA))
+				cr_server.head_spu->dispatch_table.BlendFunc(blendSrc, blendDst);
+		}
+		else
+		/* Knockout Blending */
+		{
+			cr_server.head_spu->dispatch_table.Color4f(0, 0, 0, 1);
+
+			if (blend)
+				cr_server.head_spu->dispatch_table.Disable(GL_BLEND);
+			p = cr_server.overlap_knockout;
+			while (p)
+			{
+				__draw_poly(p);
+				p = p->next;
+			}	
+			if (blend)
+				cr_server.head_spu->dispatch_table.Enable(GL_BLEND);
+		}
+
+
+		/* return things to normal */
+		switch (mm)
+		{
+			case GL_PROJECTION:
+				cr_server.head_spu->dispatch_table.PopMatrix();
+				cr_server.head_spu->dispatch_table.MatrixMode(GL_PROJECTION);
+				cr_server.head_spu->dispatch_table.PopMatrix();
+				break;
+			case GL_MODELVIEW:
+				cr_server.head_spu->dispatch_table.PopMatrix();
+				cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
+				cr_server.head_spu->dispatch_table.PopMatrix();
+				break;
+			default:
+				cr_server.head_spu->dispatch_table.PopMatrix();
+				cr_server.head_spu->dispatch_table.MatrixMode(GL_MODELVIEW);
+				cr_server.head_spu->dispatch_table.PopMatrix();
+				cr_server.head_spu->dispatch_table.MatrixMode(mm);
+				break;
+		}
+
+		if (lighting)
+			cr_server.head_spu->dispatch_table.Enable(GL_LIGHTING);
+		if (fog)
+			cr_server.head_spu->dispatch_table.Enable(GL_FOG);
+		if (tex[0])
+			cr_server.head_spu->dispatch_table.Enable(GL_TEXTURE_1D);
+		if (tex[1])
+			cr_server.head_spu->dispatch_table.Enable(GL_TEXTURE_2D);
+		if (tex[2])
+			cr_server.head_spu->dispatch_table.Enable(GL_TEXTURE_3D);
+		if (cull)
+			cr_server.head_spu->dispatch_table.Enable(GL_CULL_FACE);
+	
+		cr_server.head_spu->dispatch_table.Color4f(col.r, col.g, col.b, col.a);
+	}
+#endif
+
+	/* Check if using a file network */
+	if (!cr_server.clients[0]->conn->actual_network && window == MAGIC_OFFSET)
+		window = 0;
+
+	ctx = crStateGetCurrent();
+
+	CRASSERT(cr_server.curClient && cr_server.curClient->currentMural == mural);
+
+    if (ctx->framebufferobject.drawFB
+            || (ctx->buffer.drawBuffer != GL_FRONT && ctx->buffer.drawBuffer != GL_FRONT_LEFT))
+        mural->bFbDraw = GL_FALSE;
+
+    CR_SERVER_DUMP_SWAPBUFFERS_ENTER();
+
+    if (crServerIsRedirectedToFBO())
+    {
+        crServerMuralFBOSwapBuffers(mural);
+        crServerPresentFBO(mural);
+    }
+    else
+    {
+        cr_server.head_spu->dispatch_table.SwapBuffers( mural->spuWindow, flags );
+    }
+
+    CR_SERVER_DUMP_SWAPBUFFERS_LEAVE();
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchFlush(void)
+{
+    CRContext *ctx = crStateGetCurrent();
+    cr_server.head_spu->dispatch_table.Flush();
+
+    if (cr_server.curClient && cr_server.curClient->currentMural)
+    {
+        CRMuralInfo *mural = cr_server.curClient->currentMural;
+        if (mural->bFbDraw)
+        {
+            if (crServerIsRedirectedToFBO())
+                crServerPresentFBO(mural);
+        }
+
+        if (ctx->framebufferobject.drawFB
+                || (ctx->buffer.drawBuffer != GL_FRONT && ctx->buffer.drawBuffer != GL_FRONT_LEFT))
+            mural->bFbDraw = GL_FALSE;
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchFinish(void)
+{
+    CRContext *ctx = crStateGetCurrent();
+
+    cr_server.head_spu->dispatch_table.Finish();
+
+    if (cr_server.curClient && cr_server.curClient->currentMural)
+    {
+        CRMuralInfo *mural = cr_server.curClient->currentMural;
+        if (mural->bFbDraw)
+        {
+            if (crServerIsRedirectedToFBO())
+                crServerPresentFBO(mural);
+        }
+
+        if (ctx->framebufferobject.drawFB
+                || (ctx->buffer.drawBuffer != GL_FRONT && ctx->buffer.drawBuffer != GL_FRONT_LEFT))
+            mural->bFbDraw = GL_FALSE;
+    }
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clip.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clip.c	(revision 78189)
+++ 	(revision )
@@ -1,588 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-/*
- * This code contributed by Karl Rasche <rkarl@vr.clemson.edu>
- */
-
-
-#include <math.h>
-
-#include "cr_server.h"
-#include "cr_mem.h"
-#include "server.h"
-
-
-static void
-__find_intersection(double *s, double *e, double *clp, double *clp_next,
-										double *intr)
-{
-	double v1[2], v2[2];
-	double A, B, T;
-
-	v1[0] = e[0] - s[0];
-	v1[1] = e[1] - s[1];
-	v2[0] = clp_next[0] - clp[0];
-	v2[1] = clp_next[1] - clp[1];
-	
-	if ((v1[1]) && (v2[0]))
-	{
-		A =  (clp[1]-s[1])/v1[1] + (v2[1]/v1[1])*(s[0]-clp[0])/v2[0];
-		B = 1.-(v2[1]/v1[1])*(v1[0]/v2[0]);
-		if (B)
-			T = A/B;
-		else
-		{
-			T = 0;
-		}
-
-		intr[0] = s[0]+T*v1[0];
-		intr[1] = s[1]+T*v1[1];
-	}
-	else
-	if (v1[1])
-	{
-		/* clp -> clp_next is vertical */
-		T = (clp[0]-s[0])/v1[0];
-
-		intr[0] = s[0]+T*v1[0];
-		intr[1] = s[1]+T*v1[1];
-	}
-	else
-	{
-		/* s -> e is horizontal */
-		T = (s[1]-clp[1])/v2[1];
-
-		intr[0] = clp[0]+T*v2[0];
-		intr[1] = clp[1]+T*v2[1];
-	}
-
-}
-
-static void
- __clip_one_side(double *poly, int npnts, double *clp, double *clp_next,
-								 double *norm, 
-								 double **new_poly_in, int *new_npnts_in,
-								 double **new_poly_out, int *new_npnts_out)
-{
-	int a, sin, ein;
-	double *s, *e, intr[2]; 
-	
-	*new_poly_in  = (double *)crAlloc(2*npnts*2*sizeof(double));
-	*new_npnts_in = 0;
-
-	*new_poly_out  = (double *)crAlloc(2*npnts*2*sizeof(double));
-	*new_npnts_out = 0;
-
-	s = poly;
-
-	for (a=0; a<npnts; a++)
-	{
-		e = poly+2*((a+1)%npnts);
-
-		if (((e[0]-clp[0])*norm[0]) + ((e[1]-clp[1])*norm[1]) >= 0)
-			ein = 0;
-		else
-			ein = 1;
-
-		if (((s[0]-clp[0])*norm[0]) + ((s[1]-clp[1])*norm[1]) >= 0)
-			sin = 0;
-		else
-			sin = 1;
-	
-		if (sin && ein)
-		{
-			/* case 1: */
-			crMemcpy(*new_poly_in+2*(*new_npnts_in), e, 2*sizeof(double));
-			(*new_npnts_in)++;
-		}
-		else
-		if (sin && (!ein))
-		{
-			/* case 2: */
-
-			__find_intersection(s, e, clp, clp_next, intr);
-
-			crMemcpy(*new_poly_in+2*(*new_npnts_in), intr, 2*sizeof(double));
-			(*new_npnts_in)++;
-
-			crMemcpy(*new_poly_out+2*(*new_npnts_out), intr, 2*sizeof(double));
-			(*new_npnts_out)++;
-			crMemcpy(*new_poly_out+2*(*new_npnts_out), e, 2*sizeof(double));
-			(*new_npnts_out)++;
-		}
-		else
-		if ((!sin) && ein)
-		{
-			/* case 4: */
-			__find_intersection(s, e, clp, clp_next, intr);
-
-			crMemcpy((*new_poly_in)+2*(*new_npnts_in), intr, 2*sizeof(double));
-			(*new_npnts_in)++;
-			crMemcpy((*new_poly_in)+2*(*new_npnts_in), e, 2*sizeof(double));
-			(*new_npnts_in)++;
-
-			crMemcpy(*new_poly_out+2*(*new_npnts_out), intr, 2*sizeof(double));
-			(*new_npnts_out)++;
-		}
-		else
-		{
-			crMemcpy(*new_poly_out+2*(*new_npnts_out), e, 2*sizeof(double));
-			(*new_npnts_out)++;
-		}
-
-		s =  e;
-	}
-}
-
-/* 
- * Sutherland/Hodgman clipping for interior & exterior regions. 
- * length_of((*new_vert_out)[a]) == nclip_to_vert
- */
-static void
-__clip(double *poly, int nvert, double *clip_to_poly, int nclip_to_vert,
-			 double **new_vert_in, int *nnew_vert_in,
-			 double ***new_vert_out, int **nnew_vert_out)
-{
-	int a, side, *nout;
-	double *clip_normals, *s, *e, *n, *new_vert_src; 
-	double *norm, *clp, *clp_next;
- 	double **out;
-	
-	*new_vert_out = (double **)crAlloc(nclip_to_vert*sizeof(double *));
-	*nnew_vert_out = (int *)crAlloc(nclip_to_vert*sizeof(int));
-
-	/* 
-	 * First, compute normals for the clip poly. This 
-	 * breaks for multiple (3+) adjacent colinear vertices
- 	 */
-	clip_normals = (double *)crAlloc(nclip_to_vert*2*sizeof(double));
-	for (a=0; a<nclip_to_vert; a++)
-	{
-		s = clip_to_poly+2*a;
-		e = clip_to_poly+2*((a+1)%nclip_to_vert);
-		n = clip_to_poly+2*((a+2)%nclip_to_vert);
-
-		norm = clip_normals+2*a;
-		norm[0]   = e[1]-s[1];
-		norm[1] = -1*(e[0]-s[0]);
-		
-		/* 
-		 * if dot(norm, n-e) > 0), the normals are backwards,
-		 * 	assuming the clip region is convex 
-		 */ 
-		if (norm[0]*(n[0]-e[0]) + norm[1]*(n[1]-e[1]) > 0)
-		{
-			norm[0] *= -1;
-			norm[1] *= -1;
-		}
-	}
-
-	new_vert_src  = (double *)crAlloc(nvert*nclip_to_vert*2*sizeof(double));
-	crMemcpy(new_vert_src, poly, 2*nvert*sizeof(double));
-
-	for (side=0; side<nclip_to_vert; side++)
-	{
-		clp      = clip_to_poly+2*side;
-		clp_next = clip_to_poly+2*((side+1)%nclip_to_vert);
-		norm = clip_normals+2*side;
-		*nnew_vert_in = 0;
-
-		nout = (*nnew_vert_out)+side;
-		out  = (*new_vert_out)+side;
-
-	 	__clip_one_side(new_vert_src, nvert, clp, clp_next, norm,
-				new_vert_in, nnew_vert_in, 
-				out, nout);
-
-		crMemcpy(new_vert_src, (*new_vert_in), 2*(*nnew_vert_in)*sizeof(double));
-		if (side != nclip_to_vert-1)
-			crFree(*new_vert_in);
-		nvert = *nnew_vert_in;
-	}
-}
-
-/* 
- * Given a bitmap and a group of 'base' polygons [the quads we are testing],
- * perform the unions and differences specified by the map and return
- * the resulting geometry
- */
-static void
-__execute_combination(CRPoly **base, int n, int *mask, CRPoly **head)
-{
-	int a, b, got_intr;
-	int nin, *nout, last;
-	double *in, **out;
-	CRPoly *intr, *diff, *p;
-
-	*head = NULL;
-
-	intr = (CRPoly *)crAlloc(sizeof(CRPoly));
-	intr->next = NULL;
-
-	got_intr = 0;
-
-	/* first, intersect the first 2 polys marked */
-	for (a=0; a<n; a++)
-		if (mask[a]) break;
-	for (b=a+1; b<n; b++)
-		if (mask[b]) break;
-
-	__clip(base[a]->points, base[a]->npoints, 
-				base[b]->points, base[b]->npoints,
-				&in, &nin, &out, &nout);
-	last = b;
-
-	crFree (nout);
-	for (a=0; a<base[last]->npoints; a++)
-		if (out[a])
-			crFree(out[a]);
-	crFree(out);
-					
-
-	if (nin)
-	{
-		intr->npoints = nin;
-		intr->points = in;
-		got_intr = 1;
-	}
-
-	while (1)
-	{
-		for (a=last+1; a<n; a++)
-			if (mask[a]) break;
-
-		if (a == n) break;
-
-		if (got_intr)
-		{
-			__clip(base[a]->points, base[a]->npoints, 
-					intr->points, intr->npoints,
-					&in, &nin, &out, &nout);
-
-			crFree (nout);
-			for (b=0; b<intr->npoints; b++)
-				if (out[b])
-					crFree(out[b]);
-			crFree(out);
-
-			if (nin)
-			{
-				intr->npoints = nin;
-				intr->points = in;
-			}
-			else
-			{
-				got_intr = 0;
-				break;
-			}
-		}
-		else
-		{
-			__clip(base[a]->points, base[a]->npoints, 
-					base[last]->points, base[last]->npoints,
-					&in, &nin, &out, &nout);
-			
-			crFree (nout);
-			for (b=0; b<base[last]->npoints; b++)
-			{
-				if (out[b])
-					crFree(out[b]);
-			}
-			crFree(out);
-
-
-			if (nin)
-			{
-				intr->npoints = nin;
-				intr->points = in;
-				got_intr = 1;
-			}
-		}
-
-		last = a;
-		if (a == n) break;
-	}
-
-	/* can't subtract something from nothing! */
-	if (got_intr)
-		*head = intr;
-	else
-		return;
-	
-	/* find the first item to subtract */
-	for (a=0; a<n; a++)
-		if (!mask[a]) break;
-
-	if (a == n) return;
-	last = a;
-
-	/* and subtract it */
-	diff = NULL;
-	__clip(intr->points, intr->npoints,
-				base[last]->points, base[last]->npoints, 
-				&in, &nin, &out, &nout);
-
-	crFree(in);
-
-	for (a=0; a<base[last]->npoints; a++)	
-	{
-		if (!nout[a]) continue;
-
-		p = (CRPoly *)crAlloc(sizeof(CRPoly));
-		p->npoints = nout[a];
-		p->points  = out[a];
-		p->next = diff;
-		diff = p;
-	}
-	*head = diff;
-
-	while (1)
-	{
-		intr = diff;
-		diff = NULL;
-
-		for (a=last+1; a<n; a++)
-			if (!mask[a]) break;
-		if (a == n) return;
-
-		last = a;
-
-		/* subtract mask[a] from everything in intr and
-		 * plop it into diff */
-		while (intr)
-		{
-			__clip(intr->points, intr->npoints,
-				base[last]->points, base[last]->npoints, 
-				&in, &nin, &out, &nout);
-
-			crFree(in);
-
-			for (a=0; a<base[last]->npoints; a++)	
-			{
-				if (!nout[a]) continue;
-
-				p = (CRPoly *)crAlloc(sizeof(CRPoly));
-				p->npoints = nout[a];
-				p->points  = out[a];
-				p->next = diff;
-				diff = p;
-			}
-
-			intr = intr->next;
-		}
-
-		*head = diff;
-	}	
-
-}
-
-/*
- * Here we generate all valid bitmaps to represent union/difference
- * combinations. Each bitmap is N elements long, where N is the 
- * number of polys [quads] that we are testing for overlap
- */
-static void
-__generate_masks(int n, int ***mask, int *nmasks)
-{
-	int a, b, c, d, e;
-	int i, idx, isec_size, add;
-
-	*mask = (int **)crAlloc((unsigned int)pow(2, n)*sizeof(int));
-	for (a=0; a<pow(2, n); a++)
-		(*mask)[a] = (int *)crAlloc(n*sizeof(int));
-
-	/* compute combinations */
-	idx = 0;
-	for (isec_size=1; isec_size<n; isec_size++)
-	{
-		for (a=0; a<n; a++)
-		{
-			for (b=a+1; b<n; b++)
-			{
-				crMemset((*mask)[idx], 0, n*sizeof(int));
-				(*mask)[idx][a] = 1;
-
-				add = 1;
-				for (c=0; c<isec_size; c++)
-				{
-					i = (b+c) % n;
-					if (i == a) add = 0;
-						
-					(*mask)[idx][i] = 1;	
-				}
-
-				/* dup check */
-				if ((add) && (idx))
-				{
-					for (d=0; d<idx; d++)
-					{
-						add = 0;
-						for (e=0; e<n; e++)
-						{
-							if ((*mask)[idx][e] != (*mask)[d][e]) 
-								add = 1;
-						}
-
-						if (!add)
-							break;
-					}
-				}
-
-				if (add) 
-					idx++;
-			}
-		}
-	}
-
-	*nmasks = idx;
-}
-
-/* 
- * To compute the overlap between a series of quads (This should work 
- * for n-gons, but we'll only need quads..), first generate a series of 
- * bitmaps that represent which elements to union together, and which
- * to difference. This goes into 'mask'. We then evaluate each bitmap with
- * Sutherland-Hodgman clipping to find the interior (union) and exterior
- * (difference) regions.
- *
- * In the map, 1 == union, 0 == difference
- *
- * (*res)[a] is the head of a poly list for all the polys that convert 
- * regions of overlap between a+1 polys ((*res)[0] == NULL)
- */ 
-void
-crComputeOverlapGeom(double *quads, int nquad, CRPoly ***res)
-{
-	int a, b, idx, isec_size, **mask;
-	CRPoly *p, *next, **base;
-	
-	base = (CRPoly **)crAlloc(nquad*sizeof(CRPoly *));
-	for (a=0; a<nquad; a++)
-	{
-		p = (CRPoly *)crAlloc(sizeof(CRPoly));
-		p->npoints = 4;
-		p->points  = (double *)crAlloc(8*sizeof(double));
-		for (b=0; b<8; b++)
-		{
-			p->points[b] = quads[8*a+b];
-		}
-		p->next = NULL;
-		base[a] = p;
-	}
-	
-	*res = (CRPoly **)crAlloc(nquad*sizeof(CRPoly *));
-	for (a=0; a<nquad; a++)
-		(*res)[a] = NULL;
-	
-	__generate_masks(nquad, &mask, &idx);
-
-	for (a=0; a<idx; a++)
-	{
-		isec_size = 0;
-		for (b=0; b<nquad; b++)
-			if (mask[a][b]) isec_size++;
-		isec_size--;
-
-		__execute_combination(base, nquad, mask[a], &p);
-	
-		while (p)
-		{
-			next = p->next;
-			
-			p->next = (*res)[isec_size];
-			(*res)[isec_size] = p;
-			
-			p = next;
-		}
-	}
-
-	for (a=0; a<nquad; a++)
-	{
-		crFree(base[a]->points);
-		crFree(base[a]);
-	}
-	crFree(base);		
-
-}
-
-/*
- * This is similar to ComputeOverlapGeom above, but for "knockout" 
- * edge blending. 
- *
- * my_quad_idx is an index of quads indicating which display tile 
- * we are computing geometry for. From this, we either generate
- * geometry, or not, such that all geometry can be drawn in black 
- * and only one tile will show through the blend as non-black.
- *
- * To add a combination to our set of geom, we must test that:
- * 		+ mask[a][my_quad_idx] is set
- * 		+ mask[a][my_quad_idx] is not the first element set in
- * 			mask[a].
- * If these conditions hold, execute mask[a] and draw the resulting
- * geometry in black
- *
- * Unlike ComputeOverlapGeom, res is just a list of polys to draw in black
- */ 	
-void
-crComputeKnockoutGeom(double *quads, int nquad, int my_quad_idx, CRPoly **res)
-{
-	int a, b, idx, first, **mask;
-	CRPoly *p, *next, **base;
-	
-	base = (CRPoly **) crAlloc(nquad*sizeof(CRPoly *));
-	for (a=0; a<nquad; a++)
-	{
-		p = (CRPoly *) crAlloc(sizeof(CRPoly));
-		p->npoints = 4;
-		p->points  = (double *) crAlloc(8*sizeof(double));
-		for (b=0; b<8; b++)
-		{
-			p->points[b] = quads[8*a+b];
-		}
-		p->next = NULL;
-		base[a] = p;
-	}
-	
-	(*res) = NULL;
-	
-	__generate_masks(nquad, &mask, &idx);
-
-	for (a=0; a<idx; a++)
-	{
-		/* test for above conditions */
-		if (!mask[a][my_quad_idx]) continue;	
-
-		first = -1;
-		for (b=0; b<nquad; b++)
-			if (mask[a][b]) 
-			{
-				first = b;
-				break;
-			}
-		if (first == my_quad_idx) continue;
-
-
-		__execute_combination(base, nquad, mask[a], &p);
-	
-		while (p)
-		{
-			next = p->next;
-			
-			p->next = *res;
-			*res = p;
-			
-			p = next;
-		}
-	}
-
-	for (a=0; a<nquad; a++)
-	{
-		crFree(base[a]->points);
-		crFree(base[a]);
-	}
-	crFree(base);		
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clip.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clip.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_clip.cpp	(revision 78190)
@@ -0,0 +1,588 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+/*
+ * This code contributed by Karl Rasche <rkarl@vr.clemson.edu>
+ */
+
+
+#include <math.h>
+
+#include "cr_server.h"
+#include "cr_mem.h"
+#include "server.h"
+
+
+static void
+__find_intersection(double *s, double *e, double *clp, double *clp_next,
+										double *intr)
+{
+	double v1[2], v2[2];
+	double A, B, T;
+
+	v1[0] = e[0] - s[0];
+	v1[1] = e[1] - s[1];
+	v2[0] = clp_next[0] - clp[0];
+	v2[1] = clp_next[1] - clp[1];
+	
+	if ((v1[1]) && (v2[0]))
+	{
+		A =  (clp[1]-s[1])/v1[1] + (v2[1]/v1[1])*(s[0]-clp[0])/v2[0];
+		B = 1.-(v2[1]/v1[1])*(v1[0]/v2[0]);
+		if (B)
+			T = A/B;
+		else
+		{
+			T = 0;
+		}
+
+		intr[0] = s[0]+T*v1[0];
+		intr[1] = s[1]+T*v1[1];
+	}
+	else
+	if (v1[1])
+	{
+		/* clp -> clp_next is vertical */
+		T = (clp[0]-s[0])/v1[0];
+
+		intr[0] = s[0]+T*v1[0];
+		intr[1] = s[1]+T*v1[1];
+	}
+	else
+	{
+		/* s -> e is horizontal */
+		T = (s[1]-clp[1])/v2[1];
+
+		intr[0] = clp[0]+T*v2[0];
+		intr[1] = clp[1]+T*v2[1];
+	}
+
+}
+
+static void
+ __clip_one_side(double *poly, int npnts, double *clp, double *clp_next,
+								 double *norm, 
+								 double **new_poly_in, int *new_npnts_in,
+								 double **new_poly_out, int *new_npnts_out)
+{
+	int a, sin, ein;
+	double *s, *e, intr[2]; 
+	
+	*new_poly_in  = (double *)crAlloc(2*npnts*2*sizeof(double));
+	*new_npnts_in = 0;
+
+	*new_poly_out  = (double *)crAlloc(2*npnts*2*sizeof(double));
+	*new_npnts_out = 0;
+
+	s = poly;
+
+	for (a=0; a<npnts; a++)
+	{
+		e = poly+2*((a+1)%npnts);
+
+		if (((e[0]-clp[0])*norm[0]) + ((e[1]-clp[1])*norm[1]) >= 0)
+			ein = 0;
+		else
+			ein = 1;
+
+		if (((s[0]-clp[0])*norm[0]) + ((s[1]-clp[1])*norm[1]) >= 0)
+			sin = 0;
+		else
+			sin = 1;
+	
+		if (sin && ein)
+		{
+			/* case 1: */
+			crMemcpy(*new_poly_in+2*(*new_npnts_in), e, 2*sizeof(double));
+			(*new_npnts_in)++;
+		}
+		else
+		if (sin && (!ein))
+		{
+			/* case 2: */
+
+			__find_intersection(s, e, clp, clp_next, intr);
+
+			crMemcpy(*new_poly_in+2*(*new_npnts_in), intr, 2*sizeof(double));
+			(*new_npnts_in)++;
+
+			crMemcpy(*new_poly_out+2*(*new_npnts_out), intr, 2*sizeof(double));
+			(*new_npnts_out)++;
+			crMemcpy(*new_poly_out+2*(*new_npnts_out), e, 2*sizeof(double));
+			(*new_npnts_out)++;
+		}
+		else
+		if ((!sin) && ein)
+		{
+			/* case 4: */
+			__find_intersection(s, e, clp, clp_next, intr);
+
+			crMemcpy((*new_poly_in)+2*(*new_npnts_in), intr, 2*sizeof(double));
+			(*new_npnts_in)++;
+			crMemcpy((*new_poly_in)+2*(*new_npnts_in), e, 2*sizeof(double));
+			(*new_npnts_in)++;
+
+			crMemcpy(*new_poly_out+2*(*new_npnts_out), intr, 2*sizeof(double));
+			(*new_npnts_out)++;
+		}
+		else
+		{
+			crMemcpy(*new_poly_out+2*(*new_npnts_out), e, 2*sizeof(double));
+			(*new_npnts_out)++;
+		}
+
+		s =  e;
+	}
+}
+
+/* 
+ * Sutherland/Hodgman clipping for interior & exterior regions. 
+ * length_of((*new_vert_out)[a]) == nclip_to_vert
+ */
+static void
+__clip(double *poly, int nvert, double *clip_to_poly, int nclip_to_vert,
+			 double **new_vert_in, int *nnew_vert_in,
+			 double ***new_vert_out, int **nnew_vert_out)
+{
+	int a, side, *nout;
+	double *clip_normals, *s, *e, *n, *new_vert_src; 
+	double *norm, *clp, *clp_next;
+ 	double **out;
+	
+	*new_vert_out = (double **)crAlloc(nclip_to_vert*sizeof(double *));
+	*nnew_vert_out = (int *)crAlloc(nclip_to_vert*sizeof(int));
+
+	/* 
+	 * First, compute normals for the clip poly. This 
+	 * breaks for multiple (3+) adjacent colinear vertices
+ 	 */
+	clip_normals = (double *)crAlloc(nclip_to_vert*2*sizeof(double));
+	for (a=0; a<nclip_to_vert; a++)
+	{
+		s = clip_to_poly+2*a;
+		e = clip_to_poly+2*((a+1)%nclip_to_vert);
+		n = clip_to_poly+2*((a+2)%nclip_to_vert);
+
+		norm = clip_normals+2*a;
+		norm[0]   = e[1]-s[1];
+		norm[1] = -1*(e[0]-s[0]);
+		
+		/* 
+		 * if dot(norm, n-e) > 0), the normals are backwards,
+		 * 	assuming the clip region is convex 
+		 */ 
+		if (norm[0]*(n[0]-e[0]) + norm[1]*(n[1]-e[1]) > 0)
+		{
+			norm[0] *= -1;
+			norm[1] *= -1;
+		}
+	}
+
+	new_vert_src  = (double *)crAlloc(nvert*nclip_to_vert*2*sizeof(double));
+	crMemcpy(new_vert_src, poly, 2*nvert*sizeof(double));
+
+	for (side=0; side<nclip_to_vert; side++)
+	{
+		clp      = clip_to_poly+2*side;
+		clp_next = clip_to_poly+2*((side+1)%nclip_to_vert);
+		norm = clip_normals+2*side;
+		*nnew_vert_in = 0;
+
+		nout = (*nnew_vert_out)+side;
+		out  = (*new_vert_out)+side;
+
+	 	__clip_one_side(new_vert_src, nvert, clp, clp_next, norm,
+				new_vert_in, nnew_vert_in, 
+				out, nout);
+
+		crMemcpy(new_vert_src, (*new_vert_in), 2*(*nnew_vert_in)*sizeof(double));
+		if (side != nclip_to_vert-1)
+			crFree(*new_vert_in);
+		nvert = *nnew_vert_in;
+	}
+}
+
+/* 
+ * Given a bitmap and a group of 'base' polygons [the quads we are testing],
+ * perform the unions and differences specified by the map and return
+ * the resulting geometry
+ */
+static void
+__execute_combination(CRPoly **base, int n, int *mask, CRPoly **head)
+{
+	int a, b, got_intr;
+	int nin, *nout, last;
+	double *in, **out;
+	CRPoly *intr, *diff, *p;
+
+	*head = NULL;
+
+	intr = (CRPoly *)crAlloc(sizeof(CRPoly));
+	intr->next = NULL;
+
+	got_intr = 0;
+
+	/* first, intersect the first 2 polys marked */
+	for (a=0; a<n; a++)
+		if (mask[a]) break;
+	for (b=a+1; b<n; b++)
+		if (mask[b]) break;
+
+	__clip(base[a]->points, base[a]->npoints, 
+				base[b]->points, base[b]->npoints,
+				&in, &nin, &out, &nout);
+	last = b;
+
+	crFree (nout);
+	for (a=0; a<base[last]->npoints; a++)
+		if (out[a])
+			crFree(out[a]);
+	crFree(out);
+					
+
+	if (nin)
+	{
+		intr->npoints = nin;
+		intr->points = in;
+		got_intr = 1;
+	}
+
+	while (1)
+	{
+		for (a=last+1; a<n; a++)
+			if (mask[a]) break;
+
+		if (a == n) break;
+
+		if (got_intr)
+		{
+			__clip(base[a]->points, base[a]->npoints, 
+					intr->points, intr->npoints,
+					&in, &nin, &out, &nout);
+
+			crFree (nout);
+			for (b=0; b<intr->npoints; b++)
+				if (out[b])
+					crFree(out[b]);
+			crFree(out);
+
+			if (nin)
+			{
+				intr->npoints = nin;
+				intr->points = in;
+			}
+			else
+			{
+				got_intr = 0;
+				break;
+			}
+		}
+		else
+		{
+			__clip(base[a]->points, base[a]->npoints, 
+					base[last]->points, base[last]->npoints,
+					&in, &nin, &out, &nout);
+			
+			crFree (nout);
+			for (b=0; b<base[last]->npoints; b++)
+			{
+				if (out[b])
+					crFree(out[b]);
+			}
+			crFree(out);
+
+
+			if (nin)
+			{
+				intr->npoints = nin;
+				intr->points = in;
+				got_intr = 1;
+			}
+		}
+
+		last = a;
+		if (a == n) break;
+	}
+
+	/* can't subtract something from nothing! */
+	if (got_intr)
+		*head = intr;
+	else
+		return;
+	
+	/* find the first item to subtract */
+	for (a=0; a<n; a++)
+		if (!mask[a]) break;
+
+	if (a == n) return;
+	last = a;
+
+	/* and subtract it */
+	diff = NULL;
+	__clip(intr->points, intr->npoints,
+				base[last]->points, base[last]->npoints, 
+				&in, &nin, &out, &nout);
+
+	crFree(in);
+
+	for (a=0; a<base[last]->npoints; a++)	
+	{
+		if (!nout[a]) continue;
+
+		p = (CRPoly *)crAlloc(sizeof(CRPoly));
+		p->npoints = nout[a];
+		p->points  = out[a];
+		p->next = diff;
+		diff = p;
+	}
+	*head = diff;
+
+	while (1)
+	{
+		intr = diff;
+		diff = NULL;
+
+		for (a=last+1; a<n; a++)
+			if (!mask[a]) break;
+		if (a == n) return;
+
+		last = a;
+
+		/* subtract mask[a] from everything in intr and
+		 * plop it into diff */
+		while (intr)
+		{
+			__clip(intr->points, intr->npoints,
+				base[last]->points, base[last]->npoints, 
+				&in, &nin, &out, &nout);
+
+			crFree(in);
+
+			for (a=0; a<base[last]->npoints; a++)	
+			{
+				if (!nout[a]) continue;
+
+				p = (CRPoly *)crAlloc(sizeof(CRPoly));
+				p->npoints = nout[a];
+				p->points  = out[a];
+				p->next = diff;
+				diff = p;
+			}
+
+			intr = intr->next;
+		}
+
+		*head = diff;
+	}	
+
+}
+
+/*
+ * Here we generate all valid bitmaps to represent union/difference
+ * combinations. Each bitmap is N elements long, where N is the 
+ * number of polys [quads] that we are testing for overlap
+ */
+static void
+__generate_masks(int n, int ***mask, int *nmasks)
+{
+	int a, b, c, d, e;
+	int i, idx, isec_size, add;
+
+	*mask = (int **)crAlloc((unsigned int)(1 << n)*sizeof(int));
+	for (a=0; a<(1 << n); a++)
+		(*mask)[a] = (int *)crAlloc(n*sizeof(int));
+
+	/* compute combinations */
+	idx = 0;
+	for (isec_size=1; isec_size<n; isec_size++)
+	{
+		for (a=0; a<n; a++)
+		{
+			for (b=a+1; b<n; b++)
+			{
+				crMemset((*mask)[idx], 0, n*sizeof(int));
+				(*mask)[idx][a] = 1;
+
+				add = 1;
+				for (c=0; c<isec_size; c++)
+				{
+					i = (b+c) % n;
+					if (i == a) add = 0;
+						
+					(*mask)[idx][i] = 1;	
+				}
+
+				/* dup check */
+				if ((add) && (idx))
+				{
+					for (d=0; d<idx; d++)
+					{
+						add = 0;
+						for (e=0; e<n; e++)
+						{
+							if ((*mask)[idx][e] != (*mask)[d][e]) 
+								add = 1;
+						}
+
+						if (!add)
+							break;
+					}
+				}
+
+				if (add) 
+					idx++;
+			}
+		}
+	}
+
+	*nmasks = idx;
+}
+
+/* 
+ * To compute the overlap between a series of quads (This should work 
+ * for n-gons, but we'll only need quads..), first generate a series of 
+ * bitmaps that represent which elements to union together, and which
+ * to difference. This goes into 'mask'. We then evaluate each bitmap with
+ * Sutherland-Hodgman clipping to find the interior (union) and exterior
+ * (difference) regions.
+ *
+ * In the map, 1 == union, 0 == difference
+ *
+ * (*res)[a] is the head of a poly list for all the polys that convert 
+ * regions of overlap between a+1 polys ((*res)[0] == NULL)
+ */ 
+void
+crComputeOverlapGeom(double *quads, int nquad, CRPoly ***res)
+{
+	int a, b, idx, isec_size, **mask;
+	CRPoly *p, *next, **base;
+	
+	base = (CRPoly **)crAlloc(nquad*sizeof(CRPoly *));
+	for (a=0; a<nquad; a++)
+	{
+		p = (CRPoly *)crAlloc(sizeof(CRPoly));
+		p->npoints = 4;
+		p->points  = (double *)crAlloc(8*sizeof(double));
+		for (b=0; b<8; b++)
+		{
+			p->points[b] = quads[8*a+b];
+		}
+		p->next = NULL;
+		base[a] = p;
+	}
+	
+	*res = (CRPoly **)crAlloc(nquad*sizeof(CRPoly *));
+	for (a=0; a<nquad; a++)
+		(*res)[a] = NULL;
+	
+	__generate_masks(nquad, &mask, &idx);
+
+	for (a=0; a<idx; a++)
+	{
+		isec_size = 0;
+		for (b=0; b<nquad; b++)
+			if (mask[a][b]) isec_size++;
+		isec_size--;
+
+		__execute_combination(base, nquad, mask[a], &p);
+	
+		while (p)
+		{
+			next = p->next;
+			
+			p->next = (*res)[isec_size];
+			(*res)[isec_size] = p;
+			
+			p = next;
+		}
+	}
+
+	for (a=0; a<nquad; a++)
+	{
+		crFree(base[a]->points);
+		crFree(base[a]);
+	}
+	crFree(base);		
+
+}
+
+/*
+ * This is similar to ComputeOverlapGeom above, but for "knockout" 
+ * edge blending. 
+ *
+ * my_quad_idx is an index of quads indicating which display tile 
+ * we are computing geometry for. From this, we either generate
+ * geometry, or not, such that all geometry can be drawn in black 
+ * and only one tile will show through the blend as non-black.
+ *
+ * To add a combination to our set of geom, we must test that:
+ * 		+ mask[a][my_quad_idx] is set
+ * 		+ mask[a][my_quad_idx] is not the first element set in
+ * 			mask[a].
+ * If these conditions hold, execute mask[a] and draw the resulting
+ * geometry in black
+ *
+ * Unlike ComputeOverlapGeom, res is just a list of polys to draw in black
+ */ 	
+void
+crComputeKnockoutGeom(double *quads, int nquad, int my_quad_idx, CRPoly **res)
+{
+	int a, b, idx, first, **mask;
+	CRPoly *p, *next, **base;
+	
+	base = (CRPoly **) crAlloc(nquad*sizeof(CRPoly *));
+	for (a=0; a<nquad; a++)
+	{
+		p = (CRPoly *) crAlloc(sizeof(CRPoly));
+		p->npoints = 4;
+		p->points  = (double *) crAlloc(8*sizeof(double));
+		for (b=0; b<8; b++)
+		{
+			p->points[b] = quads[8*a+b];
+		}
+		p->next = NULL;
+		base[a] = p;
+	}
+	
+	(*res) = NULL;
+	
+	__generate_masks(nquad, &mask, &idx);
+
+	for (a=0; a<idx; a++)
+	{
+		/* test for above conditions */
+		if (!mask[a][my_quad_idx]) continue;	
+
+		first = -1;
+		for (b=0; b<nquad; b++)
+			if (mask[a][b]) 
+			{
+				first = b;
+				break;
+			}
+		if (first == my_quad_idx) continue;
+
+
+		__execute_combination(base, nquad, mask[a], &p);
+	
+		while (p)
+		{
+			next = p->next;
+			
+			p->next = *res;
+			*res = p;
+			
+			p = next;
+		}
+	}
+
+	for (a=0; a<nquad; a++)
+	{
+		crFree(base[a]->points);
+		crFree(base[a]);
+	}
+	crFree(base);		
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c	(revision 78189)
+++ 	(revision )
@@ -1,404 +1,0 @@
-    /* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include <string.h>
-#include "cr_mem.h"
-#include "cr_environment.h"
-#include "cr_string.h"
-#include "cr_error.h"
-#include "cr_glstate.h"
-#include "server.h"
-
-#ifdef WINDOWS
-#pragma warning( disable: 4706 )
-#endif
-
-static void
-setDefaults(void)
-{
-    if (!cr_server.tcpip_port)
-        cr_server.tcpip_port = DEFAULT_SERVER_PORT;
-    cr_server.run_queue = NULL;
-    cr_server.optimizeBucket = 1;
-    cr_server.useL2 = 0;
-    cr_server.maxBarrierCount = 0;
-    cr_server.ignore_papi = 0;
-    cr_server.only_swap_once = 0;
-    cr_server.overlapBlending = 0;
-    cr_server.debug_barriers = 0;
-    cr_server.sharedDisplayLists = 0;
-    cr_server.sharedTextureObjects = 0;
-    cr_server.sharedPrograms = 0;
-    cr_server.sharedWindows = 0;
-    cr_server.useDMX = 0;
-    cr_server.vpProjectionMatrixParameter = -1;
-    cr_server.vpProjectionMatrixVariable = NULL;
-    cr_server.currentProgram = 0;
-
-    cr_server.num_overlap_intens = 0;
-    cr_server.overlap_intens = 0;
-    crMemset(&cr_server.MainContextInfo, 0, sizeof (cr_server.MainContextInfo));
-
-    crMatrixInit(&cr_server.viewMatrix[0]);
-    crMatrixInit(&cr_server.viewMatrix[1]);
-    crMatrixInit(&cr_server.projectionMatrix[0]);
-    crMatrixInit(&cr_server.projectionMatrix[1]);
-    cr_server.currentEye = -1;
-
-    cr_server.uniqueWindows = 0;
-
-    cr_server.screenCount = 0;
-    cr_server.bUsePBOForReadback = GL_FALSE;
-    cr_server.bWindowsInitiallyHidden = GL_FALSE;
-
-    cr_server.pfnNotifyEventCB = NULL;
-}
-
-/* Check if host reports minimal OpenGL capabilities.
- *
- * Require OpenGL 2.1 or later.
- *
- * For example, on Windows host this may happen if host has no graphics
- * card drivers installed or drivers were not properly signed or VBox
- * is running via remote desktop session etc. Currently, we take care
- * about Windows host only when specific RENDERER and VERSION strings
- * returned in this case. Later this check should be expanded to the
- * rest of hosts. */
-static bool crServerHasInsufficientCaps()
-{
-    const char *pszRealVersion;
-    int rc;
-    uint32_t u32VerMajor = 0;
-    uint32_t u32VerMinor = 0;
-    char *pszNext = NULL;
-
-    if (!cr_server.head_spu)
-        return true;
-
-    pszRealVersion = (const char *)cr_server.head_spu->dispatch_table.GetString(GL_REAL_VERSION);
-    if (!pszRealVersion)
-        return true; /* No version == insufficient. */
-
-    rc = RTStrToUInt32Ex(pszRealVersion, &pszNext, 10, &u32VerMajor);
-    if (   RT_SUCCESS(rc)
-        && *pszNext == '.')
-            RTStrToUInt32Ex(pszNext + 1, NULL, 10, &u32VerMinor);
-
-    crInfo("Host supports version %d.%d [%s]", u32VerMajor, u32VerMinor, pszRealVersion);
-
-    if (   u32VerMajor > 2
-        || (u32VerMajor == 2 && u32VerMinor >= 1))
-        return false; /* >= 2.1, i.e. good enough. */
-
-    return true; /* Insufficient. */
-}
-
-void crServerSetVBoxConfiguration()
-{
-    CRMuralInfo *defaultMural;
-    char response[8096];
-
-    char **spuchain;
-    int num_spus;
-    int *spu_ids;
-    char **spu_names;
-    char *spu_dir = NULL;
-    int i;
-    /* Quadrics defaults */
-    int my_rank = 0;
-    int low_context = CR_QUADRICS_DEFAULT_LOW_CONTEXT;
-    int high_context = CR_QUADRICS_DEFAULT_HIGH_CONTEXT;
-    unsigned char key[16]= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-    char hostname[1024];
-    char **clientchain, **clientlist;
-    GLint dims[4];
-    const char * env;
-
-    defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
-    CRASSERT(defaultMural);
-
-    setDefaults();
-
-    /*
-     * Get my hostname
-     */
-    if (crGetHostname(hostname, sizeof(hostname)))
-    {
-        crError("CRServer: Couldn't get my own hostname?");
-    }
-
-#ifdef VBOX_WITH_CR_DISPLAY_LISTS
-    strcpy(response, "1 0 expando");
-#else
-    strcpy(response, "1 0 render");
-#endif
-    crDebug("CRServer: my SPU chain: %s", response);
-
-    /* response will describe the SPU chain.
-     * Example "2 5 wet 6 render"
-     */
-    spuchain = crStrSplit(response, " ");
-    num_spus = crStrToInt(spuchain[0]);
-    spu_ids = (int *) crAlloc(num_spus * sizeof(*spu_ids));
-    spu_names = (char **) crAlloc((num_spus + 1) * sizeof(*spu_names));
-    for (i = 0; i < num_spus; i++)
-    {
-        spu_ids[i] = crStrToInt(spuchain[2 * i + 1]);
-        spu_names[i] = crStrdup(spuchain[2 * i + 2]);
-        crDebug("SPU %d/%d: (%d) \"%s\"", i + 1, num_spus, spu_ids[i],
-                        spu_names[i]);
-    }
-    spu_names[i] = NULL;
-
-    crNetSetRank(0);
-    crNetSetContextRange(32, 35);
-    crNetSetNodeRange("iam0", "iamvis20");
-    crNetSetKey(key,sizeof(key));
-    crNetSetKey(key,sizeof(key));
-    cr_server.tcpip_port = 7000;
-
-    crDebug("CRServer: my port number is %d", cr_server.tcpip_port);
-
-    /*
-     * Load the SPUs
-     */
-    cr_server.head_spu =
-        crSPULoadChain(num_spus, spu_ids, spu_names, spu_dir, &cr_server);
-
-    env = crGetenv( "CR_SERVER_DEFAULT_VISUAL_BITS" );
-    if (env != NULL && env[0] != '\0')
-    {
-        unsigned int bits = (unsigned int)crStrParseI32(env, 0);
-        if (bits <= CR_ALL_BITS)
-            cr_server.fVisualBitsDefault = bits;
-        else
-            crWarning("invalid bits option %c", bits);
-    }
-    else
-        cr_server.fVisualBitsDefault = CR_RGB_BIT | CR_ALPHA_BIT | CR_DOUBLE_BIT;
-
-    env = crGetenv("CR_SERVER_CAPS");
-    if (env && env[0] != '\0')
-    {
-        cr_server.u32Caps = crStrParseI32(env, 0);
-        cr_server.u32Caps &= CR_VBOX_CAPS_ALL;
-    }
-    else
-    {
-        cr_server.u32Caps = CR_VBOX_CAP_TEX_PRESENT
-                | CR_VBOX_CAP_CMDVBVA
-                | CR_VBOX_CAP_CMDBLOCKS
-                | CR_VBOX_CAP_GETATTRIBSLOCATIONS
-                | CR_VBOX_CAP_CMDBLOCKS_FLUSH
-                ;
-    }
-
-    if (crServerHasInsufficientCaps())
-    {
-        crDebug("Cfg: report minimal OpenGL capabilities");
-        cr_server.u32Caps |= CR_VBOX_CAP_HOST_CAPS_NOT_SUFFICIENT;
-    }
-
-    crInfo("Cfg: u32Caps(%#x), fVisualBitsDefault(%#x)",
-            cr_server.u32Caps,
-            cr_server.fVisualBitsDefault);
-
-    /* Need to do this as early as possible */
-
-    cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_POSITION_CR, 0, GL_INT, 2, &dims[0]);
-    cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, 0, GL_INT, 2, &dims[2]);
-    
-    defaultMural->gX = dims[0];
-    defaultMural->gY = dims[1];
-    defaultMural->width = dims[2];
-    defaultMural->height = dims[3];
-
-    crFree(spu_ids);
-    crFreeStrings(spu_names);
-    crFreeStrings(spuchain);
-    if (spu_dir)
-        crFree(spu_dir);
-
-    cr_server.mtu = 1024 * 30;
-
-    /*
-     * Get a list of all the clients talking to me.
-     */
-    if (cr_server.vncMode) {
-        /* we're inside a vnc viewer */
-        /*if (!crMothershipSendString( conn, response, "getvncclient %s", hostname ))
-            crError( "Bad Mothership response: %s", response );*/
-    }
-    else {
-        //crMothershipGetClients(conn, response);
-        strcpy(response, "1 tcpip 1");
-    }
-
-    crDebug("CRServer: my clients: %s", response);
-
-    /*
-     * 'response' will now contain a number indicating the number of clients
-     * of this server, followed by a comma-separated list of protocol/SPU ID
-     * pairs.
-     * Example: "3 tcpip 1,gm 2,via 10"
-     */
-    clientchain = crStrSplitn(response, " ", 1);
-    cr_server.numClients = crStrToInt(clientchain[0]);
-    if (cr_server.numClients == 0)
-    {
-        crError("I have no clients!  What's a poor server to do?");
-    }
-    clientlist = crStrSplit(clientchain[1], ",");
-
-    /*
-     * Connect to initial set of clients.
-     * Call crNetAcceptClient() for each client.
-     * Also, look for a client that's _not_ using the file: protocol.
-     */
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        CRClient *newClient = (CRClient *) crCalloc(sizeof(CRClient));
-#ifdef VBOX
-        sscanf(clientlist[i], "%1023s %d", cr_server.protocol, &(newClient->spu_id));
-#else
-        sscanf(clientlist[i], "%s %d", cr_server.protocol, &(newClient->spu_id));
-#endif
-        newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
-                                            cr_server.tcpip_port,
-                                            cr_server.mtu, 0);
-        newClient->currentCtxInfo = &cr_server.MainContextInfo;
-        crServerAddToRunQueue(newClient);
-
-        cr_server.clients[i] = newClient;
-    }
-
-    /* set default client and mural */
-    if (cr_server.numClients > 0) {
-         cr_server.curClient = cr_server.clients[0];
-         cr_server.curClient->currentMural = defaultMural;
-         cr_server.client_spu_id =cr_server.clients[0]->spu_id;
-    }
-
-    crFreeStrings(clientchain);
-    crFreeStrings(clientlist);
-
-    /* Ask the mothership for the tile info */
-    //crServerGetTileInfoFromMothership(conn, defaultMural);
-
-    if (cr_server.vncMode) {
-        /* In vnc mode, we reset the mothership configuration so that it can be
-         * used by subsequent OpenGL apps without having to spawn a new mothership
-         * on a new port.
-         */
-        crDebug("CRServer: Resetting mothership to initial state");
-        //crMothershipReset(conn);
-    }
-
-    //crMothershipDisconnect(conn);
-}
-
-void crServerSetVBoxConfigurationHGCM()
-{
-    CRMuralInfo *defaultMural;
-
-#ifdef VBOX_WITH_CR_DISPLAY_LISTS
-    int spu_ids[1]     = {0};
-    char *spu_names[1] = {"expando"};
-#else
-    int spu_ids[1]     = {0};
-    char *spu_names[1] = {"render"};
-#endif
-    char *spu_dir = NULL;
-    int i;
-    GLint dims[4];
-    const char * env;
-
-    defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
-    CRASSERT(defaultMural);
-
-    /// @todo should be moved to addclient so we have a chain for each client
-
-    setDefaults();
-    
-    /* Load the SPUs */    
-    cr_server.head_spu = crSPULoadChain(1, spu_ids, spu_names, spu_dir, &cr_server);
-
-    if (!cr_server.head_spu)
-        return;
-
-
-    env = crGetenv( "CR_SERVER_DEFAULT_VISUAL_BITS" );
-    if (env != NULL && env[0] != '\0')
-    {
-        unsigned int bits = (unsigned int)crStrParseI32(env, 0);
-        if (bits <= CR_ALL_BITS)
-            cr_server.fVisualBitsDefault = bits;
-        else
-            crWarning("invalid bits option %c", bits);
-    }
-    else
-        cr_server.fVisualBitsDefault = CR_RGB_BIT | CR_ALPHA_BIT | CR_DOUBLE_BIT;
-
-
-    env = crGetenv("CR_SERVER_CAPS");
-    if (env && env[0] != '\0')
-    {
-        cr_server.u32Caps = crStrParseI32(env, 0);
-        cr_server.u32Caps &= CR_VBOX_CAPS_ALL;
-    }
-    else
-    {
-        cr_server.u32Caps = CR_VBOX_CAP_TEX_PRESENT
-                | CR_VBOX_CAP_CMDVBVA
-                | CR_VBOX_CAP_CMDBLOCKS
-                | CR_VBOX_CAP_GETATTRIBSLOCATIONS
-                | CR_VBOX_CAP_CMDBLOCKS_FLUSH
-                ;
-    }
-
-    if (crServerHasInsufficientCaps())
-    {
-        crDebug("Cfg: report minimal OpenGL capabilities");
-        cr_server.u32Caps |= CR_VBOX_CAP_HOST_CAPS_NOT_SUFFICIENT;
-    }
-
-    crInfo("Cfg: u32Caps(%#x), fVisualBitsDefault(%#x)",
-            cr_server.u32Caps,
-            cr_server.fVisualBitsDefault);
-
-    cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_POSITION_CR, 0, GL_INT, 2, &dims[0]);
-    cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, 0, GL_INT, 2, &dims[2]);
-    
-    defaultMural->gX = dims[0];
-    defaultMural->gY = dims[1];
-    defaultMural->width = dims[2];
-    defaultMural->height = dims[3];
-
-    cr_server.mtu = 1024 * 250;
-
-    cr_server.numClients = 0;
-    strcpy(cr_server.protocol, "vboxhgcm");
-
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        CRClient *newClient = (CRClient *) crCalloc(sizeof(CRClient));
-        newClient->spu_id = 0;
-        newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
-                                            cr_server.tcpip_port,
-                                            cr_server.mtu, 0);
-        newClient->currentCtxInfo = &cr_server.MainContextInfo;
-        crServerAddToRunQueue(newClient);
-
-        cr_server.clients[i] = newClient;
-    }
-
-    /* set default client and mural */
-    if (cr_server.numClients > 0) {
-         cr_server.curClient = cr_server.clients[0];
-         cr_server.curClient->currentMural = defaultMural;
-         cr_server.client_spu_id =cr_server.clients[0]->spu_id;
-    }
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.cpp	(revision 78190)
@@ -0,0 +1,194 @@
+    /* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include <string.h>
+#include "cr_mem.h"
+#include "cr_string.h"
+#include "cr_error.h"
+#include "cr_glstate.h"
+#include "server.h"
+
+#include <iprt/env.h>
+
+#ifdef WINDOWS
+#pragma warning( disable: 4706 )
+#endif
+
+static void
+setDefaults(void)
+{
+    cr_server.run_queue = NULL;
+    cr_server.optimizeBucket = 1;
+    cr_server.useL2 = 0;
+    cr_server.maxBarrierCount = 0;
+    cr_server.ignore_papi = 0;
+    cr_server.only_swap_once = 0;
+    cr_server.overlapBlending = 0;
+    cr_server.debug_barriers = 0;
+    cr_server.sharedDisplayLists = 0;
+    cr_server.sharedTextureObjects = 0;
+    cr_server.sharedPrograms = 0;
+    cr_server.sharedWindows = 0;
+    cr_server.useDMX = 0;
+    cr_server.vpProjectionMatrixParameter = -1;
+    cr_server.vpProjectionMatrixVariable = NULL;
+    cr_server.currentProgram = 0;
+
+    cr_server.num_overlap_intens = 0;
+    cr_server.overlap_intens = 0;
+    crMemset(&cr_server.MainContextInfo, 0, sizeof (cr_server.MainContextInfo));
+
+    crMatrixInit(&cr_server.viewMatrix[0]);
+    crMatrixInit(&cr_server.viewMatrix[1]);
+    crMatrixInit(&cr_server.projectionMatrix[0]);
+    crMatrixInit(&cr_server.projectionMatrix[1]);
+    cr_server.currentEye = -1;
+
+    cr_server.uniqueWindows = 0;
+
+    cr_server.screenCount = 0;
+    cr_server.bUsePBOForReadback = GL_FALSE;
+    cr_server.bWindowsInitiallyHidden = GL_FALSE;
+
+    cr_server.pfnNotifyEventCB = NULL;
+}
+
+/* Check if host reports minimal OpenGL capabilities.
+ *
+ * Require OpenGL 2.1 or later.
+ *
+ * For example, on Windows host this may happen if host has no graphics
+ * card drivers installed or drivers were not properly signed or VBox
+ * is running via remote desktop session etc. Currently, we take care
+ * about Windows host only when specific RENDERER and VERSION strings
+ * returned in this case. Later this check should be expanded to the
+ * rest of hosts. */
+static bool crServerHasInsufficientCaps()
+{
+    const char *pszRealVersion;
+    int rc;
+    uint32_t u32VerMajor = 0;
+    uint32_t u32VerMinor = 0;
+    char *pszNext = NULL;
+
+    if (!cr_server.head_spu)
+        return true;
+
+    pszRealVersion = (const char *)cr_server.head_spu->dispatch_table.GetString(GL_REAL_VERSION);
+    if (!pszRealVersion)
+        return true; /* No version == insufficient. */
+
+    rc = RTStrToUInt32Ex(pszRealVersion, &pszNext, 10, &u32VerMajor);
+    if (   RT_SUCCESS(rc)
+        && *pszNext == '.')
+            RTStrToUInt32Ex(pszNext + 1, NULL, 10, &u32VerMinor);
+
+    crInfo("Host supports version %d.%d [%s]", u32VerMajor, u32VerMinor, pszRealVersion);
+
+    if (   u32VerMajor > 2
+        || (u32VerMajor == 2 && u32VerMinor >= 1))
+        return false; /* >= 2.1, i.e. good enough. */
+
+    return true; /* Insufficient. */
+}
+
+void crServerSetVBoxConfigurationHGCM()
+{
+    CRMuralInfo *defaultMural;
+
+    int spu_ids[1]     = {0};
+    char *spu_names[1] = {"render"};
+    char *spu_dir = NULL;
+    int i;
+    GLint dims[4];
+    const char * env;
+
+    defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
+    CRASSERT(defaultMural);
+
+    /// @todo should be moved to addclient so we have a chain for each client
+
+    setDefaults();
+    
+    /* Load the SPUs */    
+    cr_server.head_spu = crSPULoadChain(1, spu_ids, spu_names, spu_dir, &cr_server);
+
+    if (!cr_server.head_spu)
+        return;
+
+
+    env = RTEnvGet( "CR_SERVER_DEFAULT_VISUAL_BITS" );
+    if (env != NULL && env[0] != '\0')
+    {
+        unsigned int bits = (unsigned int)crStrParseI32(env, 0);
+        if (bits <= CR_ALL_BITS)
+            cr_server.fVisualBitsDefault = bits;
+        else
+            crWarning("invalid bits option %c", bits);
+    }
+    else
+        cr_server.fVisualBitsDefault = CR_RGB_BIT | CR_ALPHA_BIT | CR_DOUBLE_BIT;
+
+
+    env = RTEnvGet("CR_SERVER_CAPS");
+    if (env && env[0] != '\0')
+    {
+        cr_server.u32Caps = crStrParseI32(env, 0);
+        cr_server.u32Caps &= CR_VBOX_CAPS_ALL;
+    }
+    else
+    {
+        cr_server.u32Caps = CR_VBOX_CAP_TEX_PRESENT
+                | CR_VBOX_CAP_CMDVBVA
+                | CR_VBOX_CAP_CMDBLOCKS
+                | CR_VBOX_CAP_GETATTRIBSLOCATIONS
+                | CR_VBOX_CAP_CMDBLOCKS_FLUSH
+                ;
+    }
+
+    if (crServerHasInsufficientCaps())
+    {
+        crDebug("Cfg: report minimal OpenGL capabilities");
+        cr_server.u32Caps |= CR_VBOX_CAP_HOST_CAPS_NOT_SUFFICIENT;
+    }
+
+    crInfo("Cfg: u32Caps(%#x), fVisualBitsDefault(%#x)",
+            cr_server.u32Caps,
+            cr_server.fVisualBitsDefault);
+
+    cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_POSITION_CR, 0, GL_INT, 2, &dims[0]);
+    cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, 0, GL_INT, 2, &dims[2]);
+    
+    defaultMural->gX = dims[0];
+    defaultMural->gY = dims[1];
+    defaultMural->width = dims[2];
+    defaultMural->height = dims[3];
+
+    cr_server.mtu = 1024 * 250;
+
+    cr_server.numClients = 0;
+    strcpy(cr_server.protocol, "vboxhgcm");
+
+    for (i = 0; i < cr_server.numClients; i++)
+    {
+        CRClient *newClient = (CRClient *) crCalloc(sizeof(CRClient));
+        newClient->spu_id = 0;
+        newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
+                                            cr_server.tcpip_port,
+                                            cr_server.mtu, 0);
+        newClient->currentCtxInfo = &cr_server.MainContextInfo;
+        crServerAddToRunQueue(newClient);
+
+        cr_server.clients[i] = newClient;
+    }
+
+    /* set default client and mural */
+    if (cr_server.numClients > 0) {
+         cr_server.curClient = cr_server.clients[0];
+         cr_server.curClient->currentMural = defaultMural;
+         cr_server.client_spu_id =cr_server.clients[0]->spu_id;
+    }
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.c	(revision 78189)
+++ 	(revision )
@@ -1,481 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved.
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-    
-#include "cr_spu.h"
-#include "chromium.h"
-#include "cr_error.h"
-#include "cr_net.h"
-#include "cr_rand.h"
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-
-GLint SERVER_DISPATCH_APIENTRY
-crServerDispatchCreateContext(const char *dpyName, GLint visualBits, GLint shareCtx)
-{
-    return crServerDispatchCreateContextEx(dpyName, visualBits, shareCtx, -1, -1);
-}
-
-GLint crServerDispatchCreateContextEx(const char *dpyName, GLint visualBits, GLint shareCtx, GLint preloadCtxID, int32_t internalID)
-{
-    GLint retVal = -1;
-    CRContext *newCtx;
-    CRContextInfo *pContextInfo;
-    GLboolean fFirst = GL_FALSE;
-
-    dpyName = "";
-
-    if (shareCtx > 0) {
-        crWarning("CRServer: context sharing not implemented.");
-        shareCtx = 0;
-    }
-
-    pContextInfo = (CRContextInfo *) crAlloc(sizeof (CRContextInfo));
-    if (!pContextInfo)
-    {
-        crWarning("failed to alloc context info!");
-        return -1;
-    }
-
-    pContextInfo->currentMural = NULL;
-
-    pContextInfo->CreateInfo.requestedVisualBits = visualBits;
-
-    if (cr_server.fVisualBitsDefault)
-        visualBits = cr_server.fVisualBitsDefault;
-
-    pContextInfo->CreateInfo.realVisualBits = visualBits;
-
-    /* Since the Cr server serialized all incoming clients/contexts into
-     * one outgoing GL stream, we only need to create one context for the
-     * head SPU.  We'll only have to make it current once too, below.
-     */
-    if (cr_server.firstCallCreateContext) {
-        cr_server.MainContextInfo.CreateInfo.realVisualBits = visualBits;
-        cr_server.MainContextInfo.SpuContext = cr_server.head_spu->dispatch_table.
-            CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.realVisualBits, shareCtx);
-        if (cr_server.MainContextInfo.SpuContext < 0) {
-            crWarning("crServerDispatchCreateContext() failed.");
-            crFree(pContextInfo);
-            return -1;
-        }
-        cr_server.MainContextInfo.pContext = crStateCreateContext(&cr_server.limits, visualBits, NULL);
-        CRASSERT(cr_server.MainContextInfo.pContext);
-        cr_server.firstCallCreateContext = GL_FALSE;
-        fFirst = GL_TRUE;
-
-        cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_SET_DEFAULT_SHARED_CTX, cr_server.MainContextInfo.SpuContext);
-    }
-    else {
-        /* second or third or ... context */
-        if (!cr_server.bUseMultipleContexts && ((visualBits & cr_server.MainContextInfo.CreateInfo.realVisualBits) != visualBits)) {
-            int oldSpuContext;
-            /* should never be here */
-            CRASSERT(0);
-            /* the new context needs new visual attributes */
-            cr_server.MainContextInfo.CreateInfo.realVisualBits |= visualBits;
-            crWarning("crServerDispatchCreateContext requires new visual (0x%x).",
-                    cr_server.MainContextInfo.CreateInfo.realVisualBits);
-
-            /* Here, we used to just destroy the old rendering context.
-             * Unfortunately, this had the side effect of destroying
-             * all display lists and textures that had been loaded on
-             * the old context as well.
-             *
-             * Now, first try to create a new context, with a suitable
-             * visual, sharing display lists and textures with the
-             * old context.  Then destroy the old context.
-             */
-
-            /* create new rendering context with suitable visual */
-            oldSpuContext = cr_server.MainContextInfo.SpuContext;
-            cr_server.MainContextInfo.SpuContext = cr_server.head_spu->dispatch_table.
-                CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.realVisualBits, cr_server.MainContextInfo.SpuContext);
-            /* destroy old rendering context */
-            cr_server.head_spu->dispatch_table.DestroyContext(oldSpuContext);
-            if (cr_server.MainContextInfo.SpuContext < 0) {
-                crWarning("crServerDispatchCreateContext() failed.");
-                crFree(pContextInfo);
-                return -1;
-            }
-
-            /* we do not need to clean up the old default context explicitly, since the above cr_server.head_spu->dispatch_table.DestroyContext call
-             * will do that for us */
-            cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_SET_DEFAULT_SHARED_CTX, cr_server.MainContextInfo.SpuContext);
-        }
-    }
-
-    if (cr_server.bUseMultipleContexts) {
-        pContextInfo->SpuContext = cr_server.head_spu->dispatch_table.
-                CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.realVisualBits, cr_server.MainContextInfo.SpuContext);
-        if (pContextInfo->SpuContext < 0) {
-            crWarning("crServerDispatchCreateContext() failed.");
-            crStateEnableDiffOnMakeCurrent(GL_TRUE);
-            cr_server.bUseMultipleContexts = GL_FALSE;
-            if (!fFirst)
-                crError("creating shared context failed, while it is expected to work!");
-        }
-        else if (fFirst)
-        {
-            crStateEnableDiffOnMakeCurrent(GL_FALSE);
-        }
-    }
-    else
-    {
-        pContextInfo->SpuContext = -1;
-    }
-
-    /* Now create a new state-tracker context and initialize the
-     * dispatch function pointers.
-     */
-    newCtx = crStateCreateContextEx(&cr_server.limits, visualBits, NULL, internalID);
-    if (newCtx) {
-        crStateSetCurrentPointers( newCtx, &(cr_server.current) );
-        crStateResetCurrentPointers(&(cr_server.current));
-        retVal = preloadCtxID<0 ? (GLint)crHashtableAllocKeys( cr_server.contextTable, 1 ) : preloadCtxID;
-
-        pContextInfo->pContext = newCtx;
-        Assert(pContextInfo->CreateInfo.realVisualBits == visualBits);
-        pContextInfo->CreateInfo.externalID = retVal;
-        pContextInfo->CreateInfo.pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
-        crHashtableAdd(cr_server.contextTable, retVal, pContextInfo);
-    }
-
-    if (retVal != -1 && !cr_server.bIsInLoadingState) {
-        int pos;
-        for (pos = 0; pos < CR_MAX_CONTEXTS; pos++) {
-            if (cr_server.curClient->contextList[pos] == 0) {
-                cr_server.curClient->contextList[pos] = retVal;
-                break;
-            }
-        }
-    }
-
-    crServerReturnValue( &retVal, sizeof(retVal) );
-
-    return retVal;
-}
-
-static int crServerRemoveClientContext(CRClient *pClient, GLint ctx)
-{
-    int pos;
-
-    for (pos = 0; pos < CR_MAX_CONTEXTS; ++pos)
-    {
-        if (pClient->contextList[pos] == ctx)
-        {
-            pClient->contextList[pos] = 0;
-            return true;
-        }
-    }
-
-    return false;
-}
-
-static void crServerCleanupMuralCtxUsageCB(unsigned long key, void *data1, void *data2)
-{
-    CRMuralInfo *mural = (CRMuralInfo *) data1;
-    CRContext *ctx = (CRContext *) data2;
-
-    CR_STATE_SHAREDOBJ_USAGE_CLEAR(mural, ctx);
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchDestroyContext( GLint ctx )
-{
-    CRContextInfo *crCtxInfo;
-    CRContext *crCtx;
-    int32_t client;
-    CRClientNode *pNode;
-    int found=false;
-
-    crCtxInfo = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, ctx);
-    if (!crCtxInfo) {
-        crWarning("CRServer: DestroyContext invalid context %d", ctx);
-        return;
-    }
-    crCtx = crCtxInfo->pContext;
-    CRASSERT(crCtx);
-
-    crDebug("CRServer: DestroyContext context %d", ctx);
-
-    if (cr_server.currentCtxInfo == crCtxInfo)
-    {
-        CRMuralInfo *dummyMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
-        crServerPerformMakeCurrent(dummyMural, &cr_server.MainContextInfo);
-        CRASSERT(cr_server.currentCtxInfo == &cr_server.MainContextInfo);
-    }
-
-    crHashtableWalk(cr_server.muralTable, crServerCleanupMuralCtxUsageCB, crCtx);
-    crCtxInfo->currentMural = NULL;
-    crHashtableDelete(cr_server.contextTable, ctx, NULL);
-    crStateDestroyContext( crCtx );
-
-    if (crCtxInfo->CreateInfo.pszDpyName)
-        crFree(crCtxInfo->CreateInfo.pszDpyName);
-
-    if (crCtxInfo->SpuContext >= 0)
-        cr_server.head_spu->dispatch_table.DestroyContext(crCtxInfo->SpuContext);
-
-    crFree(crCtxInfo);
-
-    if (cr_server.curClient)
-    {
-        /* If we delete our current context, default back to the null context */
-        if (cr_server.curClient->currentCtxInfo == crCtxInfo) {
-            cr_server.curClient->currentContextNumber = -1;
-            cr_server.curClient->currentCtxInfo = &cr_server.MainContextInfo;
-        }
-
-        found = crServerRemoveClientContext(cr_server.curClient, ctx);
-
-        /*Some application call destroy context not in a thread where it was created...have do deal with it.*/
-        if (!found)
-        {
-            for (client=0; client<cr_server.numClients; ++client)
-            {
-                if (cr_server.clients[client]==cr_server.curClient)
-                    continue;
-
-                found = crServerRemoveClientContext(cr_server.clients[client], ctx);
-
-                if (found) break;
-            }
-        }
-
-        if (!found)
-        {
-            pNode=cr_server.pCleanupClient;
-
-            while (pNode && !found)
-            {
-                found = crServerRemoveClientContext(pNode->pClient, ctx);
-                pNode = pNode->next;
-            }
-        }
-
-        CRASSERT(found);
-    }
-
-    /*Make sure this context isn't active in other clients*/
-    for (client=0; client<cr_server.numClients; ++client)
-    {
-        if (cr_server.clients[client]->currentCtxInfo == crCtxInfo)
-        {
-            cr_server.clients[client]->currentContextNumber = -1;
-            cr_server.clients[client]->currentCtxInfo = &cr_server.MainContextInfo;
-        }
-    }
-
-    pNode=cr_server.pCleanupClient;
-    while (pNode)
-    {
-        if (pNode->pClient->currentCtxInfo == crCtxInfo)
-        {
-            pNode->pClient->currentContextNumber = -1;
-            pNode->pClient->currentCtxInfo = &cr_server.MainContextInfo;
-        }
-        pNode = pNode->next;
-    }
-
-    CRASSERT(cr_server.currentCtxInfo != crCtxInfo);
-}
-
-void crServerPerformMakeCurrent( CRMuralInfo *mural, CRContextInfo *ctxInfo )
-{
-    CRMuralInfo *oldMural;
-    CRContext *ctx, *oldCtx = NULL;
-    GLuint idDrawFBO, idReadFBO;
-    GLint context = ctxInfo->CreateInfo.externalID;
-    GLint window = mural->CreateInfo.externalID;
-
-    cr_server.bForceMakeCurrentOnClientSwitch = GL_FALSE;
-
-    ctx = ctxInfo->pContext;
-    CRASSERT(ctx);
-
-    oldMural = cr_server.currentMural;
-
-    /* Ubuntu 11.04 hosts misbehave if context window switch is
-     * done with non-default framebuffer object settings.
-     * crStateSwitchPrepare & crStateSwitchPostprocess are supposed to work around this problem
-     * crStateSwitchPrepare restores the FBO state to its default values before the context window switch,
-     * while crStateSwitchPostprocess restores it back to the original values */
-    oldCtx = crStateGetCurrent();
-    if (oldMural && oldMural->fRedirected && crServerSupportRedirMuralFBO())
-    {
-        idDrawFBO = CR_SERVER_FBO_FOR_IDX(oldMural, oldMural->iCurDrawBuffer);
-        idReadFBO = CR_SERVER_FBO_FOR_IDX(oldMural, oldMural->iCurReadBuffer);
-    }
-    else
-    {
-        idDrawFBO = 0;
-        idReadFBO = 0;
-    }
-    crStateSwitchPrepare(cr_server.bUseMultipleContexts ? NULL : ctx, oldCtx, idDrawFBO, idReadFBO);
-
-    if (cr_server.curClient)
-    {
-        /*
-        crDebug("**** %s client %d  curCtx=%d curWin=%d", __func__,
-                        cr_server.curClient->number, ctxPos, window);
-        */
-        cr_server.curClient->currentContextNumber = context;
-        cr_server.curClient->currentCtxInfo = ctxInfo;
-        cr_server.curClient->currentMural = mural;
-        cr_server.curClient->currentWindow = window;
-
-        CRASSERT(cr_server.curClient->currentCtxInfo);
-        CRASSERT(cr_server.curClient->currentCtxInfo->pContext);
-    }
-
-    /* This is a hack to force updating the 'current' attribs */
-    crStateUpdateColorBits();
-
-    if (ctx)
-        crStateSetCurrentPointers( ctx, &(cr_server.current) );
-
-    /* check if being made current for first time, update viewport */
-#if 0
-    if (ctx) {
-        /* initialize the viewport */
-        if (ctx->viewport.viewportW == 0) {
-            ctx->viewport.viewportW = mural->width;
-            ctx->viewport.viewportH = mural->height;
-            ctx->viewport.scissorW = mural->width;
-            ctx->viewport.scissorH = mural->height;
-        }
-    }
-#endif
-
-    /*
-    crDebug("**** %s  currentWindow %d  newWindow %d", __func__,
-                    cr_server.currentWindow, window);
-    */
-
-    if (1/*cr_server.firstCallMakeCurrent ||
-            cr_server.currentWindow != window ||
-            cr_server.currentNativeWindow != nativeWindow*/) {
-        /* Since the cr server serialized all incoming contexts/clients into
-         * one output stream of GL commands, we only need to call the head
-         * SPU's MakeCurrent() function once.
-         * BUT, if we're rendering to multiple windows, we do have to issue
-         * MakeCurrent() calls sometimes.  The same GL context will always be
-         * used though.
-         */
-        cr_server.head_spu->dispatch_table.MakeCurrent( mural->spuWindow,
-                                                        0,
-                                                        ctxInfo->SpuContext >= 0
-                                                            ? ctxInfo->SpuContext
-                                                              : cr_server.MainContextInfo.SpuContext);
-
-        CR_STATE_SHAREDOBJ_USAGE_SET(mural, ctx);
-        if (cr_server.currentCtxInfo)
-            cr_server.currentCtxInfo->currentMural = NULL;
-        ctxInfo->currentMural = mural;
-
-        cr_server.firstCallMakeCurrent = GL_FALSE;
-        cr_server.currentCtxInfo = ctxInfo;
-        cr_server.currentWindow = window;
-        cr_server.currentNativeWindow = 0;
-        cr_server.currentMural = mural;
-    }
-
-    /* This used to be earlier, after crStateUpdateColorBits() call */
-    crStateMakeCurrent( ctx );
-
-    if (mural && mural->fRedirected  && crServerSupportRedirMuralFBO())
-    {
-        GLuint id = crServerMuralFBOIdxFromBufferName(mural, ctx->buffer.drawBuffer);
-        if (id != mural->iCurDrawBuffer)
-        {
-            crDebug("DBO draw buffer changed on make current");
-            mural->iCurDrawBuffer = id;
-        }
-
-        id = crServerMuralFBOIdxFromBufferName(mural, ctx->buffer.readBuffer);
-        if (id != mural->iCurReadBuffer)
-        {
-            crDebug("DBO read buffer changed on make current");
-            mural->iCurReadBuffer = id;
-        }
-
-        idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
-        idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
-    }
-    else
-    {
-        idDrawFBO = 0;
-        idReadFBO = 0;
-    }
-    crStateSwitchPostprocess(ctx, cr_server.bUseMultipleContexts ? NULL : oldCtx, idDrawFBO, idReadFBO);
-
-    if (!ctx->framebufferobject.drawFB
-            && (ctx->buffer.drawBuffer == GL_FRONT || ctx->buffer.drawBuffer == GL_FRONT_LEFT)
-            && cr_server.curClient)
-        cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
-
-    if (!mural->fRedirected)
-    {
-        ctx->buffer.width = mural->width;
-        ctx->buffer.height = mural->height;
-    }
-    else
-    {
-        ctx->buffer.width = 0;
-        ctx->buffer.height = 0;
-    }
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchMakeCurrent( GLint window, GLint nativeWindow, GLint context )
-{
-    CRMuralInfo *mural;
-    CRContextInfo *ctxInfo = NULL;
-
-    if (context >= 0 && window >= 0) {
-        mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
-        if (!mural)
-        {
-            crWarning("CRServer: invalid window %d passed to crServerDispatchMakeCurrent()", window);
-            return;
-        }
-
-        /* Update the state tracker's current context */
-        ctxInfo = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, context);
-        if (!ctxInfo) {
-            crWarning("CRserver: NULL context in MakeCurrent %d", context);
-            return;
-        }
-    }
-    else {
-#if 0
-        oldMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, cr_server.currentWindow);
-        if (oldMural && oldMural->bUseFBO && crServerSupportRedirMuralFBO())
-        {
-            if (!crStateGetCurrent()->framebufferobject.drawFB)
-            {
-                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0);
-            }
-            if (!crStateGetCurrent()->framebufferobject.readFB)
-            {
-                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, 0);
-            }
-        }
-
-        ctxInfo = &cr_server.MainContextInfo;
-        window = -1;
-        mural = NULL;
-#endif
-        cr_server.bForceMakeCurrentOnClientSwitch = GL_TRUE;
-        return;
-    }
-
-    crServerPerformMakeCurrent( mural, ctxInfo );
-}
-
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_context.cpp	(revision 78190)
@@ -0,0 +1,480 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved.
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+    
+#include "cr_spu.h"
+#include "chromium.h"
+#include "cr_error.h"
+#include "cr_net.h"
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_mem.h"
+#include "cr_string.h"
+
+GLint SERVER_DISPATCH_APIENTRY
+crServerDispatchCreateContext(const char *dpyName, GLint visualBits, GLint shareCtx)
+{
+    return crServerDispatchCreateContextEx(dpyName, visualBits, shareCtx, -1, -1);
+}
+
+GLint crServerDispatchCreateContextEx(const char *dpyName, GLint visualBits, GLint shareCtx, GLint preloadCtxID, int32_t internalID)
+{
+    GLint retVal = -1;
+    CRContext *newCtx;
+    CRContextInfo *pContextInfo;
+    GLboolean fFirst = GL_FALSE;
+
+    dpyName = "";
+
+    if (shareCtx > 0) {
+        crWarning("CRServer: context sharing not implemented.");
+        shareCtx = 0;
+    }
+
+    pContextInfo = (CRContextInfo *) crAlloc(sizeof (CRContextInfo));
+    if (!pContextInfo)
+    {
+        crWarning("failed to alloc context info!");
+        return -1;
+    }
+
+    pContextInfo->currentMural = NULL;
+
+    pContextInfo->CreateInfo.requestedVisualBits = visualBits;
+
+    if (cr_server.fVisualBitsDefault)
+        visualBits = cr_server.fVisualBitsDefault;
+
+    pContextInfo->CreateInfo.realVisualBits = visualBits;
+
+    /* Since the Cr server serialized all incoming clients/contexts into
+     * one outgoing GL stream, we only need to create one context for the
+     * head SPU.  We'll only have to make it current once too, below.
+     */
+    if (cr_server.firstCallCreateContext) {
+        cr_server.MainContextInfo.CreateInfo.realVisualBits = visualBits;
+        cr_server.MainContextInfo.SpuContext = cr_server.head_spu->dispatch_table.
+            CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.realVisualBits, shareCtx);
+        if (cr_server.MainContextInfo.SpuContext < 0) {
+            crWarning("crServerDispatchCreateContext() failed.");
+            crFree(pContextInfo);
+            return -1;
+        }
+        cr_server.MainContextInfo.pContext = crStateCreateContext(&cr_server.limits, visualBits, NULL);
+        CRASSERT(cr_server.MainContextInfo.pContext);
+        cr_server.firstCallCreateContext = GL_FALSE;
+        fFirst = GL_TRUE;
+
+        cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_SET_DEFAULT_SHARED_CTX, cr_server.MainContextInfo.SpuContext);
+    }
+    else {
+        /* second or third or ... context */
+        if (!cr_server.bUseMultipleContexts && ((visualBits & cr_server.MainContextInfo.CreateInfo.realVisualBits) != visualBits)) {
+            int oldSpuContext;
+            /* should never be here */
+            CRASSERT(0);
+            /* the new context needs new visual attributes */
+            cr_server.MainContextInfo.CreateInfo.realVisualBits |= visualBits;
+            crWarning("crServerDispatchCreateContext requires new visual (0x%x).",
+                    cr_server.MainContextInfo.CreateInfo.realVisualBits);
+
+            /* Here, we used to just destroy the old rendering context.
+             * Unfortunately, this had the side effect of destroying
+             * all display lists and textures that had been loaded on
+             * the old context as well.
+             *
+             * Now, first try to create a new context, with a suitable
+             * visual, sharing display lists and textures with the
+             * old context.  Then destroy the old context.
+             */
+
+            /* create new rendering context with suitable visual */
+            oldSpuContext = cr_server.MainContextInfo.SpuContext;
+            cr_server.MainContextInfo.SpuContext = cr_server.head_spu->dispatch_table.
+                CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.realVisualBits, cr_server.MainContextInfo.SpuContext);
+            /* destroy old rendering context */
+            cr_server.head_spu->dispatch_table.DestroyContext(oldSpuContext);
+            if (cr_server.MainContextInfo.SpuContext < 0) {
+                crWarning("crServerDispatchCreateContext() failed.");
+                crFree(pContextInfo);
+                return -1;
+            }
+
+            /* we do not need to clean up the old default context explicitly, since the above cr_server.head_spu->dispatch_table.DestroyContext call
+             * will do that for us */
+            cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_SET_DEFAULT_SHARED_CTX, cr_server.MainContextInfo.SpuContext);
+        }
+    }
+
+    if (cr_server.bUseMultipleContexts) {
+        pContextInfo->SpuContext = cr_server.head_spu->dispatch_table.
+                CreateContext(dpyName, cr_server.MainContextInfo.CreateInfo.realVisualBits, cr_server.MainContextInfo.SpuContext);
+        if (pContextInfo->SpuContext < 0) {
+            crWarning("crServerDispatchCreateContext() failed.");
+            crStateEnableDiffOnMakeCurrent(GL_TRUE);
+            cr_server.bUseMultipleContexts = GL_FALSE;
+            if (!fFirst)
+                crError("creating shared context failed, while it is expected to work!");
+        }
+        else if (fFirst)
+        {
+            crStateEnableDiffOnMakeCurrent(GL_FALSE);
+        }
+    }
+    else
+    {
+        pContextInfo->SpuContext = -1;
+    }
+
+    /* Now create a new state-tracker context and initialize the
+     * dispatch function pointers.
+     */
+    newCtx = crStateCreateContextEx(&cr_server.limits, visualBits, NULL, internalID);
+    if (newCtx) {
+        crStateSetCurrentPointers( newCtx, &(cr_server.current) );
+        crStateResetCurrentPointers(&(cr_server.current));
+        retVal = preloadCtxID<0 ? (GLint)crHashtableAllocKeys( cr_server.contextTable, 1 ) : preloadCtxID;
+
+        pContextInfo->pContext = newCtx;
+        Assert(pContextInfo->CreateInfo.realVisualBits == visualBits);
+        pContextInfo->CreateInfo.externalID = retVal;
+        pContextInfo->CreateInfo.pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
+        crHashtableAdd(cr_server.contextTable, retVal, pContextInfo);
+    }
+
+    if (retVal != -1 && !cr_server.bIsInLoadingState) {
+        int pos;
+        for (pos = 0; pos < CR_MAX_CONTEXTS; pos++) {
+            if (cr_server.curClient->contextList[pos] == 0) {
+                cr_server.curClient->contextList[pos] = retVal;
+                break;
+            }
+        }
+    }
+
+    crServerReturnValue( &retVal, sizeof(retVal) );
+
+    return retVal;
+}
+
+static int crServerRemoveClientContext(CRClient *pClient, GLint ctx)
+{
+    int pos;
+
+    for (pos = 0; pos < CR_MAX_CONTEXTS; ++pos)
+    {
+        if (pClient->contextList[pos] == ctx)
+        {
+            pClient->contextList[pos] = 0;
+            return true;
+        }
+    }
+
+    return false;
+}
+
+static void crServerCleanupMuralCtxUsageCB(unsigned long key, void *data1, void *data2)
+{
+    CRMuralInfo *mural = (CRMuralInfo *) data1;
+    CRContext *ctx = (CRContext *) data2;
+
+    CR_STATE_SHAREDOBJ_USAGE_CLEAR(mural, ctx);
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchDestroyContext( GLint ctx )
+{
+    CRContextInfo *crCtxInfo;
+    CRContext *crCtx;
+    int32_t client;
+    CRClientNode *pNode;
+    int found=false;
+
+    crCtxInfo = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, ctx);
+    if (!crCtxInfo) {
+        crWarning("CRServer: DestroyContext invalid context %d", ctx);
+        return;
+    }
+    crCtx = crCtxInfo->pContext;
+    CRASSERT(crCtx);
+
+    crDebug("CRServer: DestroyContext context %d", ctx);
+
+    if (cr_server.currentCtxInfo == crCtxInfo)
+    {
+        CRMuralInfo *dummyMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
+        crServerPerformMakeCurrent(dummyMural, &cr_server.MainContextInfo);
+        CRASSERT(cr_server.currentCtxInfo == &cr_server.MainContextInfo);
+    }
+
+    crHashtableWalk(cr_server.muralTable, crServerCleanupMuralCtxUsageCB, crCtx);
+    crCtxInfo->currentMural = NULL;
+    crHashtableDelete(cr_server.contextTable, ctx, NULL);
+    crStateDestroyContext( crCtx );
+
+    if (crCtxInfo->CreateInfo.pszDpyName)
+        crFree(crCtxInfo->CreateInfo.pszDpyName);
+
+    if (crCtxInfo->SpuContext >= 0)
+        cr_server.head_spu->dispatch_table.DestroyContext(crCtxInfo->SpuContext);
+
+    crFree(crCtxInfo);
+
+    if (cr_server.curClient)
+    {
+        /* If we delete our current context, default back to the null context */
+        if (cr_server.curClient->currentCtxInfo == crCtxInfo) {
+            cr_server.curClient->currentContextNumber = -1;
+            cr_server.curClient->currentCtxInfo = &cr_server.MainContextInfo;
+        }
+
+        found = crServerRemoveClientContext(cr_server.curClient, ctx);
+
+        /*Some application call destroy context not in a thread where it was created...have do deal with it.*/
+        if (!found)
+        {
+            for (client=0; client<cr_server.numClients; ++client)
+            {
+                if (cr_server.clients[client]==cr_server.curClient)
+                    continue;
+
+                found = crServerRemoveClientContext(cr_server.clients[client], ctx);
+
+                if (found) break;
+            }
+        }
+
+        if (!found)
+        {
+            pNode=cr_server.pCleanupClient;
+
+            while (pNode && !found)
+            {
+                found = crServerRemoveClientContext(pNode->pClient, ctx);
+                pNode = pNode->next;
+            }
+        }
+
+        CRASSERT(found);
+    }
+
+    /*Make sure this context isn't active in other clients*/
+    for (client=0; client<cr_server.numClients; ++client)
+    {
+        if (cr_server.clients[client]->currentCtxInfo == crCtxInfo)
+        {
+            cr_server.clients[client]->currentContextNumber = -1;
+            cr_server.clients[client]->currentCtxInfo = &cr_server.MainContextInfo;
+        }
+    }
+
+    pNode=cr_server.pCleanupClient;
+    while (pNode)
+    {
+        if (pNode->pClient->currentCtxInfo == crCtxInfo)
+        {
+            pNode->pClient->currentContextNumber = -1;
+            pNode->pClient->currentCtxInfo = &cr_server.MainContextInfo;
+        }
+        pNode = pNode->next;
+    }
+
+    CRASSERT(cr_server.currentCtxInfo != crCtxInfo);
+}
+
+void crServerPerformMakeCurrent( CRMuralInfo *mural, CRContextInfo *ctxInfo )
+{
+    CRMuralInfo *oldMural;
+    CRContext *ctx, *oldCtx = NULL;
+    GLuint idDrawFBO, idReadFBO;
+    GLint context = ctxInfo->CreateInfo.externalID;
+    GLint window = mural->CreateInfo.externalID;
+
+    cr_server.bForceMakeCurrentOnClientSwitch = GL_FALSE;
+
+    ctx = ctxInfo->pContext;
+    CRASSERT(ctx);
+
+    oldMural = cr_server.currentMural;
+
+    /* Ubuntu 11.04 hosts misbehave if context window switch is
+     * done with non-default framebuffer object settings.
+     * crStateSwitchPrepare & crStateSwitchPostprocess are supposed to work around this problem
+     * crStateSwitchPrepare restores the FBO state to its default values before the context window switch,
+     * while crStateSwitchPostprocess restores it back to the original values */
+    oldCtx = crStateGetCurrent();
+    if (oldMural && oldMural->fRedirected && crServerSupportRedirMuralFBO())
+    {
+        idDrawFBO = CR_SERVER_FBO_FOR_IDX(oldMural, oldMural->iCurDrawBuffer);
+        idReadFBO = CR_SERVER_FBO_FOR_IDX(oldMural, oldMural->iCurReadBuffer);
+    }
+    else
+    {
+        idDrawFBO = 0;
+        idReadFBO = 0;
+    }
+    crStateSwitchPrepare(cr_server.bUseMultipleContexts ? NULL : ctx, oldCtx, idDrawFBO, idReadFBO);
+
+    if (cr_server.curClient)
+    {
+        /*
+        crDebug("**** %s client %d  curCtx=%d curWin=%d", __func__,
+                        cr_server.curClient->number, ctxPos, window);
+        */
+        cr_server.curClient->currentContextNumber = context;
+        cr_server.curClient->currentCtxInfo = ctxInfo;
+        cr_server.curClient->currentMural = mural;
+        cr_server.curClient->currentWindow = window;
+
+        CRASSERT(cr_server.curClient->currentCtxInfo);
+        CRASSERT(cr_server.curClient->currentCtxInfo->pContext);
+    }
+
+    /* This is a hack to force updating the 'current' attribs */
+    crStateUpdateColorBits();
+
+    if (ctx)
+        crStateSetCurrentPointers( ctx, &(cr_server.current) );
+
+    /* check if being made current for first time, update viewport */
+#if 0
+    if (ctx) {
+        /* initialize the viewport */
+        if (ctx->viewport.viewportW == 0) {
+            ctx->viewport.viewportW = mural->width;
+            ctx->viewport.viewportH = mural->height;
+            ctx->viewport.scissorW = mural->width;
+            ctx->viewport.scissorH = mural->height;
+        }
+    }
+#endif
+
+    /*
+    crDebug("**** %s  currentWindow %d  newWindow %d", __func__,
+                    cr_server.currentWindow, window);
+    */
+
+    if (1/*cr_server.firstCallMakeCurrent ||
+            cr_server.currentWindow != window ||
+            cr_server.currentNativeWindow != nativeWindow*/) {
+        /* Since the cr server serialized all incoming contexts/clients into
+         * one output stream of GL commands, we only need to call the head
+         * SPU's MakeCurrent() function once.
+         * BUT, if we're rendering to multiple windows, we do have to issue
+         * MakeCurrent() calls sometimes.  The same GL context will always be
+         * used though.
+         */
+        cr_server.head_spu->dispatch_table.MakeCurrent( mural->spuWindow,
+                                                        0,
+                                                        ctxInfo->SpuContext >= 0
+                                                            ? ctxInfo->SpuContext
+                                                              : cr_server.MainContextInfo.SpuContext);
+
+        CR_STATE_SHAREDOBJ_USAGE_SET(mural, ctx);
+        if (cr_server.currentCtxInfo)
+            cr_server.currentCtxInfo->currentMural = NULL;
+        ctxInfo->currentMural = mural;
+
+        cr_server.firstCallMakeCurrent = GL_FALSE;
+        cr_server.currentCtxInfo = ctxInfo;
+        cr_server.currentWindow = window;
+        cr_server.currentNativeWindow = 0;
+        cr_server.currentMural = mural;
+    }
+
+    /* This used to be earlier, after crStateUpdateColorBits() call */
+    crStateMakeCurrent( ctx );
+
+    if (mural && mural->fRedirected  && crServerSupportRedirMuralFBO())
+    {
+        GLuint id = crServerMuralFBOIdxFromBufferName(mural, ctx->buffer.drawBuffer);
+        if (id != mural->iCurDrawBuffer)
+        {
+            crDebug("DBO draw buffer changed on make current");
+            mural->iCurDrawBuffer = id;
+        }
+
+        id = crServerMuralFBOIdxFromBufferName(mural, ctx->buffer.readBuffer);
+        if (id != mural->iCurReadBuffer)
+        {
+            crDebug("DBO read buffer changed on make current");
+            mural->iCurReadBuffer = id;
+        }
+
+        idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
+        idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
+    }
+    else
+    {
+        idDrawFBO = 0;
+        idReadFBO = 0;
+    }
+    crStateSwitchPostprocess(ctx, cr_server.bUseMultipleContexts ? NULL : oldCtx, idDrawFBO, idReadFBO);
+
+    if (!ctx->framebufferobject.drawFB
+            && (ctx->buffer.drawBuffer == GL_FRONT || ctx->buffer.drawBuffer == GL_FRONT_LEFT)
+            && cr_server.curClient)
+        cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
+
+    if (!mural->fRedirected)
+    {
+        ctx->buffer.width = mural->width;
+        ctx->buffer.height = mural->height;
+    }
+    else
+    {
+        ctx->buffer.width = 0;
+        ctx->buffer.height = 0;
+    }
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchMakeCurrent( GLint window, GLint nativeWindow, GLint context )
+{
+    CRMuralInfo *mural;
+    CRContextInfo *ctxInfo = NULL;
+
+    if (context >= 0 && window >= 0) {
+        mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
+        if (!mural)
+        {
+            crWarning("CRServer: invalid window %d passed to crServerDispatchMakeCurrent()", window);
+            return;
+        }
+
+        /* Update the state tracker's current context */
+        ctxInfo = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, context);
+        if (!ctxInfo) {
+            crWarning("CRserver: NULL context in MakeCurrent %d", context);
+            return;
+        }
+    }
+    else {
+#if 0
+        oldMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, cr_server.currentWindow);
+        if (oldMural && oldMural->bUseFBO && crServerSupportRedirMuralFBO())
+        {
+            if (!crStateGetCurrent()->framebufferobject.drawFB)
+            {
+                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0);
+            }
+            if (!crStateGetCurrent()->framebufferobject.readFB)
+            {
+                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, 0);
+            }
+        }
+
+        ctxInfo = &cr_server.MainContextInfo;
+        window = -1;
+        mural = NULL;
+#endif
+        cr_server.bForceMakeCurrentOnClientSwitch = GL_TRUE;
+        return;
+    }
+
+    crServerPerformMakeCurrent( mural, ctxInfo );
+}
+
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch.py
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch.py	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_dispatch.py	(revision 78190)
@@ -110,5 +110,5 @@
         print('\t{')
         print('\t\tcr_server.head_spu->dispatch_table.%s(%s);' % (func_name, apiutil.MakeCallStringForDispatcher(params) ))
-        print("\t\tcr_server.current.c.%s.%s%s = cr_unpackData;" % (name,type,array))
+        print("\t\tcr_server.current.c.%s.%s%s = cr_server.pUnpackerState->pbUnpackData;" % (name,type,array))
         print('\t}')
         print('}\n')
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_framebuffer.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_framebuffer.c	(revision 78189)
+++ 	(revision )
@@ -1,237 +1,0 @@
-/* $Id$ */
-/** @file
- * VBox OpenGL: EXT_framebuffer_object
- */
-
-/*
- * Copyright (C) 2009-2019 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#include "cr_spu.h"
-#include "chromium.h"
-#include "cr_mem.h"
-#include "cr_net.h"
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_unpack.h"
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGenFramebuffersEXT(GLsizei n, GLuint *framebuffers)
-{
-    GLuint *local_buffers;
-    (void) framebuffers;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchGenFramebuffersEXT: parameter 'n' is out of range");
-        return;
-    }
-
-    local_buffers = (GLuint *)crCalloc(n * sizeof(*local_buffers));
-
-    crStateGenFramebuffersEXT(n, local_buffers);
-
-    crServerReturnValue(local_buffers, n * sizeof(*local_buffers));
-    crFree(local_buffers);
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers)
-{
-    GLuint *local_buffers;
-    (void) renderbuffers;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchGenRenderbuffersEXT: parameter 'n' is out of range");
-        return;
-    }
-
-    local_buffers = (GLuint *)crCalloc(n * sizeof(*local_buffers));
-
-    crStateGenRenderbuffersEXT(n, local_buffers);
-
-    crServerReturnValue(local_buffers, n * sizeof(*local_buffers));
-    crFree(local_buffers);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
-{
-    crStateFramebufferTexture1DEXT(target, attachment, textarget, texture, level);
-    cr_server.head_spu->dispatch_table.FramebufferTexture1DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
-{
-    crStateFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
-    cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
-{
-    crStateFramebufferTexture3DEXT(target, attachment, textarget, texture, level, zoffset);
-    cr_server.head_spu->dispatch_table.FramebufferTexture3DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level, zoffset);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchBindFramebufferEXT(GLenum target, GLuint framebuffer)
-{
-#ifdef DEBUG_misha
-    GLint rfb = 0, dfb = 0;
-#endif
-        crStateBindFramebufferEXT(target, framebuffer);
-
-    if (0==framebuffer)
-    {
-        CRContext *ctx = crStateGetCurrent();
-        if (ctx->buffer.drawBuffer == GL_FRONT || ctx->buffer.drawBuffer == GL_FRONT_LEFT || ctx->buffer.drawBuffer == GL_FRONT_RIGHT)
-            cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
-    }
-
-    if (0==framebuffer && crServerIsRedirectedToFBO())
-    {
-        CRMuralInfo *mural = cr_server.curClient->currentMural;
-        if (target == GL_FRAMEBUFFER)
-        {
-            GLuint idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
-            GLuint idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
-            if (idDrawFBO == idReadFBO)
-                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_FRAMEBUFFER, idDrawFBO);
-            else
-            {
-                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, idReadFBO);
-                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, idDrawFBO);
-            }
-        }
-        else if (target == GL_READ_FRAMEBUFFER)
-        {
-            GLuint idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
-            cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, idReadFBO);
-        }
-        else if (target == GL_DRAW_FRAMEBUFFER)
-        {
-            GLuint idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
-            cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, idDrawFBO);
-        }
-        else
-        {
-            crWarning("unknown target %d", target);
-        }
-#ifdef DEBUG_misha
-        cr_server.head_spu->dispatch_table.GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
-        cr_server.head_spu->dispatch_table.GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
-        if (GL_FRAMEBUFFER_EXT == target)
-        {
-            Assert(rfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
-            Assert(dfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
-        }
-        else if (GL_READ_FRAMEBUFFER_EXT == target)
-        {
-            Assert(rfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
-        }
-        else if (GL_DRAW_FRAMEBUFFER_EXT == target)
-        {
-            Assert(dfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
-        }
-        else
-        {
-            Assert(0);
-        }
-#endif
-    }
-    else
-    {
-        cr_server.head_spu->dispatch_table.BindFramebufferEXT(target, crStateGetFramebufferHWID(framebuffer));
-#ifdef DEBUG_misha
-        cr_server.head_spu->dispatch_table.GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
-        cr_server.head_spu->dispatch_table.GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
-        if (GL_FRAMEBUFFER_EXT == target)
-        {
-            Assert(rfb == crStateGetFramebufferHWID(framebuffer));
-            Assert(dfb == crStateGetFramebufferHWID(framebuffer));
-        }
-        else if (GL_READ_FRAMEBUFFER_EXT == target)
-        {
-            Assert(rfb == crStateGetFramebufferHWID(framebuffer));
-        }
-        else if (GL_DRAW_FRAMEBUFFER_EXT == target)
-        {
-            Assert(dfb == crStateGetFramebufferHWID(framebuffer));
-        }
-        else
-        {
-            Assert(0);
-        }
-#endif
-    }
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchBindRenderbufferEXT(GLenum target, GLuint renderbuffer)
-{
-        crStateBindRenderbufferEXT(target, renderbuffer);
-        cr_server.head_spu->dispatch_table.BindRenderbufferEXT(target, crStateGetRenderbufferHWID(renderbuffer));
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers)
-{
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint) || !DATA_POINTER_CHECK(n * sizeof(GLuint)))
-    {
-        crError("crStateDeleteFramebuffersEXT: parameter 'n' is out of range");
-        return;
-    }
-
-    crStateDeleteFramebuffersEXT(n, framebuffers);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers)
-{
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint) || !DATA_POINTER_CHECK(n * sizeof(GLuint)))
-    {
-        crError("glDeleteRenderbuffersEXT: parameter 'n' is out of range");
-        return;
-    }
-
-    crStateDeleteRenderbuffersEXT(n, renderbuffers);
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
-{
-        crStateFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer);
-        cr_server.head_spu->dispatch_table.FramebufferRenderbufferEXT(target, attachment, renderbuffertarget, crStateGetRenderbufferHWID(renderbuffer));
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params)
-{
-        GLint local_params[1];
-        (void) params;
-        crStateGetFramebufferAttachmentParameterivEXT(target, attachment, pname, local_params);
-
-        crServerReturnValue(&(local_params[0]), 1*sizeof(GLint));
-}
-
-GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsFramebufferEXT( GLuint framebuffer )
-{
-    /* since GenFramebuffers/Renderbuffers issued to host ogl only on bind + some other ops, the host drivers may not know about them
-     * so use state data*/
-    GLboolean retval = crStateIsFramebufferEXT(framebuffer);
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
-
-GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsRenderbufferEXT( GLuint renderbuffer )
-{
-    /* since GenFramebuffers/Renderbuffers issued to host ogl only on bind + some other ops, the host drivers may not know about them
-     * so use state data*/
-    GLboolean retval = crStateIsRenderbufferEXT(renderbuffer);
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_framebuffer.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_framebuffer.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_framebuffer.cpp	(revision 78190)
@@ -0,0 +1,237 @@
+/* $Id$ */
+/** @file
+ * VBox OpenGL: EXT_framebuffer_object
+ */
+
+/*
+ * Copyright (C) 2009-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include "cr_spu.h"
+#include "chromium.h"
+#include "cr_mem.h"
+#include "cr_net.h"
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_unpack.h"
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGenFramebuffersEXT(GLsizei n, GLuint *framebuffers)
+{
+    GLuint *local_buffers;
+    (void) framebuffers;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchGenFramebuffersEXT: parameter 'n' is out of range");
+        return;
+    }
+
+    local_buffers = (GLuint *)crCalloc(n * sizeof(*local_buffers));
+
+    crStateGenFramebuffersEXT(n, local_buffers);
+
+    crServerReturnValue(local_buffers, n * sizeof(*local_buffers));
+    crFree(local_buffers);
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers)
+{
+    GLuint *local_buffers;
+    (void) renderbuffers;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchGenRenderbuffersEXT: parameter 'n' is out of range");
+        return;
+    }
+
+    local_buffers = (GLuint *)crCalloc(n * sizeof(*local_buffers));
+
+    crStateGenRenderbuffersEXT(n, local_buffers);
+
+    crServerReturnValue(local_buffers, n * sizeof(*local_buffers));
+    crFree(local_buffers);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+    crStateFramebufferTexture1DEXT(target, attachment, textarget, texture, level);
+    cr_server.head_spu->dispatch_table.FramebufferTexture1DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+    crStateFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
+    cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
+{
+    crStateFramebufferTexture3DEXT(target, attachment, textarget, texture, level, zoffset);
+    cr_server.head_spu->dispatch_table.FramebufferTexture3DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level, zoffset);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchBindFramebufferEXT(GLenum target, GLuint framebuffer)
+{
+#ifdef DEBUG_misha
+    GLint rfb = 0, dfb = 0;
+#endif
+        crStateBindFramebufferEXT(target, framebuffer);
+
+    if (0==framebuffer)
+    {
+        CRContext *ctx = crStateGetCurrent();
+        if (ctx->buffer.drawBuffer == GL_FRONT || ctx->buffer.drawBuffer == GL_FRONT_LEFT || ctx->buffer.drawBuffer == GL_FRONT_RIGHT)
+            cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
+    }
+
+    if (0==framebuffer && crServerIsRedirectedToFBO())
+    {
+        CRMuralInfo *mural = cr_server.curClient->currentMural;
+        if (target == GL_FRAMEBUFFER)
+        {
+            GLuint idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
+            GLuint idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
+            if (idDrawFBO == idReadFBO)
+                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_FRAMEBUFFER, idDrawFBO);
+            else
+            {
+                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, idReadFBO);
+                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, idDrawFBO);
+            }
+        }
+        else if (target == GL_READ_FRAMEBUFFER)
+        {
+            GLuint idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
+            cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, idReadFBO);
+        }
+        else if (target == GL_DRAW_FRAMEBUFFER)
+        {
+            GLuint idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
+            cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, idDrawFBO);
+        }
+        else
+        {
+            crWarning("unknown target %d", target);
+        }
+#ifdef DEBUG_misha
+        cr_server.head_spu->dispatch_table.GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
+        cr_server.head_spu->dispatch_table.GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
+        if (GL_FRAMEBUFFER_EXT == target)
+        {
+            Assert(rfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
+            Assert(dfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
+        }
+        else if (GL_READ_FRAMEBUFFER_EXT == target)
+        {
+            Assert(rfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
+        }
+        else if (GL_DRAW_FRAMEBUFFER_EXT == target)
+        {
+            Assert(dfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
+        }
+        else
+        {
+            Assert(0);
+        }
+#endif
+    }
+    else
+    {
+        cr_server.head_spu->dispatch_table.BindFramebufferEXT(target, crStateGetFramebufferHWID(framebuffer));
+#ifdef DEBUG_misha
+        cr_server.head_spu->dispatch_table.GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
+        cr_server.head_spu->dispatch_table.GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
+        if (GL_FRAMEBUFFER_EXT == target)
+        {
+            Assert(rfb == crStateGetFramebufferHWID(framebuffer));
+            Assert(dfb == crStateGetFramebufferHWID(framebuffer));
+        }
+        else if (GL_READ_FRAMEBUFFER_EXT == target)
+        {
+            Assert(rfb == crStateGetFramebufferHWID(framebuffer));
+        }
+        else if (GL_DRAW_FRAMEBUFFER_EXT == target)
+        {
+            Assert(dfb == crStateGetFramebufferHWID(framebuffer));
+        }
+        else
+        {
+            Assert(0);
+        }
+#endif
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchBindRenderbufferEXT(GLenum target, GLuint renderbuffer)
+{
+        crStateBindRenderbufferEXT(target, renderbuffer);
+        cr_server.head_spu->dispatch_table.BindRenderbufferEXT(target, crStateGetRenderbufferHWID(renderbuffer));
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers)
+{
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crStateDeleteFramebuffersEXT: parameter 'n' is out of range");
+        return;
+    }
+
+    crStateDeleteFramebuffersEXT(n, framebuffers);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers)
+{
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("glDeleteRenderbuffersEXT: parameter 'n' is out of range");
+        return;
+    }
+
+    crStateDeleteRenderbuffersEXT(n, renderbuffers);
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+        crStateFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer);
+        cr_server.head_spu->dispatch_table.FramebufferRenderbufferEXT(target, attachment, renderbuffertarget, crStateGetRenderbufferHWID(renderbuffer));
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params)
+{
+        GLint local_params[1];
+        (void) params;
+        crStateGetFramebufferAttachmentParameterivEXT(target, attachment, pname, local_params);
+
+        crServerReturnValue(&(local_params[0]), 1*sizeof(GLint));
+}
+
+GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsFramebufferEXT( GLuint framebuffer )
+{
+    /* since GenFramebuffers/Renderbuffers issued to host ogl only on bind + some other ops, the host drivers may not know about them
+     * so use state data*/
+    GLboolean retval = crStateIsFramebufferEXT(framebuffer);
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
+
+GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsRenderbufferEXT( GLuint renderbuffer )
+{
+    /* since GenFramebuffers/Renderbuffers issued to host ogl only on bind + some other ops, the host drivers may not know about them
+     * so use state data*/
+    GLboolean retval = crStateIsRenderbufferEXT(renderbuffer);
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_gentextures.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_gentextures.c	(revision 78189)
+++ 	(revision )
@@ -1,142 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_spu.h"
-#include "chromium.h"
-#include "cr_mem.h"
-#include "cr_net.h"
-#include "server_dispatch.h"
-#include "server.h"
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGenTextures( GLsizei n, GLuint *textures )
-{
-    GLuint *local_textures;
-    (void) textures;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchGenTextures: parameter 'n' is out of range");
-        return;
-    }
-
-    local_textures = (GLuint *)crCalloc(n * sizeof(*local_textures));
-
-    if (!local_textures)
-    {
-        crError("crServerDispatchGenTextures: out of memory");
-        return;
-    }
-
-    crStateGenTextures(n, local_textures);
-
-    crServerReturnValue(local_textures, n*sizeof(*local_textures));
-    crFree( local_textures );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsNV( GLsizei n, GLuint * ids )
-{
-    GLuint *local_progs;
-    (void) ids;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchGenProgramsNV: parameter 'n' is out of range");
-        return;
-    }
-
-    local_progs = (GLuint *)crCalloc(n * sizeof(*local_progs));
-
-    if (!local_progs)
-    {
-        crError("crServerDispatchGenProgramsNV: out of memory");
-        return;
-    }
-
-    cr_server.head_spu->dispatch_table.GenProgramsNV( n, local_progs );
-    crServerReturnValue( local_progs, n*sizeof( *local_progs ) );
-    crFree( local_progs );
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGenFencesNV( GLsizei n, GLuint * ids )
-{
-    GLuint *local_fences;
-    (void) ids;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchGenFencesNV: parameter 'n' is out of range");
-        return;
-    }
-
-    local_fences = (GLuint *)crCalloc(n * sizeof(*local_fences));
-
-    if (!local_fences)
-    {
-        crError("crServerDispatchGenFencesNV: out of memory");
-        return;
-    }
-
-    cr_server.head_spu->dispatch_table.GenFencesNV( n, local_fences );
-    crServerReturnValue( local_fences, n*sizeof( *local_fences ) );
-    crFree( local_fences );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsARB( GLsizei n, GLuint * ids )
-{
-    GLuint *local_progs;
-    GLsizei i;
-    (void) ids;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchGenProgramsARB: parameter 'n' is out of range");
-        return;
-    }
-
-    local_progs = (GLuint *)crCalloc(n * sizeof(*local_progs));
-
-    if (!local_progs)
-    {
-        crError("crServerDispatchGenProgramsARB: out of money");
-        return;
-    }
-
-    cr_server.head_spu->dispatch_table.GenProgramsARB( n, local_progs );
-
-    /* see comments in crServerDispatchGenTextures */
-    for (i=0; i<n; ++i)
-    {
-        GLuint tID = crServerTranslateProgramID(local_progs[i]);
-        while (crStateIsProgramARB(tID))
-        {
-            cr_server.head_spu->dispatch_table.GenProgramsARB(1, &tID);
-            local_progs[i] = tID;
-            tID = crServerTranslateProgramID(tID);
-        }
-    }
-
-    crServerReturnValue( local_progs, n * sizeof( *local_progs ) );
-    crFree( local_progs );
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
-{
-    GLsizei tw, th;
-
-    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &tw);
-    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &th);
-
-    /* Workaround for a wine or ati bug. Host drivers crash unless we first provide texture bounds. */
-    if (((tw!=width) || (th!=height)) && (internalFormat==GL_DEPTH_COMPONENT24))
-    {
-        crServerDispatchTexImage2D(target, level, internalFormat, width, height, border, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
-    }
-
-    crStateCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
-    cr_server.head_spu->dispatch_table.CopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_gentextures.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_gentextures.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_gentextures.cpp	(revision 78190)
@@ -0,0 +1,142 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "cr_spu.h"
+#include "chromium.h"
+#include "cr_mem.h"
+#include "cr_net.h"
+#include "server_dispatch.h"
+#include "server.h"
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGenTextures( GLsizei n, GLuint *textures )
+{
+    GLuint *local_textures;
+    (void) textures;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchGenTextures: parameter 'n' is out of range");
+        return;
+    }
+
+    local_textures = (GLuint *)crCalloc(n * sizeof(*local_textures));
+
+    if (!local_textures)
+    {
+        crError("crServerDispatchGenTextures: out of memory");
+        return;
+    }
+
+    crStateGenTextures(n, local_textures);
+
+    crServerReturnValue(local_textures, n*sizeof(*local_textures));
+    crFree( local_textures );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsNV( GLsizei n, GLuint * ids )
+{
+    GLuint *local_progs;
+    (void) ids;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchGenProgramsNV: parameter 'n' is out of range");
+        return;
+    }
+
+    local_progs = (GLuint *)crCalloc(n * sizeof(*local_progs));
+
+    if (!local_progs)
+    {
+        crError("crServerDispatchGenProgramsNV: out of memory");
+        return;
+    }
+
+    cr_server.head_spu->dispatch_table.GenProgramsNV( n, local_progs );
+    crServerReturnValue( local_progs, n*sizeof( *local_progs ) );
+    crFree( local_progs );
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGenFencesNV( GLsizei n, GLuint * ids )
+{
+    GLuint *local_fences;
+    (void) ids;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchGenFencesNV: parameter 'n' is out of range");
+        return;
+    }
+
+    local_fences = (GLuint *)crCalloc(n * sizeof(*local_fences));
+
+    if (!local_fences)
+    {
+        crError("crServerDispatchGenFencesNV: out of memory");
+        return;
+    }
+
+    cr_server.head_spu->dispatch_table.GenFencesNV( n, local_fences );
+    crServerReturnValue( local_fences, n*sizeof( *local_fences ) );
+    crFree( local_fences );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsARB( GLsizei n, GLuint * ids )
+{
+    GLuint *local_progs;
+    GLsizei i;
+    (void) ids;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchGenProgramsARB: parameter 'n' is out of range");
+        return;
+    }
+
+    local_progs = (GLuint *)crCalloc(n * sizeof(*local_progs));
+
+    if (!local_progs)
+    {
+        crError("crServerDispatchGenProgramsARB: out of money");
+        return;
+    }
+
+    cr_server.head_spu->dispatch_table.GenProgramsARB( n, local_progs );
+
+    /* see comments in crServerDispatchGenTextures */
+    for (i=0; i<n; ++i)
+    {
+        GLuint tID = crServerTranslateProgramID(local_progs[i]);
+        while (crStateIsProgramARB(tID))
+        {
+            cr_server.head_spu->dispatch_table.GenProgramsARB(1, &tID);
+            local_progs[i] = tID;
+            tID = crServerTranslateProgramID(tID);
+        }
+    }
+
+    crServerReturnValue( local_progs, n * sizeof( *local_progs ) );
+    crFree( local_progs );
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+    GLsizei tw, th;
+
+    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &tw);
+    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &th);
+
+    /* Workaround for a wine or ati bug. Host drivers crash unless we first provide texture bounds. */
+    if (((tw!=width) || (th!=height)) && (internalFormat==GL_DEPTH_COMPONENT24))
+    {
+        crServerDispatchTexImage2D(target, level, internalFormat, width, height, border, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
+    }
+
+    crStateCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
+    cr_server.head_spu->dispatch_table.CopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getmap.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getmap.c	(revision 78189)
+++ 	(revision )
@@ -1,247 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_spu.h"
-#include "chromium.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_net.h"
-#include "server_dispatch.h"
-#include "server.h"
-
-static GLuint __evaluator_components( GLenum target )
-{
-   switch (target) {
-      case GL_MAP1_VERTEX_3:        return 3;
-      case GL_MAP1_VERTEX_4:        return 4;
-      case GL_MAP1_INDEX:        return 1;
-      case GL_MAP1_COLOR_4:        return 4;
-      case GL_MAP1_NORMAL:        return 3;
-      case GL_MAP1_TEXTURE_COORD_1:    return 1;
-      case GL_MAP1_TEXTURE_COORD_2:    return 2;
-      case GL_MAP1_TEXTURE_COORD_3:    return 3;
-      case GL_MAP1_TEXTURE_COORD_4:    return 4;
-      case GL_MAP2_VERTEX_3:        return 3;
-      case GL_MAP2_VERTEX_4:        return 4;
-      case GL_MAP2_INDEX:        return 1;
-      case GL_MAP2_COLOR_4:        return 4;
-      case GL_MAP2_NORMAL:        return 3;
-      case GL_MAP2_TEXTURE_COORD_1:    return 1;
-      case GL_MAP2_TEXTURE_COORD_2:    return 2;
-      case GL_MAP2_TEXTURE_COORD_3:    return 3;
-      case GL_MAP2_TEXTURE_COORD_4:    return 4;
-      default:    return 0;
-   }
-}
-
-static GLuint __evaluator_dimension( GLenum target )
-{
-    switch( target )
-    {
-        case GL_MAP1_COLOR_4:
-        case GL_MAP1_INDEX:
-        case GL_MAP1_NORMAL:
-        case GL_MAP1_TEXTURE_COORD_1:
-        case GL_MAP1_TEXTURE_COORD_2:
-        case GL_MAP1_TEXTURE_COORD_3:
-        case GL_MAP1_TEXTURE_COORD_4:
-        case GL_MAP1_VERTEX_3:
-        case GL_MAP1_VERTEX_4:
-            return 1;
-
-        case GL_MAP2_COLOR_4:
-        case GL_MAP2_INDEX:
-        case GL_MAP2_NORMAL:
-        case GL_MAP2_TEXTURE_COORD_1:
-        case GL_MAP2_TEXTURE_COORD_2:
-        case GL_MAP2_TEXTURE_COORD_3:
-        case GL_MAP2_TEXTURE_COORD_4:
-        case GL_MAP2_VERTEX_3:
-        case GL_MAP2_VERTEX_4:
-            return 2;
-
-        default:
-            return 0;
-    }
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapdv( GLenum target, GLenum query, GLdouble *v )
-{
-    GLdouble *coeffs = NULL;
-    GLdouble *retptr = NULL;
-    GLdouble order[2]  = {0};
-    GLdouble domain[4] = {0};
-    GLint tempOrder[2] = {0};
-    int dimension, evalcomp;
-    unsigned int size = sizeof(GLdouble);
-    (void) v;
-
-    evalcomp  = __evaluator_components(target);
-    dimension = __evaluator_dimension(target);
-
-    if (evalcomp == 0 || dimension == 0)
-    {
-        crError( "Bad target in crServerDispatchGetMapdv: %d", target );
-        return;
-    }
-
-    switch(query)
-    {
-        case GL_ORDER:
-            cr_server.head_spu->dispatch_table.GetMapdv( target, query, order );
-            retptr = &(order[0]);
-            size *= dimension;
-            break;
-        case GL_DOMAIN:
-            cr_server.head_spu->dispatch_table.GetMapdv( target, query, domain );
-            retptr = &(domain[0]);
-            size *= dimension * 2;
-            break;
-        case GL_COEFF:
-            cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
-            size *= evalcomp * tempOrder[0];
-            if (dimension == 2)
-                size *= tempOrder[1];
-
-            if (size)
-                coeffs = (GLdouble *) crCalloc( size );
-
-            if (coeffs)
-            {
-                cr_server.head_spu->dispatch_table.GetMapdv( target, query, coeffs );
-                retptr = coeffs;
-            }
-            break;
-        default:
-            crError( "Bad query in crServerDispatchGetMapdv: %d", query );
-            return;
-    }
-
-    crServerReturnValue( retptr, size );
-    if (coeffs)
-    {
-        crFree(coeffs);
-    }
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapfv( GLenum target, GLenum query, GLfloat *v )
-{
-    GLfloat *coeffs = NULL;
-    GLfloat *retptr = NULL;
-    GLfloat order[2] = {0};
-    GLfloat domain[4] = {0};
-    GLint tempOrder[2] = {0};
-    int dimension, evalcomp;
-    unsigned int size = sizeof(GLfloat);
-    (void) v;
-
-    evalcomp  = __evaluator_components(target);
-    dimension = __evaluator_dimension(target);
-
-    if (evalcomp == 0 || dimension == 0)
-    {
-        crError( "Bad target in crServerDispatchGetMapfv: %d", target );
-        return;
-    }
-
-    switch(query)
-    {
-        case GL_ORDER:
-            cr_server.head_spu->dispatch_table.GetMapfv( target, query, order );
-            retptr = &(order[0]);
-            size *= dimension;
-            break;
-        case GL_DOMAIN:
-            cr_server.head_spu->dispatch_table.GetMapfv( target, query, domain );
-            retptr = &(domain[0]);
-            size *= dimension * 2;
-            break;
-        case GL_COEFF:
-            cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
-            size *= evalcomp * tempOrder[0];
-            if (dimension == 2)
-                size *= tempOrder[1];
-
-            if (size)
-                coeffs = (GLfloat *) crCalloc( size );
-
-            if (coeffs)
-            {
-                cr_server.head_spu->dispatch_table.GetMapfv( target, query, coeffs );
-                retptr = coeffs;
-            }
-            break;
-        default:
-            crError( "Bad query in crServerDispatchGetMapfv: %d", query );
-            return;
-    }
-
-    crServerReturnValue( retptr, size );
-    if (coeffs)
-    {
-        crFree(coeffs);
-    }
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapiv( GLenum target, GLenum query, GLint *v )
-{
-    GLint *coeffs = NULL;
-    GLint *retptr = NULL;
-    GLint order[2] = {0};
-    GLint domain[4] = {0};
-    GLint tempOrder[2] = {0};
-    int dimension, evalcomp;
-    unsigned int size = sizeof(GLint);
-    (void) v;
-
-    evalcomp  = __evaluator_components(target);
-    dimension = __evaluator_dimension(target);
-
-    if (evalcomp == 0 || dimension == 0)
-    {
-        crError( "Bad target in crServerDispatchGetMapiv: %d", target );
-        return;
-    }
-
-    switch(query)
-    {
-        case GL_ORDER:
-            cr_server.head_spu->dispatch_table.GetMapiv( target, query, order );
-            retptr = &(order[0]);
-            size *= dimension;
-            break;
-        case GL_DOMAIN:
-            cr_server.head_spu->dispatch_table.GetMapiv( target, query, domain );
-            retptr = &(domain[0]);
-            size *= dimension * 2;
-            break;
-        case GL_COEFF:
-            cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
-            size *= evalcomp * tempOrder[0];
-            if (dimension == 2)
-                size *= tempOrder[1];
-
-            if (size)
-                coeffs = (GLint *) crCalloc( size );
-
-            if (coeffs)
-            {
-                cr_server.head_spu->dispatch_table.GetMapiv( target, query, coeffs );
-                retptr = coeffs;
-            }
-            break;
-        default:
-            crError( "Bad query in crServerDispatchGetMapiv: %d", query );
-            break;
-    }
-
-    crServerReturnValue( retptr, size );
-    if (coeffs)
-    {
-        crFree(coeffs);
-    }
-}
-
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getmap.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getmap.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getmap.cpp	(revision 78190)
@@ -0,0 +1,247 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "cr_spu.h"
+#include "chromium.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "cr_net.h"
+#include "server_dispatch.h"
+#include "server.h"
+
+static GLuint __evaluator_components( GLenum target )
+{
+   switch (target) {
+      case GL_MAP1_VERTEX_3:        return 3;
+      case GL_MAP1_VERTEX_4:        return 4;
+      case GL_MAP1_INDEX:        return 1;
+      case GL_MAP1_COLOR_4:        return 4;
+      case GL_MAP1_NORMAL:        return 3;
+      case GL_MAP1_TEXTURE_COORD_1:    return 1;
+      case GL_MAP1_TEXTURE_COORD_2:    return 2;
+      case GL_MAP1_TEXTURE_COORD_3:    return 3;
+      case GL_MAP1_TEXTURE_COORD_4:    return 4;
+      case GL_MAP2_VERTEX_3:        return 3;
+      case GL_MAP2_VERTEX_4:        return 4;
+      case GL_MAP2_INDEX:        return 1;
+      case GL_MAP2_COLOR_4:        return 4;
+      case GL_MAP2_NORMAL:        return 3;
+      case GL_MAP2_TEXTURE_COORD_1:    return 1;
+      case GL_MAP2_TEXTURE_COORD_2:    return 2;
+      case GL_MAP2_TEXTURE_COORD_3:    return 3;
+      case GL_MAP2_TEXTURE_COORD_4:    return 4;
+      default:    return 0;
+   }
+}
+
+static GLuint __evaluator_dimension( GLenum target )
+{
+    switch( target )
+    {
+        case GL_MAP1_COLOR_4:
+        case GL_MAP1_INDEX:
+        case GL_MAP1_NORMAL:
+        case GL_MAP1_TEXTURE_COORD_1:
+        case GL_MAP1_TEXTURE_COORD_2:
+        case GL_MAP1_TEXTURE_COORD_3:
+        case GL_MAP1_TEXTURE_COORD_4:
+        case GL_MAP1_VERTEX_3:
+        case GL_MAP1_VERTEX_4:
+            return 1;
+
+        case GL_MAP2_COLOR_4:
+        case GL_MAP2_INDEX:
+        case GL_MAP2_NORMAL:
+        case GL_MAP2_TEXTURE_COORD_1:
+        case GL_MAP2_TEXTURE_COORD_2:
+        case GL_MAP2_TEXTURE_COORD_3:
+        case GL_MAP2_TEXTURE_COORD_4:
+        case GL_MAP2_VERTEX_3:
+        case GL_MAP2_VERTEX_4:
+            return 2;
+
+        default:
+            return 0;
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapdv( GLenum target, GLenum query, GLdouble *v )
+{
+    GLdouble *coeffs = NULL;
+    GLdouble *retptr = NULL;
+    GLdouble order[2]  = {0};
+    GLdouble domain[4] = {0};
+    GLint tempOrder[2] = {0};
+    int dimension, evalcomp;
+    unsigned int size = sizeof(GLdouble);
+    (void) v;
+
+    evalcomp  = __evaluator_components(target);
+    dimension = __evaluator_dimension(target);
+
+    if (evalcomp == 0 || dimension == 0)
+    {
+        crError( "Bad target in crServerDispatchGetMapdv: %d", target );
+        return;
+    }
+
+    switch(query)
+    {
+        case GL_ORDER:
+            cr_server.head_spu->dispatch_table.GetMapdv( target, query, order );
+            retptr = &(order[0]);
+            size *= dimension;
+            break;
+        case GL_DOMAIN:
+            cr_server.head_spu->dispatch_table.GetMapdv( target, query, domain );
+            retptr = &(domain[0]);
+            size *= dimension * 2;
+            break;
+        case GL_COEFF:
+            cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
+            size *= evalcomp * tempOrder[0];
+            if (dimension == 2)
+                size *= tempOrder[1];
+
+            if (size)
+                coeffs = (GLdouble *) crCalloc( size );
+
+            if (coeffs)
+            {
+                cr_server.head_spu->dispatch_table.GetMapdv( target, query, coeffs );
+                retptr = coeffs;
+            }
+            break;
+        default:
+            crError( "Bad query in crServerDispatchGetMapdv: %d", query );
+            return;
+    }
+
+    crServerReturnValue( retptr, size );
+    if (coeffs)
+    {
+        crFree(coeffs);
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapfv( GLenum target, GLenum query, GLfloat *v )
+{
+    GLfloat *coeffs = NULL;
+    GLfloat *retptr = NULL;
+    GLfloat order[2] = {0};
+    GLfloat domain[4] = {0};
+    GLint tempOrder[2] = {0};
+    int dimension, evalcomp;
+    unsigned int size = sizeof(GLfloat);
+    (void) v;
+
+    evalcomp  = __evaluator_components(target);
+    dimension = __evaluator_dimension(target);
+
+    if (evalcomp == 0 || dimension == 0)
+    {
+        crError( "Bad target in crServerDispatchGetMapfv: %d", target );
+        return;
+    }
+
+    switch(query)
+    {
+        case GL_ORDER:
+            cr_server.head_spu->dispatch_table.GetMapfv( target, query, order );
+            retptr = &(order[0]);
+            size *= dimension;
+            break;
+        case GL_DOMAIN:
+            cr_server.head_spu->dispatch_table.GetMapfv( target, query, domain );
+            retptr = &(domain[0]);
+            size *= dimension * 2;
+            break;
+        case GL_COEFF:
+            cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
+            size *= evalcomp * tempOrder[0];
+            if (dimension == 2)
+                size *= tempOrder[1];
+
+            if (size)
+                coeffs = (GLfloat *) crCalloc( size );
+
+            if (coeffs)
+            {
+                cr_server.head_spu->dispatch_table.GetMapfv( target, query, coeffs );
+                retptr = coeffs;
+            }
+            break;
+        default:
+            crError( "Bad query in crServerDispatchGetMapfv: %d", query );
+            return;
+    }
+
+    crServerReturnValue( retptr, size );
+    if (coeffs)
+    {
+        crFree(coeffs);
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetMapiv( GLenum target, GLenum query, GLint *v )
+{
+    GLint *coeffs = NULL;
+    GLint *retptr = NULL;
+    GLint order[2] = {0};
+    GLint domain[4] = {0};
+    GLint tempOrder[2] = {0};
+    int dimension, evalcomp;
+    unsigned int size = sizeof(GLint);
+    (void) v;
+
+    evalcomp  = __evaluator_components(target);
+    dimension = __evaluator_dimension(target);
+
+    if (evalcomp == 0 || dimension == 0)
+    {
+        crError( "Bad target in crServerDispatchGetMapiv: %d", target );
+        return;
+    }
+
+    switch(query)
+    {
+        case GL_ORDER:
+            cr_server.head_spu->dispatch_table.GetMapiv( target, query, order );
+            retptr = &(order[0]);
+            size *= dimension;
+            break;
+        case GL_DOMAIN:
+            cr_server.head_spu->dispatch_table.GetMapiv( target, query, domain );
+            retptr = &(domain[0]);
+            size *= dimension * 2;
+            break;
+        case GL_COEFF:
+            cr_server.head_spu->dispatch_table.GetMapiv( target, GL_ORDER, tempOrder );
+            size *= evalcomp * tempOrder[0];
+            if (dimension == 2)
+                size *= tempOrder[1];
+
+            if (size)
+                coeffs = (GLint *) crCalloc( size );
+
+            if (coeffs)
+            {
+                cr_server.head_spu->dispatch_table.GetMapiv( target, query, coeffs );
+                retptr = coeffs;
+            }
+            break;
+        default:
+            crError( "Bad query in crServerDispatchGetMapiv: %d", query );
+            break;
+    }
+
+    crServerReturnValue( retptr, size );
+    if (coeffs)
+    {
+        crFree(coeffs);
+    }
+}
+
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpixelmap.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpixelmap.c	(revision 78189)
+++ 	(revision )
@@ -1,142 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_spu.h"
-#include "chromium.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_net.h"
-#include "server_dispatch.h"
-#include "server.h"
-
-static GLint __sizeQuery( GLenum map )
-{
-    GLint get_values;
-    /* Windows compiler gets mad if variables might be uninitialized */
-    GLenum newmap = GL_PIXEL_MAP_I_TO_I_SIZE;
-
-    switch( map )
-    {
-        case GL_PIXEL_MAP_I_TO_I: 
-            newmap = GL_PIXEL_MAP_I_TO_I_SIZE;
-            break;
-        case GL_PIXEL_MAP_S_TO_S: 
-            newmap = GL_PIXEL_MAP_S_TO_S_SIZE;
-            break;
-        case GL_PIXEL_MAP_I_TO_R: 
-            newmap = GL_PIXEL_MAP_I_TO_R_SIZE;
-            break;
-        case GL_PIXEL_MAP_I_TO_G: 
-            newmap = GL_PIXEL_MAP_I_TO_G_SIZE;
-            break;
-        case GL_PIXEL_MAP_I_TO_B: 
-            newmap = GL_PIXEL_MAP_I_TO_B_SIZE;
-            break;
-        case GL_PIXEL_MAP_I_TO_A: 
-            newmap = GL_PIXEL_MAP_I_TO_A_SIZE;
-            break;
-        case GL_PIXEL_MAP_R_TO_R: 
-            newmap = GL_PIXEL_MAP_R_TO_R_SIZE;
-            break;
-        case GL_PIXEL_MAP_G_TO_G: 
-            newmap = GL_PIXEL_MAP_G_TO_G_SIZE;
-            break;
-        case GL_PIXEL_MAP_B_TO_B: 
-            newmap = GL_PIXEL_MAP_B_TO_B_SIZE;
-            break;
-        case GL_PIXEL_MAP_A_TO_A: 
-            newmap = GL_PIXEL_MAP_A_TO_A_SIZE;
-            break;
-        default: 
-            crError( "Bad map in crServerDispatchGetPixelMap: %d", map );
-            break;
-    }
-
-    cr_server.head_spu->dispatch_table.GetIntegerv( newmap, &get_values );
-
-    return get_values;
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetPixelMapfv( GLenum map, GLfloat *values )
-{
-#ifdef CR_ARB_pixel_buffer_object
-    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
-    {
-        GLvoid *pbo_offset;
-
-        pbo_offset = (GLfloat*) ((uintptr_t) *((GLint*)values));
-
-        cr_server.head_spu->dispatch_table.GetPixelMapfv( map, pbo_offset );
-    }
-    else
-#endif
-    {
-        int size = sizeof( GLfloat );
-        int tabsize = __sizeQuery( map );
-        GLfloat *local_values;
-
-        size *= tabsize;
-        local_values = (GLfloat*)crCalloc( size );
-
-        cr_server.head_spu->dispatch_table.GetPixelMapfv( map, local_values );
-        crServerReturnValue( local_values, size );
-        crFree( local_values );
-    }
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetPixelMapuiv( GLenum map, GLuint *values )
-{
-#ifdef CR_ARB_pixel_buffer_object
-    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
-    {
-        GLvoid *pbo_offset;
-
-        pbo_offset = (GLuint*) ((uintptr_t) *((GLint*)values));
-
-        cr_server.head_spu->dispatch_table.GetPixelMapuiv( map, pbo_offset );
-    }
-    else
-#endif
-    {
-        int size = sizeof( GLuint );
-        int tabsize = __sizeQuery( map );
-        GLuint *local_values;
-
-        size *= tabsize;
-        local_values = (GLuint*)crCalloc( size );
-
-        cr_server.head_spu->dispatch_table.GetPixelMapuiv( map, local_values );
-        crServerReturnValue( local_values, size );
-        crFree( local_values );
-    }
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetPixelMapusv( GLenum map, GLushort *values )
-{
-#ifdef CR_ARB_pixel_buffer_object
-    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
-    {
-        GLvoid *pbo_offset;
-
-        pbo_offset = (GLushort*) ((uintptr_t) *((GLint*)values));
-
-        cr_server.head_spu->dispatch_table.GetPixelMapusv( map, pbo_offset );
-    }
-    else
-#endif
-    {
-        int size = sizeof( GLushort );
-        int tabsize = __sizeQuery( map );
-        GLushort *local_values;
-
-        size *= tabsize;
-        local_values = (GLushort*)crCalloc( size );
-
-        cr_server.head_spu->dispatch_table.GetPixelMapusv( map, local_values );
-        crServerReturnValue( local_values, size );
-        crFree( local_values );
-    }
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpixelmap.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpixelmap.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpixelmap.cpp	(revision 78190)
@@ -0,0 +1,142 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "cr_spu.h"
+#include "chromium.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "cr_net.h"
+#include "server_dispatch.h"
+#include "server.h"
+
+static GLint __sizeQuery( GLenum map )
+{
+    GLint get_values;
+    /* Windows compiler gets mad if variables might be uninitialized */
+    GLenum newmap = GL_PIXEL_MAP_I_TO_I_SIZE;
+
+    switch( map )
+    {
+        case GL_PIXEL_MAP_I_TO_I: 
+            newmap = GL_PIXEL_MAP_I_TO_I_SIZE;
+            break;
+        case GL_PIXEL_MAP_S_TO_S: 
+            newmap = GL_PIXEL_MAP_S_TO_S_SIZE;
+            break;
+        case GL_PIXEL_MAP_I_TO_R: 
+            newmap = GL_PIXEL_MAP_I_TO_R_SIZE;
+            break;
+        case GL_PIXEL_MAP_I_TO_G: 
+            newmap = GL_PIXEL_MAP_I_TO_G_SIZE;
+            break;
+        case GL_PIXEL_MAP_I_TO_B: 
+            newmap = GL_PIXEL_MAP_I_TO_B_SIZE;
+            break;
+        case GL_PIXEL_MAP_I_TO_A: 
+            newmap = GL_PIXEL_MAP_I_TO_A_SIZE;
+            break;
+        case GL_PIXEL_MAP_R_TO_R: 
+            newmap = GL_PIXEL_MAP_R_TO_R_SIZE;
+            break;
+        case GL_PIXEL_MAP_G_TO_G: 
+            newmap = GL_PIXEL_MAP_G_TO_G_SIZE;
+            break;
+        case GL_PIXEL_MAP_B_TO_B: 
+            newmap = GL_PIXEL_MAP_B_TO_B_SIZE;
+            break;
+        case GL_PIXEL_MAP_A_TO_A: 
+            newmap = GL_PIXEL_MAP_A_TO_A_SIZE;
+            break;
+        default: 
+            crError( "Bad map in crServerDispatchGetPixelMap: %d", map );
+            break;
+    }
+
+    cr_server.head_spu->dispatch_table.GetIntegerv( newmap, &get_values );
+
+    return get_values;
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetPixelMapfv( GLenum map, GLfloat *values )
+{
+#ifdef CR_ARB_pixel_buffer_object
+    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
+    {
+        GLvoid *pbo_offset;
+
+        pbo_offset = (GLfloat*) ((uintptr_t) *((GLint*)values));
+
+        cr_server.head_spu->dispatch_table.GetPixelMapfv( map, (GLfloat *)pbo_offset );
+    }
+    else
+#endif
+    {
+        int size = sizeof( GLfloat );
+        int tabsize = __sizeQuery( map );
+        GLfloat *local_values;
+
+        size *= tabsize;
+        local_values = (GLfloat*)crCalloc( size );
+
+        cr_server.head_spu->dispatch_table.GetPixelMapfv( map, local_values );
+        crServerReturnValue( local_values, size );
+        crFree( local_values );
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetPixelMapuiv( GLenum map, GLuint *values )
+{
+#ifdef CR_ARB_pixel_buffer_object
+    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
+    {
+        GLvoid *pbo_offset;
+
+        pbo_offset = (GLuint*) ((uintptr_t) *((GLint*)values));
+
+        cr_server.head_spu->dispatch_table.GetPixelMapuiv( map, (GLuint *)pbo_offset );
+    }
+    else
+#endif
+    {
+        int size = sizeof( GLuint );
+        int tabsize = __sizeQuery( map );
+        GLuint *local_values;
+
+        size *= tabsize;
+        local_values = (GLuint*)crCalloc( size );
+
+        cr_server.head_spu->dispatch_table.GetPixelMapuiv( map, local_values );
+        crServerReturnValue( local_values, size );
+        crFree( local_values );
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetPixelMapusv( GLenum map, GLushort *values )
+{
+#ifdef CR_ARB_pixel_buffer_object
+    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
+    {
+        GLvoid *pbo_offset;
+
+        pbo_offset = (GLushort*) ((uintptr_t) *((GLint*)values));
+
+        cr_server.head_spu->dispatch_table.GetPixelMapusv( map, (GLushort *)pbo_offset );
+    }
+    else
+#endif
+    {
+        int size = sizeof( GLushort );
+        int tabsize = __sizeQuery( map );
+        GLushort *local_values;
+
+        size *= tabsize;
+        local_values = (GLushort*)crCalloc( size );
+
+        cr_server.head_spu->dispatch_table.GetPixelMapusv( map, local_values );
+        crServerReturnValue( local_values, size );
+        crFree( local_values );
+    }
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpointer.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpointer.c	(revision 78189)
+++ 	(revision )
@@ -1,32 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "chromium.h"
-#include "cr_error.h" 
-#include "server_dispatch.h"
-#include "server.h"
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetPointerv( GLenum pname, GLvoid **pointer )
-{
-	crError( "glGetPointerv isn't *ever* allowed to be on the wire!" );
-	(void) pname;
-	(void) pointer;
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetVertexAttribPointervNV( GLuint index, GLenum pname, GLvoid ** pointer )
-{
-	crError( "glGetVertexAttribPointervNV isn't *ever* allowed to be on the wire!" );
-	(void) pname;
-	(void) pointer;
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetVertexAttribPointervARB( GLuint index, GLenum pname, GLvoid ** pointer )
-{
-	crError( "glGetVertexAttribPointervNV isn't *ever* allowed to be on the wire!" );
-	(void) pname;
-	(void) pointer;
-}
-
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpointer.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpointer.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getpointer.cpp	(revision 78190)
@@ -0,0 +1,32 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "chromium.h"
+#include "cr_error.h" 
+#include "server_dispatch.h"
+#include "server.h"
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetPointerv( GLenum pname, GLvoid **pointer )
+{
+	crError( "glGetPointerv isn't *ever* allowed to be on the wire!" );
+	(void) pname;
+	(void) pointer;
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetVertexAttribPointervNV( GLuint index, GLenum pname, GLvoid ** pointer )
+{
+	crError( "glGetVertexAttribPointervNV isn't *ever* allowed to be on the wire!" );
+	(void) pname;
+	(void) pointer;
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetVertexAttribPointervARB( GLuint index, GLenum pname, GLvoid ** pointer )
+{
+	crError( "glGetVertexAttribPointervNV isn't *ever* allowed to be on the wire!" );
+	(void) pname;
+	(void) pointer;
+}
+
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getshaders.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getshaders.c	(revision 78189)
+++ 	(revision )
@@ -1,395 +1,0 @@
-/* $Id$ */
-/** @file
- * VBox OpenGL GLSL related get functions
- */
-
-/*
- * Copyright (C) 2009-2019 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#include "cr_spu.h"
-#include "chromium.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_net.h"
-#include "server_dispatch.h"
-#include "server.h"
-
-#include <iprt/assert.h>
-
-#ifdef CR_OPENGL_VERSION_2_0
-
-typedef struct _crGetActive_t
-{
-    GLsizei length;
-    GLint   size;
-    GLenum  type;
-} crGetActive_t;
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, char *name)
-{
-    crGetActive_t *pLocal = NULL;
-
-    if (bufSize > 0 && bufSize < INT32_MAX / 2)
-        pLocal = (crGetActive_t*)crCalloc(bufSize + sizeof(crGetActive_t));
-
-    if (!pLocal)
-    {
-        crGetActive_t zero;
-        zero.length = 0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-
-    cr_server.head_spu->dispatch_table.GetActiveAttrib(crStateGetProgramHWID(program), index, bufSize, &pLocal->length, &pLocal->size, &pLocal->type, (char*)&pLocal[1]);
-    crServerReturnValue(pLocal, pLocal->length+1+sizeof(crGetActive_t));
-    crFree(pLocal);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, char *name)
-{
-    crGetActive_t *pLocal = NULL;
-
-    if (bufSize > 0 && bufSize < INT32_MAX / 2)
-        pLocal = (crGetActive_t*) crCalloc(bufSize + sizeof(crGetActive_t));
-
-    if (!pLocal)
-    {
-        crGetActive_t zero;
-        zero.length = 0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-
-    cr_server.head_spu->dispatch_table.GetActiveUniform(crStateGetProgramHWID(program), index, bufSize, &pLocal->length, &pLocal->size, &pLocal->type, (char*)&pLocal[1]);
-    crServerReturnValue(pLocal, pLocal->length+1+sizeof(crGetActive_t));
-    crFree(pLocal);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders)
-{
-    GLsizei *pLocal = NULL;
-
-    if (maxCount > 0 && maxCount < INT32_MAX / sizeof(GLuint) / 2)
-        pLocal = (GLsizei*) crCalloc(maxCount * sizeof(GLuint) + sizeof(GLsizei));
-
-    if (!pLocal)
-    {
-        GLsizei zero=0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-    /* initial (fallback )value */
-    *pLocal = 0;
-    cr_server.head_spu->dispatch_table.GetAttachedShaders(crStateGetProgramHWID(program), maxCount, pLocal, (GLuint*)&pLocal[1]);
-
-    {
-        GLsizei i;
-        GLuint *ids=(GLuint*)&pLocal[1];
-
-        for (i=0; i<*pLocal; ++i)
-          ids[i] = crStateGLSLShaderHWIDtoID(ids[i]);
-    }
-
-    crServerReturnValue(pLocal, (*pLocal)*sizeof(GLuint)+sizeof(GLsizei));
-    crFree(pLocal);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedObjectsARB(VBoxGLhandleARB containerObj, GLsizei maxCount, GLsizei * count, VBoxGLhandleARB * obj)
-{
-    GLsizei *pLocal = NULL;
-
-    if (maxCount > 0 && maxCount < INT32_MAX / sizeof(VBoxGLhandleARB) / 2)
-        pLocal = (GLsizei*) crCalloc(maxCount * sizeof(VBoxGLhandleARB) + sizeof(GLsizei));
-
-    if (!pLocal)
-    {
-        GLsizei zero=0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-    /* initial (fallback )value */
-    *pLocal = 0;
-    cr_server.head_spu->dispatch_table.GetAttachedObjectsARB(crStateGetProgramHWID(containerObj), maxCount, pLocal, (VBoxGLhandleARB*)&pLocal[1]);
-
-    {
-        GLsizei i;
-        GLuint *ids=(GLuint*)&pLocal[1];
-
-        for (i=0; i<*pLocal; ++i)
-          ids[i] = crStateGLSLShaderHWIDtoID(ids[i]);
-    }
-
-    crServerReturnValue(pLocal, (*pLocal)*sizeof(VBoxGLhandleARB)+sizeof(GLsizei));
-    crFree(pLocal);
-}
-
-AssertCompile(sizeof(GLsizei) == 4);
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetInfoLogARB(VBoxGLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog)
-{
-    GLsizei *pLocal = NULL;
-    GLuint hwid;
-
-    if (maxLength > 0 && maxLength < INT32_MAX / 2)
-        pLocal = (GLsizei*) crCalloc(maxLength + sizeof(GLsizei));
-
-    if (!pLocal)
-    {
-        GLsizei zero=0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-    /* initial (fallback )value */
-    *pLocal = 0;
-    /** @todo recheck*/
-    hwid = crStateGetProgramHWID(obj);
-    if (!hwid) hwid = crStateGetShaderHWID(obj);
-    cr_server.head_spu->dispatch_table.GetInfoLogARB(hwid, maxLength, pLocal, (char*)&pLocal[1]);
-    CRASSERT((*pLocal) <= maxLength);
-    crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei));
-    crFree(pLocal);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, char *infoLog)
-{
-    GLsizei *pLocal = NULL;
-
-    if (bufSize > 0 && bufSize < INT32_MAX / 2)
-        pLocal = (GLsizei*) crCalloc(bufSize + sizeof(GLsizei));
-
-    if (!pLocal)
-    {
-        GLsizei zero=0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-    /* initial (fallback )value */
-    *pLocal = 0;
-    cr_server.head_spu->dispatch_table.GetShaderInfoLog(crStateGetShaderHWID(shader), bufSize, pLocal, (char*)&pLocal[1]);
-    crServerReturnValue(pLocal, pLocal[0]+sizeof(GLsizei));
-    crFree(pLocal);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, char *infoLog)
-{
-    GLsizei *pLocal = NULL;
-
-    if (bufSize > 0 && bufSize < INT32_MAX / 2)
-        pLocal = (GLsizei*) crCalloc(bufSize + sizeof(GLsizei));
-
-    if (!pLocal)
-    {
-        GLsizei zero=0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-    /* initial (fallback )value */
-    *pLocal = 0;
-    cr_server.head_spu->dispatch_table.GetProgramInfoLog(crStateGetProgramHWID(program), bufSize, pLocal, (char*)&pLocal[1]);
-    CRASSERT(pLocal[0] <= bufSize);
-    crServerReturnValue(pLocal, pLocal[0]+sizeof(GLsizei));
-    crFree(pLocal);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, char *source)
-{
-    GLsizei *pLocal = NULL;
-
-    if (bufSize > 0 && bufSize < INT32_MAX / 2)
-        pLocal = (GLsizei*) crCalloc(bufSize + sizeof(GLsizei));
-
-    if (!pLocal)
-    {
-        GLsizei zero=0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-    /* initial (fallback )value */
-    *pLocal = 0;
-    cr_server.head_spu->dispatch_table.GetShaderSource(crStateGetShaderHWID(shader), bufSize, pLocal, (char*)&pLocal[1]);
-    CRASSERT(pLocal[0] <= bufSize);
-    crServerReturnValue(pLocal, pLocal[0]+sizeof(GLsizei));
-    crFree(pLocal);
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGetUniformsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData)
-{
-    GLsizei *pLocal = NULL;
-
-    (void) cbData;
-    (void) pData;
-
-    if (maxcbData > 0 && maxcbData < INT32_MAX / 2)
-        pLocal = (GLsizei*) crCalloc(maxcbData + sizeof(GLsizei));
-
-    if (!pLocal)
-    {
-        GLsizei zero=0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-
-    /* initial (fallback )value */
-    *pLocal = 0;
-    crStateGLSLProgramCacheUniforms(program, maxcbData, pLocal, (char*)&pLocal[1]);
-
-    crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei));
-    crFree(pLocal);
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGetAttribsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData)
-{
-    GLsizei *pLocal = NULL;
-
-    (void) cbData;
-    (void) pData;
-
-    if (maxcbData > 0 && maxcbData < INT32_MAX / 2)
-        pLocal = (GLsizei*) crCalloc(maxcbData + sizeof(GLsizei));
-
-    if (!pLocal)
-    {
-        GLsizei zero=0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-
-    /* initial (fallback )value */
-    *pLocal = 0;
-    crStateGLSLProgramCacheAttribs(program, maxcbData, pLocal, (char*)&pLocal[1]);
-
-    crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei));
-    crFree(pLocal);
-}
-
-static GLint __GetUniformSize(GLuint program, GLint location)
-{
-    GLint  size = 0;
-    GLenum type = 0;
-
-    /** @todo check if index and location is the same*/
-    cr_server.head_spu->dispatch_table.GetActiveUniform(crStateGetProgramHWID(program), location, 0, NULL, &size, &type, NULL);
-
-    return crStateGetUniformSize(type);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformfv(GLuint program, GLint location, GLfloat *params)
-{
-    int size = __GetUniformSize(program, location) * sizeof(GLfloat);
-    GLfloat *pLocal;
-
-    pLocal = (GLfloat*) crCalloc(size);
-    if (!pLocal)
-    {
-        GLsizei zero=0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-
-    cr_server.head_spu->dispatch_table.GetUniformfv(crStateGetProgramHWID(program), location, pLocal);
-
-    crServerReturnValue(pLocal, size);
-    crFree(pLocal);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformiv(GLuint program, GLint location, GLint *params)
-{
-    int size = __GetUniformSize(program, location) * sizeof(GLint);
-    GLint *pLocal;
-
-    pLocal = (GLint*) crCalloc(size);
-    if (!pLocal)
-    {
-        GLsizei zero=0;
-        crServerReturnValue(&zero, sizeof(zero));
-        return;
-    }
-
-    cr_server.head_spu->dispatch_table.GetUniformiv(crStateGetProgramHWID(program), location, pLocal);
-
-    crServerReturnValue(pLocal, size);
-    crFree(pLocal);
-}
-
-GLuint SERVER_DISPATCH_APIENTRY crServerDispatchCreateShader(GLenum type)
-{
-    GLuint retval, hwVal;
-    hwVal = cr_server.head_spu->dispatch_table.CreateShader(type);
-    retval = crStateCreateShader(hwVal, type);
-    crServerReturnValue(&retval, sizeof(retval));
-    return retval; /* ignored */
-}
-
-GLuint SERVER_DISPATCH_APIENTRY crServerDispatchCreateProgram(void)
-{
-    GLuint retval, hwVal;
-    hwVal = cr_server.head_spu->dispatch_table.CreateProgram();
-    retval = crStateCreateProgram(hwVal);
-    crServerReturnValue(&retval, sizeof(retval));
-    return retval; /* ignored */
-}
-
-GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsShader(GLuint shader)
-{
-    GLboolean retval;
-    retval = cr_server.head_spu->dispatch_table.IsShader(crStateGetShaderHWID(shader));
-    crServerReturnValue(&retval, sizeof(retval));
-    return retval; /* ignored */
-}
-
-GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsProgram(GLuint program)
-{
-    GLboolean retval;
-    retval = cr_server.head_spu->dispatch_table.IsProgram(crStateGetProgramHWID(program));
-    crServerReturnValue(&retval, sizeof(retval));
-    return retval; /* ignored */
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetObjectParameterfvARB( VBoxGLhandleARB obj, GLenum pname, GLfloat * params )
-{
-    GLfloat local_params[1] = {0};
-    GLuint hwid = crStateGetProgramHWID(obj);
-    (void) params;
-
-    if (!hwid)
-    {
-        hwid = crStateGetShaderHWID(obj);
-        if (!hwid)
-        {
-            crWarning("Unknown object %i, in crServerDispatchGetObjectParameterfvARB", obj);
-        }
-    }
-
-    cr_server.head_spu->dispatch_table.GetObjectParameterfvARB( hwid, pname, local_params );
-    crServerReturnValue( &(local_params[0]), 1*sizeof(GLfloat) );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetObjectParameterivARB( VBoxGLhandleARB obj, GLenum pname, GLint * params )
-{
-    GLint local_params[1] = {0};
-    GLuint hwid = crStateGetProgramHWID(obj);
-    if (!hwid)
-    {
-        hwid = crStateGetShaderHWID(obj);
-        if (!hwid)
-        {
-            crWarning("Unknown object %i, in crServerDispatchGetObjectParameterivARB", obj);
-        }
-    }
-
-    (void) params;
-    cr_server.head_spu->dispatch_table.GetObjectParameterivARB( hwid, pname, local_params );
-    crServerReturnValue( &(local_params[0]), 1*sizeof(GLint) );
-}
-#endif /* #ifdef CR_OPENGL_VERSION_2_0 */
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getshaders.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getshaders.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getshaders.cpp	(revision 78190)
@@ -0,0 +1,395 @@
+/* $Id$ */
+/** @file
+ * VBox OpenGL GLSL related get functions
+ */
+
+/*
+ * Copyright (C) 2009-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include "cr_spu.h"
+#include "chromium.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "cr_net.h"
+#include "server_dispatch.h"
+#include "server.h"
+
+#include <iprt/assert.h>
+
+#ifdef CR_OPENGL_VERSION_2_0
+
+typedef struct _crGetActive_t
+{
+    GLsizei length;
+    GLint   size;
+    GLenum  type;
+} crGetActive_t;
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, char *name)
+{
+    crGetActive_t *pLocal = NULL;
+
+    if (bufSize > 0 && bufSize < INT32_MAX / 2)
+        pLocal = (crGetActive_t*)crCalloc(bufSize + sizeof(crGetActive_t));
+
+    if (!pLocal)
+    {
+        crGetActive_t zero;
+        zero.length = 0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+
+    cr_server.head_spu->dispatch_table.GetActiveAttrib(crStateGetProgramHWID(program), index, bufSize, &pLocal->length, &pLocal->size, &pLocal->type, (char*)&pLocal[1]);
+    crServerReturnValue(pLocal, pLocal->length+1+sizeof(crGetActive_t));
+    crFree(pLocal);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, char *name)
+{
+    crGetActive_t *pLocal = NULL;
+
+    if (bufSize > 0 && bufSize < INT32_MAX / 2)
+        pLocal = (crGetActive_t*) crCalloc(bufSize + sizeof(crGetActive_t));
+
+    if (!pLocal)
+    {
+        crGetActive_t zero;
+        zero.length = 0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+
+    cr_server.head_spu->dispatch_table.GetActiveUniform(crStateGetProgramHWID(program), index, bufSize, &pLocal->length, &pLocal->size, &pLocal->type, (char*)&pLocal[1]);
+    crServerReturnValue(pLocal, pLocal->length+1+sizeof(crGetActive_t));
+    crFree(pLocal);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders)
+{
+    GLsizei *pLocal = NULL;
+
+    if (maxCount > 0 && maxCount < INT32_MAX / sizeof(GLuint) / 2)
+        pLocal = (GLsizei*) crCalloc(maxCount * sizeof(GLuint) + sizeof(GLsizei));
+
+    if (!pLocal)
+    {
+        GLsizei zero=0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+    /* initial (fallback )value */
+    *pLocal = 0;
+    cr_server.head_spu->dispatch_table.GetAttachedShaders(crStateGetProgramHWID(program), maxCount, pLocal, (GLuint*)&pLocal[1]);
+
+    {
+        GLsizei i;
+        GLuint *ids=(GLuint*)&pLocal[1];
+
+        for (i=0; i<*pLocal; ++i)
+          ids[i] = crStateGLSLShaderHWIDtoID(ids[i]);
+    }
+
+    crServerReturnValue(pLocal, (*pLocal)*sizeof(GLuint)+sizeof(GLsizei));
+    crFree(pLocal);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetAttachedObjectsARB(VBoxGLhandleARB containerObj, GLsizei maxCount, GLsizei * count, VBoxGLhandleARB * obj)
+{
+    GLsizei *pLocal = NULL;
+
+    if (maxCount > 0 && maxCount < INT32_MAX / sizeof(VBoxGLhandleARB) / 2)
+        pLocal = (GLsizei*) crCalloc(maxCount * sizeof(VBoxGLhandleARB) + sizeof(GLsizei));
+
+    if (!pLocal)
+    {
+        GLsizei zero=0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+    /* initial (fallback )value */
+    *pLocal = 0;
+    cr_server.head_spu->dispatch_table.GetAttachedObjectsARB(crStateGetProgramHWID(containerObj), maxCount, pLocal, (VBoxGLhandleARB*)&pLocal[1]);
+
+    {
+        GLsizei i;
+        GLuint *ids=(GLuint*)&pLocal[1];
+
+        for (i=0; i<*pLocal; ++i)
+          ids[i] = crStateGLSLShaderHWIDtoID(ids[i]);
+    }
+
+    crServerReturnValue(pLocal, (*pLocal)*sizeof(VBoxGLhandleARB)+sizeof(GLsizei));
+    crFree(pLocal);
+}
+
+AssertCompile(sizeof(GLsizei) == 4);
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetInfoLogARB(VBoxGLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog)
+{
+    GLsizei *pLocal = NULL;
+    GLuint hwid;
+
+    if (maxLength > 0 && maxLength < INT32_MAX / 2)
+        pLocal = (GLsizei*) crCalloc(maxLength + sizeof(GLsizei));
+
+    if (!pLocal)
+    {
+        GLsizei zero=0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+    /* initial (fallback )value */
+    *pLocal = 0;
+    /** @todo recheck*/
+    hwid = crStateGetProgramHWID(obj);
+    if (!hwid) hwid = crStateGetShaderHWID(obj);
+    cr_server.head_spu->dispatch_table.GetInfoLogARB(hwid, maxLength, pLocal, (char*)&pLocal[1]);
+    CRASSERT((*pLocal) <= maxLength);
+    crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei));
+    crFree(pLocal);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei *length, char *infoLog)
+{
+    GLsizei *pLocal = NULL;
+
+    if (bufSize > 0 && bufSize < INT32_MAX / 2)
+        pLocal = (GLsizei*) crCalloc(bufSize + sizeof(GLsizei));
+
+    if (!pLocal)
+    {
+        GLsizei zero=0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+    /* initial (fallback )value */
+    *pLocal = 0;
+    cr_server.head_spu->dispatch_table.GetShaderInfoLog(crStateGetShaderHWID(shader), bufSize, pLocal, (char*)&pLocal[1]);
+    crServerReturnValue(pLocal, pLocal[0]+sizeof(GLsizei));
+    crFree(pLocal);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei *length, char *infoLog)
+{
+    GLsizei *pLocal = NULL;
+
+    if (bufSize > 0 && bufSize < INT32_MAX / 2)
+        pLocal = (GLsizei*) crCalloc(bufSize + sizeof(GLsizei));
+
+    if (!pLocal)
+    {
+        GLsizei zero=0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+    /* initial (fallback )value */
+    *pLocal = 0;
+    cr_server.head_spu->dispatch_table.GetProgramInfoLog(crStateGetProgramHWID(program), bufSize, pLocal, (char*)&pLocal[1]);
+    CRASSERT(pLocal[0] <= bufSize);
+    crServerReturnValue(pLocal, pLocal[0]+sizeof(GLsizei));
+    crFree(pLocal);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei *length, char *source)
+{
+    GLsizei *pLocal = NULL;
+
+    if (bufSize > 0 && bufSize < INT32_MAX / 2)
+        pLocal = (GLsizei*) crCalloc(bufSize + sizeof(GLsizei));
+
+    if (!pLocal)
+    {
+        GLsizei zero=0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+    /* initial (fallback )value */
+    *pLocal = 0;
+    cr_server.head_spu->dispatch_table.GetShaderSource(crStateGetShaderHWID(shader), bufSize, pLocal, (char*)&pLocal[1]);
+    CRASSERT(pLocal[0] <= bufSize);
+    crServerReturnValue(pLocal, pLocal[0]+sizeof(GLsizei));
+    crFree(pLocal);
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGetUniformsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData)
+{
+    GLsizei *pLocal = NULL;
+
+    (void) cbData;
+    (void) pData;
+
+    if (maxcbData > 0 && maxcbData < INT32_MAX / 2)
+        pLocal = (GLsizei*) crCalloc(maxcbData + sizeof(GLsizei));
+
+    if (!pLocal)
+    {
+        GLsizei zero=0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+
+    /* initial (fallback )value */
+    *pLocal = 0;
+    crStateGLSLProgramCacheUniforms(program, maxcbData, pLocal, (char*)&pLocal[1]);
+
+    crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei));
+    crFree(pLocal);
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGetAttribsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData)
+{
+    GLsizei *pLocal = NULL;
+
+    (void) cbData;
+    (void) pData;
+
+    if (maxcbData > 0 && maxcbData < INT32_MAX / 2)
+        pLocal = (GLsizei*) crCalloc(maxcbData + sizeof(GLsizei));
+
+    if (!pLocal)
+    {
+        GLsizei zero=0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+
+    /* initial (fallback )value */
+    *pLocal = 0;
+    crStateGLSLProgramCacheAttribs(program, maxcbData, pLocal, (char*)&pLocal[1]);
+
+    crServerReturnValue(pLocal, (*pLocal)+sizeof(GLsizei));
+    crFree(pLocal);
+}
+
+static GLint __GetUniformSize(GLuint program, GLint location)
+{
+    GLint  size = 0;
+    GLenum type = 0;
+
+    /** @todo check if index and location is the same*/
+    cr_server.head_spu->dispatch_table.GetActiveUniform(crStateGetProgramHWID(program), location, 0, NULL, &size, &type, NULL);
+
+    return crStateGetUniformSize(type);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformfv(GLuint program, GLint location, GLfloat *params)
+{
+    int size = __GetUniformSize(program, location) * sizeof(GLfloat);
+    GLfloat *pLocal;
+
+    pLocal = (GLfloat*) crCalloc(size);
+    if (!pLocal)
+    {
+        GLsizei zero=0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+
+    cr_server.head_spu->dispatch_table.GetUniformfv(crStateGetProgramHWID(program), location, pLocal);
+
+    crServerReturnValue(pLocal, size);
+    crFree(pLocal);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformiv(GLuint program, GLint location, GLint *params)
+{
+    int size = __GetUniformSize(program, location) * sizeof(GLint);
+    GLint *pLocal;
+
+    pLocal = (GLint*) crCalloc(size);
+    if (!pLocal)
+    {
+        GLsizei zero=0;
+        crServerReturnValue(&zero, sizeof(zero));
+        return;
+    }
+
+    cr_server.head_spu->dispatch_table.GetUniformiv(crStateGetProgramHWID(program), location, pLocal);
+
+    crServerReturnValue(pLocal, size);
+    crFree(pLocal);
+}
+
+GLuint SERVER_DISPATCH_APIENTRY crServerDispatchCreateShader(GLenum type)
+{
+    GLuint retval, hwVal;
+    hwVal = cr_server.head_spu->dispatch_table.CreateShader(type);
+    retval = crStateCreateShader(hwVal, type);
+    crServerReturnValue(&retval, sizeof(retval));
+    return retval; /* ignored */
+}
+
+GLuint SERVER_DISPATCH_APIENTRY crServerDispatchCreateProgram(void)
+{
+    GLuint retval, hwVal;
+    hwVal = cr_server.head_spu->dispatch_table.CreateProgram();
+    retval = crStateCreateProgram(hwVal);
+    crServerReturnValue(&retval, sizeof(retval));
+    return retval; /* ignored */
+}
+
+GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsShader(GLuint shader)
+{
+    GLboolean retval;
+    retval = cr_server.head_spu->dispatch_table.IsShader(crStateGetShaderHWID(shader));
+    crServerReturnValue(&retval, sizeof(retval));
+    return retval; /* ignored */
+}
+
+GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsProgram(GLuint program)
+{
+    GLboolean retval;
+    retval = cr_server.head_spu->dispatch_table.IsProgram(crStateGetProgramHWID(program));
+    crServerReturnValue(&retval, sizeof(retval));
+    return retval; /* ignored */
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetObjectParameterfvARB( VBoxGLhandleARB obj, GLenum pname, GLfloat * params )
+{
+    GLfloat local_params[1] = {0};
+    GLuint hwid = crStateGetProgramHWID(obj);
+    (void) params;
+
+    if (!hwid)
+    {
+        hwid = crStateGetShaderHWID(obj);
+        if (!hwid)
+        {
+            crWarning("Unknown object %i, in crServerDispatchGetObjectParameterfvARB", obj);
+        }
+    }
+
+    cr_server.head_spu->dispatch_table.GetObjectParameterfvARB( hwid, pname, local_params );
+    crServerReturnValue( &(local_params[0]), 1*sizeof(GLfloat) );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetObjectParameterivARB( VBoxGLhandleARB obj, GLenum pname, GLint * params )
+{
+    GLint local_params[1] = {0};
+    GLuint hwid = crStateGetProgramHWID(obj);
+    if (!hwid)
+    {
+        hwid = crStateGetShaderHWID(obj);
+        if (!hwid)
+        {
+            crWarning("Unknown object %i, in crServerDispatchGetObjectParameterivARB", obj);
+        }
+    }
+
+    (void) params;
+    cr_server.head_spu->dispatch_table.GetObjectParameterivARB( hwid, pname, local_params );
+    crServerReturnValue( &(local_params[0]), 1*sizeof(GLint) );
+}
+#endif /* #ifdef CR_OPENGL_VERSION_2_0 */
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getstring.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getstring.c	(revision 78189)
+++ 	(revision )
@@ -1,38 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "chromium.h"
-#include "cr_error.h" 
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_string.h"
-
-const GLubyte * SERVER_DISPATCH_APIENTRY crServerDispatchGetString( GLenum name )
-{
-	const GLubyte *retval;
-	retval = cr_server.head_spu->dispatch_table.GetString( name );
-	if (retval)
-		crServerReturnValue( retval, crStrlen((char *)retval) + 1 );
-	else
-		crServerReturnValue( "", 1 ); /* empty string */
-	return retval; /* WILL PROBABLY BE IGNORED */
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramStringNV( GLuint id, GLenum pname, GLubyte * program )
-{
-	crError( "glGetProgramStringNV isn't *ever* allowed to be on the wire!" );
-	(void) id;
-	(void) pname;
-	(void) program;
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramStringARB( GLuint id, GLenum pname, void * program )
-{
-	crError( "glGetProgramStringARB isn't *ever* allowed to be on the wire!" );
-	(void) id;
-	(void) pname;
-	(void) program;
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getstring.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getstring.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getstring.cpp	(revision 78190)
@@ -0,0 +1,38 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "chromium.h"
+#include "cr_error.h" 
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_string.h"
+
+const GLubyte * SERVER_DISPATCH_APIENTRY crServerDispatchGetString( GLenum name )
+{
+	const GLubyte *retval;
+	retval = cr_server.head_spu->dispatch_table.GetString( name );
+	if (retval)
+		crServerReturnValue( retval, crStrlen((char *)retval) + 1 );
+	else
+		crServerReturnValue( "", 1 ); /* empty string */
+	return retval; /* WILL PROBABLY BE IGNORED */
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramStringNV( GLuint id, GLenum pname, GLubyte * program )
+{
+	crError( "glGetProgramStringNV isn't *ever* allowed to be on the wire!" );
+	(void) id;
+	(void) pname;
+	(void) program;
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramStringARB( GLuint id, GLenum pname, void * program )
+{
+	crError( "glGetProgramStringARB isn't *ever* allowed to be on the wire!" );
+	(void) id;
+	(void) pname;
+	(void) program;
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getteximage.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getteximage.c	(revision 78189)
+++ 	(revision )
@@ -1,156 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "chromium.h"
-#include "cr_error.h" 
-#include "cr_mem.h"
-#include "cr_pixeldata.h"
-#include "server_dispatch.h"
-#include "server.h"
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGetTexImage(GLenum target, GLint level, GLenum format,
-                            GLenum type, GLvoid * pixels)
-{
-    GLsizei width, height, depth, size;
-    GLvoid *buffer = NULL;
-
-
-#ifdef CR_ARB_pixel_buffer_object
-    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
-    {
-        GLvoid *pbo_offset;
-
-        /*pixels are actually a pointer to location of 8byte network pointer in hgcm buffer
-          regardless of guest/host bitness we're using only 4lower bytes as there're no
-          pbo>4gb (yet?)
-         */
-        pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)pixels));
-
-        cr_server.head_spu->dispatch_table.GetTexImage(target, level, format, type, pbo_offset);
-
-        return;
-    }
-#endif
-
-    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
-    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
-    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
-
-    size = crTextureSize(format, type, width, height, depth);
-
-#if 0
-    {
-        CRContext *ctx = crStateGetCurrent();
-        CRTextureObj *tobj;
-        CRTextureLevel *tl;
-        GLint id;
-
-        crDebug("GetTexImage: %d, %i, %d, %d", target, level, format, type);
-        crDebug("===StateTracker===");
-        crDebug("Current TU: %i", ctx->texture.curTextureUnit);
-
-        if (target==GL_TEXTURE_2D)
-        {
-            tobj = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D;
-            CRASSERT(tobj);
-            tl = &tobj->level[0][level];
-            crDebug("Texture %i(hw %i), w=%i, h=%i", tobj->id, tobj->hwid, tl->width, tl->height, tl->depth);
-        }
-        else
-        {
-            crDebug("Not 2D tex");
-        }
-
-        crDebug("===GPU===");
-        cr_server.head_spu->dispatch_table.GetIntegerv(GL_ACTIVE_TEXTURE, &id);
-        crDebug("Current TU: %i", id);
-        if (target==GL_TEXTURE_2D)
-        {
-            cr_server.head_spu->dispatch_table.GetIntegerv(GL_TEXTURE_BINDING_2D, &id);
-            crDebug("Texture: %i, w=%i, h=%i, d=%i", id, width, height, depth);
-        }
-    }
-#endif
-
-    if (size && (buffer = crCalloc(size))) {
-        /* Note, the other pixel PACK parameters (default values) should
-         * be OK at this point.
-         */
-        cr_server.head_spu->dispatch_table.PixelStorei(GL_PACK_ALIGNMENT, 1);
-        cr_server.head_spu->dispatch_table.GetTexImage(target, level, format, type, buffer);
-        crServerReturnValue( buffer, size );
-        crFree(buffer);
-    }
-    else {
-        /* need to return _something_ to avoid blowing up */
-        GLuint dummy = 0;
-        crServerReturnValue( (GLvoid *) &dummy, sizeof(dummy) );
-    }
-}
-
-
-#if CR_ARB_texture_compression
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGetCompressedTexImageARB(GLenum target, GLint level,
-                                         GLvoid *img)
-{
-    GLint size;
-    GLvoid *buffer=NULL;
-
-#ifdef CR_ARB_pixel_buffer_object
-    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
-    {
-        GLvoid *pbo_offset;
-
-        pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)img));
-
-        cr_server.head_spu->dispatch_table.GetCompressedTexImageARB(target, level, pbo_offset);
-
-        return;
-    }
-#endif
-
-    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &size);
-
-    if (size && (buffer = crCalloc(size))) {
-        /* XXX the pixel PACK parameter should be OK at this point */
-        cr_server.head_spu->dispatch_table.GetCompressedTexImageARB(target, level, buffer);
-        crServerReturnValue( buffer, size );
-        crFree(buffer);
-    }
-    else {
-        /* need to return _something_ to avoid blowing up */
-        GLuint dummy = 0;
-        crServerReturnValue( (GLvoid *) &dummy, sizeof(dummy) );
-    }
-}
-
-#endif /* CR_ARB_texture_compression */
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetPolygonStipple( GLubyte * mask )
-{
-#ifdef CR_ARB_pixel_buffer_object
-    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
-    {
-        GLvoid *pbo_offset;
-
-        pbo_offset = (GLubyte*) ((uintptr_t) *((GLint*)mask));
-
-        cr_server.head_spu->dispatch_table.GetPolygonStipple(pbo_offset);
-    }
-    else
-#endif
-    {    
-        GLubyte local_mask[128];
-
-        memset(local_mask, 0, sizeof(local_mask));
-
-        cr_server.head_spu->dispatch_table.GetPolygonStipple( local_mask );
-        crServerReturnValue( &(local_mask[0]), 128*sizeof(GLubyte) );
-    }
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getteximage.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getteximage.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_getteximage.cpp	(revision 78190)
@@ -0,0 +1,156 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "chromium.h"
+#include "cr_error.h" 
+#include "cr_mem.h"
+#include "cr_pixeldata.h"
+#include "server_dispatch.h"
+#include "server.h"
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGetTexImage(GLenum target, GLint level, GLenum format,
+                            GLenum type, GLvoid * pixels)
+{
+    GLsizei width, height, depth, size;
+    GLvoid *buffer = NULL;
+
+
+#ifdef CR_ARB_pixel_buffer_object
+    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
+    {
+        GLvoid *pbo_offset;
+
+        /*pixels are actually a pointer to location of 8byte network pointer in hgcm buffer
+          regardless of guest/host bitness we're using only 4lower bytes as there're no
+          pbo>4gb (yet?)
+         */
+        pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)pixels));
+
+        cr_server.head_spu->dispatch_table.GetTexImage(target, level, format, type, pbo_offset);
+
+        return;
+    }
+#endif
+
+    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &width);
+    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &height);
+    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_DEPTH, &depth);
+
+    size = crTextureSize(format, type, width, height, depth);
+
+#if 0
+    {
+        CRContext *ctx = crStateGetCurrent();
+        CRTextureObj *tobj;
+        CRTextureLevel *tl;
+        GLint id;
+
+        crDebug("GetTexImage: %d, %i, %d, %d", target, level, format, type);
+        crDebug("===StateTracker===");
+        crDebug("Current TU: %i", ctx->texture.curTextureUnit);
+
+        if (target==GL_TEXTURE_2D)
+        {
+            tobj = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D;
+            CRASSERT(tobj);
+            tl = &tobj->level[0][level];
+            crDebug("Texture %i(hw %i), w=%i, h=%i", tobj->id, tobj->hwid, tl->width, tl->height, tl->depth);
+        }
+        else
+        {
+            crDebug("Not 2D tex");
+        }
+
+        crDebug("===GPU===");
+        cr_server.head_spu->dispatch_table.GetIntegerv(GL_ACTIVE_TEXTURE, &id);
+        crDebug("Current TU: %i", id);
+        if (target==GL_TEXTURE_2D)
+        {
+            cr_server.head_spu->dispatch_table.GetIntegerv(GL_TEXTURE_BINDING_2D, &id);
+            crDebug("Texture: %i, w=%i, h=%i, d=%i", id, width, height, depth);
+        }
+    }
+#endif
+
+    if (size && (buffer = crCalloc(size))) {
+        /* Note, the other pixel PACK parameters (default values) should
+         * be OK at this point.
+         */
+        cr_server.head_spu->dispatch_table.PixelStorei(GL_PACK_ALIGNMENT, 1);
+        cr_server.head_spu->dispatch_table.GetTexImage(target, level, format, type, buffer);
+        crServerReturnValue( buffer, size );
+        crFree(buffer);
+    }
+    else {
+        /* need to return _something_ to avoid blowing up */
+        GLuint dummy = 0;
+        crServerReturnValue( (GLvoid *) &dummy, sizeof(dummy) );
+    }
+}
+
+
+#if CR_ARB_texture_compression
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGetCompressedTexImageARB(GLenum target, GLint level,
+                                         GLvoid *img)
+{
+    GLint size;
+    GLvoid *buffer=NULL;
+
+#ifdef CR_ARB_pixel_buffer_object
+    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
+    {
+        GLvoid *pbo_offset;
+
+        pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)img));
+
+        cr_server.head_spu->dispatch_table.GetCompressedTexImageARB(target, level, pbo_offset);
+
+        return;
+    }
+#endif
+
+    cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &size);
+
+    if (size && (buffer = crCalloc(size))) {
+        /* XXX the pixel PACK parameter should be OK at this point */
+        cr_server.head_spu->dispatch_table.GetCompressedTexImageARB(target, level, buffer);
+        crServerReturnValue( buffer, size );
+        crFree(buffer);
+    }
+    else {
+        /* need to return _something_ to avoid blowing up */
+        GLuint dummy = 0;
+        crServerReturnValue( (GLvoid *) &dummy, sizeof(dummy) );
+    }
+}
+
+#endif /* CR_ARB_texture_compression */
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetPolygonStipple( GLubyte * mask )
+{
+#ifdef CR_ARB_pixel_buffer_object
+    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
+    {
+        GLvoid *pbo_offset;
+
+        pbo_offset = (GLubyte*) ((uintptr_t) *((GLint*)mask));
+
+        cr_server.head_spu->dispatch_table.GetPolygonStipple((GLubyte *)pbo_offset);
+    }
+    else
+#endif
+    {    
+        GLubyte local_mask[128];
+
+        memset(local_mask, 0, sizeof(local_mask));
+
+        cr_server.head_spu->dispatch_table.GetPolygonStipple( local_mask );
+        crServerReturnValue( &(local_mask[0]), 128*sizeof(GLubyte) );
+    }
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_glsl.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_glsl.c	(revision 78189)
+++ 	(revision )
@@ -1,262 +1,0 @@
-/* $Id$ */
-/** @file
- * VBox OpenGL - GLSL related functions
- */
-
-/*
- * Copyright (C) 2009-2019 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#include "cr_spu.h"
-#include "chromium.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_net.h"
-#include "server_dispatch.h"
-#include "server.h"
-
-#ifdef CR_OPENGL_VERSION_2_0
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchShaderSource(GLuint shader, GLsizei count, const char ** string, const GLint * length)
-{
-    /*@todo?crStateShaderSource(shader...);*/
-#ifdef DEBUG_misha
-    GLenum err = cr_server.head_spu->dispatch_table.GetError();
-#endif
-    cr_server.head_spu->dispatch_table.ShaderSource(crStateGetShaderHWID(shader), count, string, length);
-#ifdef DEBUG_misha
-    err = cr_server.head_spu->dispatch_table.GetError();
-    CRASSERT(err == GL_NO_ERROR);
-#endif
-    CR_SERVER_DUMP_SHADER_SOURCE(shader);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchCompileShader(GLuint shader)
-{
-#ifdef DEBUG_misha
-    GLint iCompileStatus = GL_FALSE;
-#endif
-    crStateCompileShader(shader);
-    cr_server.head_spu->dispatch_table.CompileShader(crStateGetShaderHWID(shader));
-#ifdef DEBUG_misha
-    cr_server.head_spu->dispatch_table.GetShaderiv(crStateGetShaderHWID(shader), GL_COMPILE_STATUS, &iCompileStatus);
-    Assert(iCompileStatus == GL_TRUE);
-#endif
-    CR_SERVER_DUMP_COMPILE_SHADER(shader);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteShader(GLuint shader)
-{
-    GLuint shaderHW = crStateGetShaderHWID(shader);
-    crStateDeleteShader(shader);
-    if (shaderHW)
-        cr_server.head_spu->dispatch_table.DeleteShader(shaderHW);
-    else
-        crWarning("crServerDispatchDeleteShader: hwid not found for shader(%d)", shader);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchAttachShader(GLuint program, GLuint shader)
-{
-    crStateAttachShader(program, shader);
-    cr_server.head_spu->dispatch_table.AttachShader(crStateGetProgramHWID(program), crStateGetShaderHWID(shader));
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDetachShader(GLuint program, GLuint shader)
-{
-    crStateDetachShader(program, shader);
-    cr_server.head_spu->dispatch_table.DetachShader(crStateGetProgramHWID(program), crStateGetShaderHWID(shader));
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchLinkProgram(GLuint program)
-{
-    crStateLinkProgram(program);
-    cr_server.head_spu->dispatch_table.LinkProgram(crStateGetProgramHWID(program));
-    CR_SERVER_DUMP_LINK_PROGRAM(program);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchUseProgram(GLuint program)
-{
-    crStateUseProgram(program);
-    cr_server.head_spu->dispatch_table.UseProgram(crStateGetProgramHWID(program));
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteProgram(GLuint program)
-{
-    GLuint hwId = crStateGetProgramHWID(program);
-    crStateDeleteProgram(program);
-    if (hwId)
-        cr_server.head_spu->dispatch_table.DeleteProgram(hwId);
-    else
-        crWarning("crServerDispatchDeleteProgram: hwid not found for program(%d)", program);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchValidateProgram(GLuint program)
-{
-    crStateValidateProgram(program);
-    cr_server.head_spu->dispatch_table.ValidateProgram(crStateGetProgramHWID(program));
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchBindAttribLocation(GLuint program, GLuint index, const char * name)
-{
-    crStateBindAttribLocation(program, index, name);
-    cr_server.head_spu->dispatch_table.BindAttribLocation(crStateGetProgramHWID(program), index, name);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteObjectARB(VBoxGLhandleARB obj)
-{
-    GLuint hwid =  crStateDeleteObjectARB(obj);
-
-    if (hwid)
-        cr_server.head_spu->dispatch_table.DeleteObjectARB(hwid);
-    else
-        crWarning("zero hwid for object %d", obj);
-}
-
-GLint SERVER_DISPATCH_APIENTRY crServerDispatchGetAttribLocation( GLuint program, const char * name )
-{
-    GLint retval;
-    retval = cr_server.head_spu->dispatch_table.GetAttribLocation(crStateGetProgramHWID(program), name );
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
-
-VBoxGLhandleARB SERVER_DISPATCH_APIENTRY crServerDispatchGetHandleARB( GLenum pname )
-{
-    VBoxGLhandleARB retval;
-    retval = cr_server.head_spu->dispatch_table.GetHandleARB(pname);
-    if (pname==GL_PROGRAM_OBJECT_ARB)
-    {
-        retval = crStateGLSLProgramHWIDtoID(retval);
-    }
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
-
-GLint SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformLocation(GLuint program, const char * name)
-{
-    GLint retval;
-    retval = cr_server.head_spu->dispatch_table.GetUniformLocation(crStateGetProgramHWID(program), name);
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramiv( GLuint program, GLenum pname, GLint * params )
-{
-    GLint local_params[1] = {0};
-    (void) params;
-    cr_server.head_spu->dispatch_table.GetProgramiv(crStateGetProgramHWID(program), pname, local_params);
-    crServerReturnValue( &(local_params[0]), 1*sizeof(GLint) );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderiv( GLuint shader, GLenum pname, GLint * params )
-{
-    GLint local_params[1] = {0};
-    (void) params;
-    cr_server.head_spu->dispatch_table.GetShaderiv( crStateGetShaderHWID(shader), pname, local_params );
-    crServerReturnValue( &(local_params[0]), 1*sizeof(GLint) );
-}
-#endif /* #ifdef CR_OPENGL_VERSION_2_0 */
-
-/* XXXX Note: shared/separate Program ID numbers aren't totally implemented! */
-GLuint crServerTranslateProgramID( GLuint id )
-{
-    if (!cr_server.sharedPrograms && id) {
-        int client = cr_server.curClient->number;
-        return id + client * 100000;
-    }
-    return id;
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteProgramsARB(GLsizei n, const GLuint * programs)
-{
-    GLuint *pLocalProgs;
-    GLint i;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchDeleteProgramsARB: parameter 'n' is out of range");
-        return;
-    }
-
-    pLocalProgs = (GLuint *)crAlloc(n * sizeof(GLuint));
-
-    if (!pLocalProgs) {
-        crError("crServerDispatchDeleteProgramsARB: out of memory");
-        return;
-    }
-    for (i = 0; i < n; i++) {
-        pLocalProgs[i] = crServerTranslateProgramID(programs[i]);
-    }
-    crStateDeleteProgramsARB(n, pLocalProgs);
-    cr_server.head_spu->dispatch_table.DeleteProgramsARB(n, pLocalProgs);
-    crFree(pLocalProgs);
-}
-
-
-/** @todo will fail for progs loaded from snapshot */
-GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsProgramARB( GLuint program )
-{
-    GLboolean retval;
-    program = crServerTranslateProgramID(program);
-    retval = cr_server.head_spu->dispatch_table.IsProgramARB( program );
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
-
-
-GLboolean SERVER_DISPATCH_APIENTRY
-crServerDispatchAreProgramsResidentNV(GLsizei n, const GLuint *programs,
-                                                                            GLboolean *residences)
-{
-    GLboolean retval = GL_FALSE;
-    GLboolean *res;
-    GLsizei i;
-    (void) residences;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchAreProgramsResidentNV: parameter 'n' is out of range");
-        return GL_FALSE;
-    }
-
-    res = (GLboolean *)crCalloc(n * sizeof(GLboolean));
-
-    if (!res) {
-        crError("crServerDispatchAreProgramsResidentNV: out of memory");
-        return GL_FALSE;
-    }
-
-    if (!cr_server.sharedTextureObjects) {
-        GLuint *programs2 = (GLuint *) crCalloc(n * sizeof(GLuint));
-        if (programs2)
-        {
-            for (i = 0; i < n; i++)
-                programs2[i] = crServerTranslateProgramID(programs[i]);
-
-            retval = cr_server.head_spu->dispatch_table.AreProgramsResidentNV(n, programs2, res);
-            crFree(programs2);
-        }
-        else
-        {
-            crError("crServerDispatchAreProgramsResidentNV: out of memory");
-        }
-    }
-    else {
-        retval = cr_server.head_spu->dispatch_table.AreProgramsResidentNV(n, programs, res);
-    }
-
-    crServerReturnValue(res, n * sizeof(GLboolean));
-    crFree(res);
-
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
-
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_glsl.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_glsl.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_glsl.cpp	(revision 78190)
@@ -0,0 +1,262 @@
+/* $Id$ */
+/** @file
+ * VBox OpenGL - GLSL related functions
+ */
+
+/*
+ * Copyright (C) 2009-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include "cr_spu.h"
+#include "chromium.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "cr_net.h"
+#include "server_dispatch.h"
+#include "server.h"
+
+#ifdef CR_OPENGL_VERSION_2_0
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchShaderSource(GLuint shader, GLsizei count, const char ** string, const GLint * length)
+{
+    /*@todo?crStateShaderSource(shader...);*/
+#ifdef DEBUG_misha
+    GLenum err = cr_server.head_spu->dispatch_table.GetError();
+#endif
+    cr_server.head_spu->dispatch_table.ShaderSource(crStateGetShaderHWID(shader), count, string, length);
+#ifdef DEBUG_misha
+    err = cr_server.head_spu->dispatch_table.GetError();
+    CRASSERT(err == GL_NO_ERROR);
+#endif
+    CR_SERVER_DUMP_SHADER_SOURCE(shader);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchCompileShader(GLuint shader)
+{
+#ifdef DEBUG_misha
+    GLint iCompileStatus = GL_FALSE;
+#endif
+    crStateCompileShader(shader);
+    cr_server.head_spu->dispatch_table.CompileShader(crStateGetShaderHWID(shader));
+#ifdef DEBUG_misha
+    cr_server.head_spu->dispatch_table.GetShaderiv(crStateGetShaderHWID(shader), GL_COMPILE_STATUS, &iCompileStatus);
+    Assert(iCompileStatus == GL_TRUE);
+#endif
+    CR_SERVER_DUMP_COMPILE_SHADER(shader);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteShader(GLuint shader)
+{
+    GLuint shaderHW = crStateGetShaderHWID(shader);
+    crStateDeleteShader(shader);
+    if (shaderHW)
+        cr_server.head_spu->dispatch_table.DeleteShader(shaderHW);
+    else
+        crWarning("crServerDispatchDeleteShader: hwid not found for shader(%d)", shader);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchAttachShader(GLuint program, GLuint shader)
+{
+    crStateAttachShader(program, shader);
+    cr_server.head_spu->dispatch_table.AttachShader(crStateGetProgramHWID(program), crStateGetShaderHWID(shader));
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDetachShader(GLuint program, GLuint shader)
+{
+    crStateDetachShader(program, shader);
+    cr_server.head_spu->dispatch_table.DetachShader(crStateGetProgramHWID(program), crStateGetShaderHWID(shader));
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchLinkProgram(GLuint program)
+{
+    crStateLinkProgram(program);
+    cr_server.head_spu->dispatch_table.LinkProgram(crStateGetProgramHWID(program));
+    CR_SERVER_DUMP_LINK_PROGRAM(program);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchUseProgram(GLuint program)
+{
+    crStateUseProgram(program);
+    cr_server.head_spu->dispatch_table.UseProgram(crStateGetProgramHWID(program));
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteProgram(GLuint program)
+{
+    GLuint hwId = crStateGetProgramHWID(program);
+    crStateDeleteProgram(program);
+    if (hwId)
+        cr_server.head_spu->dispatch_table.DeleteProgram(hwId);
+    else
+        crWarning("crServerDispatchDeleteProgram: hwid not found for program(%d)", program);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchValidateProgram(GLuint program)
+{
+    crStateValidateProgram(program);
+    cr_server.head_spu->dispatch_table.ValidateProgram(crStateGetProgramHWID(program));
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchBindAttribLocation(GLuint program, GLuint index, const char * name)
+{
+    crStateBindAttribLocation(program, index, name);
+    cr_server.head_spu->dispatch_table.BindAttribLocation(crStateGetProgramHWID(program), index, name);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteObjectARB(VBoxGLhandleARB obj)
+{
+    GLuint hwid =  crStateDeleteObjectARB(obj);
+
+    if (hwid)
+        cr_server.head_spu->dispatch_table.DeleteObjectARB(hwid);
+    else
+        crWarning("zero hwid for object %d", obj);
+}
+
+GLint SERVER_DISPATCH_APIENTRY crServerDispatchGetAttribLocation( GLuint program, const char * name )
+{
+    GLint retval;
+    retval = cr_server.head_spu->dispatch_table.GetAttribLocation(crStateGetProgramHWID(program), name );
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
+
+VBoxGLhandleARB SERVER_DISPATCH_APIENTRY crServerDispatchGetHandleARB( GLenum pname )
+{
+    VBoxGLhandleARB retval;
+    retval = cr_server.head_spu->dispatch_table.GetHandleARB(pname);
+    if (pname==GL_PROGRAM_OBJECT_ARB)
+    {
+        retval = crStateGLSLProgramHWIDtoID(retval);
+    }
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
+
+GLint SERVER_DISPATCH_APIENTRY crServerDispatchGetUniformLocation(GLuint program, const char * name)
+{
+    GLint retval;
+    retval = cr_server.head_spu->dispatch_table.GetUniformLocation(crStateGetProgramHWID(program), name);
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetProgramiv( GLuint program, GLenum pname, GLint * params )
+{
+    GLint local_params[1] = {0};
+    (void) params;
+    cr_server.head_spu->dispatch_table.GetProgramiv(crStateGetProgramHWID(program), pname, local_params);
+    crServerReturnValue( &(local_params[0]), 1*sizeof(GLint) );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetShaderiv( GLuint shader, GLenum pname, GLint * params )
+{
+    GLint local_params[1] = {0};
+    (void) params;
+    cr_server.head_spu->dispatch_table.GetShaderiv( crStateGetShaderHWID(shader), pname, local_params );
+    crServerReturnValue( &(local_params[0]), 1*sizeof(GLint) );
+}
+#endif /* #ifdef CR_OPENGL_VERSION_2_0 */
+
+/* XXXX Note: shared/separate Program ID numbers aren't totally implemented! */
+GLuint crServerTranslateProgramID( GLuint id )
+{
+    if (!cr_server.sharedPrograms && id) {
+        int client = cr_server.curClient->number;
+        return id + client * 100000;
+    }
+    return id;
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteProgramsARB(GLsizei n, const GLuint * programs)
+{
+    GLuint *pLocalProgs;
+    GLint i;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchDeleteProgramsARB: parameter 'n' is out of range");
+        return;
+    }
+
+    pLocalProgs = (GLuint *)crAlloc(n * sizeof(GLuint));
+
+    if (!pLocalProgs) {
+        crError("crServerDispatchDeleteProgramsARB: out of memory");
+        return;
+    }
+    for (i = 0; i < n; i++) {
+        pLocalProgs[i] = crServerTranslateProgramID(programs[i]);
+    }
+    crStateDeleteProgramsARB(n, pLocalProgs);
+    cr_server.head_spu->dispatch_table.DeleteProgramsARB(n, pLocalProgs);
+    crFree(pLocalProgs);
+}
+
+
+/** @todo will fail for progs loaded from snapshot */
+GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsProgramARB( GLuint program )
+{
+    GLboolean retval;
+    program = crServerTranslateProgramID(program);
+    retval = cr_server.head_spu->dispatch_table.IsProgramARB( program );
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
+
+
+GLboolean SERVER_DISPATCH_APIENTRY
+crServerDispatchAreProgramsResidentNV(GLsizei n, const GLuint *programs,
+                                                                            GLboolean *residences)
+{
+    GLboolean retval = GL_FALSE;
+    GLboolean *res;
+    GLsizei i;
+    (void) residences;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchAreProgramsResidentNV: parameter 'n' is out of range");
+        return GL_FALSE;
+    }
+
+    res = (GLboolean *)crCalloc(n * sizeof(GLboolean));
+
+    if (!res) {
+        crError("crServerDispatchAreProgramsResidentNV: out of memory");
+        return GL_FALSE;
+    }
+
+    if (!cr_server.sharedTextureObjects) {
+        GLuint *programs2 = (GLuint *) crCalloc(n * sizeof(GLuint));
+        if (programs2)
+        {
+            for (i = 0; i < n; i++)
+                programs2[i] = crServerTranslateProgramID(programs[i]);
+
+            retval = cr_server.head_spu->dispatch_table.AreProgramsResidentNV(n, programs2, res);
+            crFree(programs2);
+        }
+        else
+        {
+            crError("crServerDispatchAreProgramsResidentNV: out of memory");
+        }
+    }
+    else {
+        retval = cr_server.head_spu->dispatch_table.AreProgramsResidentNV(n, programs, res);
+    }
+
+    crServerReturnValue(res, n * sizeof(GLboolean));
+    crFree(res);
+
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
+
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.c	(revision 78189)
+++ 	(revision )
@@ -1,284 +1,0 @@
-/* Copyright (c) 2001-2003, Stanford University
-    All rights reserved.
-
-    See the file LICENSE.txt for information on redistributing this software. */
-
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_mem.h"
-
-
-/*
- * Notes on ID translation:
- *
- * If a server has multiple clients (in the case of parallel applications)
- * and N of the clients all create a display list with ID K, does K name
- * one display list or N different display lists?
- *
- * By default, there is one display list named K.  If the clients put
- * identical commands into list K, then this is fine.  But if the clients
- * each put something different into list K when they created it, then this
- * is a serious problem.
- *
- * By zeroing the 'shared_display_lists' configuration option, we can tell
- * the server to make list K be unique for all N clients.  We do this by
- * translating K into a new, unique ID dependent on which client we're
- * talking to (curClient->number).
- *
- * Same story for texture objects, vertex programs, etc.
- *
- * The application can also dynamically switch between shared and private
- * display lists with:
- *   glChromiumParameteri(GL_SHARED_DISPLAY_LISTS_CR, GL_TRUE)
- * and
- *   glChromiumParameteri(GL_SHARED_DISPLAY_LISTS_CR, GL_FALSE)
- *
- */
-
-
-
-static GLuint TranslateListID( GLuint id )
-{
-#ifndef VBOX_WITH_CR_DISPLAY_LISTS
-    if (!cr_server.sharedDisplayLists) {
-        int client = cr_server.curClient->number;
-        return id + client * 100000;
-    }
-#endif
-    return id;
-}
-
-
-GLuint SERVER_DISPATCH_APIENTRY crServerDispatchGenLists( GLsizei range )
-{
-    GLuint retval;
-    retval = cr_server.head_spu->dispatch_table.GenLists( range );
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchNewList( GLuint list, GLenum mode )
-{
-    if (mode == GL_COMPILE_AND_EXECUTE)
-        crWarning("using glNewList(GL_COMPILE_AND_EXECUTE) can confuse the crserver");
-
-    list = TranslateListID( list );
-    crStateNewList( list, mode );
-    cr_server.head_spu->dispatch_table.NewList( list, mode );
-}
-
-static void crServerQueryHWState()
-{
-    if (!cr_server.bUseMultipleContexts)
-    {
-        GLuint fbFbo, bbFbo;
-        CRClient *client = cr_server.curClient;
-        CRMuralInfo *mural = client ? client->currentMural : NULL;
-        if (mural && mural->fRedirected)
-        {
-            fbFbo = mural->aidFBOs[CR_SERVER_FBO_FB_IDX(mural)];
-            bbFbo = mural->aidFBOs[CR_SERVER_FBO_BB_IDX(mural)];
-        }
-        else
-        {
-            fbFbo = bbFbo = 0;
-        }
-        crStateQueryHWState(fbFbo, bbFbo);
-    }
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchEndList(void)
-{
-    CRContext *g = crStateGetCurrent();
-    CRListsState *l = &(g->lists);
-
-    cr_server.head_spu->dispatch_table.EndList();
-    crStateEndList();
-
-#ifndef IN_GUEST
-    if (l->mode==GL_COMPILE)
-    {
-        crServerQueryHWState();
-    }
-#endif
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchCallList( GLuint list )
-{
-    list = TranslateListID( list );
-
-    if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
-        /* we're not compiling, so execute the list now */
-        /* Issue the list as-is */
-        cr_server.head_spu->dispatch_table.CallList( list );
-        crServerQueryHWState();
-    }
-    else {
-        /* we're compiling glCallList into another list - just pass it through */
-        cr_server.head_spu->dispatch_table.CallList( list );
-    }
-}
-
-
-#ifndef VBOX_WITH_CR_DISPLAY_LISTS
-/**
- * Translate an array of display list IDs from various datatypes to GLuint
- * IDs while adding the per-client offset.
- */
-static void
-TranslateListIDs(GLsizei n, GLenum type, const GLvoid *lists, GLuint *newLists)
-{
-    int offset = cr_server.curClient->number * 100000;
-    GLsizei i;
-    switch (type) {
-    case GL_UNSIGNED_BYTE:
-        {
-            const GLubyte *src = (const GLubyte *) lists;
-            for (i = 0; i < n; i++) {
-                newLists[i] = src[i] + offset;
-            }
-        }
-        break;
-    case GL_BYTE:
-        {
-            const GLbyte *src = (const GLbyte *) lists;
-            for (i = 0; i < n; i++) {
-                newLists[i] = src[i] + offset;
-            }
-        }
-        break;
-    case GL_UNSIGNED_SHORT:
-        {
-            const GLushort *src = (const GLushort *) lists;
-            for (i = 0; i < n; i++) {
-                newLists[i] = src[i] + offset;
-            }
-        }
-        break;
-    case GL_SHORT:
-        {
-            const GLshort *src = (const GLshort *) lists;
-            for (i = 0; i < n; i++) {
-                newLists[i] = src[i] + offset;
-            }
-        }
-        break;
-    case GL_UNSIGNED_INT:
-        {
-            const GLuint *src = (const GLuint *) lists;
-            for (i = 0; i < n; i++) {
-                newLists[i] = src[i] + offset;
-            }
-        }
-        break;
-    case GL_INT:
-        {
-            const GLint *src = (const GLint *) lists;
-            for (i = 0; i < n; i++) {
-                newLists[i] = src[i] + offset;
-            }
-        }
-        break;
-    case GL_FLOAT:
-        {
-            const GLfloat *src = (const GLfloat *) lists;
-            for (i = 0; i < n; i++) {
-                newLists[i] = (GLuint) src[i] + offset;
-            }
-        }
-        break;
-    case GL_2_BYTES:
-        {
-            const GLubyte *src = (const GLubyte *) lists;
-            for (i = 0; i < n; i++) {
-                newLists[i] = (src[i*2+0] * 256 +
-                                             src[i*2+1]) + offset;
-            }
-        }
-        break;
-    case GL_3_BYTES:
-        {
-            const GLubyte *src = (const GLubyte *) lists;
-            for (i = 0; i < n; i++) {
-                newLists[i] = (src[i*3+0] * 256 * 256 +
-                                             src[i*3+1] * 256 +
-                                             src[i*3+2]) + offset;
-            }
-        }
-        break;
-    case GL_4_BYTES:
-        {
-            const GLubyte *src = (const GLubyte *) lists;
-            for (i = 0; i < n; i++) {
-                newLists[i] = (src[i*4+0] * 256 * 256 * 256 +
-                                             src[i*4+1] * 256 * 256 +
-                                             src[i*4+2] * 256 +
-                                             src[i*4+3]) + offset;
-            }
-        }
-        break;
-    default:
-        crWarning("CRServer: invalid display list datatype 0x%x", type);
-    }
-}
-#endif
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchCallLists( GLsizei n, GLenum type, const GLvoid *lists )
-{
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchCallLists: parameter 'n' is out of range");
-        return;
-    }
-
-#ifndef VBOX_WITH_CR_DISPLAY_LISTS
-    if (!cr_server.sharedDisplayLists) {
-        /* need to translate IDs */
-        GLuint *newLists = (GLuint *) crAlloc(n * sizeof(GLuint));
-        if (newLists) {
-            TranslateListIDs(n, type, lists, newLists);
-        }
-        lists = newLists;
-        type = GL_UNSIGNED_INT;
-    }
-#endif
-
-    if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
-        /* we're not compiling, so execute the list now */
-        /* Issue the list as-is */
-        cr_server.head_spu->dispatch_table.CallLists( n, type, lists );
-        crServerQueryHWState();
-    }
-    else {
-        /* we're compiling glCallList into another list - just pass it through */
-        cr_server.head_spu->dispatch_table.CallLists( n, type, lists );
-    }
-
-#ifndef VBOX_WITH_CR_DISPLAY_LISTS
-    if (!cr_server.sharedDisplayLists) {
-        crFree((void *) lists);  /* malloc'd above */
-    }
-#endif
-}
-
-
-GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsList( GLuint list )
-{
-    GLboolean retval;
-    list = TranslateListID( list );
-    retval = cr_server.head_spu->dispatch_table.IsList( list );
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval;
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteLists( GLuint list, GLsizei range )
-{
-    list = TranslateListID( list );
-    crStateDeleteLists( list, range );
-    cr_server.head_spu->dispatch_table.DeleteLists( list, range );
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_lists.cpp	(revision 78190)
@@ -0,0 +1,276 @@
+/* Copyright (c) 2001-2003, Stanford University
+    All rights reserved.
+
+    See the file LICENSE.txt for information on redistributing this software. */
+
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_mem.h"
+
+
+/*
+ * Notes on ID translation:
+ *
+ * If a server has multiple clients (in the case of parallel applications)
+ * and N of the clients all create a display list with ID K, does K name
+ * one display list or N different display lists?
+ *
+ * By default, there is one display list named K.  If the clients put
+ * identical commands into list K, then this is fine.  But if the clients
+ * each put something different into list K when they created it, then this
+ * is a serious problem.
+ *
+ * By zeroing the 'shared_display_lists' configuration option, we can tell
+ * the server to make list K be unique for all N clients.  We do this by
+ * translating K into a new, unique ID dependent on which client we're
+ * talking to (curClient->number).
+ *
+ * Same story for texture objects, vertex programs, etc.
+ *
+ * The application can also dynamically switch between shared and private
+ * display lists with:
+ *   glChromiumParameteri(GL_SHARED_DISPLAY_LISTS_CR, GL_TRUE)
+ * and
+ *   glChromiumParameteri(GL_SHARED_DISPLAY_LISTS_CR, GL_FALSE)
+ *
+ */
+
+
+
+static GLuint TranslateListID( GLuint id )
+{
+    if (!cr_server.sharedDisplayLists) {
+        int client = cr_server.curClient->number;
+        return id + client * 100000;
+    }
+    return id;
+}
+
+
+GLuint SERVER_DISPATCH_APIENTRY crServerDispatchGenLists( GLsizei range )
+{
+    GLuint retval;
+    retval = cr_server.head_spu->dispatch_table.GenLists( range );
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchNewList( GLuint list, GLenum mode )
+{
+    if (mode == GL_COMPILE_AND_EXECUTE)
+        crWarning("using glNewList(GL_COMPILE_AND_EXECUTE) can confuse the crserver");
+
+    list = TranslateListID( list );
+    crStateNewList( list, mode );
+    cr_server.head_spu->dispatch_table.NewList( list, mode );
+}
+
+static void crServerQueryHWState()
+{
+    if (!cr_server.bUseMultipleContexts)
+    {
+        GLuint fbFbo, bbFbo;
+        CRClient *client = cr_server.curClient;
+        CRMuralInfo *mural = client ? client->currentMural : NULL;
+        if (mural && mural->fRedirected)
+        {
+            fbFbo = mural->aidFBOs[CR_SERVER_FBO_FB_IDX(mural)];
+            bbFbo = mural->aidFBOs[CR_SERVER_FBO_BB_IDX(mural)];
+        }
+        else
+        {
+            fbFbo = bbFbo = 0;
+        }
+        crStateQueryHWState(fbFbo, bbFbo);
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchEndList(void)
+{
+    CRContext *g = crStateGetCurrent();
+    CRListsState *l = &(g->lists);
+
+    cr_server.head_spu->dispatch_table.EndList();
+    crStateEndList();
+
+#ifndef IN_GUEST
+    if (l->mode==GL_COMPILE)
+    {
+        crServerQueryHWState();
+    }
+#endif
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchCallList( GLuint list )
+{
+    list = TranslateListID( list );
+
+    if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
+        /* we're not compiling, so execute the list now */
+        /* Issue the list as-is */
+        cr_server.head_spu->dispatch_table.CallList( list );
+        crServerQueryHWState();
+    }
+    else {
+        /* we're compiling glCallList into another list - just pass it through */
+        cr_server.head_spu->dispatch_table.CallList( list );
+    }
+}
+
+
+/**
+ * Translate an array of display list IDs from various datatypes to GLuint
+ * IDs while adding the per-client offset.
+ */
+static void
+TranslateListIDs(GLsizei n, GLenum type, const GLvoid *lists, GLuint *newLists)
+{
+    int offset = cr_server.curClient->number * 100000;
+    GLsizei i;
+    switch (type) {
+    case GL_UNSIGNED_BYTE:
+        {
+            const GLubyte *src = (const GLubyte *) lists;
+            for (i = 0; i < n; i++) {
+                newLists[i] = src[i] + offset;
+            }
+        }
+        break;
+    case GL_BYTE:
+        {
+            const GLbyte *src = (const GLbyte *) lists;
+            for (i = 0; i < n; i++) {
+                newLists[i] = src[i] + offset;
+            }
+        }
+        break;
+    case GL_UNSIGNED_SHORT:
+        {
+            const GLushort *src = (const GLushort *) lists;
+            for (i = 0; i < n; i++) {
+                newLists[i] = src[i] + offset;
+            }
+        }
+        break;
+    case GL_SHORT:
+        {
+            const GLshort *src = (const GLshort *) lists;
+            for (i = 0; i < n; i++) {
+                newLists[i] = src[i] + offset;
+            }
+        }
+        break;
+    case GL_UNSIGNED_INT:
+        {
+            const GLuint *src = (const GLuint *) lists;
+            for (i = 0; i < n; i++) {
+                newLists[i] = src[i] + offset;
+            }
+        }
+        break;
+    case GL_INT:
+        {
+            const GLint *src = (const GLint *) lists;
+            for (i = 0; i < n; i++) {
+                newLists[i] = src[i] + offset;
+            }
+        }
+        break;
+    case GL_FLOAT:
+        {
+            const GLfloat *src = (const GLfloat *) lists;
+            for (i = 0; i < n; i++) {
+                newLists[i] = (GLuint) src[i] + offset;
+            }
+        }
+        break;
+    case GL_2_BYTES:
+        {
+            const GLubyte *src = (const GLubyte *) lists;
+            for (i = 0; i < n; i++) {
+                newLists[i] = (src[i*2+0] * 256 +
+                                             src[i*2+1]) + offset;
+            }
+        }
+        break;
+    case GL_3_BYTES:
+        {
+            const GLubyte *src = (const GLubyte *) lists;
+            for (i = 0; i < n; i++) {
+                newLists[i] = (src[i*3+0] * 256 * 256 +
+                                             src[i*3+1] * 256 +
+                                             src[i*3+2]) + offset;
+            }
+        }
+        break;
+    case GL_4_BYTES:
+        {
+            const GLubyte *src = (const GLubyte *) lists;
+            for (i = 0; i < n; i++) {
+                newLists[i] = (src[i*4+0] * 256 * 256 * 256 +
+                                             src[i*4+1] * 256 * 256 +
+                                             src[i*4+2] * 256 +
+                                             src[i*4+3]) + offset;
+            }
+        }
+        break;
+    default:
+        crWarning("CRServer: invalid display list datatype 0x%x", type);
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchCallLists( GLsizei n, GLenum type, const GLvoid *lists )
+{
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchCallLists: parameter 'n' is out of range");
+        return;
+    }
+
+    if (!cr_server.sharedDisplayLists) {
+        /* need to translate IDs */
+        GLuint *newLists = (GLuint *) crAlloc(n * sizeof(GLuint));
+        if (newLists) {
+            TranslateListIDs(n, type, lists, newLists);
+        }
+        lists = newLists;
+        type = GL_UNSIGNED_INT;
+    }
+
+    if (cr_server.curClient->currentCtxInfo->pContext->lists.mode == 0) {
+        /* we're not compiling, so execute the list now */
+        /* Issue the list as-is */
+        cr_server.head_spu->dispatch_table.CallLists( n, type, lists );
+        crServerQueryHWState();
+    }
+    else {
+        /* we're compiling glCallList into another list - just pass it through */
+        cr_server.head_spu->dispatch_table.CallLists( n, type, lists );
+    }
+
+    if (!cr_server.sharedDisplayLists) {
+        crFree((void *) lists);  /* malloc'd above */
+    }
+}
+
+
+GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsList( GLuint list )
+{
+    GLboolean retval;
+    list = TranslateListID( list );
+    retval = cr_server.head_spu->dispatch_table.IsList( list );
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval;
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteLists( GLuint list, GLsizei range )
+{
+    list = TranslateListID( list );
+    crStateDeleteLists( list, range );
+    cr_server.head_spu->dispatch_table.DeleteLists( list, range );
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.c	(revision 78189)
+++ 	(revision )
@@ -1,4039 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "server.h"
-#include "cr_net.h"
-#include "cr_unpack.h"
-#include "cr_error.h"
-#include "cr_glstate.h"
-#include "cr_string.h"
-#include "cr_mem.h"
-#include "cr_hash.h"
-#include "cr_vreg.h"
-#include "cr_environment.h"
-#include "cr_pixeldata.h"
-
-#ifdef VBOX_WITH_CR_DISPLAY_LISTS
-# include "cr_dlm.h"
-#endif
-
-#include "server_dispatch.h"
-#include "state/cr_texture.h"
-#include "render/renderspu.h"
-#include <signal.h>
-#include <stdlib.h>
-#define DEBUG_FP_EXCEPTIONS 0
-#if DEBUG_FP_EXCEPTIONS
-#include <fpu_control.h>
-#include <math.h>
-#endif
-#include <iprt/assert.h>
-#include <VBox/err.h>
-#include <VBox/log.h>
-#include <VBox/AssertGuest.h>
-
-#ifdef VBOXCR_LOGFPS
-#include <iprt/timer.h>
-#endif
-
-#ifdef VBOX_WITH_CRHGSMI
-# include <VBox/HostServices/VBoxCrOpenGLSvc.h>
-uint8_t* g_pvVRamBase = NULL;
-uint32_t g_cbVRam = 0;
-PPDMLED g_pLed = NULL;
-
-HCRHGSMICMDCOMPLETION g_hCrHgsmiCompletion = NULL;
-PFNCRHGSMICMDCOMPLETION g_pfnCrHgsmiCompletion = NULL;
-#endif
-
-/**
- * \mainpage CrServerLib
- *
- * \section CrServerLibIntroduction Introduction
- *
- * Chromium consists of all the top-level files in the cr
- * directory.  The core module basically takes care of API dispatch,
- * and OpenGL state management.
- */
-
-
-/**
- * CRServer global data
- */
-CRServer cr_server;
-
-int tearingdown = 0; /* can't be static */
-
-static DECLCALLBACK(int8_t) crVBoxCrCmdCmd(HVBOXCRCMDSVR hSvr,
-                                           const VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd);
-
-DECLINLINE(CRClient*) crVBoxServerClientById(uint32_t u32ClientID)
-{
-    int32_t i;
-
-    if (cr_server.fCrCmdEnabled)
-        return CrHTableGet(&cr_server.clientTable, u32ClientID);
-
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        if (cr_server.clients[i] && cr_server.clients[i]->conn
-            && cr_server.clients[i]->conn->u32ClientID==u32ClientID)
-        {
-            return cr_server.clients[i];
-        }
-    }
-
-    return NULL;
-}
-
-int32_t crVBoxServerClientGet(uint32_t u32ClientID, CRClient **ppClient)
-{
-    CRClient *pClient = NULL;
-
-    pClient = crVBoxServerClientById(u32ClientID);
-
-    if (!pClient)
-    {
-        WARN(("client not found!"));
-        *ppClient = NULL;
-        return VERR_INVALID_PARAMETER;
-    }
-
-    if (!pClient->conn->vMajor)
-    {
-        WARN(("no major version specified for client!"));
-        *ppClient = NULL;
-        return VERR_NOT_SUPPORTED;
-    }
-
-    *ppClient = pClient;
-
-    return VINF_SUCCESS;
-}
-
-
-/**
- * Return pointer to server's first SPU.
- */
-SPU*
-crServerHeadSPU(void)
-{
-     return cr_server.head_spu;
-}
-
-
-
-static void DeleteBarrierCallback( void *data )
-{
-    CRServerBarrier *barrier = (CRServerBarrier *) data;
-    crFree(barrier->waiting);
-    crFree(barrier);
-}
-
-
-static void deleteContextInfoCallback( void *data )
-{
-    CRContextInfo *c = (CRContextInfo *) data;
-    crStateDestroyContext(c->pContext);
-    if (c->CreateInfo.pszDpyName)
-        crFree(c->CreateInfo.pszDpyName);
-    crFree(c);
-}
-
-static void deleteMuralInfoCallback( void *data )
-{
-    CRMuralInfo *m = (CRMuralInfo *) data;
-    if (m->spuWindow != CR_RENDER_DEFAULT_WINDOW_ID) /* <- do not do term for default mural as it does not contain any info to be freed,
-                                                      * and renderspu will destroy it up itself*/
-    {
-        crServerMuralTerm(m);
-    }
-    crFree(m);
-}
-
-static int crVBoxServerCrCmdDisablePostProcess(VBOXCRCMDCTL_HGCMENABLE_DATA *pData);
-
-static void crServerTearDown( void )
-{
-    GLint i;
-    CRClientNode *pNode, *pNext;
-    GLboolean fOldEnableDiff;
-    GLboolean fContextsDeleted = GL_FALSE;
-
-    /* avoid a race condition */
-    if (tearingdown)
-        return;
-
-    tearingdown = 1;
-
-    if (cr_server.fCrCmdEnabled)
-    {
-        VBOXCRCMDCTL_HGCMENABLE_DATA EnableData;
-        /* crVBoxServerHgcmEnable will erase the DisableData, preserve it here */
-        VBOXCRCMDCTL_HGCMDISABLE_DATA DisableData = cr_server.DisableData;
-        int rc;
-
-        CRASSERT(DisableData.pfnNotifyTerm);
-        rc = DisableData.pfnNotifyTerm(DisableData.hNotifyTerm, &EnableData);
-        if (!RT_SUCCESS(rc))
-        {
-            WARN(("pfnNotifyTerm failed %d", rc));
-            return;
-        }
-
-        crVBoxServerCrCmdDisablePostProcess(&EnableData);
-        fContextsDeleted = GL_TRUE;
-
-        CRASSERT(DisableData.pfnNotifyTermDone);
-        DisableData.pfnNotifyTermDone(DisableData.hNotifyTerm);
-
-        Assert(!cr_server.fCrCmdEnabled);
-    }
-
-    crStateSetCurrent( NULL );
-
-    cr_server.curClient = NULL;
-    cr_server.run_queue = NULL;
-
-    crFree( cr_server.overlap_intens );
-    cr_server.overlap_intens = NULL;
-
-    /* needed to make sure window dummy mural not get created on mural destruction
-     * and generally this should be zeroed up */
-    cr_server.currentCtxInfo = NULL;
-    cr_server.currentWindow = -1;
-    cr_server.currentNativeWindow = 0;
-    cr_server.currentMural = NULL;
-
-    if (!fContextsDeleted)
-    {
-#ifndef VBOX_WITH_CR_DISPLAY_LISTS
-        /* sync our state with renderspu,
-         * do it before mural & context deletion to avoid deleting currently set murals/contexts*/
-        cr_server.head_spu->dispatch_table.MakeCurrent(CR_RENDER_DEFAULT_WINDOW_ID, 0, CR_RENDER_DEFAULT_CONTEXT_ID);
-#endif
-    }
-
-    /* Deallocate all semaphores */
-    crFreeHashtable(cr_server.semaphores, crFree);
-    cr_server.semaphores = NULL;
-
-    /* Deallocate all barriers */
-    crFreeHashtable(cr_server.barriers, DeleteBarrierCallback);
-    cr_server.barriers = NULL;
-
-#if 0 /** @todo @bugref{8662} -- can trigger SEGFAULTs during savestate */
-    /* Free all context info */
-    crFreeHashtable(cr_server.contextTable, deleteContextInfoCallback);
-#endif
-
-    /* synchronize with reality */
-    if (!fContextsDeleted)
-    {
-        fOldEnableDiff = crStateEnableDiffOnMakeCurrent(GL_FALSE);
-        if(cr_server.MainContextInfo.pContext)
-            crStateMakeCurrent(cr_server.MainContextInfo.pContext);
-        crStateEnableDiffOnMakeCurrent(fOldEnableDiff);
-    }
-
-    /* Free vertex programs */
-    crFreeHashtable(cr_server.programTable, crFree);
-
-    /* Free murals */
-    crFreeHashtable(cr_server.muralTable, deleteMuralInfoCallback);
-
-    CrPMgrTerm();
-
-    if (CrBltIsInitialized(&cr_server.Blitter))
-    {
-        CrBltTerm(&cr_server.Blitter);
-    }
-
-    /* Free dummy murals */
-    crFreeHashtable(cr_server.dummyMuralTable, deleteMuralInfoCallback);
-
-    for (i = 0; i < cr_server.numClients; i++) {
-        if (cr_server.clients[i]) {
-            CRConnection *conn = cr_server.clients[i]->conn;
-            crNetFreeConnection(conn);
-            crFree(cr_server.clients[i]);
-        }
-    }
-    cr_server.numClients = 0;
-
-    pNode = cr_server.pCleanupClient;
-    while (pNode)
-    {
-        pNext=pNode->next;
-        crFree(pNode->pClient);
-        crFree(pNode);
-        pNode=pNext;
-    }
-    cr_server.pCleanupClient = NULL;
-
-    if (crServerRpwIsInitialized(&cr_server.RpwWorker))
-    {
-        crServerRpwTerm(&cr_server.RpwWorker);
-    }
-
-#if 1
-    /* disable these two lines if trying to get stack traces with valgrind */
-    crSPUUnloadChain(cr_server.head_spu);
-    cr_server.head_spu = NULL;
-#endif
-
-    crStateDestroy();
-
-    crNetTearDown();
-
-    VBoxVrListClear(&cr_server.RootVr);
-
-    VBoxVrTerm();
-
-    RTSemEventDestroy(cr_server.hCalloutCompletionEvent);
-}
-
-static void crServerClose( unsigned int id )
-{
-    crError( "Client disconnected!" );
-    (void) id;
-}
-
-static void crServerCleanup( int sigio )
-{
-    crServerTearDown();
-
-    tearingdown = 0;
-}
-
-
-void
-crServerSetPort(int port)
-{
-    cr_server.tcpip_port = port;
-}
-
-
-
-static void
-crPrintHelp(void)
-{
-    printf("Usage: crserver [OPTIONS]\n");
-    printf("Options:\n");
-    printf("  -mothership URL  Specifies URL for contacting the mothership.\n");
-    printf("                   URL is of the form [protocol://]hostname[:port]\n");
-    printf("  -port N          Specifies the port number this server will listen to.\n");
-    printf("  -help            Prints this information.\n");
-}
-
-
-/**
- * Do CRServer initializations.  After this, we can begin servicing clients.
- */
-void
-crServerInit(int argc, char *argv[])
-{
-    int i;
-    const char*env;
-    char *mothership = NULL;
-    CRMuralInfo *defaultMural;
-    int rc = VBoxVrInit();
-    if (!RT_SUCCESS(rc))
-    {
-        crWarning("VBoxVrInit failed, rc %d", rc);
-        return;
-    }
-
-    for (i = 1 ; i < argc ; i++)
-    {
-        if (!crStrcmp( argv[i], "-mothership" ))
-        {
-            if (i == argc - 1)
-            {
-                crError( "-mothership requires an argument" );
-            }
-            mothership = argv[i+1];
-            i++;
-        }
-        else if (!crStrcmp( argv[i], "-port" ))
-        {
-            /* This is the port on which we'll accept client connections */
-            if (i == argc - 1)
-            {
-                crError( "-port requires an argument" );
-            }
-            cr_server.tcpip_port = crStrToInt(argv[i+1]);
-            i++;
-        }
-        else if (!crStrcmp( argv[i], "-vncmode" ))
-        {
-            cr_server.vncMode = 1;
-        }
-        else if (!crStrcmp( argv[i], "-help" ))
-        {
-            crPrintHelp();
-            exit(0);
-        }
-    }
-
-    signal( SIGTERM, crServerCleanup );
-    signal( SIGINT, crServerCleanup );
-#ifndef WINDOWS
-    signal( SIGPIPE, SIG_IGN );
-#endif
-
-#if DEBUG_FP_EXCEPTIONS
-    {
-        fpu_control_t mask;
-        _FPU_GETCW(mask);
-        mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM
-                            | _FPU_MASK_OM | _FPU_MASK_UM);
-        _FPU_SETCW(mask);
-    }
-#endif
-
-    cr_server.fCrCmdEnabled = GL_FALSE;
-    cr_server.fProcessingPendedCommands = GL_FALSE;
-    CrHTableCreate(&cr_server.clientTable, CR_MAX_CLIENTS);
-
-    cr_server.bUseMultipleContexts = (crGetenv( "CR_SERVER_ENABLE_MULTIPLE_CONTEXTS" ) != NULL);
-
-    if (cr_server.bUseMultipleContexts)
-    {
-        crInfo("Info: using multiple contexts!");
-        crDebug("Debug: using multiple contexts!");
-    }
-
-    cr_server.firstCallCreateContext = GL_TRUE;
-    cr_server.firstCallMakeCurrent = GL_TRUE;
-    cr_server.bForceMakeCurrentOnClientSwitch = GL_FALSE;
-
-    /*
-     * Create default mural info and hash table.
-     */
-    cr_server.muralTable = crAllocHashtable();
-    defaultMural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo));
-    defaultMural->spuWindow = CR_RENDER_DEFAULT_WINDOW_ID;
-    crHashtableAdd(cr_server.muralTable, 0, defaultMural);
-
-    cr_server.programTable = crAllocHashtable();
-
-    crNetInit(crServerRecv, crServerClose);
-    crStateInit();
-
-    crServerSetVBoxConfiguration();
-
-    crStateLimitsInit( &(cr_server.limits) );
-
-    /*
-     * Default context
-     */
-    cr_server.contextTable = crAllocHashtable();
-    cr_server.curClient->currentCtxInfo = &cr_server.MainContextInfo;
-
-    cr_server.dummyMuralTable = crAllocHashtable();
-
-    CrPMgrInit();
-
-    cr_server.fRootVrOn = GL_FALSE;
-    VBoxVrListInit(&cr_server.RootVr);
-    crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint));
-
-    crMemset(&cr_server.RpwWorker, 0, sizeof (cr_server.RpwWorker));
-
-    env = crGetenv("CR_SERVER_BFB");
-    if (env)
-    {
-        cr_server.fBlitterMode = env[0] - '0';
-    }
-    else
-    {
-        cr_server.fBlitterMode = CR_SERVER_BFB_DISABLED;
-    }
-    crMemset(&cr_server.Blitter, 0, sizeof (cr_server.Blitter));
-
-    crServerInitDispatch();
-    crServerInitTmpCtxDispatch();
-    crStateDiffAPI( &(cr_server.head_spu->dispatch_table) );
-
-#ifdef VBOX_WITH_CRSERVER_DUMPER
-    crMemset(&cr_server.Recorder, 0, sizeof (cr_server.Recorder));
-    crMemset(&cr_server.RecorderBlitter, 0, sizeof (cr_server.RecorderBlitter));
-    crMemset(&cr_server.DbgPrintDumper, 0, sizeof (cr_server.DbgPrintDumper));
-    crMemset(&cr_server.HtmlDumper, 0, sizeof (cr_server.HtmlDumper));
-    cr_server.pDumper = NULL;
-#endif
-
-    crUnpackSetReturnPointer( &(cr_server.return_ptr) );
-    crUnpackSetWritebackPointer( &(cr_server.writeback_ptr) );
-
-    cr_server.barriers = crAllocHashtable();
-    cr_server.semaphores = crAllocHashtable();
-}
-
-void crVBoxServerTearDown(void)
-{
-    crServerTearDown();
-}
-
-/**
- * Do CRServer initializations.  After this, we can begin servicing clients.
- */
-GLboolean crVBoxServerInit(void)
-{
-    CRMuralInfo *defaultMural;
-    const char*env;
-    int rc = VBoxVrInit();
-    if (!RT_SUCCESS(rc))
-    {
-        crWarning("VBoxVrInit failed, rc %d", rc);
-        return GL_FALSE;
-    }
-
-#if DEBUG_FP_EXCEPTIONS
-    {
-        fpu_control_t mask;
-        _FPU_GETCW(mask);
-        mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM
-                            | _FPU_MASK_OM | _FPU_MASK_UM);
-        _FPU_SETCW(mask);
-    }
-#endif
-
-    cr_server.fCrCmdEnabled = GL_FALSE;
-    cr_server.fProcessingPendedCommands = GL_FALSE;
-    CrHTableCreate(&cr_server.clientTable, CR_MAX_CLIENTS);
-
-    cr_server.bUseMultipleContexts = (crGetenv( "CR_SERVER_ENABLE_MULTIPLE_CONTEXTS" ) != NULL);
-
-    if (cr_server.bUseMultipleContexts)
-    {
-        crInfo("Info: using multiple contexts!");
-        crDebug("Debug: using multiple contexts!");
-    }
-
-    crNetInit(crServerRecv, crServerClose);
-
-    cr_server.firstCallCreateContext = GL_TRUE;
-    cr_server.firstCallMakeCurrent = GL_TRUE;
-
-    cr_server.bIsInLoadingState = GL_FALSE;
-    cr_server.bIsInSavingState  = GL_FALSE;
-    cr_server.bForceMakeCurrentOnClientSwitch = GL_FALSE;
-
-    cr_server.pCleanupClient = NULL;
-
-    rc = RTSemEventCreate(&cr_server.hCalloutCompletionEvent);
-    if (!RT_SUCCESS(rc))
-    {
-        WARN(("RTSemEventCreate failed %d", rc));
-        return GL_FALSE;
-    }
-
-    /*
-     * Create default mural info and hash table.
-     */
-    cr_server.muralTable = crAllocHashtable();
-    defaultMural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo));
-    defaultMural->spuWindow = CR_RENDER_DEFAULT_WINDOW_ID;
-    crHashtableAdd(cr_server.muralTable, 0, defaultMural);
-
-    cr_server.programTable = crAllocHashtable();
-
-    crStateInit();
-
-    crStateLimitsInit( &(cr_server.limits) );
-
-    cr_server.barriers = crAllocHashtable();
-    cr_server.semaphores = crAllocHashtable();
-
-    crUnpackSetReturnPointer( &(cr_server.return_ptr) );
-    crUnpackSetWritebackPointer( &(cr_server.writeback_ptr) );
-
-    /*
-     * Default context
-     */
-    cr_server.contextTable = crAllocHashtable();
-
-    cr_server.dummyMuralTable = crAllocHashtable();
-
-    CrPMgrInit();
-
-    cr_server.fRootVrOn = GL_FALSE;
-    VBoxVrListInit(&cr_server.RootVr);
-    crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint));
-
-    crMemset(&cr_server.RpwWorker, 0, sizeof (cr_server.RpwWorker));
-
-    env = crGetenv("CR_SERVER_BFB");
-    if (env)
-    {
-        cr_server.fBlitterMode = env[0] - '0';
-    }
-    else
-    {
-        cr_server.fBlitterMode = CR_SERVER_BFB_DISABLED;
-    }
-    crMemset(&cr_server.Blitter, 0, sizeof (cr_server.Blitter));
-
-    crServerSetVBoxConfigurationHGCM();
-
-    if (!cr_server.head_spu)
-    {
-        crStateDestroy();
-        return GL_FALSE;
-    }
-
-    crServerInitDispatch();
-    crServerInitTmpCtxDispatch();
-    crStateDiffAPI( &(cr_server.head_spu->dispatch_table) );
-
-#ifdef VBOX_WITH_CRSERVER_DUMPER
-    crMemset(&cr_server.Recorder, 0, sizeof (cr_server.Recorder));
-    crMemset(&cr_server.RecorderBlitter, 0, sizeof (cr_server.RecorderBlitter));
-    crMemset(&cr_server.DbgPrintDumper, 0, sizeof (cr_server.DbgPrintDumper));
-    crMemset(&cr_server.HtmlDumper, 0, sizeof (cr_server.HtmlDumper));
-    cr_server.pDumper = NULL;
-#endif
-
-    /*Check for PBO support*/
-    if (crStateGetCurrent()->extensions.ARB_pixel_buffer_object)
-    {
-        cr_server.bUsePBOForReadback=GL_TRUE;
-    }
-
-    return GL_TRUE;
-}
-
-static int32_t crVBoxServerAddClientObj(uint32_t u32ClientID, CRClient **ppNewClient)
-{
-    CRClient *newClient;
-
-    if (cr_server.numClients>=CR_MAX_CLIENTS)
-    {
-        if (ppNewClient)
-            *ppNewClient = NULL;
-        return VERR_MAX_THRDS_REACHED;
-    }
-
-    newClient = (CRClient *) crCalloc(sizeof(CRClient));
-    crDebug("crServer: AddClient u32ClientID=%d", u32ClientID);
-
-    newClient->spu_id = 0;
-    newClient->currentCtxInfo = &cr_server.MainContextInfo;
-    newClient->currentContextNumber = -1;
-    newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
-                                        cr_server.tcpip_port,
-                                        cr_server.mtu, 0);
-    newClient->conn->u32ClientID = u32ClientID;
-
-    cr_server.clients[cr_server.numClients++] = newClient;
-
-    crServerAddToRunQueue(newClient);
-
-    if (ppNewClient)
-        *ppNewClient = newClient;
-
-    return VINF_SUCCESS;
-}
-
-int32_t crVBoxServerAddClient(uint32_t u32ClientID)
-{
-    CRClient *newClient;
-
-    if (cr_server.numClients>=CR_MAX_CLIENTS)
-    {
-        return VERR_MAX_THRDS_REACHED;
-    }
-
-    newClient = (CRClient *) crCalloc(sizeof(CRClient));
-    crDebug("crServer: AddClient u32ClientID=%d", u32ClientID);
-
-    newClient->spu_id = 0;
-    newClient->currentCtxInfo = &cr_server.MainContextInfo;
-    newClient->currentContextNumber = -1;
-    newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
-                                        cr_server.tcpip_port,
-                                        cr_server.mtu, 0);
-    newClient->conn->u32ClientID = u32ClientID;
-
-    cr_server.clients[cr_server.numClients++] = newClient;
-
-    crServerAddToRunQueue(newClient);
-
-    return VINF_SUCCESS;
-}
-
-static void crVBoxServerRemoveClientObj(CRClient *pClient)
-{
-#ifdef VBOX_WITH_CRHGSMI
-    CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-#endif
-
-    /* Disconnect the client */
-    pClient->conn->Disconnect(pClient->conn);
-
-    /* Let server clear client from the queue */
-    crServerDeleteClient(pClient);
-}
-
-static void crVBoxServerRemoveAllClients()
-{
-    int32_t i;
-    for (i = cr_server.numClients - 1; i >= 0; --i)
-    {
-        Assert(cr_server.clients[i]);
-        crVBoxServerRemoveClientObj(cr_server.clients[i]);
-    }
-}
-
-void crVBoxServerRemoveClient(uint32_t u32ClientID)
-{
-    CRClient *pClient=NULL;
-    int32_t i;
-
-    crDebug("crServer: RemoveClient u32ClientID=%d", u32ClientID);
-
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        if (cr_server.clients[i] && cr_server.clients[i]->conn
-            && cr_server.clients[i]->conn->u32ClientID==u32ClientID)
-        {
-            pClient = cr_server.clients[i];
-            break;
-        }
-    }
-    //if (!pClient) return VERR_INVALID_PARAMETER;
-    if (!pClient)
-    {
-        WARN(("Invalid client id %u passed to crVBoxServerRemoveClient", u32ClientID));
-        return;
-    }
-
-    crVBoxServerRemoveClientObj(pClient);
-}
-
-static void crVBoxServerInternalClientWriteRead(CRClient *pClient)
-{
-#ifdef VBOXCR_LOGFPS
-    uint64_t tstart, tend;
-#endif
-
-    /*crDebug("=>crServer: ClientWrite u32ClientID=%d", u32ClientID);*/
-
-
-#ifdef VBOXCR_LOGFPS
-    tstart = RTTimeNanoTS();
-#endif
-
-    /* This should be setup already */
-    CRASSERT(pClient->conn->pBuffer);
-    CRASSERT(pClient->conn->cbBuffer);
-#ifdef VBOX_WITH_CRHGSMI
-    CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(&pClient->conn->CmdData);
-#endif
-
-    if (
-#ifdef VBOX_WITH_CRHGSMI
-         !CRVBOXHGSMI_CMDDATA_IS_SET(&pClient->conn->CmdData) &&
-#endif
-         cr_server.run_queue->client != pClient
-         && crServerClientInBeginEnd(cr_server.run_queue->client))
-    {
-        crDebug("crServer: client %d blocked, allow_redir_ptr = 0", pClient->conn->u32ClientID);
-        pClient->conn->allow_redir_ptr = 0;
-    }
-    else
-    {
-        pClient->conn->allow_redir_ptr = 1;
-    }
-
-    crNetRecv();
-    CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
-    CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-    crServerServiceClients();
-    crStateResetCurrentPointers(&cr_server.current);
-
-#ifndef VBOX_WITH_CRHGSMI
-    CRASSERT(!pClient->conn->allow_redir_ptr || crNetNumMessages(pClient->conn)==0);
-#endif
-
-#ifdef VBOXCR_LOGFPS
-    tend = RTTimeNanoTS();
-    pClient->timeUsed += tend-tstart;
-#endif
-    /*crDebug("<=crServer: ClientWrite u32ClientID=%d", u32ClientID);*/
-}
-
-
-int32_t crVBoxServerClientWrite(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t cbBuffer)
-{
-    CRClient *pClient=NULL;
-    int32_t rc = crVBoxServerClientGet(u32ClientID, &pClient);
-
-    if (RT_FAILURE(rc))
-        return rc;
-
-    CRASSERT(pBuffer);
-
-    /* This should never fire unless we start to multithread */
-    CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
-
-    pClient->conn->pBuffer = pBuffer;
-    pClient->conn->cbBuffer = cbBuffer;
-#ifdef VBOX_WITH_CRHGSMI
-    CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-#endif
-
-    crVBoxServerInternalClientWriteRead(pClient);
-
-    return VINF_SUCCESS;
-}
-
-int32_t crVBoxServerInternalClientRead(CRClient *pClient, uint8_t *pBuffer, uint32_t *pcbBuffer)
-{
-    if (pClient->conn->cbHostBuffer > *pcbBuffer)
-    {
-        crDebug("crServer: [%lx] ClientRead u32ClientID=%d FAIL, host buffer too small %d of %d",
-                  crThreadID(), pClient->conn->u32ClientID, *pcbBuffer, pClient->conn->cbHostBuffer);
-
-        /* Return the size of needed buffer */
-        *pcbBuffer = pClient->conn->cbHostBuffer;
-
-        return VERR_BUFFER_OVERFLOW;
-    }
-
-    *pcbBuffer = pClient->conn->cbHostBuffer;
-
-    if (*pcbBuffer)
-    {
-        CRASSERT(pClient->conn->pHostBuffer);
-
-        crMemcpy(pBuffer, pClient->conn->pHostBuffer, *pcbBuffer);
-        pClient->conn->cbHostBuffer = 0;
-    }
-
-    return VINF_SUCCESS;
-}
-
-int32_t crVBoxServerClientRead(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t *pcbBuffer)
-{
-    CRClient *pClient=NULL;
-    int32_t rc = crVBoxServerClientGet(u32ClientID, &pClient);
-
-    if (RT_FAILURE(rc))
-        return rc;
-
-#ifdef VBOX_WITH_CRHGSMI
-    CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-#endif
-
-    return crVBoxServerInternalClientRead(pClient, pBuffer, pcbBuffer);
-}
-
-extern DECLEXPORT(int32_t) crVBoxServerClientGetCapsLegacy(uint32_t u32ClientID, uint32_t *pu32Caps)
-{
-    uint32_t u32Caps = cr_server.u32Caps;
-    u32Caps &= ~CR_VBOX_CAP_CMDVBVA;
-    *pu32Caps = u32Caps;
-    return VINF_SUCCESS;
-}
-
-extern DECLEXPORT(int32_t) crVBoxServerClientGetCapsNew(uint32_t u32ClientID, CR_CAPS_INFO *pInfo)
-{
-    pInfo->u32Caps = cr_server.u32Caps;
-    pInfo->u32CmdVbvaVersion = CR_CMDVBVA_VERSION;
-    return VINF_SUCCESS;
-}
-
-static int32_t crVBoxServerClientObjSetVersion(CRClient *pClient, uint32_t vMajor, uint32_t vMinor)
-{
-    pClient->conn->vMajor = vMajor;
-    pClient->conn->vMinor = vMinor;
-
-    if (vMajor != CR_PROTOCOL_VERSION_MAJOR
-        || vMinor != CR_PROTOCOL_VERSION_MINOR)
-        return VERR_NOT_SUPPORTED;
-    return VINF_SUCCESS;
-}
-
-int32_t crVBoxServerClientSetVersion(uint32_t u32ClientID, uint32_t vMajor, uint32_t vMinor)
-{
-    CRClient *pClient=NULL;
-    int32_t i;
-
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        if (cr_server.clients[i] && cr_server.clients[i]->conn
-            && cr_server.clients[i]->conn->u32ClientID==u32ClientID)
-        {
-            pClient = cr_server.clients[i];
-            break;
-        }
-    }
-    if (!pClient) return VERR_INVALID_PARAMETER;
-
-    return crVBoxServerClientObjSetVersion(pClient, vMajor, vMinor);
-}
-
-static int32_t crVBoxServerClientObjSetPID(CRClient *pClient, uint64_t pid)
-{
-    pClient->pid = pid;
-
-    return VINF_SUCCESS;
-}
-
-int32_t crVBoxServerClientSetPID(uint32_t u32ClientID, uint64_t pid)
-{
-    CRClient *pClient=NULL;
-    int32_t i;
-
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        if (cr_server.clients[i] && cr_server.clients[i]->conn
-            && cr_server.clients[i]->conn->u32ClientID==u32ClientID)
-        {
-            pClient = cr_server.clients[i];
-            break;
-        }
-    }
-    if (!pClient) return VERR_INVALID_PARAMETER;
-
-    return crVBoxServerClientObjSetPID(pClient, pid);
-}
-
-int
-CRServerMain(int argc, char *argv[])
-{
-    crServerInit(argc, argv);
-
-    crServerSerializeRemoteStreams();
-
-    crServerTearDown();
-
-    tearingdown = 0;
-
-    return 0;
-}
-
-static void crVBoxServerSaveMuralCB(unsigned long key, void *data1, void *data2)
-{
-    CRMuralInfo *pMI = (CRMuralInfo*) data1;
-    PSSMHANDLE pSSM = (PSSMHANDLE) data2;
-    int32_t rc;
-
-    CRASSERT(pMI && pSSM);
-
-    /* Don't store default mural */
-    if (!key) return;
-
-    rc = SSMR3PutMem(pSSM, &key, sizeof(key));
-    CRASSERT(rc == VINF_SUCCESS);
-
-    rc = SSMR3PutMem(pSSM, pMI, RT_UOFFSETOF(CRMuralInfo, CreateInfo));
-    CRASSERT(rc == VINF_SUCCESS);
-
-    if (pMI->pVisibleRects)
-    {
-        rc = SSMR3PutMem(pSSM, pMI->pVisibleRects, 4*sizeof(GLint)*pMI->cVisibleRects);
-    }
-
-    rc = SSMR3PutMem(pSSM, pMI->ctxUsage, sizeof (pMI->ctxUsage));
-    CRASSERT(rc == VINF_SUCCESS);
-}
-
-/** @todo add hashtable walker with result info and intermediate abort */
-static void crVBoxServerSaveCreateInfoCB(unsigned long key, void *data1, void *data2)
-{
-    CRCreateInfo_t *pCreateInfo = (CRCreateInfo_t *)data1;
-    PSSMHANDLE pSSM = (PSSMHANDLE) data2;
-    int32_t rc;
-
-    CRASSERT(pCreateInfo && pSSM);
-
-    /* Don't store default mural create info */
-    if (!key) return;
-
-    rc = SSMR3PutMem(pSSM, &key, sizeof(key));
-    CRASSERT(rc == VINF_SUCCESS);
-
-    rc = SSMR3PutMem(pSSM, pCreateInfo, sizeof(*pCreateInfo));
-    CRASSERT(rc == VINF_SUCCESS);
-
-    if (pCreateInfo->pszDpyName)
-    {
-        rc = SSMR3PutStrZ(pSSM, pCreateInfo->pszDpyName);
-        CRASSERT(rc == VINF_SUCCESS);
-    }
-}
-
-static void crVBoxServerSaveCreateInfoFromMuralInfoCB(unsigned long key, void *data1, void *data2)
-{
-    CRMuralInfo *pMural = (CRMuralInfo *)data1;
-    CRCreateInfo_t CreateInfo;
-    CreateInfo.pszDpyName = pMural->CreateInfo.pszDpyName;
-    CreateInfo.visualBits = pMural->CreateInfo.requestedVisualBits;
-    CreateInfo.externalID = pMural->CreateInfo.externalID;
-    crVBoxServerSaveCreateInfoCB(key, &CreateInfo, data2);
-}
-
-static void crVBoxServerSaveCreateInfoFromCtxInfoCB(unsigned long key, void *data1, void *data2)
-{
-    CRContextInfo *pContextInfo = (CRContextInfo *)data1;
-    CRCreateInfo_t CreateInfo;
-    CreateInfo.pszDpyName = pContextInfo->CreateInfo.pszDpyName;
-    CreateInfo.visualBits = pContextInfo->CreateInfo.requestedVisualBits;
-    /* saved state contains internal id */
-    CreateInfo.externalID = pContextInfo->pContext->id;
-    crVBoxServerSaveCreateInfoCB(key, &CreateInfo, data2);
-}
-
-static void crVBoxServerSyncTextureCB(unsigned long key, void *data1, void *data2)
-{
-    CRTextureObj *pTexture = (CRTextureObj *) data1;
-    CRContext *pContext = (CRContext *) data2;
-
-    CRASSERT(pTexture && pContext);
-    crStateTextureObjectDiff(pContext, NULL, NULL, pTexture, GL_TRUE);
-}
-
-typedef struct CRVBOX_SAVE_STATE_GLOBAL
-{
-    /* context id -> mural association
-     * on context data save, each context will be made current with the corresponding mural from this table
-     * thus saving the mural front & back buffer data */
-    CRHashTable *contextMuralTable;
-    /* mural id -> context info
-     * for murals that do not have associated context in contextMuralTable
-     * we still need to save*/
-    CRHashTable *additionalMuralContextTable;
-
-    PSSMHANDLE pSSM;
-
-    int rc;
-} CRVBOX_SAVE_STATE_GLOBAL, *PCRVBOX_SAVE_STATE_GLOBAL;
-
-
-typedef struct CRVBOX_CTXWND_CTXWALKER_CB
-{
-    PCRVBOX_SAVE_STATE_GLOBAL pGlobal;
-    CRHashTable *usedMuralTable;
-    GLuint cAdditionalMurals;
-} CRVBOX_CTXWND_CTXWALKER_CB, *PCRVBOX_CTXWND_CTXWALKER_CB;
-
-static void crVBoxServerBuildAdditionalWindowContextMapCB(unsigned long key, void *data1, void *data2)
-{
-    CRMuralInfo * pMural = (CRMuralInfo *) data1;
-    PCRVBOX_CTXWND_CTXWALKER_CB pData = (PCRVBOX_CTXWND_CTXWALKER_CB)data2;
-    CRContextInfo *pContextInfo = NULL;
-
-    if (!pMural->CreateInfo.externalID)
-    {
-        CRASSERT(!key);
-        return;
-    }
-
-    if (crHashtableSearch(pData->usedMuralTable, pMural->CreateInfo.externalID))
-    {
-        Assert(crHashtableGetDataKey(pData->pGlobal->contextMuralTable, pMural, NULL));
-        return;
-    }
-
-    Assert(!crHashtableGetDataKey(pData->pGlobal->contextMuralTable, pMural, NULL));
-
-    if (cr_server.MainContextInfo.CreateInfo.realVisualBits == pMural->CreateInfo.realVisualBits)
-    {
-        pContextInfo = &cr_server.MainContextInfo;
-    }
-    else
-    {
-        crWarning("different visual bits not implemented!");
-        pContextInfo = &cr_server.MainContextInfo;
-    }
-
-    crHashtableAdd(pData->pGlobal->additionalMuralContextTable, pMural->CreateInfo.externalID, pContextInfo);
-}
-
-
-typedef struct CRVBOX_CTXWND_WNDWALKER_CB
-{
-    PCRVBOX_SAVE_STATE_GLOBAL pGlobal;
-    CRHashTable *usedMuralTable;
-    CRContextInfo *pContextInfo;
-    CRMuralInfo * pMural;
-} CRVBOX_CTXWND_WNDWALKER_CB, *PCRVBOX_CTXWND_WNDWALKER_CB;
-
-static void crVBoxServerBuildContextWindowMapWindowWalkerCB(unsigned long key, void *data1, void *data2)
-{
-    CRMuralInfo * pMural = (CRMuralInfo *) data1;
-    PCRVBOX_CTXWND_WNDWALKER_CB pData = (PCRVBOX_CTXWND_WNDWALKER_CB)data2;
-
-    Assert(pData->pMural != pMural);
-    Assert(pData->pContextInfo);
-
-    if (pData->pMural)
-        return;
-
-    if (!pMural->CreateInfo.externalID)
-    {
-        CRASSERT(!key);
-        return;
-    }
-
-    if (!CR_STATE_SHAREDOBJ_USAGE_IS_SET(pMural, pData->pContextInfo->pContext))
-        return;
-
-    if (crHashtableSearch(pData->usedMuralTable, pMural->CreateInfo.externalID))
-        return;
-
-    CRASSERT(pMural->CreateInfo.realVisualBits == pData->pContextInfo->CreateInfo.realVisualBits);
-    pData->pMural = pMural;
-}
-
-static void crVBoxServerBuildContextUsedWindowMapCB(unsigned long key, void *data1, void *data2)
-{
-    CRContextInfo *pContextInfo = (CRContextInfo *)data1;
-    PCRVBOX_CTXWND_CTXWALKER_CB pData = (PCRVBOX_CTXWND_CTXWALKER_CB)data2;
-
-    if (!pContextInfo->currentMural)
-        return;
-
-    crHashtableAdd(pData->pGlobal->contextMuralTable, pContextInfo->CreateInfo.externalID, pContextInfo->currentMural);
-    crHashtableAdd(pData->usedMuralTable, pContextInfo->currentMural->CreateInfo.externalID, pContextInfo->currentMural);
-}
-
-CRMuralInfo * crServerGetDummyMural(GLint visualBits)
-{
-    CRMuralInfo * pMural = (CRMuralInfo *)crHashtableSearch(cr_server.dummyMuralTable, visualBits);
-    if (!pMural)
-    {
-        GLint id;
-        pMural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo));
-        if (!pMural)
-        {
-            crWarning("crCalloc failed!");
-            return NULL;
-        }
-        id = crServerMuralInit(pMural, GL_FALSE, visualBits, 0);
-        if (id < 0)
-        {
-            crWarning("crServerMuralInit failed!");
-            crFree(pMural);
-            return NULL;
-        }
-
-        crHashtableAdd(cr_server.dummyMuralTable, visualBits, pMural);
-    }
-
-    return pMural;
-}
-
-static void crVBoxServerBuildContextUnusedWindowMapCB(unsigned long key, void *data1, void *data2)
-{
-    CRContextInfo *pContextInfo = (CRContextInfo *)data1;
-    PCRVBOX_CTXWND_CTXWALKER_CB pData = (PCRVBOX_CTXWND_CTXWALKER_CB)data2;
-    CRMuralInfo * pMural = NULL;
-
-    if (pContextInfo->currentMural)
-        return;
-
-    Assert(crHashtableNumElements(pData->pGlobal->contextMuralTable) <= crHashtableNumElements(cr_server.muralTable) - 1);
-    if (crHashtableNumElements(pData->pGlobal->contextMuralTable) < crHashtableNumElements(cr_server.muralTable) - 1)
-    {
-        CRVBOX_CTXWND_WNDWALKER_CB MuralData;
-        MuralData.pGlobal = pData->pGlobal;
-        MuralData.usedMuralTable = pData->usedMuralTable;
-        MuralData.pContextInfo = pContextInfo;
-        MuralData.pMural = NULL;
-
-        crHashtableWalk(cr_server.muralTable, crVBoxServerBuildContextWindowMapWindowWalkerCB, &MuralData);
-
-        pMural = MuralData.pMural;
-
-    }
-
-    if (!pMural)
-    {
-        pMural = crServerGetDummyMural(pContextInfo->CreateInfo.realVisualBits);
-        if (!pMural)
-        {
-            crWarning("crServerGetDummyMural failed");
-            return;
-        }
-    }
-    else
-    {
-        crHashtableAdd(pData->usedMuralTable, pMural->CreateInfo.externalID, pMural);
-        ++pData->cAdditionalMurals;
-    }
-
-    crHashtableAdd(pData->pGlobal->contextMuralTable, pContextInfo->CreateInfo.externalID, pMural);
-}
-
-static void crVBoxServerBuildSaveStateGlobal(PCRVBOX_SAVE_STATE_GLOBAL pGlobal)
-{
-    CRVBOX_CTXWND_CTXWALKER_CB Data;
-    GLuint cMurals;
-    pGlobal->contextMuralTable = crAllocHashtable();
-    pGlobal->additionalMuralContextTable = crAllocHashtable();
-    /* 1. go through all contexts and match all having currentMural set */
-    Data.pGlobal = pGlobal;
-    Data.usedMuralTable = crAllocHashtable();
-    Data.cAdditionalMurals = 0;
-    crHashtableWalk(cr_server.contextTable, crVBoxServerBuildContextUsedWindowMapCB, &Data);
-
-    cMurals = crHashtableNumElements(pGlobal->contextMuralTable);
-    CRASSERT(cMurals <= crHashtableNumElements(cr_server.contextTable));
-    CRASSERT(cMurals <= crHashtableNumElements(cr_server.muralTable) - 1);
-    CRASSERT(cMurals == crHashtableNumElements(Data.usedMuralTable));
-    if (cMurals < crHashtableNumElements(cr_server.contextTable))
-    {
-        Data.cAdditionalMurals = 0;
-        crHashtableWalk(cr_server.contextTable, crVBoxServerBuildContextUnusedWindowMapCB, &Data);
-    }
-
-    CRASSERT(crHashtableNumElements(pGlobal->contextMuralTable) == crHashtableNumElements(cr_server.contextTable));
-    CRASSERT(cMurals + Data.cAdditionalMurals <= crHashtableNumElements(cr_server.muralTable) - 1);
-    if (cMurals + Data.cAdditionalMurals < crHashtableNumElements(cr_server.muralTable) - 1)
-    {
-        crHashtableWalk(cr_server.muralTable, crVBoxServerBuildAdditionalWindowContextMapCB, &Data);
-        CRASSERT(cMurals + Data.cAdditionalMurals + crHashtableNumElements(pGlobal->additionalMuralContextTable) == crHashtableNumElements(cr_server.muralTable) - 1);
-    }
-
-    crFreeHashtable(Data.usedMuralTable, NULL);
-}
-
-static void crVBoxServerFBImageDataTerm(CRFBData *pData)
-{
-    GLuint i;
-    for (i = 0; i < pData->cElements; ++i)
-    {
-        CRFBDataElement * pEl = &pData->aElements[i];
-        if (pEl->pvData)
-        {
-            crFree(pEl->pvData);
-            /* sanity */
-            pEl->pvData = NULL;
-        }
-    }
-    pData->cElements = 0;
-}
-
-static int crVBoxAddFBDataElement(CRFBData *pData, GLint idFBO, GLenum enmBuffer, GLint width, GLint height, GLenum enmFormat, GLenum enmType)
-{
-    CRFBDataElement *pEl;
-
-    AssertCompile(sizeof (GLfloat) == 4);
-    AssertCompile(sizeof (GLuint) == 4);
-
-    pEl = &pData->aElements[pData->cElements];
-    pEl->idFBO = idFBO;
-    pEl->enmBuffer = enmBuffer;
-    pEl->posX = 0;
-    pEl->posY = 0;
-    pEl->width = width;
-    pEl->height = height;
-    pEl->enmFormat = enmFormat;
-    pEl->enmType = enmType;
-    pEl->cbData = width * height * 4;
-
-    pEl->pvData = crCalloc(pEl->cbData);
-    if (!pEl->pvData)
-    {
-        crVBoxServerFBImageDataTerm(pData);
-        crWarning(": crCalloc failed");
-        return VERR_NO_MEMORY;
-    }
-
-    ++pData->cElements;
-
-    return VINF_SUCCESS;
-}
-
-/* Add framebuffer image elements arrording to SSM version. Please refer to cr_version.h
- * in order to distinguish between versions. */
-static int crVBoxServerFBImageDataInitEx(CRFBData *pData, CRContextInfo *pCtxInfo, CRMuralInfo *pMural, GLboolean fWrite, uint32_t version, GLuint overrideWidth, GLuint overrideHeight)
-{
-    CRContext *pContext;
-    GLuint i;
-    GLfloat *pF;
-    GLuint width;
-    GLuint height;
-    int rc;
-
-    crMemset(pData, 0, sizeof (*pData));
-
-    pContext = pCtxInfo->pContext;
-
-    /* the version should be always actual when we do reads,
-     * i.e. it could differ on writes when snapshot is getting loaded */
-    CRASSERT(fWrite || version == SHCROGL_SSM_VERSION);
-
-    width = overrideWidth ? overrideWidth : pMural->width;
-    height = overrideHeight ? overrideHeight : pMural->height;
-
-    if (!width || !height)
-        return VINF_SUCCESS;
-
-    if (pMural)
-    {
-        if (fWrite)
-        {
-            if (!pContext->framebufferobject.drawFB)
-                pData->idOverrrideFBO = CR_SERVER_FBO_FOR_IDX(pMural, pMural->iCurDrawBuffer);
-        }
-        else
-        {
-            if (!pContext->framebufferobject.readFB)
-                pData->idOverrrideFBO = CR_SERVER_FBO_FOR_IDX(pMural, pMural->iCurReadBuffer);
-        }
-    }
-
-    pData->u32Version = version;
-
-    pData->cElements = 0;
-
-    rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0,
-        pData->aElements[1].idFBO ? GL_COLOR_ATTACHMENT0 : GL_FRONT, width, height, GL_RGBA, GL_UNSIGNED_BYTE);
-    AssertReturn(rc == VINF_SUCCESS, rc);
-
-    /* There is a lot of code that assumes we have double buffering, just assert here to print a warning in the log
-     * so that we know that something irregular is going on. */
-    CRASSERT(pCtxInfo->CreateInfo.requestedVisualBits & CR_DOUBLE_BIT);
-
-    if ((   pCtxInfo->CreateInfo.requestedVisualBits & CR_DOUBLE_BIT)
-         || version < SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL) /* <- Older version had a typo which lead to back always being used,
-                                                                      *    no matter what the visual bits are. */
-    {
-        rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_BB_IDX(pMural)] : 0,
-            pData->aElements[1].idFBO ? GL_COLOR_ATTACHMENT0 : GL_BACK, width, height, GL_RGBA, GL_UNSIGNED_BYTE);
-        AssertReturn(rc == VINF_SUCCESS, rc);
-    }
-
-    if (version < SHCROGL_SSM_VERSION_WITH_SAVED_DEPTH_STENCIL_BUFFER)
-        return VINF_SUCCESS;
-
-    if (version < SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL)
-    {
-        rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0,
-            pMural ? pMural->idDepthStencilRB : 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT);
-        AssertReturn(rc == VINF_SUCCESS, rc);
-
-        /* Init to default depth value, just in case. "pData->cElements - 1" because we incremented counter in crVBoxAddFBDataElement(). */
-        pF = (GLfloat*)pData->aElements[pData->cElements - 1].pvData;
-        for (i = 0; i < width * height; ++i)
-            pF[i] = 1.;
-
-        rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0,
-            pMural ? pMural->idDepthStencilRB : 0, width, height, GL_STENCIL_INDEX, GL_UNSIGNED_INT);
-        AssertReturn(rc == VINF_SUCCESS, rc);
-
-        return VINF_SUCCESS;
-    }
-
-    if (version < SHCROGL_SSM_VERSION_WITH_SEPARATE_DEPTH_STENCIL_BUFFERS)
-    {
-        /* Use GL_DEPTH_STENCIL only in case if both CR_STENCIL_BIT and CR_DEPTH_BIT specified. */
-        if (   (pCtxInfo->CreateInfo.requestedVisualBits & CR_STENCIL_BIT)
-            && (pCtxInfo->CreateInfo.requestedVisualBits & CR_DEPTH_BIT))
-        {
-            rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0, 0,
-                width, height, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
-            AssertReturn(rc == VINF_SUCCESS, rc);
-        }
-
-        return VINF_SUCCESS;
-    }
-
-    /* Current SSM verion (SHCROGL_SSM_VERSION_WITH_SEPARATE_DEPTH_STENCIL_BUFFERS). */
-
-    if (pCtxInfo->CreateInfo.requestedVisualBits & CR_DEPTH_BIT)
-    {
-        rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0,
-            pMural ? pMural->idDepthStencilRB : 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT);
-        AssertReturn(rc == VINF_SUCCESS, rc);
-
-        /* Init to default depth value, just in case. "pData->cElements - 1" because we incremented counter in crVBoxAddFBDataElement(). */
-        pF = (GLfloat*)pData->aElements[pData->cElements - 1].pvData;
-        for (i = 0; i < width * height; ++i)
-            pF[i] = 1.;
-    }
-
-    if (pCtxInfo->CreateInfo.requestedVisualBits & CR_STENCIL_BIT)
-    {
-        rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0,
-            pMural ? pMural->idDepthStencilRB : 0, width, height, GL_STENCIL_INDEX, GL_UNSIGNED_INT);
-        AssertReturn(rc == VINF_SUCCESS, rc);
-    }
-
-    return VINF_SUCCESS;
-}
-
-static int crVBoxServerSaveFBImage(PSSMHANDLE pSSM)
-{
-    CRContextInfo *pCtxInfo;
-    CRContext *pContext;
-    CRMuralInfo *pMural;
-    int32_t rc;
-    GLuint i;
-    struct
-    {
-        CRFBData data;
-        CRFBDataElement buffer[3]; /* CRFBData::aElements[1] + buffer[3] gives 4: back, front, depth and stencil  */
-    } Data;
-
-    Assert(sizeof (Data) >= RT_UOFFSETOF(CRFBData, aElements[4]));
-
-    pCtxInfo = cr_server.currentCtxInfo;
-    pContext = pCtxInfo->pContext;
-    pMural = pCtxInfo->currentMural;
-
-    rc = crVBoxServerFBImageDataInitEx(&Data.data, pCtxInfo, pMural, GL_FALSE, SHCROGL_SSM_VERSION, 0, 0);
-    if (!RT_SUCCESS(rc))
-    {
-        crWarning("crVBoxServerFBImageDataInit failed rc %d", rc);
-        return rc;
-    }
-
-    rc = crStateAcquireFBImage(pContext, &Data.data);
-    AssertRCReturn(rc, rc);
-
-    for (i = 0; i < Data.data.cElements; ++i)
-    {
-        CRFBDataElement * pEl = &Data.data.aElements[i];
-        rc = SSMR3PutMem(pSSM, pEl->pvData, pEl->cbData);
-        AssertRCReturn(rc, rc);
-    }
-
-    crVBoxServerFBImageDataTerm(&Data.data);
-
-    return VINF_SUCCESS;
-}
-
-#define CRSERVER_ASSERTRC_RETURN_VOID(_rc) do { \
-        if(!RT_SUCCESS((_rc))) { \
-            AssertFailed(); \
-            return; \
-        } \
-    } while (0)
-
-static void crVBoxServerSaveAdditionalMuralsCB(unsigned long key, void *data1, void *data2)
-{
-    CRContextInfo *pContextInfo = (CRContextInfo *) data1;
-    PCRVBOX_SAVE_STATE_GLOBAL pData = (PCRVBOX_SAVE_STATE_GLOBAL)data2;
-    CRMuralInfo *pMural = (CRMuralInfo*)crHashtableSearch(cr_server.muralTable, key);
-    PSSMHANDLE pSSM = pData->pSSM;
-    CRbitvalue initialCtxUsage[CR_MAX_BITARRAY];
-    CRMuralInfo *pInitialCurMural = pContextInfo->currentMural;
-
-    crMemcpy(initialCtxUsage, pMural->ctxUsage, sizeof (initialCtxUsage));
-
-    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
-
-    pData->rc = SSMR3PutMem(pSSM, &key, sizeof(key));
-    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
-
-    pData->rc = SSMR3PutMem(pSSM, &pContextInfo->CreateInfo.externalID, sizeof(pContextInfo->CreateInfo.externalID));
-    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
-
-    crServerPerformMakeCurrent(pMural, pContextInfo);
-
-    pData->rc = crVBoxServerSaveFBImage(pSSM);
-
-    /* restore the reference data, we synchronize it with the HW state in a later crServerPerformMakeCurrent call */
-    crMemcpy(pMural->ctxUsage, initialCtxUsage, sizeof (initialCtxUsage));
-    pContextInfo->currentMural = pInitialCurMural;
-
-    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
-}
-
-static void crVBoxServerSaveContextStateCB(unsigned long key, void *data1, void *data2)
-{
-    CRContextInfo *pContextInfo = (CRContextInfo *) data1;
-    CRContext *pContext = pContextInfo->pContext;
-    PCRVBOX_SAVE_STATE_GLOBAL pData = (PCRVBOX_SAVE_STATE_GLOBAL)data2;
-    PSSMHANDLE pSSM = pData->pSSM;
-    CRMuralInfo *pMural = (CRMuralInfo*)crHashtableSearch(pData->contextMuralTable, key);
-    CRMuralInfo *pContextCurrentMural = pContextInfo->currentMural;
-    const int32_t i32Dummy = 0;
-
-    AssertCompile(sizeof (i32Dummy) == sizeof (pMural->CreateInfo.externalID));
-    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
-
-    CRASSERT(pContext && pSSM);
-    CRASSERT(pMural);
-    CRASSERT(pMural->CreateInfo.externalID);
-
-    /* We could have skipped saving the key and use similar callback to load context states back,
-     * but there's no guarantee we'd traverse hashtable in same order after loading.
-     */
-    pData->rc = SSMR3PutMem(pSSM, &key, sizeof(key));
-    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
-
-#ifdef DEBUG_misha
-    {
-            unsigned long id;
-            if (!crHashtableGetDataKey(cr_server.contextTable, pContextInfo, &id))
-                crWarning("No client id for server ctx %d", pContextInfo->CreateInfo.externalID);
-            else
-                CRASSERT(id == key);
-    }
-#endif
-
-#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
-    if (pContextInfo->currentMural
-            || crHashtableSearch(cr_server.muralTable, pMural->CreateInfo.externalID) /* <- this is not a dummy mural */
-            )
-    {
-        CRASSERT(pMural->CreateInfo.externalID);
-        CRASSERT(!crHashtableSearch(cr_server.dummyMuralTable, pMural->CreateInfo.externalID));
-        pData->rc = SSMR3PutMem(pSSM, &pMural->CreateInfo.externalID, sizeof(pMural->CreateInfo.externalID));
-    }
-    else
-    {
-        /* this is a dummy mural */
-        CRASSERT(!pMural->width);
-        CRASSERT(!pMural->height);
-        CRASSERT(crHashtableSearch(cr_server.dummyMuralTable, pMural->CreateInfo.externalID));
-        pData->rc = SSMR3PutMem(pSSM, &i32Dummy, sizeof(pMural->CreateInfo.externalID));
-    }
-    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
-
-    CRASSERT(CR_STATE_SHAREDOBJ_USAGE_IS_SET(pMural, pContext));
-    CRASSERT(pContextInfo->currentMural == pMural || !pContextInfo->currentMural);
-    CRASSERT(cr_server.curClient);
-
-    crServerPerformMakeCurrent(pMural, pContextInfo);
-#endif
-
-    pData->rc = crStateSaveContext(pContext, pSSM);
-    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
-
-    pData->rc = crVBoxServerSaveFBImage(pSSM);
-    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
-
-    /* restore the initial current mural */
-    pContextInfo->currentMural = pContextCurrentMural;
-}
-
-static uint32_t g_hackVBoxServerSaveLoadCallsLeft = 0;
-
-static int32_t crVBoxServerSaveStatePerform(PSSMHANDLE pSSM)
-{
-    int32_t  rc, i;
-    uint32_t ui32;
-    GLboolean b;
-    unsigned long key;
-    GLenum err;
-#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
-    CRClient *curClient;
-    CRMuralInfo *curMural = NULL;
-    CRContextInfo *curCtxInfo = NULL;
-#endif
-    CRVBOX_SAVE_STATE_GLOBAL Data;
-
-    crMemset(&Data, 0, sizeof (Data));
-
-#if 0
-    crVBoxServerCheckConsistency();
-#endif
-
-    /* We shouldn't be called if there's no clients at all*/
-    CRASSERT(cr_server.numClients > 0);
-
-    /** @todo it's hack atm */
-    /* We want to be called only once to save server state but atm we're being called from svcSaveState
-     * for every connected client (e.g. guest opengl application)
-     */
-    if (!cr_server.bIsInSavingState) /* It's first call */
-    {
-        cr_server.bIsInSavingState = GL_TRUE;
-
-        /* Store number of clients */
-        rc = SSMR3PutU32(pSSM, (uint32_t) cr_server.numClients);
-        AssertRCReturn(rc, rc);
-
-        /* we get called only once for CrCmd case, so disable the hack */
-        g_hackVBoxServerSaveLoadCallsLeft = cr_server.fCrCmdEnabled ? 1 : cr_server.numClients;
-    }
-
-    g_hackVBoxServerSaveLoadCallsLeft--;
-
-    /* Do nothing until we're being called last time */
-    if (g_hackVBoxServerSaveLoadCallsLeft>0)
-    {
-        return VINF_SUCCESS;
-    }
-
-#ifdef DEBUG_misha
-#define CR_DBG_STR_STATE_SAVE_START "VBox.Cr.StateSaveStart"
-#define CR_DBG_STR_STATE_SAVE_STOP "VBox.Cr.StateSaveStop"
-
-    if (cr_server.head_spu->dispatch_table.StringMarkerGREMEDY)
-        cr_server.head_spu->dispatch_table.StringMarkerGREMEDY(sizeof (CR_DBG_STR_STATE_SAVE_START), CR_DBG_STR_STATE_SAVE_START);
-#endif
-
-    /* Save rendering contexts creation info */
-    ui32 = crHashtableNumElements(cr_server.contextTable);
-    rc = SSMR3PutU32(pSSM, (uint32_t) ui32);
-    AssertRCReturn(rc, rc);
-    crHashtableWalk(cr_server.contextTable, crVBoxServerSaveCreateInfoFromCtxInfoCB, pSSM);
-
-#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
-    curClient = cr_server.curClient;
-    /* Save current win and ctx IDs, as we'd rebind contexts when saving textures */
-    if (curClient)
-    {
-        curCtxInfo = cr_server.curClient->currentCtxInfo;
-        curMural = cr_server.curClient->currentMural;
-    }
-    else if (cr_server.numClients)
-    {
-        cr_server.curClient = cr_server.clients[0];
-    }
-#endif
-
-    /* first save windows info */
-    /* Save windows creation info */
-    ui32 = crHashtableNumElements(cr_server.muralTable);
-    /* There should be default mural always */
-    CRASSERT(ui32>=1);
-    rc = SSMR3PutU32(pSSM, (uint32_t) ui32-1);
-    AssertRCReturn(rc, rc);
-    crHashtableWalk(cr_server.muralTable, crVBoxServerSaveCreateInfoFromMuralInfoCB, pSSM);
-
-    /* Save cr_server.muralTable
-     * @todo we don't need it all, just geometry info actually
-     */
-    rc = SSMR3PutU32(pSSM, (uint32_t) ui32-1);
-    AssertRCReturn(rc, rc);
-    crHashtableWalk(cr_server.muralTable, crVBoxServerSaveMuralCB, pSSM);
-
-    /* we need to save front & backbuffer data for each mural first create a context -> mural association */
-    crVBoxServerBuildSaveStateGlobal(&Data);
-
-    rc = crStateSaveGlobals(pSSM);
-    AssertRCReturn(rc, rc);
-
-    Data.pSSM = pSSM;
-    /* Save contexts state tracker data */
-    /** @todo For now just some blind data dumps,
-     * but I've a feeling those should be saved/restored in a very strict sequence to
-     * allow diff_api to work correctly.
-     * Should be tested more with multiply guest opengl apps working when saving VM snapshot.
-     */
-    crHashtableWalk(cr_server.contextTable, crVBoxServerSaveContextStateCB, &Data);
-    AssertRCReturn(Data.rc, Data.rc);
-
-    ui32 = crHashtableNumElements(Data.additionalMuralContextTable);
-    rc = SSMR3PutU32(pSSM, (uint32_t) ui32);
-    AssertRCReturn(rc, rc);
-
-    crHashtableWalk(Data.additionalMuralContextTable, crVBoxServerSaveAdditionalMuralsCB, &Data);
-    AssertRCReturn(Data.rc, Data.rc);
-
-#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
-    cr_server.curClient = curClient;
-    /* Restore original win and ctx IDs*/
-    if (curClient && curMural && curCtxInfo)
-    {
-        crServerPerformMakeCurrent(curMural, curCtxInfo);
-    }
-    else
-    {
-        cr_server.bForceMakeCurrentOnClientSwitch = GL_TRUE;
-    }
-#endif
-
-    /* Save clients info */
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        if (cr_server.clients[i] && cr_server.clients[i]->conn)
-        {
-            CRClient *pClient = cr_server.clients[i];
-
-            rc = SSMR3PutU32(pSSM, pClient->conn->u32ClientID);
-            AssertRCReturn(rc, rc);
-
-            rc = SSMR3PutU32(pSSM, pClient->conn->vMajor);
-            AssertRCReturn(rc, rc);
-
-            rc = SSMR3PutU32(pSSM, pClient->conn->vMinor);
-            AssertRCReturn(rc, rc);
-
-            rc = SSMR3PutMem(pSSM, pClient, sizeof(*pClient));
-            AssertRCReturn(rc, rc);
-
-            if (pClient->currentCtxInfo && pClient->currentCtxInfo->pContext && pClient->currentContextNumber > 0)
-            {
-                b = crHashtableGetDataKey(cr_server.contextTable, pClient->currentCtxInfo, &key);
-                CRASSERT(b);
-                rc = SSMR3PutMem(pSSM, &key, sizeof(key));
-                AssertRCReturn(rc, rc);
-            }
-
-            if (pClient->currentMural && pClient->currentWindow > 0)
-            {
-                b = crHashtableGetDataKey(cr_server.muralTable, pClient->currentMural, &key);
-                CRASSERT(b);
-                rc = SSMR3PutMem(pSSM, &key, sizeof(key));
-                AssertRCReturn(rc, rc);
-            }
-        }
-    }
-
-    rc = crServerPendSaveState(pSSM);
-    AssertRCReturn(rc, rc);
-
-    rc = CrPMgrSaveState(pSSM);
-    AssertRCReturn(rc, rc);
-
-#ifdef VBOX_WITH_CR_DISPLAY_LISTS
-    if (cr_server.head_spu->dispatch_table.spu_save_state)
-    {
-        rc = cr_server.head_spu->dispatch_table.spu_save_state((void *)pSSM);
-        AssertRCReturn(rc, rc);
-    }
-    else
-        crDebug("Do not save %s SPU state: no interface exported.", cr_server.head_spu->name);
-#endif
-
-    /* all context gl error states should have now be synced with chromium erro states,
-     * reset the error if any */
-    while ((err = cr_server.head_spu->dispatch_table.GetError()) != GL_NO_ERROR)
-        crWarning("crServer: glGetError %d after saving snapshot", err);
-
-    cr_server.bIsInSavingState = GL_FALSE;
-
-#ifdef DEBUG_misha
-    if (cr_server.head_spu->dispatch_table.StringMarkerGREMEDY)
-        cr_server.head_spu->dispatch_table.StringMarkerGREMEDY(sizeof (CR_DBG_STR_STATE_SAVE_STOP), CR_DBG_STR_STATE_SAVE_STOP);
-#endif
-
-    return VINF_SUCCESS;
-}
-
-DECLEXPORT(int32_t) crVBoxServerSaveState(PSSMHANDLE pSSM)
-{
-    if (cr_server.fCrCmdEnabled)
-    {
-        WARN(("we should not be called with cmd enabled!"));
-        return VERR_INTERNAL_ERROR;
-    }
-
-    return crVBoxServerSaveStatePerform(pSSM);
-}
-
-static DECLCALLBACK(CRContext*) crVBoxServerGetContextCB(void* pvData)
-{
-    CRContextInfo* pContextInfo = (CRContextInfo*)pvData;
-    CRASSERT(pContextInfo);
-    CRASSERT(pContextInfo->pContext);
-    return pContextInfo->pContext;
-}
-
-typedef struct CR_SERVER_LOADSTATE_READER
-{
-    PSSMHANDLE pSSM;
-    uint32_t cbBuffer;
-    uint32_t cbData;
-    uint32_t offData;
-    uint8_t *pu8Buffer;
-} CR_SERVER_LOADSTATE_READER;
-
-static void crServerLsrInit(CR_SERVER_LOADSTATE_READER *pReader, PSSMHANDLE pSSM)
-{
-    memset(pReader, 0, sizeof (*pReader));
-    pReader->pSSM = pSSM;
-}
-
-static void crServerLsrTerm(CR_SERVER_LOADSTATE_READER *pReader)
-{
-    if (pReader->pu8Buffer)
-        RTMemFree(pReader->pu8Buffer);
-
-    /* sanity */
-    memset(pReader, 0, sizeof (*pReader));
-}
-
-static int crServerLsrDataGetMem(CR_SERVER_LOADSTATE_READER *pReader, void *pvBuffer, uint32_t cbBuffer)
-{
-    int rc = VINF_SUCCESS;
-    uint32_t cbRemaining = cbBuffer;
-    if (pReader->cbData)
-    {
-        uint8_t cbData = RT_MIN(pReader->cbData, cbBuffer);
-        memcpy(pvBuffer, pReader->pu8Buffer + pReader->offData, cbData);
-        pReader->cbData -= cbData;
-        pReader->offData += cbData;
-
-        cbRemaining -= cbData;
-        pvBuffer = ((uint8_t*)pvBuffer) + cbData;
-    }
-
-    if (cbRemaining)
-    {
-        rc = SSMR3GetMem(pReader->pSSM, pvBuffer, cbRemaining);
-        AssertRC(rc);
-    }
-
-    return rc;
-}
-
-static int crServerLsrDataGetU32(CR_SERVER_LOADSTATE_READER *pReader, uint32_t *pu32)
-{
-    return crServerLsrDataGetMem(pReader, pu32, sizeof (*pu32));
-}
-
-static int crServerLsrDataPutMem(CR_SERVER_LOADSTATE_READER *pReader, void *pvBuffer, uint32_t cbBuffer)
-{
-    if (!pReader->cbData && pReader->cbBuffer >= cbBuffer)
-    {
-        pReader->offData = 0;
-        pReader->cbData = cbBuffer;
-        memcpy(pReader->pu8Buffer, pvBuffer, cbBuffer);
-    }
-    else if (pReader->offData >= cbBuffer)
-    {
-        pReader->offData -= cbBuffer;
-        pReader->cbData += cbBuffer;
-        memcpy(pReader->pu8Buffer + pReader->offData, pvBuffer, cbBuffer);
-    }
-    else
-    {
-        uint8_t *pu8Buffer = pReader->pu8Buffer;
-
-        pReader->pu8Buffer = (uint8_t*)RTMemAlloc(cbBuffer + pReader->cbData);
-        if (!pReader->pu8Buffer)
-        {
-            crWarning("failed to allocate mem %d", cbBuffer + pReader->cbData);
-            return VERR_NO_MEMORY;
-        }
-
-        memcpy(pReader->pu8Buffer, pvBuffer, cbBuffer);
-        if (pu8Buffer)
-        {
-            memcpy(pReader->pu8Buffer + cbBuffer, pu8Buffer + pReader->offData, pReader->cbData);
-            RTMemFree(pu8Buffer);
-        }
-        else
-        {
-            Assert(!pReader->cbData);
-        }
-        pReader->offData = 0;
-        pReader->cbData += cbBuffer;
-    }
-
-    return VINF_SUCCESS;
-}
-
-/* data to be skipped */
-
-typedef struct CR_SERVER_BUGGY_MURAL_DATA_2
-{
-    void*ListHead_pNext;
-    void*ListHead_pPrev;
-    uint32_t cEntries;
-} CR_SERVER_BUGGY_MURAL_DATA_2;
-typedef struct CR_SERVER_BUGGY_MURAL_DATA_1
-{
-    /* VBOXVR_COMPOSITOR_ENTRY Ce; */
-    void*Ce_Node_pNext;
-    void*Ce_Node_pPrev;
-    CR_SERVER_BUGGY_MURAL_DATA_2 Vr;
-    /* VBOXVR_TEXTURE Tex; */
-    uint32_t Tex_width;
-    uint32_t Tex_height;
-    uint32_t Tex_target;
-    uint32_t Tex_hwid;
-    /* RTPOINT Pos; */
-    uint32_t Pos_x;
-    uint32_t Pos_y;
-    uint32_t fChanged;
-    uint32_t cRects;
-    void* paSrcRects;
-    void* paDstRects;
-} CR_SERVER_BUGGY_MURAL_DATA_1;
-
-typedef struct CR_SERVER_BUGGY_MURAL_DATA_4
-{
-    uint32_t                   u32Magic;
-    int32_t                    cLockers;
-    RTNATIVETHREAD             NativeThreadOwner;
-    int32_t                    cNestings;
-    uint32_t                            fFlags;
-    void*                          EventSem;
-    R3R0PTRTYPE(PRTLOCKVALRECEXCL)      pValidatorRec;
-    RTHCPTR                             Alignment;
-} CR_SERVER_BUGGY_MURAL_DATA_4;
-
-typedef struct CR_SERVER_BUGGY_MURAL_DATA_3
-{
-    void*Compositor_List_pNext;
-    void*Compositor_List_pPrev;
-    void*Compositor_pfnEntryRemoved;
-    float StretchX;
-    float StretchY;
-    uint32_t cRects;
-    uint32_t cRectsBuffer;
-    void*paSrcRects;
-    void*paDstRects;
-    CR_SERVER_BUGGY_MURAL_DATA_4 CritSect;
-} CR_SERVER_BUGGY_MURAL_DATA_3;
-
-typedef struct CR_SERVER_BUGGY_MURAL_DATA
-{
-    uint8_t fRootVrOn;
-    CR_SERVER_BUGGY_MURAL_DATA_1 RootVrCEntry;
-    CR_SERVER_BUGGY_MURAL_DATA_3 RootVrCompositor;
-} CR_SERVER_BUGGY_MURAL_DATA;
-
-AssertCompile(sizeof (CR_SERVER_BUGGY_MURAL_DATA) < sizeof (CRClient));
-
-static int32_t crVBoxServerLoadMurals(CR_SERVER_LOADSTATE_READER *pReader, uint32_t version)
-{
-    unsigned long key;
-    uint32_t ui, uiNumElems;
-    bool fBuggyMuralData = false;
-    /* Load windows */
-    int32_t rc = crServerLsrDataGetU32(pReader, &uiNumElems);
-    AssertLogRelRCReturn(rc, rc);
-    for (ui=0; ui<uiNumElems; ++ui)
-    {
-        CRCreateInfo_t createInfo;
-        char psz[200];
-        GLint winID;
-        unsigned long key;
-
-        rc = crServerLsrDataGetMem(pReader, &key, sizeof(key));
-        AssertLogRelRCReturn(rc, rc);
-        rc = crServerLsrDataGetMem(pReader, &createInfo, sizeof(createInfo));
-        AssertLogRelRCReturn(rc, rc);
-
-        CRASSERT(!pReader->cbData);
-
-        if (createInfo.pszDpyName)
-        {
-            rc = SSMR3GetStrZEx(pReader->pSSM, psz, 200, NULL);
-            AssertLogRelRCReturn(rc, rc);
-            createInfo.pszDpyName = psz;
-        }
-
-        winID = crServerDispatchWindowCreateEx(createInfo.pszDpyName, createInfo.visualBits, key);
-        CRASSERT((int64_t)winID == (int64_t)key);
-    }
-
-    /* Load cr_server.muralTable */
-    rc = SSMR3GetU32(pReader->pSSM, &uiNumElems);
-    AssertLogRelRCReturn(rc, rc);
-    for (ui=0; ui<uiNumElems; ++ui)
-    {
-        CRMuralInfo muralInfo;
-        CRMuralInfo *pActualMural = NULL;
-
-        rc = crServerLsrDataGetMem(pReader, &key, sizeof(key));
-        AssertLogRelRCReturn(rc, rc);
-        rc = crServerLsrDataGetMem(pReader, &muralInfo, RT_UOFFSETOF(CRMuralInfo, CreateInfo));
-        AssertLogRelRCReturn(rc, rc);
-
-        if (version <= SHCROGL_SSM_VERSION_BEFORE_FRONT_DRAW_TRACKING)
-            muralInfo.bFbDraw = GL_TRUE;
-
-        if (!ui && version == SHCROGL_SSM_VERSION_WITH_BUGGY_MURAL_INFO)
-        {
-            /* Lookahead buffer used to determine whether the data erroneously stored root visible regions data */
-            union
-            {
-                void * apv[1];
-                CR_SERVER_BUGGY_MURAL_DATA Data;
-                /* need to chak spuWindow, so taking the offset of filed following it*/
-                uint8_t au8[RT_UOFFSETOF(CRMuralInfo, screenId)];
-                RTRECT aVisRects[sizeof (CR_SERVER_BUGGY_MURAL_DATA) / sizeof (RTRECT)];
-            } LaBuf;
-
-            do {
-                /* first value is bool (uint8_t) value followed by pointer-size-based alignment.
-                 * the mural memory is zero-initialized initially, so we can be sure the padding is zeroed */
-                rc = crServerLsrDataGetMem(pReader, &LaBuf, sizeof (LaBuf));
-                AssertLogRelRCReturn(rc, rc);
-                if (LaBuf.apv[0] != NULL && LaBuf.apv[0] != ((void *)(uintptr_t)1))
-                    break;
-
-                /* check that the pointers are either valid or NULL */
-                if(LaBuf.Data.RootVrCEntry.Ce_Node_pNext && !RT_VALID_PTR(LaBuf.Data.RootVrCEntry.Ce_Node_pNext))
-                    break;
-                if(LaBuf.Data.RootVrCEntry.Ce_Node_pPrev && !RT_VALID_PTR(LaBuf.Data.RootVrCEntry.Ce_Node_pPrev))
-                    break;
-                if(LaBuf.Data.RootVrCEntry.Vr.ListHead_pNext && !RT_VALID_PTR(LaBuf.Data.RootVrCEntry.Vr.ListHead_pNext))
-                    break;
-                if(LaBuf.Data.RootVrCEntry.Vr.ListHead_pPrev && !RT_VALID_PTR(LaBuf.Data.RootVrCEntry.Vr.ListHead_pPrev))
-                    break;
-
-                /* the entry can can be the only one within the (mural) compositor,
-                 * so its compositor entry node can either contain NULL pNext and pPrev,
-                 * or both of them pointing to compositor's list head */
-                if (LaBuf.Data.RootVrCEntry.Ce_Node_pNext != LaBuf.Data.RootVrCEntry.Ce_Node_pPrev)
-                    break;
-
-                /* can either both or none be NULL */
-                if (!LaBuf.Data.RootVrCEntry.Ce_Node_pNext != !LaBuf.Data.RootVrCEntry.Ce_Node_pPrev)
-                    break;
-
-                if (!LaBuf.Data.fRootVrOn)
-                {
-                    if (LaBuf.Data.RootVrCEntry.Ce_Node_pNext || LaBuf.Data.RootVrCEntry.Ce_Node_pPrev)
-                        break;
-
-                    /* either non-initialized (zeroed) or empty list */
-                    if (LaBuf.Data.RootVrCEntry.Vr.ListHead_pNext != LaBuf.Data.RootVrCEntry.Vr.ListHead_pPrev)
-                        break;
-
-                    if (LaBuf.Data.RootVrCEntry.Vr.cEntries)
-                        break;
-                }
-                else
-                {
-                    /* the entry should be initialized */
-                    if (!LaBuf.Data.RootVrCEntry.Vr.ListHead_pNext)
-                        break;
-                    if (!LaBuf.Data.RootVrCEntry.Vr.ListHead_pPrev)
-                        break;
-
-                    if (LaBuf.Data.RootVrCEntry.Vr.cEntries)
-                    {
-                        /* entry should be in compositor list*/
-                        if (LaBuf.Data.RootVrCEntry.Ce_Node_pPrev == NULL)
-                            break;
-                        CRASSERT(LaBuf.Data.RootVrCEntry.Ce_Node_pNext);
-                    }
-                    else
-                    {
-                        /* entry should NOT be in compositor list*/
-                        if (LaBuf.Data.RootVrCEntry.Ce_Node_pPrev != NULL)
-                            break;
-                        CRASSERT(!LaBuf.Data.RootVrCEntry.Ce_Node_pNext);
-                    }
-                }
-
-                /* fExpectPtr == true, the valid pointer values should not match possible mural width/height/position */
-                fBuggyMuralData = true;
-                break;
-
-            } while (0);
-
-            rc = crServerLsrDataPutMem(pReader, &LaBuf, sizeof (LaBuf));
-            AssertLogRelRCReturn(rc, rc);
-        }
-
-        if (fBuggyMuralData)
-        {
-            CR_SERVER_BUGGY_MURAL_DATA Tmp;
-            rc = crServerLsrDataGetMem(pReader, &Tmp, sizeof (Tmp));
-            AssertLogRelRCReturn(rc, rc);
-        }
-
-        if (muralInfo.pVisibleRects)
-        {
-            muralInfo.pVisibleRects = crAlloc(4*sizeof(GLint)*muralInfo.cVisibleRects);
-            if (!muralInfo.pVisibleRects)
-            {
-                return VERR_NO_MEMORY;
-            }
-
-            rc = crServerLsrDataGetMem(pReader, muralInfo.pVisibleRects, 4*sizeof(GLint)*muralInfo.cVisibleRects);
-            AssertLogRelRCReturn(rc, rc);
-        }
-
-        pActualMural = (CRMuralInfo *)crHashtableSearch(cr_server.muralTable, key);
-        CRASSERT(pActualMural);
-
-        if (version >= SHCROGL_SSM_VERSION_WITH_WINDOW_CTX_USAGE)
-        {
-            rc = crServerLsrDataGetMem(pReader, pActualMural->ctxUsage, sizeof (pActualMural->ctxUsage));
-            CRASSERT(rc == VINF_SUCCESS);
-        }
-
-        /* Restore windows geometry info */
-        crServerDispatchWindowSize(key, muralInfo.width, muralInfo.height);
-        crServerDispatchWindowPosition(key, muralInfo.gX, muralInfo.gY);
-        /* Same workaround as described in stub.c:stubUpdateWindowVisibileRegions for compiz on a freshly booted VM*/
-        if (muralInfo.bReceivedRects)
-        {
-            crServerDispatchWindowVisibleRegion(key, muralInfo.cVisibleRects, muralInfo.pVisibleRects);
-        }
-        crServerDispatchWindowShow(key, muralInfo.bVisible);
-
-        if (muralInfo.pVisibleRects)
-        {
-            crFree(muralInfo.pVisibleRects);
-        }
-    }
-
-    CRASSERT(RT_SUCCESS(rc));
-    return VINF_SUCCESS;
-}
-
-static int crVBoxServerLoadFBImage(PSSMHANDLE pSSM, uint32_t version,
-        CRContextInfo* pContextInfo, CRMuralInfo *pMural)
-{
-    CRContext *pContext = pContextInfo->pContext;
-    int32_t rc = VINF_SUCCESS;
-    GLuint i;
-    /* can apply the data right away */
-    struct
-    {
-        CRFBData data;
-        CRFBDataElement buffer[3]; /* CRFBData::aElements[1] + buffer[3] gives 4: back, front, depth and stencil  */
-    } Data;
-
-    Assert(sizeof (Data) >= RT_UOFFSETOF(CRFBData, aElements[4]));
-
-    if (version >= SHCROGL_SSM_VERSION_WITH_SAVED_DEPTH_STENCIL_BUFFER)
-    {
-        if (!pMural->width || !pMural->height)
-            return VINF_SUCCESS;
-
-        rc = crVBoxServerFBImageDataInitEx(&Data.data, pContextInfo, pMural, GL_TRUE, version, 0, 0);
-        if (!RT_SUCCESS(rc))
-        {
-            crWarning("crVBoxServerFBImageDataInit failed rc %d", rc);
-            return rc;
-        }
-    }
-    else
-    {
-        GLint storedWidth, storedHeight;
-
-        if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA)
-        {
-            CRASSERT(cr_server.currentCtxInfo == pContextInfo);
-            CRASSERT(cr_server.currentMural == pMural);
-            storedWidth = pMural->width;
-            storedHeight = pMural->height;
-        }
-        else
-        {
-            storedWidth = pContext->buffer.storedWidth;
-            storedHeight = pContext->buffer.storedHeight;
-        }
-
-        if (!storedWidth || !storedHeight)
-            return VINF_SUCCESS;
-
-        rc = crVBoxServerFBImageDataInitEx(&Data.data, pContextInfo, pMural, GL_TRUE, version, storedWidth, storedHeight);
-        if (!RT_SUCCESS(rc))
-        {
-            crWarning("crVBoxServerFBImageDataInit failed rc %d", rc);
-            return rc;
-        }
-    }
-
-    CRASSERT(Data.data.cElements);
-
-    for (i = 0; i < Data.data.cElements; ++i)
-    {
-        CRFBDataElement * pEl = &Data.data.aElements[i];
-        rc = SSMR3GetMem(pSSM, pEl->pvData, pEl->cbData);
-        AssertLogRelRCReturn(rc, rc);
-    }
-
-    if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA)
-    {
-        CRBufferState *pBuf = &pContext->buffer;
-        /* can apply the data right away */
-        CRASSERT(cr_server.currentCtxInfo == &cr_server.MainContextInfo);
-        CRASSERT(cr_server.currentMural);
-
-        cr_server.head_spu->dispatch_table.MakeCurrent( pMural->spuWindow,
-                                                                0,
-                                                                pContextInfo->SpuContext >= 0
-                                                                    ? pContextInfo->SpuContext
-                                                                      : cr_server.MainContextInfo.SpuContext);
-        crStateApplyFBImage(pContext, &Data.data);
-        CRASSERT(!pBuf->pFrontImg);
-        CRASSERT(!pBuf->pBackImg);
-        crVBoxServerFBImageDataTerm(&Data.data);
-
-        crServerPresentFBO(pMural);
-
-        CRASSERT(cr_server.currentMural);
-        cr_server.head_spu->dispatch_table.MakeCurrent( cr_server.currentMural->spuWindow,
-                                                                    0,
-                                                                    cr_server.currentCtxInfo->SpuContext >= 0
-                                                                        ? cr_server.currentCtxInfo->SpuContext
-                                                                          : cr_server.MainContextInfo.SpuContext);
-    }
-    else
-    {
-        CRBufferState *pBuf = &pContext->buffer;
-        CRASSERT(!pBuf->pFrontImg);
-        CRASSERT(!pBuf->pBackImg);
-        CRASSERT(Data.data.cElements); /* <- older versions always saved front and back, and we filtered out the null-sized buffers above */
-
-        if (Data.data.cElements)
-        {
-            CRFBData *pLazyData = crAlloc(RT_UOFFSETOF_DYN(CRFBData, aElements[Data.data.cElements]));
-            if (!RT_SUCCESS(rc))
-            {
-                crVBoxServerFBImageDataTerm(&Data.data);
-                crWarning("crAlloc failed");
-                return VERR_NO_MEMORY;
-            }
-
-            crMemcpy(pLazyData, &Data.data, RT_UOFFSETOF_DYN(CRFBData, aElements[Data.data.cElements]));
-            pBuf->pFrontImg = pLazyData;
-        }
-    }
-
-    CRASSERT(RT_SUCCESS(rc));
-    return VINF_SUCCESS;
-}
-
-static int32_t crVBoxServerLoadStatePerform(PSSMHANDLE pSSM, uint32_t version)
-{
-    int32_t  rc, i;
-    uint32_t ui, uiNumElems;
-    unsigned long key;
-    GLenum err;
-    CR_SERVER_LOADSTATE_READER Reader;
-
-    if (!cr_server.bIsInLoadingState)
-    {
-        /* AssertRCReturn(...) will leave us in loading state, but it doesn't matter as we'd be failing anyway */
-        cr_server.bIsInLoadingState = GL_TRUE;
-
-        /* Read number of clients */
-        rc = SSMR3GetU32(pSSM, &g_hackVBoxServerSaveLoadCallsLeft);
-        AssertLogRelRCReturn(rc, rc);
-
-        Assert(g_hackVBoxServerSaveLoadCallsLeft);
-        /* we get called only once for CrCmd */
-        if (cr_server.fCrCmdEnabled)
-            g_hackVBoxServerSaveLoadCallsLeft = 1;
-    }
-
-    g_hackVBoxServerSaveLoadCallsLeft--;
-
-    /* Do nothing until we're being called last time */
-    if (g_hackVBoxServerSaveLoadCallsLeft>0)
-    {
-        return VINF_SUCCESS;
-    }
-
-    if (version < SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS)
-    {
-        return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
-    }
-
-    crServerLsrInit(&Reader, pSSM);
-
-#ifdef DEBUG_misha
-#define CR_DBG_STR_STATE_LOAD_START "VBox.Cr.StateLoadStart"
-#define CR_DBG_STR_STATE_LOAD_STOP "VBox.Cr.StateLoadStop"
-
-    if (cr_server.head_spu->dispatch_table.StringMarkerGREMEDY)
-        cr_server.head_spu->dispatch_table.StringMarkerGREMEDY(sizeof (CR_DBG_STR_STATE_LOAD_START), CR_DBG_STR_STATE_LOAD_START);
-#endif
-
-    /* Load and recreate rendering contexts */
-    rc = SSMR3GetU32(pSSM, &uiNumElems);
-    AssertLogRelRCReturn(rc, rc);
-    for (ui = 0; ui < uiNumElems; ++ui)
-    {
-        CRCreateInfo_t createInfo;
-        char psz[200];
-        GLint ctxID;
-        CRContextInfo* pContextInfo;
-        CRContext* pContext;
-
-        rc = SSMR3GetMem(pSSM, &key, sizeof(key));
-        AssertLogRelRCReturn(rc, rc);
-        rc = SSMR3GetMem(pSSM, &createInfo, sizeof(createInfo));
-        AssertLogRelRCReturn(rc, rc);
-
-        if (createInfo.pszDpyName)
-        {
-            rc = SSMR3GetStrZEx(pSSM, psz, 200, NULL);
-            AssertLogRelRCReturn(rc, rc);
-            createInfo.pszDpyName = psz;
-        }
-
-        ctxID = crServerDispatchCreateContextEx(createInfo.pszDpyName, createInfo.visualBits, 0, key, createInfo.externalID /* <-saved state stores internal id here*/);
-        CRASSERT((int64_t)ctxID == (int64_t)key);
-
-        pContextInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, key);
-        CRASSERT(pContextInfo);
-        CRASSERT(pContextInfo->pContext);
-        pContext = pContextInfo->pContext;
-        pContext->shared->id=-1;
-    }
-
-    if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA)
-    {
-        CRASSERT(!Reader.pu8Buffer);
-        /* we have a mural data here */
-        rc = crVBoxServerLoadMurals(&Reader, version);
-        AssertLogRelRCReturn(rc, rc);
-        CRASSERT(!Reader.pu8Buffer);
-    }
-
-    if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA && uiNumElems)
-    {
-        /* set the current client to allow doing crServerPerformMakeCurrent later */
-        CRASSERT(cr_server.numClients);
-        cr_server.curClient = cr_server.clients[0];
-    }
-
-    rc = crStateLoadGlobals(pSSM, version);
-    AssertLogRelRCReturn(rc, rc);
-
-    if (uiNumElems)
-    {
-        /* ensure we have main context set up as current */
-        CRMuralInfo *pMural;
-        CRASSERT(cr_server.MainContextInfo.SpuContext > 0);
-        CRASSERT(!cr_server.currentCtxInfo);
-        CRASSERT(!cr_server.currentMural);
-        pMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
-        CRASSERT(pMural);
-        crServerPerformMakeCurrent(pMural, &cr_server.MainContextInfo);
-    }
-
-    /* Restore context state data */
-    for (ui=0; ui<uiNumElems; ++ui)
-    {
-        CRContextInfo* pContextInfo;
-        CRContext *pContext;
-        CRMuralInfo *pMural = NULL;
-        int32_t winId = 0;
-
-        rc = SSMR3GetMem(pSSM, &key, sizeof(key));
-        AssertLogRelRCReturn(rc, rc);
-
-        pContextInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, key);
-        CRASSERT(pContextInfo);
-        CRASSERT(pContextInfo->pContext);
-        pContext = pContextInfo->pContext;
-
-        if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA)
-        {
-            rc = SSMR3GetMem(pSSM, &winId, sizeof(winId));
-            AssertLogRelRCReturn(rc, rc);
-
-            if (winId)
-            {
-                pMural = (CRMuralInfo*)crHashtableSearch(cr_server.muralTable, winId);
-                CRASSERT(pMural);
-            }
-            else
-            {
-                /* null winId means a dummy mural, get it */
-                pMural = crServerGetDummyMural(pContextInfo->CreateInfo.realVisualBits);
-                CRASSERT(pMural);
-            }
-        }
-
-        rc = crStateLoadContext(pContext, cr_server.contextTable, crVBoxServerGetContextCB, pSSM, version);
-        AssertLogRelRCReturn(rc, rc);
-
-        /*Restore front/back buffer images*/
-        rc = crVBoxServerLoadFBImage(pSSM, version, pContextInfo, pMural);
-        AssertLogRelRCReturn(rc, rc);
-    }
-
-    if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA)
-    {
-        CRContextInfo *pContextInfo;
-        CRMuralInfo *pMural;
-        GLint ctxId;
-
-        rc = SSMR3GetU32(pSSM, &uiNumElems);
-        AssertLogRelRCReturn(rc, rc);
-        for (ui=0; ui<uiNumElems; ++ui)
-        {
-            CRbitvalue initialCtxUsage[CR_MAX_BITARRAY];
-            CRMuralInfo *pInitialCurMural;
-
-            rc = SSMR3GetMem(pSSM, &key, sizeof(key));
-            AssertLogRelRCReturn(rc, rc);
-
-            rc = SSMR3GetMem(pSSM, &ctxId, sizeof(ctxId));
-            AssertLogRelRCReturn(rc, rc);
-
-            pMural = (CRMuralInfo*)crHashtableSearch(cr_server.muralTable, key);
-            CRASSERT(pMural);
-            if (ctxId)
-            {
-                pContextInfo = (CRContextInfo *)crHashtableSearch(cr_server.contextTable, ctxId);
-                CRASSERT(pContextInfo);
-            }
-            else
-                pContextInfo =  &cr_server.MainContextInfo;
-
-            crMemcpy(initialCtxUsage, pMural->ctxUsage, sizeof (initialCtxUsage));
-            pInitialCurMural = pContextInfo->currentMural;
-
-            rc = crVBoxServerLoadFBImage(pSSM, version, pContextInfo, pMural);
-            AssertLogRelRCReturn(rc, rc);
-
-            /* restore the reference data, we synchronize it with the HW state in a later crServerPerformMakeCurrent call */
-            crMemcpy(pMural->ctxUsage, initialCtxUsage, sizeof (initialCtxUsage));
-            pContextInfo->currentMural = pInitialCurMural;
-        }
-
-        CRASSERT(!uiNumElems || cr_server.currentCtxInfo == &cr_server.MainContextInfo);
-
-        cr_server.curClient = NULL;
-        cr_server.bForceMakeCurrentOnClientSwitch = GL_TRUE;
-    }
-    else
-    {
-        CRServerFreeIDsPool_t dummyIdsPool;
-
-        CRASSERT(!Reader.pu8Buffer);
-
-        /* we have a mural data here */
-        rc = crVBoxServerLoadMurals(&Reader, version);
-        AssertLogRelRCReturn(rc, rc);
-
-        /* not used any more, just read it out and ignore */
-        rc = crServerLsrDataGetMem(&Reader, &dummyIdsPool, sizeof(dummyIdsPool));
-        CRASSERT(rc == VINF_SUCCESS);
-    }
-
-    /* Load clients info */
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        if (cr_server.clients[i] && cr_server.clients[i]->conn)
-        {
-            CRClient *pClient = cr_server.clients[i];
-            CRClient client;
-            unsigned long ctxID=-1, winID=-1;
-
-            rc = crServerLsrDataGetU32(&Reader, &ui);
-            AssertLogRelRCReturn(rc, rc);
-            /* If this assert fires, then we should search correct client in the list first*/
-            CRASSERT(ui == pClient->conn->u32ClientID);
-
-            if (version>=4)
-            {
-                rc = crServerLsrDataGetU32(&Reader, &pClient->conn->vMajor);
-                AssertLogRelRCReturn(rc, rc);
-
-                rc = crServerLsrDataGetU32(&Reader, &pClient->conn->vMinor);
-                AssertLogRelRCReturn(rc, rc);
-            }
-
-            rc = crServerLsrDataGetMem(&Reader, &client, sizeof(client));
-            CRASSERT(rc == VINF_SUCCESS);
-
-            client.conn = pClient->conn;
-            /* We can't reassign client number, as we'd get wrong results in TranslateTextureID
-             * and fail to bind old textures.
-             */
-            /*client.number = pClient->number;*/
-            *pClient = client;
-
-            pClient->currentContextNumber = -1;
-            pClient->currentCtxInfo = &cr_server.MainContextInfo;
-            pClient->currentMural = NULL;
-            pClient->currentWindow = -1;
-
-            cr_server.curClient = pClient;
-
-            if (client.currentCtxInfo && client.currentContextNumber > 0)
-            {
-                rc = crServerLsrDataGetMem(&Reader, &ctxID, sizeof(ctxID));
-                AssertLogRelRCReturn(rc, rc);
-                client.currentCtxInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, ctxID);
-                CRASSERT(client.currentCtxInfo);
-                CRASSERT(client.currentCtxInfo->pContext);
-                //pClient->currentCtx = client.currentCtx;
-                //pClient->currentContextNumber = ctxID;
-            }
-
-            if (client.currentMural && client.currentWindow > 0)
-            {
-                rc = crServerLsrDataGetMem(&Reader, &winID, sizeof(winID));
-                AssertLogRelRCReturn(rc, rc);
-                client.currentMural = (CRMuralInfo*) crHashtableSearch(cr_server.muralTable, winID);
-                CRASSERT(client.currentMural);
-                //pClient->currentMural = client.currentMural;
-                //pClient->currentWindow = winID;
-            }
-
-            CRASSERT(!Reader.cbData);
-
-            /* Restore client active context and window */
-            crServerDispatchMakeCurrent(winID, 0, ctxID);
-        }
-    }
-
-    cr_server.curClient = NULL;
-
-    rc = crServerPendLoadState(pSSM, version);
-    AssertLogRelRCReturn(rc, rc);
-
-    if (version >= SHCROGL_SSM_VERSION_WITH_SCREEN_INFO)
-    {
-        rc = CrPMgrLoadState(pSSM, version);
-        AssertLogRelRCReturn(rc, rc);
-    }
-
-#ifdef VBOX_WITH_CR_DISPLAY_LISTS
-    if (version >= SHCROGL_SSM_VERSION_WITH_DISPLAY_LISTS)
-    {
-        if (cr_server.head_spu->dispatch_table.spu_load_state)
-        {
-            rc = cr_server.head_spu->dispatch_table.spu_load_state((void *)pSSM);
-            AssertLogRelRCReturn(rc, rc);
-        }
-        else
-            crDebug("Do not load %s SPU state: no interface exported.", cr_server.head_spu->name);
-    }
-#endif
-
-    while ((err = cr_server.head_spu->dispatch_table.GetError()) != GL_NO_ERROR)
-        crWarning("crServer: glGetError %d after loading snapshot", err);
-
-    cr_server.bIsInLoadingState = GL_FALSE;
-
-#ifdef DEBUG_misha
-    if (cr_server.head_spu->dispatch_table.StringMarkerGREMEDY)
-        cr_server.head_spu->dispatch_table.StringMarkerGREMEDY(sizeof (CR_DBG_STR_STATE_LOAD_STOP), CR_DBG_STR_STATE_LOAD_STOP);
-#endif
-
-    CRASSERT(!Reader.cbData);
-    crServerLsrTerm(&Reader);
-
-    return VINF_SUCCESS;
-}
-
-DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version)
-{
-    if (cr_server.fCrCmdEnabled)
-    {
-        WARN(("CrCmd enabled"));
-        return VERR_INTERNAL_ERROR;
-    }
-
-    return crVBoxServerLoadStatePerform(pSSM, version);
-}
-
-#define SCREEN(i) (cr_server.screen[i])
-#define MAPPED(screen) ((screen).winID != 0)
-
-extern DECLEXPORT(void) crServerVBoxSetNotifyEventCB(PFNCRSERVERNOTIFYEVENT pfnCb)
-{
-    cr_server.pfnNotifyEventCB = pfnCb;
-}
-
-void crVBoxServerNotifyEvent(int32_t idScreen, uint32_t uEvent, void* pvData, uint32_t cbData)
-{
-    /* this is something unexpected, but just in case */
-    if (idScreen >= cr_server.screenCount)
-    {
-        crWarning("invalid screen id %d", idScreen);
-        return;
-    }
-
-    cr_server.pfnNotifyEventCB(idScreen, uEvent, pvData, cbData);
-}
-
-void crServerWindowReparent(CRMuralInfo *pMural)
-{
-    pMural->fHasParentWindow = !!cr_server.screen[pMural->screenId].winID;
-
-    renderspuReparentWindow(pMural->spuWindow);
-}
-
-DECLEXPORT(void) crServerSetUnscaledHiDPI(bool fEnable)
-{
-    renderspuSetUnscaledHiDPI(fEnable);
-}
-
-static void crVBoxServerReparentMuralCB(unsigned long key, void *data1, void *data2)
-{
-    CRMuralInfo *pMI = (CRMuralInfo*) data1;
-    int *sIndex = (int*) data2;
-
-    if (pMI->screenId == *sIndex)
-    {
-        crServerWindowReparent(pMI);
-    }
-}
-
-DECLEXPORT(int32_t) crVBoxServerSetScreenCount(int sCount)
-{
-    int i;
-
-    if (sCount > CR_MAX_GUEST_MONITORS)
-        return VERR_INVALID_PARAMETER;
-
-    /*Shouldn't happen yet, but to be safe in future*/
-    for (i = 0; i < cr_server.screenCount; /*++i - unreachable code*/)
-    {
-        if (MAPPED(SCREEN(i)))
-            WARN(("Screen count is changing, but screen[%i] is still mapped", i));
-        return VERR_NOT_IMPLEMENTED;
-    }
-
-    cr_server.screenCount = sCount;
-
-    for (i=0; i<sCount; ++i)
-    {
-        SCREEN(i).winID = 0;
-    }
-
-    return VINF_SUCCESS;
-}
-
-DECLEXPORT(int32_t) crVBoxServerUnmapScreen(int sIndex)
-{
-    crDebug("crVBoxServerUnmapScreen(%i)", sIndex);
-
-    if (sIndex<0 || sIndex>=cr_server.screenCount)
-        return VERR_INVALID_PARAMETER;
-
-    if (MAPPED(SCREEN(sIndex)))
-    {
-        SCREEN(sIndex).winID = 0;
-        renderspuSetWindowId(0);
-
-        crHashtableWalk(cr_server.muralTable, crVBoxServerReparentMuralCB, &sIndex);
-
-        crHashtableWalk(cr_server.dummyMuralTable, crVBoxServerReparentMuralCB, &sIndex);
-
-        CrPMgrScreenChanged((uint32_t)sIndex);
-    }
-
-    renderspuSetWindowId(SCREEN(0).winID);
-
-    return VINF_SUCCESS;
-}
-
-DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID)
-{
-    crDebug("crVBoxServerMapScreen(%i) [%i,%i:%u,%u %x]", sIndex, x, y, w, h, winID);
-
-    if (sIndex<0 || sIndex>=cr_server.screenCount)
-        return VERR_INVALID_PARAMETER;
-
-    if (MAPPED(SCREEN(sIndex)) && SCREEN(sIndex).winID!=winID)
-    {
-        crDebug("Mapped screen[%i] is being remapped.", sIndex);
-        crVBoxServerUnmapScreen(sIndex);
-    }
-
-    SCREEN(sIndex).winID = winID;
-    SCREEN(sIndex).x = x;
-    SCREEN(sIndex).y = y;
-    SCREEN(sIndex).w = w;
-    SCREEN(sIndex).h = h;
-
-    renderspuSetWindowId(SCREEN(sIndex).winID);
-    crHashtableWalk(cr_server.muralTable, crVBoxServerReparentMuralCB, &sIndex);
-
-    crHashtableWalk(cr_server.dummyMuralTable, crVBoxServerReparentMuralCB, &sIndex);
-    renderspuSetWindowId(SCREEN(0).winID);
-
-#ifndef WINDOWS
-    /*Restore FB content for clients, which have current window on a screen being remapped*/
-    {
-        GLint i;
-
-        for (i = 0; i < cr_server.numClients; i++)
-        {
-            cr_server.curClient = cr_server.clients[i];
-            if (cr_server.curClient->currentCtxInfo
-                && cr_server.curClient->currentCtxInfo->pContext
-                && (cr_server.curClient->currentCtxInfo->pContext->buffer.pFrontImg)
-                && cr_server.curClient->currentMural
-                && cr_server.curClient->currentMural->screenId == sIndex
-                && cr_server.curClient->currentCtxInfo->pContext->buffer.storedHeight == h
-                && cr_server.curClient->currentCtxInfo->pContext->buffer.storedWidth == w)
-            {
-                int clientWindow = cr_server.curClient->currentWindow;
-                int clientContext = cr_server.curClient->currentContextNumber;
-                CRFBData *pLazyData = (CRFBData *)cr_server.curClient->currentCtxInfo->pContext->buffer.pFrontImg;
-
-                if (clientWindow && clientWindow != cr_server.currentWindow)
-                {
-                    crServerDispatchMakeCurrent(clientWindow, 0, clientContext);
-                }
-
-                crStateApplyFBImage(cr_server.curClient->currentCtxInfo->pContext, pLazyData);
-                crStateFreeFBImageLegacy(cr_server.curClient->currentCtxInfo->pContext);
-            }
-        }
-        cr_server.curClient = NULL;
-    }
-#endif
-
-    CrPMgrScreenChanged((uint32_t)sIndex);
-
-    return VINF_SUCCESS;
-}
-
-DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, const RTRECT *pRects)
-{
-    int32_t rc = VINF_SUCCESS;
-    GLboolean fOldRootVrOn = cr_server.fRootVrOn;
-
-    /* non-zero rects pointer indicate rects are present and switched on
-     * i.e. cRects==0 and pRects!=NULL means root visible regioning is ON and there are no visible regions,
-     * while pRects==NULL means root visible regioning is OFF, i.e. everything is visible */
-    if (pRects)
-    {
-        crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint));
-        rc = VBoxVrListRectsSet(&cr_server.RootVr, cRects, pRects, NULL);
-        if (!RT_SUCCESS(rc))
-        {
-            crWarning("VBoxVrListRectsSet failed! rc %d", rc);
-            return rc;
-        }
-
-        cr_server.fRootVrOn = GL_TRUE;
-    }
-    else
-    {
-        if (!cr_server.fRootVrOn)
-            return VINF_SUCCESS;
-
-        VBoxVrListClear(&cr_server.RootVr);
-
-        cr_server.fRootVrOn = GL_FALSE;
-    }
-
-    if (!fOldRootVrOn != !cr_server.fRootVrOn)
-    {
-        rc = CrPMgrModeRootVr(cr_server.fRootVrOn);
-        if (!RT_SUCCESS(rc))
-        {
-            crWarning("CrPMgrModeRootVr failed rc %d", rc);
-            return rc;
-        }
-    }
-    else if (cr_server.fRootVrOn)
-    {
-        rc = CrPMgrRootVrUpdate();
-        if (!RT_SUCCESS(rc))
-        {
-            crWarning("CrPMgrRootVrUpdate failed rc %d", rc);
-            return rc;
-        }
-    }
-
-    return VINF_SUCCESS;
-}
-
-DECLEXPORT(int32_t) crVBoxServerSetOffscreenRendering(GLboolean value)
-{
-    return CrPMgrModeVrdp(value);
-}
-
-DECLEXPORT(int32_t) crVBoxServerOutputRedirectSet(const CROutputRedirect *pCallbacks)
-{
-    /* No need for a synchronization as this is single threaded. */
-    if (pCallbacks)
-    {
-        cr_server.outputRedirect = *pCallbacks;
-    }
-    else
-    {
-        memset (&cr_server.outputRedirect, 0, sizeof (cr_server.outputRedirect));
-    }
-
-    return VINF_SUCCESS;
-}
-
-DECLEXPORT(int32_t) crVBoxServerSetScreenViewport(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h)
-{
-    CRScreenViewportInfo *pViewport;
-    RTRECT NewRect;
-    int rc;
-
-    crDebug("crVBoxServerSetScreenViewport(%i)", sIndex);
-
-    if (sIndex<0 || sIndex>=cr_server.screenCount)
-    {
-        crWarning("crVBoxServerSetScreenViewport: invalid screen id %d", sIndex);
-        return VERR_INVALID_PARAMETER;
-    }
-
-    NewRect.xLeft = x;
-    NewRect.yTop = y;
-    NewRect.xRight = x + w;
-    NewRect.yBottom = y + h;
-
-    pViewport = &cr_server.screenVieport[sIndex];
-    /*always do viewport updates no matter whether the rectangle actually changes,
-     * this is needed to ensure window is adjusted properly on OSX */
-    pViewport->Rect = NewRect;
-    rc = CrPMgrViewportUpdate((uint32_t)sIndex);
-    if (!RT_SUCCESS(rc))
-    {
-        crWarning("CrPMgrViewportUpdate failed %d", rc);
-        return rc;
-    }
-
-    return VINF_SUCCESS;
-}
-
-static void crVBoxServerDeleteMuralCb(unsigned long key, void *data1, void *data2)
-{
-    CRHashTable *h = (CRHashTable*)data2;
-    CRMuralInfo *m = (CRMuralInfo *) data1;
-    if (m->spuWindow == CR_RENDER_DEFAULT_WINDOW_ID)
-        return;
-
-    crHashtableDelete(h, key, NULL);
-    crServerMuralTerm(m);
-    crFree(m);
-}
-
-static void crVBoxServerDefaultContextClear()
-{
-    HCR_FRAMEBUFFER hFb;
-    int rc = CrPMgrDisable();
-    if (RT_FAILURE(rc))
-    {
-        WARN(("CrPMgrDisable failed %d", rc));
-        return;
-    }
-
-    for (hFb = CrPMgrFbGetFirstEnabled(); hFb; hFb = CrPMgrFbGetNextEnabled(hFb))
-    {
-        int rc = CrFbUpdateBegin(hFb);
-        if (RT_SUCCESS(rc))
-        {
-            CrFbRegionsClear(hFb);
-            CrFbUpdateEnd(hFb);
-        }
-        else
-            WARN(("CrFbUpdateBegin failed %d", rc));
-    }
-
-    cr_server.head_spu->dispatch_table.MakeCurrent(0, 0, 0);
-    crStateCleanupCurrent();
-
-    /* note: we need to clean all contexts, since otherwise renderspu leanup won't work,
-     * i.e. renderspu would need to clean up its own internal windows, it won't be able to do that if
-     * some those windows is associated with any context.  */
-    if (cr_server.MainContextInfo.SpuContext)
-    {
-        cr_server.head_spu->dispatch_table.DestroyContext(cr_server.MainContextInfo.SpuContext);
-        crStateDestroyContext(cr_server.MainContextInfo.pContext);
-        if (cr_server.MainContextInfo.CreateInfo.pszDpyName)
-            crFree(cr_server.MainContextInfo.CreateInfo.pszDpyName);
-
-        memset(&cr_server.MainContextInfo, 0, sizeof (cr_server.MainContextInfo));
-    }
-
-    cr_server.firstCallCreateContext = GL_TRUE;
-    cr_server.firstCallMakeCurrent = GL_TRUE;
-    cr_server.bForceMakeCurrentOnClientSwitch = GL_FALSE;
-
-    CRASSERT(!cr_server.curClient);
-
-    cr_server.currentCtxInfo = NULL;
-    cr_server.currentWindow = 0;
-    cr_server.currentNativeWindow = 0;
-    cr_server.currentMural = NULL;
-
-    crStateDestroy();
-//    crStateCleanupCurrent();
-
-    if (CrBltIsInitialized(&cr_server.Blitter))
-    {
-        CrBltTerm(&cr_server.Blitter);
-        Assert(!CrBltIsInitialized(&cr_server.Blitter));
-    }
-
-    crHashtableWalk(cr_server.dummyMuralTable, crVBoxServerDeleteMuralCb, cr_server.dummyMuralTable);
-
-    cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_RENDERTHREAD_INFORM, 0);
-}
-
-static void crVBoxServerDefaultContextSet()
-{
-    cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_RENDERTHREAD_INFORM, 1);
-
-    CRASSERT(!cr_server.MainContextInfo.SpuContext);
-
-//    crStateSetCurrent(NULL);
-    crStateInit();
-    crStateDiffAPI( &(cr_server.head_spu->dispatch_table) );
-
-    CrPMgrEnable();
-}
-
-#ifdef VBOX_WITH_CRHGSMI
-
-/** @todo RT_UNTRUSTED_VOLATILE_GUEST   */
-static int32_t crVBoxServerCmdVbvaCrCmdProcess(VBOXCMDVBVA_CRCMD_CMD const RT_UNTRUSTED_VOLATILE_GUEST *pCmdTodo, uint32_t cbCmd)
-{
-    VBOXCMDVBVA_CRCMD_CMD const *pCmd = (VBOXCMDVBVA_CRCMD_CMD const *)pCmdTodo;
-    int32_t rc;
-    uint32_t cBuffers = pCmd->cBuffers;
-    uint32_t cParams;
-    uint32_t cbHdr;
-    CRVBOXHGSMIHDR *pHdr;
-    uint32_t u32Function;
-    uint32_t u32ClientID;
-    CRClient *pClient;
-
-    if (!g_pvVRamBase)
-    {
-        WARN(("g_pvVRamBase is not initialized"));
-        return VERR_INVALID_STATE;
-    }
-
-    if (!cBuffers)
-    {
-        WARN(("zero buffers passed in!"));
-        return VERR_INVALID_PARAMETER;
-    }
-
-    cParams = cBuffers-1;
-
-    if (cbCmd < RT_UOFFSETOF_DYN(VBOXCMDVBVA_CRCMD_CMD, aBuffers[cBuffers]))
-    {
-        WARN(("invalid buffer size"));
-        return VERR_INVALID_PARAMETER;
-    }
-
-    cbHdr = pCmd->aBuffers[0].cbBuffer;
-    pHdr = VBOXCRHGSMI_PTR_SAFE(pCmd->aBuffers[0].offBuffer, cbHdr, CRVBOXHGSMIHDR);
-    if (!pHdr)
-    {
-        WARN(("invalid header buffer!"));
-        return VERR_INVALID_PARAMETER;
-    }
-
-    if (cbHdr < sizeof (*pHdr))
-    {
-        WARN(("invalid header buffer size!"));
-        return VERR_INVALID_PARAMETER;
-    }
-
-    u32Function = pHdr->u32Function;
-    u32ClientID = pHdr->u32ClientID;
-
-    switch (u32Function)
-    {
-        case SHCRGL_GUEST_FN_WRITE:
-        {
-            Log(("svcCall: SHCRGL_GUEST_FN_WRITE\n"));
-
-            /** @todo Verify  */
-            if (cParams == 1)
-            {
-                CRVBOXHGSMIWRITE* pFnCmd = (CRVBOXHGSMIWRITE*)pHdr;
-                const VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1];
-                /* Fetch parameters. */
-                uint32_t cbBuffer = pBuf->cbBuffer;
-                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
-
-                if (cbHdr < sizeof (*pFnCmd))
-                {
-                    WARN(("invalid write cmd buffer size!"));
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                CRASSERT(cbBuffer);
-                if (!pBuffer)
-                {
-                    WARN(("invalid buffer data received from guest!"));
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                rc = crVBoxServerClientGet(u32ClientID, &pClient);
-                if (RT_FAILURE(rc))
-                {
-                    WARN(("crVBoxServerClientGet failed %d", rc));
-                    break;
-                }
-
-                /* This should never fire unless we start to multithread */
-                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-                pClient->conn->pBuffer = pBuffer;
-                pClient->conn->cbBuffer = cbBuffer;
-                CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, false);
-                crVBoxServerInternalClientWriteRead(pClient);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-                return VINF_SUCCESS;
-            }
-
-            WARN(("invalid number of args"));
-            rc = VERR_INVALID_PARAMETER;
-            break;
-        }
-
-        case SHCRGL_GUEST_FN_INJECT:
-        {
-            WARN(("svcCall: SHCRGL_GUEST_FN_INJECT\n"));
-
-            /** @todo Verify  */
-            if (cParams == 1)
-            {
-                CRVBOXHGSMIINJECT *pFnCmd = (CRVBOXHGSMIINJECT*)pHdr;
-                /* Fetch parameters. */
-                uint32_t u32InjectClientID = pFnCmd->u32ClientID;
-                const VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1];
-                uint32_t cbBuffer = pBuf->cbBuffer;
-                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
-
-                if (cbHdr < sizeof (*pFnCmd))
-                {
-                    WARN(("invalid inject cmd buffer size!"));
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                CRASSERT(cbBuffer);
-                if (!pBuffer)
-                {
-                    WARN(("invalid buffer data received from guest!"));
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                rc = crVBoxServerClientGet(u32InjectClientID, &pClient);
-                if (RT_FAILURE(rc))
-                {
-                    WARN(("crVBoxServerClientGet failed %d", rc));
-                    break;
-                }
-
-                /* This should never fire unless we start to multithread */
-                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-                pClient->conn->pBuffer = pBuffer;
-                pClient->conn->cbBuffer = cbBuffer;
-                CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, false);
-                crVBoxServerInternalClientWriteRead(pClient);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-                return VINF_SUCCESS;
-            }
-
-            WARN(("invalid number of args"));
-            rc = VERR_INVALID_PARAMETER;
-            break;
-        }
-
-        case SHCRGL_GUEST_FN_READ:
-        {
-            Log(("svcCall: SHCRGL_GUEST_FN_READ\n"));
-
-            /** @todo Verify  */
-            if (cParams == 1)
-            {
-                CRVBOXHGSMIREAD *pFnCmd = (CRVBOXHGSMIREAD*)pHdr;
-                const VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1];
-                /* Fetch parameters. */
-                uint32_t cbBuffer = pBuf->cbBuffer;
-                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
-
-                if (cbHdr < sizeof (*pFnCmd))
-                {
-                    WARN(("invalid read cmd buffer size!"));
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                if (!pBuffer)
-                {
-                    WARN(("invalid buffer data received from guest!"));
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                rc = crVBoxServerClientGet(u32ClientID, &pClient);
-                if (RT_FAILURE(rc))
-                {
-                    WARN(("crVBoxServerClientGet failed %d", rc));
-                    break;
-                }
-
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-                rc = crVBoxServerInternalClientRead(pClient, pBuffer, &cbBuffer);
-
-                /* Return the required buffer size always */
-                pFnCmd->cbBuffer = cbBuffer;
-
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-                /* the read command is never pended, complete it right away */
-                if (RT_FAILURE(rc))
-                {
-                    WARN(("crVBoxServerInternalClientRead failed %d", rc));
-                    break;
-                }
-
-                break;
-            }
-
-            crWarning("invalid number of args");
-            rc = VERR_INVALID_PARAMETER;
-            break;
-        }
-
-        case SHCRGL_GUEST_FN_WRITE_READ:
-        {
-            Log(("svcCall: SHCRGL_GUEST_FN_WRITE_READ\n"));
-
-            /** @todo Verify  */
-            if (cParams == 2)
-            {
-                CRVBOXHGSMIWRITEREAD *pFnCmd = (CRVBOXHGSMIWRITEREAD*)pHdr;
-                const VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1];
-                const VBOXCMDVBVA_CRCMD_BUFFER *pWbBuf = &pCmd->aBuffers[2];
-
-                /* Fetch parameters. */
-                uint32_t cbBuffer = pBuf->cbBuffer;
-                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
-
-                uint32_t cbWriteback = pWbBuf->cbBuffer;
-                char *pWriteback  = VBOXCRHGSMI_PTR_SAFE(pWbBuf->offBuffer, cbWriteback, char);
-
-                if (cbHdr < sizeof (*pFnCmd))
-                {
-                    WARN(("invalid write_read cmd buffer size!"));
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                CRASSERT(cbBuffer);
-                if (!pBuffer)
-                {
-                    WARN(("invalid write buffer data received from guest!"));
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                CRASSERT(cbWriteback);
-                if (!pWriteback)
-                {
-                    WARN(("invalid writeback buffer data received from guest!"));
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                rc = crVBoxServerClientGet(u32ClientID, &pClient);
-                if (RT_FAILURE(rc))
-                {
-                    WARN(("crVBoxServerClientGet failed %d", rc));
-                    break;
-                }
-
-                /* This should never fire unless we start to multithread */
-                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-                pClient->conn->pBuffer = pBuffer;
-                pClient->conn->cbBuffer = cbBuffer;
-                CRVBOXHGSMI_CMDDATA_SETWB(&pClient->conn->CmdData, pCmd, pHdr, pWriteback, cbWriteback, &pFnCmd->cbWriteback, false);
-                crVBoxServerInternalClientWriteRead(pClient);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-                return VINF_SUCCESS;
-            }
-
-            crWarning("invalid number of args");
-            rc = VERR_INVALID_PARAMETER;
-            break;
-        }
-
-        case SHCRGL_GUEST_FN_SET_VERSION:
-        {
-            WARN(("SHCRGL_GUEST_FN_SET_VERSION: invalid function"));
-            rc = VERR_NOT_IMPLEMENTED;
-            break;
-        }
-
-        case SHCRGL_GUEST_FN_SET_PID:
-        {
-            WARN(("SHCRGL_GUEST_FN_SET_PID: invalid function"));
-            rc = VERR_NOT_IMPLEMENTED;
-            break;
-        }
-
-        default:
-        {
-            WARN(("invalid function, %d", u32Function));
-            rc = VERR_NOT_IMPLEMENTED;
-            break;
-        }
-
-    }
-
-    pHdr->result = rc;
-
-    return VINF_SUCCESS;
-}
-
-static DECLCALLBACK(int) crVBoxCrCmdEnable(HVBOXCRCMDSVR hSvr, VBOXCRCMD_SVRENABLE_INFO *pInfo)
-{
-    Assert(!cr_server.fCrCmdEnabled);
-    Assert(!cr_server.numClients);
-
-    cr_server.CrCmdClientInfo = *pInfo;
-
-    crVBoxServerDefaultContextSet();
-
-    cr_server.fCrCmdEnabled = GL_TRUE;
-
-    crInfo("crCmd ENABLED");
-
-    return VINF_SUCCESS;
-}
-
-static DECLCALLBACK(int) crVBoxCrCmdDisable(HVBOXCRCMDSVR hSvr)
-{
-    Assert(cr_server.fCrCmdEnabled);
-
-    crVBoxServerRemoveAllClients();
-
-    CrHTableEmpty(&cr_server.clientTable);
-
-    crVBoxServerDefaultContextClear();
-
-    memset(&cr_server.CrCmdClientInfo, 0, sizeof (cr_server.CrCmdClientInfo));
-
-    cr_server.fCrCmdEnabled = GL_FALSE;
-
-    crInfo("crCmd DISABLED");
-
-    return VINF_SUCCESS;
-}
-
-static DECLCALLBACK(int) crVBoxCrCmdHostCtl(HVBOXCRCMDSVR hSvr, uint8_t* pCmd, uint32_t cbCmd)
-{
-    return crVBoxServerHostCtl((VBOXCRCMDCTL*)pCmd, cbCmd);
-}
-
-static int crVBoxCrDisconnect(uint32_t u32Client)
-{
-    CRClient *pClient = (CRClient*)CrHTableRemove(&cr_server.clientTable, u32Client);
-    if (!pClient)
-    {
-        WARN(("invalid client id"));
-        return VERR_INVALID_PARAMETER;
-    }
-
-    crVBoxServerRemoveClientObj(pClient);
-
-    return VINF_SUCCESS;
-}
-
-static int crVBoxCrConnectEx(VBOXCMDVBVA_3DCTL_CONNECT RT_UNTRUSTED_VOLATILE_GUEST *pConnect, uint32_t u32ClientId)
-{
-    CRClient *pClient;
-    int rc;
-    uint32_t const uMajorVersion = pConnect->u32MajorVersion;
-    uint32_t const uMinorVersion = pConnect->u32MinorVersion;
-    uint64_t const uPid          = pConnect->u64Pid;
-    RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
-
-    if (u32ClientId == CRHTABLE_HANDLE_INVALID)
-    {
-        /* allocate client id */
-        u32ClientId =  CrHTablePut(&cr_server.clientTable, (void *)(uintptr_t)1);
-        if (u32ClientId == CRHTABLE_HANDLE_INVALID)
-        {
-            WARN(("CrHTablePut failed"));
-            return VERR_NO_MEMORY;
-        }
-    }
-
-    rc = crVBoxServerAddClientObj(u32ClientId, &pClient);
-    if (RT_SUCCESS(rc))
-    {
-        rc = crVBoxServerClientObjSetVersion(pClient, uMajorVersion, uMinorVersion);
-        if (RT_SUCCESS(rc))
-        {
-            rc = crVBoxServerClientObjSetPID(pClient, uPid);
-            if (RT_SUCCESS(rc))
-            {
-                rc = CrHTablePutToSlot(&cr_server.clientTable, u32ClientId, pClient);
-                if (RT_SUCCESS(rc))
-                {
-                    pConnect->Hdr.u32CmdClientId = u32ClientId;
-                    return VINF_SUCCESS;
-                }
-                WARN(("CrHTablePutToSlot failed %d", rc));
-            }
-            else
-                WARN(("crVBoxServerClientObjSetPID failed %d", rc));
-        }
-        else
-            WARN(("crVBoxServerClientObjSetVersion failed %d", rc));
-
-        crVBoxServerRemoveClientObj(pClient);
-    }
-    else
-        WARN(("crVBoxServerAddClientObj failed %d", rc));
-
-    CrHTableRemove(&cr_server.clientTable, u32ClientId);
-
-    return rc;
-}
-
-static int crVBoxCrConnect(VBOXCMDVBVA_3DCTL_CONNECT RT_UNTRUSTED_VOLATILE_GUEST *pConnect)
-{
-    return crVBoxCrConnectEx(pConnect, CRHTABLE_HANDLE_INVALID);
-}
-
-/**
- * @interface_method_impl{VBOXCRCMD_SVRINFO,pfnGuestCtl}
- */
-static DECLCALLBACK(int) crVBoxCrCmdGuestCtl(HVBOXCRCMDSVR hSvr, uint8_t RT_UNTRUSTED_VOLATILE_GUEST *pbCmd, uint32_t cbCmd)
-{
-    /*
-     * Toplevel input validation.
-     */
-    ASSERT_GUEST_LOGREL_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_3DCTL), VERR_INVALID_PARAMETER);
-    {
-        VBOXCMDVBVA_3DCTL RT_UNTRUSTED_VOLATILE_GUEST *pCtl = (VBOXCMDVBVA_3DCTL RT_UNTRUSTED_VOLATILE_GUEST*)pbCmd;
-        const uint32_t uType = pCtl->u32Type;
-        RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
-
-        ASSERT_GUEST_LOGREL_RETURN(   uType == VBOXCMDVBVA3DCTL_TYPE_CMD
-                                   || uType == VBOXCMDVBVA3DCTL_TYPE_CONNECT
-                                   || uType == VBOXCMDVBVA3DCTL_TYPE_DISCONNECT
-                                   , VERR_INVALID_PARAMETER);
-        RT_UNTRUSTED_VALIDATED_FENCE();
-
-        /*
-         * Call worker abd process the request.
-         */
-        switch (uType)
-        {
-            case VBOXCMDVBVA3DCTL_TYPE_CMD:
-                ASSERT_GUEST_LOGREL_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_3DCTL_CMD), VERR_INVALID_PARAMETER);
-                {
-                    VBOXCMDVBVA_3DCTL_CMD RT_UNTRUSTED_VOLATILE_GUEST *p3DCmd
-                        = (VBOXCMDVBVA_3DCTL_CMD RT_UNTRUSTED_VOLATILE_GUEST *)pbCmd;
-                    return crVBoxCrCmdCmd(NULL, &p3DCmd->Cmd, cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_3DCTL_CMD, Cmd));
-                }
-
-            case VBOXCMDVBVA3DCTL_TYPE_CONNECT:
-                ASSERT_GUEST_LOGREL_RETURN(cbCmd == sizeof(VBOXCMDVBVA_3DCTL_CONNECT), VERR_INVALID_PARAMETER);
-                return crVBoxCrConnect((VBOXCMDVBVA_3DCTL_CONNECT RT_UNTRUSTED_VOLATILE_GUEST *)pCtl);
-
-            case VBOXCMDVBVA3DCTL_TYPE_DISCONNECT:
-                ASSERT_GUEST_LOGREL_RETURN(cbCmd == sizeof(VBOXCMDVBVA_3DCTL), VERR_INVALID_PARAMETER);
-                {
-                    uint32_t idClient = pCtl->u32CmdClientId;
-                    RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
-                    return crVBoxCrDisconnect(idClient);
-                }
-
-            default:
-                AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE);
-        }
-    }
-}
-
-static DECLCALLBACK(int) crVBoxCrCmdResize(HVBOXCRCMDSVR hSvr, const struct VBVAINFOSCREEN *pScreen, const uint32_t *pTargetMap)
-{
-    CRASSERT(cr_server.fCrCmdEnabled);
-    return CrPMgrResize(pScreen, NULL, pTargetMap);
-}
-
-static const char* gszVBoxOGLSSMMagic = "***OpenGL state data***";
-
-static int crVBoxCrCmdSaveClients(PSSMHANDLE pSSM)
-{
-    int i;
-    int rc = SSMR3PutU32(pSSM, cr_server.numClients);
-    AssertRCReturn(rc, rc);
-
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        CRClient * pClient = cr_server.clients[i];
-        Assert(pClient);
-
-        rc = SSMR3PutU32(pSSM, pClient->conn->u32ClientID);
-        AssertRCReturn(rc, rc);
-        rc = SSMR3PutU32(pSSM, pClient->conn->vMajor);
-        AssertRCReturn(rc, rc);
-        rc = SSMR3PutU32(pSSM, pClient->conn->vMinor);
-        AssertRCReturn(rc, rc);
-        rc = SSMR3PutU64(pSSM, pClient->pid);
-        AssertRCReturn(rc, rc);
-    }
-
-    return VINF_SUCCESS;
-}
-
-static int crVBoxCrCmdLoadClients(PSSMHANDLE pSSM, uint32_t u32Version)
-{
-    uint32_t i;
-    uint32_t u32;
-    VBOXCMDVBVA_3DCTL_CONNECT Connect;
-    int rc = SSMR3GetU32(pSSM, &u32);
-    AssertLogRelRCReturn(rc, rc);
-
-    for (i = 0; i < u32; i++)
-    {
-        uint32_t u32ClientID;
-        Connect.Hdr.u32Type = VBOXCMDVBVA3DCTL_TYPE_CONNECT;
-        Connect.Hdr.u32CmdClientId = 0;
-
-        rc = SSMR3GetU32(pSSM, &u32ClientID);
-        AssertLogRelRCReturn(rc, rc);
-        rc = SSMR3GetU32(pSSM, &Connect.u32MajorVersion);
-        AssertLogRelRCReturn(rc, rc);
-        rc = SSMR3GetU32(pSSM, &Connect.u32MinorVersion);
-        AssertLogRelRCReturn(rc, rc);
-        rc = SSMR3GetU64(pSSM, &Connect.u64Pid);
-        AssertLogRelRCReturn(rc, rc);
-
-        rc = crVBoxCrConnectEx(&Connect, u32ClientID);
-        AssertLogRelRCReturn(rc, rc);
-    }
-
-    return VINF_SUCCESS;
-}
-
-static DECLCALLBACK(int) crVBoxCrCmdSaveState(HVBOXCRCMDSVR hSvr, PSSMHANDLE pSSM)
-{
-    int rc = VINF_SUCCESS;
-
-    Assert(cr_server.fCrCmdEnabled);
-
-    /* Start*/
-    rc = SSMR3PutStrZ(pSSM, gszVBoxOGLSSMMagic);
-    AssertRCReturn(rc, rc);
-
-    if (!cr_server.numClients)
-    {
-        rc = SSMR3PutU32(pSSM, 0);
-        AssertRCReturn(rc, rc);
-
-        rc = SSMR3PutStrZ(pSSM, gszVBoxOGLSSMMagic);
-        AssertRCReturn(rc, rc);
-
-        return VINF_SUCCESS;
-    }
-
-    rc = SSMR3PutU32(pSSM, 1);
-    AssertRCReturn(rc, rc);
-
-    /* Version */
-    rc = SSMR3PutU32(pSSM, (uint32_t) SHCROGL_SSM_VERSION);
-    AssertRCReturn(rc, rc);
-
-    rc = crVBoxCrCmdSaveClients(pSSM);
-    AssertRCReturn(rc, rc);
-
-    /* The state itself */
-    rc = crVBoxServerSaveStatePerform(pSSM);
-    AssertRCReturn(rc, rc);
-
-    /* Save svc buffers info */
-    {
-        rc = SSMR3PutU32(pSSM, 0);
-        AssertRCReturn(rc, rc);
-
-        rc = SSMR3PutU32(pSSM, 0);
-        AssertRCReturn(rc, rc);
-    }
-
-    /* End */
-    rc = SSMR3PutStrZ(pSSM, gszVBoxOGLSSMMagic);
-    AssertRCReturn(rc, rc);
-
-    return VINF_SUCCESS;
-}
-
-static DECLCALLBACK(int) crVBoxCrCmdLoadState(HVBOXCRCMDSVR hSvr, PSSMHANDLE pSSM, uint32_t u32Version)
-{
-    int rc = VINF_SUCCESS;
-
-    char szBuf[2000];
-    uint32_t ui32;
-
-    Assert(cr_server.fCrCmdEnabled);
-
-    /* Start of data */
-    rc = SSMR3GetStrZEx(pSSM, szBuf, sizeof(szBuf), NULL);
-    AssertLogRelRCReturn(rc, rc);
-    AssertLogRelMsgReturn(!strcmp(gszVBoxOGLSSMMagic, szBuf), ("Unexpected data1: '%s'\n", szBuf), VERR_SSM_UNEXPECTED_DATA);
-
-    /* num clients */
-    rc = SSMR3GetU32(pSSM, &ui32);
-    AssertLogRelRCReturn(rc, rc);
-
-    if (!ui32)
-    {
-        /* no clients, dummy stub */
-        rc = SSMR3GetStrZEx(pSSM, szBuf, sizeof(szBuf), NULL);
-        AssertLogRelRCReturn(rc, rc);
-        AssertLogRelMsgReturn(!strcmp(gszVBoxOGLSSMMagic, szBuf), ("Unexpected data2: '%s'\n", szBuf), VERR_SSM_UNEXPECTED_DATA);
-
-        return VINF_SUCCESS;
-    }
-    AssertLogRelMsgReturn(ui32 == 1, ("Invalid client count: %#x\n", ui32), VERR_SSM_UNEXPECTED_DATA);
-
-    /* Version */
-    rc = SSMR3GetU32(pSSM, &ui32);
-    AssertLogRelRCReturn(rc, rc);
-    AssertLogRelMsgReturn(ui32 >= SHCROGL_SSM_VERSION_CRCMD, ("Unexpected version: %#x\n", ui32), VERR_SSM_UNEXPECTED_DATA);
-
-    rc = crVBoxCrCmdLoadClients(pSSM, u32Version);
-    AssertLogRelRCReturn(rc, rc);
-
-    /* The state itself */
-    rc = crVBoxServerLoadStatePerform(pSSM, ui32);
-    AssertLogRelRCReturn(rc, rc);
-
-    /* Save svc buffers info */
-    {
-        rc = SSMR3GetU32(pSSM, &ui32);
-        AssertLogRelRCReturn(rc, rc);
-        AssertLogRelMsgReturn(ui32 == 0, ("Unexpected data3: %#x\n", ui32), VERR_SSM_UNEXPECTED_DATA);
-
-        rc = SSMR3GetU32(pSSM, &ui32);
-        AssertLogRelRCReturn(rc, rc);
-        AssertLogRelMsgReturn(ui32 == 0, ("Unexpected data4: %#x\n", ui32), VERR_SSM_UNEXPECTED_DATA);
-    }
-
-    /* End */
-    rc = SSMR3GetStrZEx(pSSM, szBuf, sizeof(szBuf), NULL);
-    AssertLogRelRCReturn(rc, rc);
-    AssertLogRelMsgReturn(!strcmp(gszVBoxOGLSSMMagic, szBuf), ("Unexpected data5: '%s'\n", szBuf), VERR_SSM_UNEXPECTED_DATA);
-
-    return VINF_SUCCESS;
-}
-
-
-/**
- * @interface_method_impl{VBOXCRCMD_SVRINFO,pfnCmd}
- */
-static DECLCALLBACK(int8_t) crVBoxCrCmdCmd(HVBOXCRCMDSVR hSvr,
-                                           const VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd)
-{
-    uint8_t bOpcode = pCmd->u8OpCode;
-    RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
-    ASSERT_GUEST_LOGREL_MSG_RETURN(   bOpcode == VBOXCMDVBVA_OPTYPE_CRCMD
-                                   || bOpcode == VBOXCMDVBVA_OPTYPE_FLIP
-                                   || bOpcode == VBOXCMDVBVA_OPTYPE_BLT
-                                   || bOpcode == VBOXCMDVBVA_OPTYPE_CLRFILL,
-                                   ("%#x\n", bOpcode), -1);
-    RT_UNTRUSTED_VALIDATED_FENCE();
-
-    switch (bOpcode)
-    {
-        case VBOXCMDVBVA_OPTYPE_CRCMD:
-            ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_CRCMD), ("cbCmd=%u\n", cbCmd), -1);
-            {
-                VBOXCMDVBVA_CRCMD const RT_UNTRUSTED_VOLATILE_GUEST *pCrCmdDr
-                    = (VBOXCMDVBVA_CRCMD const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd;
-                VBOXCMDVBVA_CRCMD_CMD const RT_UNTRUSTED_VOLATILE_GUEST *pCrCmd = &pCrCmdDr->Cmd;
-                int rc = crVBoxServerCmdVbvaCrCmdProcess(pCrCmd, cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_CRCMD, Cmd));
-                ASSERT_GUEST_LOGREL_RC_RETURN(rc, -1);
-                return 0;
-            }
-
-        case VBOXCMDVBVA_OPTYPE_FLIP:
-            ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= VBOXCMDVBVA_SIZEOF_FLIPSTRUCT_MIN, ("cbCmd=%u\n", cbCmd), -1);
-            {
-                VBOXCMDVBVA_FLIP const RT_UNTRUSTED_VOLATILE_GUEST *pFlip
-                    = (VBOXCMDVBVA_FLIP const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd;
-                return crVBoxServerCrCmdFlipProcess(pFlip, cbCmd);
-            }
-
-        case VBOXCMDVBVA_OPTYPE_BLT:
-            ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_BLT_HDR), ("cbCmd=%u\n", cbCmd), -1);
-            return crVBoxServerCrCmdBltProcess((VBOXCMDVBVA_BLT_HDR const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd, cbCmd);
-
-        case VBOXCMDVBVA_OPTYPE_CLRFILL:
-            ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_CLRFILL_HDR), ("cbCmd=%u\n", cbCmd), -1);
-            return crVBoxServerCrCmdClrFillProcess((VBOXCMDVBVA_CLRFILL_HDR const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd, cbCmd);
-
-        default:
-            AssertFailedReturn(-1);
-    }
-    /* not reached */
-}
-
-/* We moved all CrHgsmi command processing to crserverlib to keep the logic of dealing with CrHgsmi commands in one place.
- *
- * For now we need the notion of CrHgdmi commands in the crserver_lib to be able to complete it asynchronously once it is really processed.
- * This help avoiding the "blocked-client" issues. The client is blocked if another client is doing begin-end stuff.
- * For now we eliminated polling that could occur on block, which caused a higher-priority thread (in guest) polling for the blocked command complition
- * to block the lower-priority thread trying to complete the blocking command.
- * And removed extra memcpy done on blocked command arrival.
- *
- * In the future we will extend CrHgsmi functionality to maintain texture data directly in CrHgsmi allocation to avoid extra memcpy-ing with PBO,
- * implement command completion and stuff necessary for GPU scheduling to work properly for WDDM Windows guests, etc.
- *
- * NOTE: it is ALWAYS responsibility of the crVBoxServerCrHgsmiCmd to complete the command!
- * */
-
-
-int32_t crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd)
-{
-
-    int32_t rc;
-    uint32_t cBuffers = pCmd->cBuffers;
-    uint32_t cParams;
-    uint32_t cbHdr;
-    CRVBOXHGSMIHDR *pHdr;
-    uint32_t u32Function;
-    uint32_t u32ClientID;
-    CRClient *pClient;
-
-    if (!g_pvVRamBase)
-    {
-        WARN(("g_pvVRamBase is not initialized"));
-
-        crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_STATE);
-        return VINF_SUCCESS;
-    }
-
-    if (!cBuffers)
-    {
-        WARN(("zero buffers passed in!"));
-
-        crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER);
-        return VINF_SUCCESS;
-    }
-
-    cParams = cBuffers-1;
-
-    cbHdr = pCmd->aBuffers[0].cbBuffer;
-    pHdr = VBOXCRHGSMI_PTR_SAFE(pCmd->aBuffers[0].offBuffer, cbHdr, CRVBOXHGSMIHDR);
-    if (!pHdr)
-    {
-        WARN(("invalid header buffer!"));
-
-        crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER);
-        return VINF_SUCCESS;
-    }
-
-    if (cbHdr < sizeof (*pHdr))
-    {
-        WARN(("invalid header buffer size!"));
-
-        crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER);
-        return VINF_SUCCESS;
-    }
-
-    u32Function = pHdr->u32Function;
-    u32ClientID = pHdr->u32ClientID;
-
-    switch (u32Function)
-    {
-        case SHCRGL_GUEST_FN_WRITE:
-        {
-            Log(("svcCall: SHCRGL_GUEST_FN_WRITE\n"));
-
-            /** @todo Verify  */
-            if (cParams == 1)
-            {
-                CRVBOXHGSMIWRITE* pFnCmd = (CRVBOXHGSMIWRITE*)pHdr;
-                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
-                /* Fetch parameters. */
-                uint32_t cbBuffer = pBuf->cbBuffer;
-                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
-
-                if (cbHdr < sizeof (*pFnCmd))
-                {
-                    crWarning("invalid write cmd buffer size!");
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                CRASSERT(cbBuffer);
-                if (!pBuffer)
-                {
-                    crWarning("invalid buffer data received from guest!");
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                rc = crVBoxServerClientGet(u32ClientID, &pClient);
-                if (RT_FAILURE(rc))
-                {
-                    break;
-                }
-
-                /* This should never fire unless we start to multithread */
-                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-                pClient->conn->pBuffer = pBuffer;
-                pClient->conn->cbBuffer = cbBuffer;
-                CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, true);
-                crVBoxServerInternalClientWriteRead(pClient);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-                return VINF_SUCCESS;
-            }
-            else
-            {
-                crWarning("invalid number of args");
-                rc = VERR_INVALID_PARAMETER;
-                break;
-            }
-            break;
-        }
-
-        case SHCRGL_GUEST_FN_INJECT:
-        {
-            Log(("svcCall: SHCRGL_GUEST_FN_INJECT\n"));
-
-            /** @todo Verify  */
-            if (cParams == 1)
-            {
-                CRVBOXHGSMIINJECT *pFnCmd = (CRVBOXHGSMIINJECT*)pHdr;
-                /* Fetch parameters. */
-                uint32_t u32InjectClientID = pFnCmd->u32ClientID;
-                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
-                uint32_t cbBuffer = pBuf->cbBuffer;
-                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
-
-                if (cbHdr < sizeof (*pFnCmd))
-                {
-                    crWarning("invalid inject cmd buffer size!");
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                CRASSERT(cbBuffer);
-                if (!pBuffer)
-                {
-                    crWarning("invalid buffer data received from guest!");
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                rc = crVBoxServerClientGet(u32InjectClientID, &pClient);
-                if (RT_FAILURE(rc))
-                {
-                    break;
-                }
-
-                /* This should never fire unless we start to multithread */
-                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-                pClient->conn->pBuffer = pBuffer;
-                pClient->conn->cbBuffer = cbBuffer;
-                CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, true);
-                crVBoxServerInternalClientWriteRead(pClient);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-                return VINF_SUCCESS;
-            }
-
-            crWarning("invalid number of args");
-            rc = VERR_INVALID_PARAMETER;
-            break;
-        }
-
-        case SHCRGL_GUEST_FN_READ:
-        {
-            Log(("svcCall: SHCRGL_GUEST_FN_READ\n"));
-
-            /** @todo Verify  */
-            if (cParams == 1)
-            {
-                CRVBOXHGSMIREAD *pFnCmd = (CRVBOXHGSMIREAD*)pHdr;
-                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
-                /* Fetch parameters. */
-                uint32_t cbBuffer = pBuf->cbBuffer;
-                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
-
-                if (cbHdr < sizeof (*pFnCmd))
-                {
-                    crWarning("invalid read cmd buffer size!");
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-
-                if (!pBuffer)
-                {
-                    crWarning("invalid buffer data received from guest!");
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                rc = crVBoxServerClientGet(u32ClientID, &pClient);
-                if (RT_FAILURE(rc))
-                {
-                    break;
-                }
-
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-                rc = crVBoxServerInternalClientRead(pClient, pBuffer, &cbBuffer);
-
-                /* Return the required buffer size always */
-                pFnCmd->cbBuffer = cbBuffer;
-
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-                /* the read command is never pended, complete it right away */
-                pHdr->result = rc;
-
-                crServerCrHgsmiCmdComplete(pCmd, VINF_SUCCESS);
-                return VINF_SUCCESS;
-            }
-
-            crWarning("invalid number of args");
-            rc = VERR_INVALID_PARAMETER;
-            break;
-        }
-
-        case SHCRGL_GUEST_FN_WRITE_READ:
-        {
-            Log(("svcCall: SHCRGL_GUEST_FN_WRITE_READ\n"));
-
-            /** @todo Verify  */
-            if (cParams == 2)
-            {
-                CRVBOXHGSMIWRITEREAD *pFnCmd = (CRVBOXHGSMIWRITEREAD*)pHdr;
-                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
-                VBOXVDMACMD_CHROMIUM_BUFFER *pWbBuf = &pCmd->aBuffers[2];
-
-                /* Fetch parameters. */
-                uint32_t cbBuffer = pBuf->cbBuffer;
-                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
-
-                uint32_t cbWriteback = pWbBuf->cbBuffer;
-                char *pWriteback  = VBOXCRHGSMI_PTR_SAFE(pWbBuf->offBuffer, cbWriteback, char);
-
-                if (cbHdr < sizeof (*pFnCmd))
-                {
-                    crWarning("invalid write_read cmd buffer size!");
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-
-                CRASSERT(cbBuffer);
-                if (!pBuffer)
-                {
-                    crWarning("invalid write buffer data received from guest!");
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-
-                CRASSERT(cbWriteback);
-                if (!pWriteback)
-                {
-                    crWarning("invalid writeback buffer data received from guest!");
-                    rc = VERR_INVALID_PARAMETER;
-                    break;
-                }
-                rc = crVBoxServerClientGet(u32ClientID, &pClient);
-                if (RT_FAILURE(rc))
-                {
-                    pHdr->result = rc;
-                    crServerCrHgsmiCmdComplete(pCmd, VINF_SUCCESS);
-                    return rc;
-                }
-
-                /* This should never fire unless we start to multithread */
-                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-
-                pClient->conn->pBuffer = pBuffer;
-                pClient->conn->cbBuffer = cbBuffer;
-                CRVBOXHGSMI_CMDDATA_SETWB(&pClient->conn->CmdData, pCmd, pHdr, pWriteback, cbWriteback, &pFnCmd->cbWriteback, true);
-                crVBoxServerInternalClientWriteRead(pClient);
-                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
-                return VINF_SUCCESS;
-            }
-
-            crWarning("invalid number of args");
-            rc = VERR_INVALID_PARAMETER;
-            break;
-        }
-
-        case SHCRGL_GUEST_FN_SET_VERSION:
-        {
-            WARN(("crVBoxServerCrHgsmiCmd, SHCRGL_GUEST_FN_SET_VERSION: invalid function"));
-            rc = VERR_NOT_IMPLEMENTED;
-            break;
-        }
-
-        case SHCRGL_GUEST_FN_SET_PID:
-        {
-            WARN(("crVBoxServerCrHgsmiCmd, SHCRGL_GUEST_FN_SET_PID: invalid function"));
-            rc = VERR_NOT_IMPLEMENTED;
-            break;
-        }
-
-        default:
-        {
-            WARN(("crVBoxServerCrHgsmiCmd: invalid functionm %d", u32Function));
-            rc = VERR_NOT_IMPLEMENTED;
-            break;
-        }
-
-    }
-
-    /* we can be on fail only here */
-    CRASSERT(RT_FAILURE(rc));
-    pHdr->result = rc;
-
-    crServerCrHgsmiCmdComplete(pCmd, VINF_SUCCESS);
-    return rc;
-
-}
-
-
-static DECLCALLBACK(bool) crVBoxServerHasDataForScreen(uint32_t u32ScreenID)
-{
-    HCR_FRAMEBUFFER hFb = CrPMgrFbGetEnabledForScreen(u32ScreenID);
-    if (hFb)
-        return CrFbHas3DData(hFb);
-
-    return false;
-}
-
-
-static DECLCALLBACK(bool) crVBoxServerHasData(void)
-{
-    HCR_FRAMEBUFFER hFb = CrPMgrFbGetFirstEnabled();
-    for (;
-            hFb;
-            hFb = CrPMgrFbGetNextEnabled(hFb))
-    {
-        if (CrFbHas3DData(hFb))
-            return true;
-    }
-
-    return false;
-}
-
-int32_t crVBoxServerCrHgsmiCtl(struct VBOXVDMACMD_CHROMIUM_CTL *pCtl, uint32_t cbCtl)
-{
-    int rc = VINF_SUCCESS;
-
-    switch (pCtl->enmType)
-    {
-        case VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP:
-        {
-            PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP pSetup = (PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP)pCtl;
-            g_pvVRamBase = (uint8_t*)pSetup->pvVRamBase;
-            g_cbVRam = pSetup->cbVRam;
-
-            g_pLed = pSetup->pLed;
-
-            cr_server.ClientInfo = pSetup->CrClientInfo;
-
-            pSetup->CrCmdServerInfo.hSvr = NULL;
-            pSetup->CrCmdServerInfo.pfnEnable = crVBoxCrCmdEnable;
-            pSetup->CrCmdServerInfo.pfnDisable = crVBoxCrCmdDisable;
-            pSetup->CrCmdServerInfo.pfnCmd = crVBoxCrCmdCmd;
-            pSetup->CrCmdServerInfo.pfnHostCtl = crVBoxCrCmdHostCtl;
-            pSetup->CrCmdServerInfo.pfnGuestCtl = crVBoxCrCmdGuestCtl;
-            pSetup->CrCmdServerInfo.pfnResize = crVBoxCrCmdResize;
-            pSetup->CrCmdServerInfo.pfnSaveState = crVBoxCrCmdSaveState;
-            pSetup->CrCmdServerInfo.pfnLoadState = crVBoxCrCmdLoadState;
-            rc = VINF_SUCCESS;
-            break;
-        }
-        case VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_BEGIN:
-        case VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_END:
-            rc = VINF_SUCCESS;
-            break;
-        case VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP_MAINCB:
-        {
-            PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP_MAINCB pSetup = (PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP_MAINCB)pCtl;
-            g_hCrHgsmiCompletion = pSetup->hCompletion;
-            g_pfnCrHgsmiCompletion = pSetup->pfnCompletion;
-
-            pSetup->MainInterface.pfnHasData = crVBoxServerHasData;
-            pSetup->MainInterface.pfnHasDataForScreen = crVBoxServerHasDataForScreen;
-
-            rc = VINF_SUCCESS;
-            break;
-        }
-        default:
-            AssertMsgFailed(("invalid param %d", pCtl->enmType));
-            rc = VERR_INVALID_PARAMETER;
-    }
-
-    /* NOTE: Control commands can NEVER be pended here, this is why its a task of a caller (Main)
-     * to complete them accordingly.
-     * This approach allows using host->host and host->guest commands in the same way here
-     * making the command completion to be the responsibility of the command originator.
-     * E.g. ctl commands can be both Hgcm Host synchronous commands that do not require completion at all,
-     * or Hgcm Host Fast Call commands that do require completion. All this details are hidden here */
-    return rc;
-}
-
-static int crVBoxServerCrCmdDisablePostProcess(VBOXCRCMDCTL_HGCMENABLE_DATA *pData)
-{
-    int rc = VINF_SUCCESS;
-    uint8_t* pCtl;
-    uint32_t cbCtl;
-    HVBOXCRCMDCTL_REMAINING_HOST_COMMAND hRHCmd = pData->hRHCmd;
-    PFNVBOXCRCMDCTL_REMAINING_HOST_COMMAND pfnRHCmd = pData->pfnRHCmd;
-
-    Assert(!cr_server.fCrCmdEnabled);
-
-    if (cr_server.numClients)
-    {
-        WARN(("cr_server.numClients(%d) is not NULL", cr_server.numClients));
-        return VERR_INVALID_STATE;
-    }
-
-    for (pCtl = pfnRHCmd(hRHCmd, &cbCtl, rc); pCtl; pCtl = pfnRHCmd(hRHCmd, &cbCtl, rc))
-    {
-        rc = crVBoxCrCmdHostCtl(NULL, pCtl, cbCtl);
-    }
-
-    memset(&cr_server.DisableData, 0, sizeof (cr_server.DisableData));
-
-    return VINF_SUCCESS;
-}
-
-int32_t crVBoxServerHgcmEnable(VBOXCRCMDCTL_HGCMENABLE_DATA *pData)
-{
-    int rc = crVBoxServerCrCmdDisablePostProcess(pData);
-    if (RT_FAILURE(rc))
-    {
-        WARN(("crVBoxServerCrCmdDisablePostProcess failed %d", rc));
-        return rc;
-    }
-
-    crVBoxServerDefaultContextSet();
-
-    return VINF_SUCCESS;
-}
-
-int32_t crVBoxServerHgcmDisable(VBOXCRCMDCTL_HGCMDISABLE_DATA *pData)
-{
-    Assert(!cr_server.fCrCmdEnabled);
-
-    Assert(!cr_server.numClients);
-
-    crVBoxServerRemoveAllClients();
-
-    CRASSERT(!cr_server.numClients);
-
-    crVBoxServerDefaultContextClear();
-
-    cr_server.DisableData = *pData;
-
-    return VINF_SUCCESS;
-}
-
-#endif
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_main.cpp	(revision 78190)
@@ -0,0 +1,3821 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "server.h"
+#include "cr_net.h"
+#include "cr_unpack.h"
+#include "cr_error.h"
+#include "cr_glstate.h"
+#include "cr_string.h"
+#include "cr_mem.h"
+#include "cr_hash.h"
+#include "cr_vreg.h"
+#include "cr_pixeldata.h"
+
+#include "server_dispatch.h"
+#include "state/cr_texture.h"
+#include "render/renderspu.h"
+#include <signal.h>
+#include <stdlib.h>
+#define DEBUG_FP_EXCEPTIONS 0
+#if DEBUG_FP_EXCEPTIONS
+#include <fpu_control.h>
+#include <math.h>
+#endif
+#include <iprt/assert.h>
+#include <iprt/env.h>
+#include <VBox/err.h>
+#include <VBox/log.h>
+#include <VBox/AssertGuest.h>
+
+#ifdef VBOXCR_LOGFPS
+#include <iprt/timer.h>
+#endif
+
+#ifdef VBOX_WITH_CRHGSMI
+# include <VBox/HostServices/VBoxCrOpenGLSvc.h>
+uint8_t* g_pvVRamBase = NULL;
+uint32_t g_cbVRam = 0;
+PPDMLED g_pLed = NULL;
+
+HCRHGSMICMDCOMPLETION g_hCrHgsmiCompletion = NULL;
+PFNCRHGSMICMDCOMPLETION g_pfnCrHgsmiCompletion = NULL;
+#endif
+
+/**
+ * \mainpage CrServerLib
+ *
+ * \section CrServerLibIntroduction Introduction
+ *
+ * Chromium consists of all the top-level files in the cr
+ * directory.  The core module basically takes care of API dispatch,
+ * and OpenGL state management.
+ */
+
+
+/**
+ * CRServer global data
+ */
+CRServer cr_server;
+
+int tearingdown = 0; /* can't be static */
+
+static DECLCALLBACK(int8_t) crVBoxCrCmdCmd(HVBOXCRCMDSVR hSvr,
+                                           const VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd);
+
+DECLINLINE(CRClient*) crVBoxServerClientById(uint32_t u32ClientID)
+{
+    int32_t i;
+
+    if (cr_server.fCrCmdEnabled)
+        return (CRClient *)CrHTableGet(&cr_server.clientTable, u32ClientID);
+
+    for (i = 0; i < cr_server.numClients; i++)
+    {
+        if (cr_server.clients[i] && cr_server.clients[i]->conn
+            && cr_server.clients[i]->conn->u32ClientID==u32ClientID)
+        {
+            return cr_server.clients[i];
+        }
+    }
+
+    return NULL;
+}
+
+int32_t crVBoxServerClientGet(uint32_t u32ClientID, CRClient **ppClient)
+{
+    CRClient *pClient = NULL;
+
+    pClient = crVBoxServerClientById(u32ClientID);
+
+    if (!pClient)
+    {
+        WARN(("client not found!"));
+        *ppClient = NULL;
+        return VERR_INVALID_PARAMETER;
+    }
+
+    if (!pClient->conn->vMajor)
+    {
+        WARN(("no major version specified for client!"));
+        *ppClient = NULL;
+        return VERR_NOT_SUPPORTED;
+    }
+
+    *ppClient = pClient;
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * Return pointer to server's first SPU.
+ */
+SPU*
+crServerHeadSPU(void)
+{
+     return cr_server.head_spu;
+}
+
+
+
+static void DeleteBarrierCallback( void *data )
+{
+    CRServerBarrier *barrier = (CRServerBarrier *) data;
+    crFree(barrier->waiting);
+    crFree(barrier);
+}
+
+
+static void deleteContextInfoCallback( void *data )
+{
+    CRContextInfo *c = (CRContextInfo *) data;
+    crStateDestroyContext(c->pContext);
+    if (c->CreateInfo.pszDpyName)
+        crFree(c->CreateInfo.pszDpyName);
+    crFree(c);
+}
+
+static void deleteMuralInfoCallback( void *data )
+{
+    CRMuralInfo *m = (CRMuralInfo *) data;
+    if (m->spuWindow != CR_RENDER_DEFAULT_WINDOW_ID) /* <- do not do term for default mural as it does not contain any info to be freed,
+                                                      * and renderspu will destroy it up itself*/
+    {
+        crServerMuralTerm(m);
+    }
+    crFree(m);
+}
+
+static int crVBoxServerCrCmdDisablePostProcess(VBOXCRCMDCTL_HGCMENABLE_DATA *pData);
+
+static void crServerTearDown( void )
+{
+    GLint i;
+    CRClientNode *pNode, *pNext;
+    GLboolean fOldEnableDiff;
+    GLboolean fContextsDeleted = GL_FALSE;
+
+    /* avoid a race condition */
+    if (tearingdown)
+        return;
+
+    tearingdown = 1;
+
+    if (cr_server.fCrCmdEnabled)
+    {
+        VBOXCRCMDCTL_HGCMENABLE_DATA EnableData;
+        /* crVBoxServerHgcmEnable will erase the DisableData, preserve it here */
+        VBOXCRCMDCTL_HGCMDISABLE_DATA DisableData = cr_server.DisableData;
+        int rc;
+
+        CRASSERT(DisableData.pfnNotifyTerm);
+        rc = DisableData.pfnNotifyTerm(DisableData.hNotifyTerm, &EnableData);
+        if (!RT_SUCCESS(rc))
+        {
+            WARN(("pfnNotifyTerm failed %d", rc));
+            return;
+        }
+
+        crVBoxServerCrCmdDisablePostProcess(&EnableData);
+        fContextsDeleted = GL_TRUE;
+
+        CRASSERT(DisableData.pfnNotifyTermDone);
+        DisableData.pfnNotifyTermDone(DisableData.hNotifyTerm);
+
+        Assert(!cr_server.fCrCmdEnabled);
+    }
+
+    crStateSetCurrent( NULL );
+
+    cr_server.curClient = NULL;
+    cr_server.run_queue = NULL;
+
+    crFree( cr_server.overlap_intens );
+    cr_server.overlap_intens = NULL;
+
+    /* needed to make sure window dummy mural not get created on mural destruction
+     * and generally this should be zeroed up */
+    cr_server.currentCtxInfo = NULL;
+    cr_server.currentWindow = -1;
+    cr_server.currentNativeWindow = 0;
+    cr_server.currentMural = NULL;
+
+    if (!fContextsDeleted)
+    {
+        /* sync our state with renderspu,
+         * do it before mural & context deletion to avoid deleting currently set murals/contexts*/
+        cr_server.head_spu->dispatch_table.MakeCurrent(CR_RENDER_DEFAULT_WINDOW_ID, 0, CR_RENDER_DEFAULT_CONTEXT_ID);
+    }
+
+    /* Deallocate all semaphores */
+    crFreeHashtable(cr_server.semaphores, crFree);
+    cr_server.semaphores = NULL;
+
+    /* Deallocate all barriers */
+    crFreeHashtable(cr_server.barriers, DeleteBarrierCallback);
+    cr_server.barriers = NULL;
+
+#if 0 /** @todo @bugref{8662} -- can trigger SEGFAULTs during savestate */
+    /* Free all context info */
+    crFreeHashtable(cr_server.contextTable, deleteContextInfoCallback);
+#endif
+
+    /* synchronize with reality */
+    if (!fContextsDeleted)
+    {
+        fOldEnableDiff = crStateEnableDiffOnMakeCurrent(GL_FALSE);
+        if(cr_server.MainContextInfo.pContext)
+            crStateMakeCurrent(cr_server.MainContextInfo.pContext);
+        crStateEnableDiffOnMakeCurrent(fOldEnableDiff);
+    }
+
+    /* Free vertex programs */
+    crFreeHashtable(cr_server.programTable, crFree);
+
+    /* Free murals */
+    crFreeHashtable(cr_server.muralTable, deleteMuralInfoCallback);
+
+    CrPMgrTerm();
+
+    if (CrBltIsInitialized(&cr_server.Blitter))
+    {
+        CrBltTerm(&cr_server.Blitter);
+    }
+
+    /* Free dummy murals */
+    crFreeHashtable(cr_server.dummyMuralTable, deleteMuralInfoCallback);
+
+    for (i = 0; i < cr_server.numClients; i++) {
+        if (cr_server.clients[i]) {
+            CRConnection *conn = cr_server.clients[i]->conn;
+            crNetFreeConnection(conn);
+            crFree(cr_server.clients[i]);
+        }
+    }
+    cr_server.numClients = 0;
+
+    pNode = cr_server.pCleanupClient;
+    while (pNode)
+    {
+        pNext=pNode->next;
+        crFree(pNode->pClient);
+        crFree(pNode);
+        pNode=pNext;
+    }
+    cr_server.pCleanupClient = NULL;
+
+    if (crServerRpwIsInitialized(&cr_server.RpwWorker))
+    {
+        crServerRpwTerm(&cr_server.RpwWorker);
+    }
+
+#if 1
+    /* disable these two lines if trying to get stack traces with valgrind */
+    crSPUUnloadChain(cr_server.head_spu);
+    cr_server.head_spu = NULL;
+#endif
+
+    crStateDestroy();
+
+    crNetTearDown();
+
+    VBoxVrListClear(&cr_server.RootVr);
+
+    VBoxVrTerm();
+
+    RTSemEventDestroy(cr_server.hCalloutCompletionEvent);
+}
+
+static void crServerClose( unsigned int id )
+{
+    crError( "Client disconnected!" );
+    (void) id;
+}
+
+void crVBoxServerTearDown(void)
+{
+    crServerTearDown();
+}
+
+/**
+ * Do CRServer initializations.  After this, we can begin servicing clients.
+ */
+GLboolean crVBoxServerInit(void)
+{
+    CRMuralInfo *defaultMural;
+    const char*env;
+    int rc = VBoxVrInit();
+    if (!RT_SUCCESS(rc))
+    {
+        crWarning("VBoxVrInit failed, rc %d", rc);
+        return GL_FALSE;
+    }
+
+#if DEBUG_FP_EXCEPTIONS
+    {
+        fpu_control_t mask;
+        _FPU_GETCW(mask);
+        mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM
+                            | _FPU_MASK_OM | _FPU_MASK_UM);
+        _FPU_SETCW(mask);
+    }
+#endif
+
+    cr_server.fCrCmdEnabled = GL_FALSE;
+    cr_server.fProcessingPendedCommands = GL_FALSE;
+    CrHTableCreate(&cr_server.clientTable, CR_MAX_CLIENTS);
+
+    cr_server.bUseMultipleContexts = RTEnvExist( "CR_SERVER_ENABLE_MULTIPLE_CONTEXTS" );
+
+    if (cr_server.bUseMultipleContexts)
+    {
+        crInfo("Info: using multiple contexts!");
+        crDebug("Debug: using multiple contexts!");
+    }
+
+    crNetInit(crServerRecv, crServerClose);
+
+    cr_server.firstCallCreateContext = GL_TRUE;
+    cr_server.firstCallMakeCurrent = GL_TRUE;
+
+    cr_server.bIsInLoadingState = GL_FALSE;
+    cr_server.bIsInSavingState  = GL_FALSE;
+    cr_server.bForceMakeCurrentOnClientSwitch = GL_FALSE;
+
+    cr_server.pCleanupClient = NULL;
+
+    rc = RTSemEventCreate(&cr_server.hCalloutCompletionEvent);
+    if (!RT_SUCCESS(rc))
+    {
+        WARN(("RTSemEventCreate failed %d", rc));
+        return GL_FALSE;
+    }
+
+    /*
+     * Create default mural info and hash table.
+     */
+    cr_server.muralTable = crAllocHashtable();
+    defaultMural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo));
+    defaultMural->spuWindow = CR_RENDER_DEFAULT_WINDOW_ID;
+    crHashtableAdd(cr_server.muralTable, 0, defaultMural);
+
+    cr_server.programTable = crAllocHashtable();
+
+    crStateInit();
+
+    crStateLimitsInit( &(cr_server.limits) );
+
+    cr_server.barriers = crAllocHashtable();
+    cr_server.semaphores = crAllocHashtable();
+
+    /*
+     * Default context
+     */
+    cr_server.contextTable = crAllocHashtable();
+
+    cr_server.dummyMuralTable = crAllocHashtable();
+
+    CrPMgrInit();
+
+    cr_server.fRootVrOn = GL_FALSE;
+    VBoxVrListInit(&cr_server.RootVr);
+    crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint));
+
+    crMemset(&cr_server.RpwWorker, 0, sizeof (cr_server.RpwWorker));
+
+    env = RTEnvGet("CR_SERVER_BFB");
+    if (env)
+    {
+        cr_server.fBlitterMode = env[0] - '0';
+    }
+    else
+    {
+        cr_server.fBlitterMode = CR_SERVER_BFB_DISABLED;
+    }
+    crMemset(&cr_server.Blitter, 0, sizeof (cr_server.Blitter));
+
+    crServerSetVBoxConfigurationHGCM();
+
+    if (!cr_server.head_spu)
+    {
+        crStateDestroy();
+        return GL_FALSE;
+    }
+
+    crServerInitDispatch();
+    crServerInitTmpCtxDispatch();
+    crStateDiffAPI( &(cr_server.head_spu->dispatch_table) );
+
+#ifdef VBOX_WITH_CRSERVER_DUMPER
+    crMemset(&cr_server.Recorder, 0, sizeof (cr_server.Recorder));
+    crMemset(&cr_server.RecorderBlitter, 0, sizeof (cr_server.RecorderBlitter));
+    crMemset(&cr_server.DbgPrintDumper, 0, sizeof (cr_server.DbgPrintDumper));
+    crMemset(&cr_server.HtmlDumper, 0, sizeof (cr_server.HtmlDumper));
+    cr_server.pDumper = NULL;
+#endif
+
+    /*Check for PBO support*/
+    if (crStateGetCurrent()->extensions.ARB_pixel_buffer_object)
+    {
+        cr_server.bUsePBOForReadback=GL_TRUE;
+    }
+
+    return GL_TRUE;
+}
+
+static int32_t crVBoxServerAddClientObj(uint32_t u32ClientID, CRClient **ppNewClient)
+{
+    CRClient *newClient;
+
+    if (cr_server.numClients>=CR_MAX_CLIENTS)
+    {
+        if (ppNewClient)
+            *ppNewClient = NULL;
+        return VERR_MAX_THRDS_REACHED;
+    }
+
+    newClient = (CRClient *) crCalloc(sizeof(CRClient));
+    crDebug("crServer: AddClient u32ClientID=%d", u32ClientID);
+
+    newClient->spu_id = 0;
+    newClient->currentCtxInfo = &cr_server.MainContextInfo;
+    newClient->currentContextNumber = -1;
+    newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
+                                        cr_server.tcpip_port,
+                                        cr_server.mtu, 0);
+    newClient->conn->u32ClientID = u32ClientID;
+
+    cr_server.clients[cr_server.numClients++] = newClient;
+
+    crServerAddToRunQueue(newClient);
+
+    if (ppNewClient)
+        *ppNewClient = newClient;
+
+    return VINF_SUCCESS;
+}
+
+int32_t crVBoxServerAddClient(uint32_t u32ClientID)
+{
+    CRClient *newClient;
+
+    if (cr_server.numClients>=CR_MAX_CLIENTS)
+    {
+        return VERR_MAX_THRDS_REACHED;
+    }
+
+    newClient = (CRClient *) crCalloc(sizeof(CRClient));
+    crDebug("crServer: AddClient u32ClientID=%d", u32ClientID);
+
+    newClient->spu_id = 0;
+    newClient->currentCtxInfo = &cr_server.MainContextInfo;
+    newClient->currentContextNumber = -1;
+    newClient->conn = crNetAcceptClient(cr_server.protocol, NULL,
+                                        cr_server.tcpip_port,
+                                        cr_server.mtu, 0);
+    newClient->conn->u32ClientID = u32ClientID;
+
+    cr_server.clients[cr_server.numClients++] = newClient;
+
+    crServerAddToRunQueue(newClient);
+
+    return VINF_SUCCESS;
+}
+
+static void crVBoxServerRemoveClientObj(CRClient *pClient)
+{
+#ifdef VBOX_WITH_CRHGSMI
+    CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+#endif
+
+    /* Disconnect the client */
+    pClient->conn->Disconnect(pClient->conn);
+
+    /* Let server clear client from the queue */
+    crServerDeleteClient(pClient);
+}
+
+static void crVBoxServerRemoveAllClients()
+{
+    int32_t i;
+    for (i = cr_server.numClients - 1; i >= 0; --i)
+    {
+        Assert(cr_server.clients[i]);
+        crVBoxServerRemoveClientObj(cr_server.clients[i]);
+    }
+}
+
+void crVBoxServerRemoveClient(uint32_t u32ClientID)
+{
+    CRClient *pClient=NULL;
+    int32_t i;
+
+    crDebug("crServer: RemoveClient u32ClientID=%d", u32ClientID);
+
+    for (i = 0; i < cr_server.numClients; i++)
+    {
+        if (cr_server.clients[i] && cr_server.clients[i]->conn
+            && cr_server.clients[i]->conn->u32ClientID==u32ClientID)
+        {
+            pClient = cr_server.clients[i];
+            break;
+        }
+    }
+    //if (!pClient) return VERR_INVALID_PARAMETER;
+    if (!pClient)
+    {
+        WARN(("Invalid client id %u passed to crVBoxServerRemoveClient", u32ClientID));
+        return;
+    }
+
+    crVBoxServerRemoveClientObj(pClient);
+}
+
+static void crVBoxServerInternalClientWriteRead(CRClient *pClient)
+{
+#ifdef VBOXCR_LOGFPS
+    uint64_t tstart, tend;
+#endif
+
+    /*crDebug("=>crServer: ClientWrite u32ClientID=%d", u32ClientID);*/
+
+
+#ifdef VBOXCR_LOGFPS
+    tstart = RTTimeNanoTS();
+#endif
+
+    /* This should be setup already */
+    CRASSERT(pClient->conn->pBuffer);
+    CRASSERT(pClient->conn->cbBuffer);
+#ifdef VBOX_WITH_CRHGSMI
+    CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(&pClient->conn->CmdData);
+#endif
+
+    if (
+#ifdef VBOX_WITH_CRHGSMI
+         !CRVBOXHGSMI_CMDDATA_IS_SET(&pClient->conn->CmdData) &&
+#endif
+         cr_server.run_queue->client != pClient
+         && crServerClientInBeginEnd(cr_server.run_queue->client))
+    {
+        crDebug("crServer: client %d blocked, allow_redir_ptr = 0", pClient->conn->u32ClientID);
+        pClient->conn->allow_redir_ptr = 0;
+    }
+    else
+    {
+        pClient->conn->allow_redir_ptr = 1;
+    }
+
+    crNetRecv();
+    CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
+    CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+    crServerServiceClients();
+    crStateResetCurrentPointers(&cr_server.current);
+
+#ifndef VBOX_WITH_CRHGSMI
+    CRASSERT(!pClient->conn->allow_redir_ptr || crNetNumMessages(pClient->conn)==0);
+#endif
+
+#ifdef VBOXCR_LOGFPS
+    tend = RTTimeNanoTS();
+    pClient->timeUsed += tend-tstart;
+#endif
+    /*crDebug("<=crServer: ClientWrite u32ClientID=%d", u32ClientID);*/
+}
+
+
+int32_t crVBoxServerClientWrite(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t cbBuffer)
+{
+    CRClient *pClient=NULL;
+    int32_t rc = crVBoxServerClientGet(u32ClientID, &pClient);
+
+    if (RT_FAILURE(rc))
+        return rc;
+
+    CRASSERT(pBuffer);
+
+    /* This should never fire unless we start to multithread */
+    CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
+
+    pClient->conn->pBuffer = pBuffer;
+    pClient->conn->cbBuffer = cbBuffer;
+#ifdef VBOX_WITH_CRHGSMI
+    CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+#endif
+
+    crVBoxServerInternalClientWriteRead(pClient);
+
+    return VINF_SUCCESS;
+}
+
+int32_t crVBoxServerInternalClientRead(CRClient *pClient, uint8_t *pBuffer, uint32_t *pcbBuffer)
+{
+    if (pClient->conn->cbHostBuffer > *pcbBuffer)
+    {
+        crDebug("crServer: [%lx] ClientRead u32ClientID=%d FAIL, host buffer too small %d of %d",
+                  crThreadID(), pClient->conn->u32ClientID, *pcbBuffer, pClient->conn->cbHostBuffer);
+
+        /* Return the size of needed buffer */
+        *pcbBuffer = pClient->conn->cbHostBuffer;
+
+        return VERR_BUFFER_OVERFLOW;
+    }
+
+    *pcbBuffer = pClient->conn->cbHostBuffer;
+
+    if (*pcbBuffer)
+    {
+        CRASSERT(pClient->conn->pHostBuffer);
+
+        crMemcpy(pBuffer, pClient->conn->pHostBuffer, *pcbBuffer);
+        pClient->conn->cbHostBuffer = 0;
+    }
+
+    return VINF_SUCCESS;
+}
+
+int32_t crVBoxServerClientRead(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t *pcbBuffer)
+{
+    CRClient *pClient=NULL;
+    int32_t rc = crVBoxServerClientGet(u32ClientID, &pClient);
+
+    if (RT_FAILURE(rc))
+        return rc;
+
+#ifdef VBOX_WITH_CRHGSMI
+    CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+#endif
+
+    return crVBoxServerInternalClientRead(pClient, pBuffer, pcbBuffer);
+}
+
+extern DECLEXPORT(int32_t) crVBoxServerClientGetCapsLegacy(uint32_t u32ClientID, uint32_t *pu32Caps)
+{
+    uint32_t u32Caps = cr_server.u32Caps;
+    u32Caps &= ~CR_VBOX_CAP_CMDVBVA;
+    *pu32Caps = u32Caps;
+    return VINF_SUCCESS;
+}
+
+extern DECLEXPORT(int32_t) crVBoxServerClientGetCapsNew(uint32_t u32ClientID, CR_CAPS_INFO *pInfo)
+{
+    pInfo->u32Caps = cr_server.u32Caps;
+    pInfo->u32CmdVbvaVersion = CR_CMDVBVA_VERSION;
+    return VINF_SUCCESS;
+}
+
+static int32_t crVBoxServerClientObjSetVersion(CRClient *pClient, uint32_t vMajor, uint32_t vMinor)
+{
+    pClient->conn->vMajor = vMajor;
+    pClient->conn->vMinor = vMinor;
+
+    if (vMajor != CR_PROTOCOL_VERSION_MAJOR
+        || vMinor != CR_PROTOCOL_VERSION_MINOR)
+        return VERR_NOT_SUPPORTED;
+    return VINF_SUCCESS;
+}
+
+int32_t crVBoxServerClientSetVersion(uint32_t u32ClientID, uint32_t vMajor, uint32_t vMinor)
+{
+    CRClient *pClient=NULL;
+    int32_t i;
+
+    for (i = 0; i < cr_server.numClients; i++)
+    {
+        if (cr_server.clients[i] && cr_server.clients[i]->conn
+            && cr_server.clients[i]->conn->u32ClientID==u32ClientID)
+        {
+            pClient = cr_server.clients[i];
+            break;
+        }
+    }
+    if (!pClient) return VERR_INVALID_PARAMETER;
+
+    return crVBoxServerClientObjSetVersion(pClient, vMajor, vMinor);
+}
+
+static int32_t crVBoxServerClientObjSetPID(CRClient *pClient, uint64_t pid)
+{
+    pClient->pid = pid;
+
+    return VINF_SUCCESS;
+}
+
+int32_t crVBoxServerClientSetPID(uint32_t u32ClientID, uint64_t pid)
+{
+    CRClient *pClient=NULL;
+    int32_t i;
+
+    for (i = 0; i < cr_server.numClients; i++)
+    {
+        if (cr_server.clients[i] && cr_server.clients[i]->conn
+            && cr_server.clients[i]->conn->u32ClientID==u32ClientID)
+        {
+            pClient = cr_server.clients[i];
+            break;
+        }
+    }
+    if (!pClient) return VERR_INVALID_PARAMETER;
+
+    return crVBoxServerClientObjSetPID(pClient, pid);
+}
+
+static void crVBoxServerSaveMuralCB(unsigned long key, void *data1, void *data2)
+{
+    CRMuralInfo *pMI = (CRMuralInfo*) data1;
+    PSSMHANDLE pSSM = (PSSMHANDLE) data2;
+    int32_t rc;
+
+    CRASSERT(pMI && pSSM);
+
+    /* Don't store default mural */
+    if (!key) return;
+
+    rc = SSMR3PutMem(pSSM, &key, sizeof(key));
+    CRASSERT(rc == VINF_SUCCESS);
+
+    rc = SSMR3PutMem(pSSM, pMI, RT_UOFFSETOF(CRMuralInfo, CreateInfo));
+    CRASSERT(rc == VINF_SUCCESS);
+
+    if (pMI->pVisibleRects)
+    {
+        rc = SSMR3PutMem(pSSM, pMI->pVisibleRects, 4*sizeof(GLint)*pMI->cVisibleRects);
+    }
+
+    rc = SSMR3PutMem(pSSM, pMI->ctxUsage, sizeof (pMI->ctxUsage));
+    CRASSERT(rc == VINF_SUCCESS);
+}
+
+/** @todo add hashtable walker with result info and intermediate abort */
+static void crVBoxServerSaveCreateInfoCB(unsigned long key, void *data1, void *data2)
+{
+    CRCreateInfo_t *pCreateInfo = (CRCreateInfo_t *)data1;
+    PSSMHANDLE pSSM = (PSSMHANDLE) data2;
+    int32_t rc;
+
+    CRASSERT(pCreateInfo && pSSM);
+
+    /* Don't store default mural create info */
+    if (!key) return;
+
+    rc = SSMR3PutMem(pSSM, &key, sizeof(key));
+    CRASSERT(rc == VINF_SUCCESS);
+
+    rc = SSMR3PutMem(pSSM, pCreateInfo, sizeof(*pCreateInfo));
+    CRASSERT(rc == VINF_SUCCESS);
+
+    if (pCreateInfo->pszDpyName)
+    {
+        rc = SSMR3PutStrZ(pSSM, pCreateInfo->pszDpyName);
+        CRASSERT(rc == VINF_SUCCESS);
+    }
+}
+
+static void crVBoxServerSaveCreateInfoFromMuralInfoCB(unsigned long key, void *data1, void *data2)
+{
+    CRMuralInfo *pMural = (CRMuralInfo *)data1;
+    CRCreateInfo_t CreateInfo;
+    CreateInfo.pszDpyName = pMural->CreateInfo.pszDpyName;
+    CreateInfo.visualBits = pMural->CreateInfo.requestedVisualBits;
+    CreateInfo.externalID = pMural->CreateInfo.externalID;
+    crVBoxServerSaveCreateInfoCB(key, &CreateInfo, data2);
+}
+
+static void crVBoxServerSaveCreateInfoFromCtxInfoCB(unsigned long key, void *data1, void *data2)
+{
+    CRContextInfo *pContextInfo = (CRContextInfo *)data1;
+    CRCreateInfo_t CreateInfo;
+    CreateInfo.pszDpyName = pContextInfo->CreateInfo.pszDpyName;
+    CreateInfo.visualBits = pContextInfo->CreateInfo.requestedVisualBits;
+    /* saved state contains internal id */
+    CreateInfo.externalID = pContextInfo->pContext->id;
+    crVBoxServerSaveCreateInfoCB(key, &CreateInfo, data2);
+}
+
+static void crVBoxServerSyncTextureCB(unsigned long key, void *data1, void *data2)
+{
+    CRTextureObj *pTexture = (CRTextureObj *) data1;
+    CRContext *pContext = (CRContext *) data2;
+
+    CRASSERT(pTexture && pContext);
+    crStateTextureObjectDiff(pContext, NULL, NULL, pTexture, GL_TRUE);
+}
+
+typedef struct CRVBOX_SAVE_STATE_GLOBAL
+{
+    /* context id -> mural association
+     * on context data save, each context will be made current with the corresponding mural from this table
+     * thus saving the mural front & back buffer data */
+    CRHashTable *contextMuralTable;
+    /* mural id -> context info
+     * for murals that do not have associated context in contextMuralTable
+     * we still need to save*/
+    CRHashTable *additionalMuralContextTable;
+
+    PSSMHANDLE pSSM;
+
+    int rc;
+} CRVBOX_SAVE_STATE_GLOBAL, *PCRVBOX_SAVE_STATE_GLOBAL;
+
+
+typedef struct CRVBOX_CTXWND_CTXWALKER_CB
+{
+    PCRVBOX_SAVE_STATE_GLOBAL pGlobal;
+    CRHashTable *usedMuralTable;
+    GLuint cAdditionalMurals;
+} CRVBOX_CTXWND_CTXWALKER_CB, *PCRVBOX_CTXWND_CTXWALKER_CB;
+
+static void crVBoxServerBuildAdditionalWindowContextMapCB(unsigned long key, void *data1, void *data2)
+{
+    CRMuralInfo * pMural = (CRMuralInfo *) data1;
+    PCRVBOX_CTXWND_CTXWALKER_CB pData = (PCRVBOX_CTXWND_CTXWALKER_CB)data2;
+    CRContextInfo *pContextInfo = NULL;
+
+    if (!pMural->CreateInfo.externalID)
+    {
+        CRASSERT(!key);
+        return;
+    }
+
+    if (crHashtableSearch(pData->usedMuralTable, pMural->CreateInfo.externalID))
+    {
+        Assert(crHashtableGetDataKey(pData->pGlobal->contextMuralTable, pMural, NULL));
+        return;
+    }
+
+    Assert(!crHashtableGetDataKey(pData->pGlobal->contextMuralTable, pMural, NULL));
+
+    if (cr_server.MainContextInfo.CreateInfo.realVisualBits == pMural->CreateInfo.realVisualBits)
+    {
+        pContextInfo = &cr_server.MainContextInfo;
+    }
+    else
+    {
+        crWarning("different visual bits not implemented!");
+        pContextInfo = &cr_server.MainContextInfo;
+    }
+
+    crHashtableAdd(pData->pGlobal->additionalMuralContextTable, pMural->CreateInfo.externalID, pContextInfo);
+}
+
+
+typedef struct CRVBOX_CTXWND_WNDWALKER_CB
+{
+    PCRVBOX_SAVE_STATE_GLOBAL pGlobal;
+    CRHashTable *usedMuralTable;
+    CRContextInfo *pContextInfo;
+    CRMuralInfo * pMural;
+} CRVBOX_CTXWND_WNDWALKER_CB, *PCRVBOX_CTXWND_WNDWALKER_CB;
+
+static void crVBoxServerBuildContextWindowMapWindowWalkerCB(unsigned long key, void *data1, void *data2)
+{
+    CRMuralInfo * pMural = (CRMuralInfo *) data1;
+    PCRVBOX_CTXWND_WNDWALKER_CB pData = (PCRVBOX_CTXWND_WNDWALKER_CB)data2;
+
+    Assert(pData->pMural != pMural);
+    Assert(pData->pContextInfo);
+
+    if (pData->pMural)
+        return;
+
+    if (!pMural->CreateInfo.externalID)
+    {
+        CRASSERT(!key);
+        return;
+    }
+
+    if (!CR_STATE_SHAREDOBJ_USAGE_IS_SET(pMural, pData->pContextInfo->pContext))
+        return;
+
+    if (crHashtableSearch(pData->usedMuralTable, pMural->CreateInfo.externalID))
+        return;
+
+    CRASSERT(pMural->CreateInfo.realVisualBits == pData->pContextInfo->CreateInfo.realVisualBits);
+    pData->pMural = pMural;
+}
+
+static void crVBoxServerBuildContextUsedWindowMapCB(unsigned long key, void *data1, void *data2)
+{
+    CRContextInfo *pContextInfo = (CRContextInfo *)data1;
+    PCRVBOX_CTXWND_CTXWALKER_CB pData = (PCRVBOX_CTXWND_CTXWALKER_CB)data2;
+
+    if (!pContextInfo->currentMural)
+        return;
+
+    crHashtableAdd(pData->pGlobal->contextMuralTable, pContextInfo->CreateInfo.externalID, pContextInfo->currentMural);
+    crHashtableAdd(pData->usedMuralTable, pContextInfo->currentMural->CreateInfo.externalID, pContextInfo->currentMural);
+}
+
+CRMuralInfo * crServerGetDummyMural(GLint visualBits)
+{
+    CRMuralInfo * pMural = (CRMuralInfo *)crHashtableSearch(cr_server.dummyMuralTable, visualBits);
+    if (!pMural)
+    {
+        GLint id;
+        pMural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo));
+        if (!pMural)
+        {
+            crWarning("crCalloc failed!");
+            return NULL;
+        }
+        id = crServerMuralInit(pMural, GL_FALSE, visualBits, 0);
+        if (id < 0)
+        {
+            crWarning("crServerMuralInit failed!");
+            crFree(pMural);
+            return NULL;
+        }
+
+        crHashtableAdd(cr_server.dummyMuralTable, visualBits, pMural);
+    }
+
+    return pMural;
+}
+
+static void crVBoxServerBuildContextUnusedWindowMapCB(unsigned long key, void *data1, void *data2)
+{
+    CRContextInfo *pContextInfo = (CRContextInfo *)data1;
+    PCRVBOX_CTXWND_CTXWALKER_CB pData = (PCRVBOX_CTXWND_CTXWALKER_CB)data2;
+    CRMuralInfo * pMural = NULL;
+
+    if (pContextInfo->currentMural)
+        return;
+
+    Assert(crHashtableNumElements(pData->pGlobal->contextMuralTable) <= crHashtableNumElements(cr_server.muralTable) - 1);
+    if (crHashtableNumElements(pData->pGlobal->contextMuralTable) < crHashtableNumElements(cr_server.muralTable) - 1)
+    {
+        CRVBOX_CTXWND_WNDWALKER_CB MuralData;
+        MuralData.pGlobal = pData->pGlobal;
+        MuralData.usedMuralTable = pData->usedMuralTable;
+        MuralData.pContextInfo = pContextInfo;
+        MuralData.pMural = NULL;
+
+        crHashtableWalk(cr_server.muralTable, crVBoxServerBuildContextWindowMapWindowWalkerCB, &MuralData);
+
+        pMural = MuralData.pMural;
+
+    }
+
+    if (!pMural)
+    {
+        pMural = crServerGetDummyMural(pContextInfo->CreateInfo.realVisualBits);
+        if (!pMural)
+        {
+            crWarning("crServerGetDummyMural failed");
+            return;
+        }
+    }
+    else
+    {
+        crHashtableAdd(pData->usedMuralTable, pMural->CreateInfo.externalID, pMural);
+        ++pData->cAdditionalMurals;
+    }
+
+    crHashtableAdd(pData->pGlobal->contextMuralTable, pContextInfo->CreateInfo.externalID, pMural);
+}
+
+static void crVBoxServerBuildSaveStateGlobal(PCRVBOX_SAVE_STATE_GLOBAL pGlobal)
+{
+    CRVBOX_CTXWND_CTXWALKER_CB Data;
+    GLuint cMurals;
+    pGlobal->contextMuralTable = crAllocHashtable();
+    pGlobal->additionalMuralContextTable = crAllocHashtable();
+    /* 1. go through all contexts and match all having currentMural set */
+    Data.pGlobal = pGlobal;
+    Data.usedMuralTable = crAllocHashtable();
+    Data.cAdditionalMurals = 0;
+    crHashtableWalk(cr_server.contextTable, crVBoxServerBuildContextUsedWindowMapCB, &Data);
+
+    cMurals = crHashtableNumElements(pGlobal->contextMuralTable);
+    CRASSERT(cMurals <= crHashtableNumElements(cr_server.contextTable));
+    CRASSERT(cMurals <= crHashtableNumElements(cr_server.muralTable) - 1);
+    CRASSERT(cMurals == crHashtableNumElements(Data.usedMuralTable));
+    if (cMurals < crHashtableNumElements(cr_server.contextTable))
+    {
+        Data.cAdditionalMurals = 0;
+        crHashtableWalk(cr_server.contextTable, crVBoxServerBuildContextUnusedWindowMapCB, &Data);
+    }
+
+    CRASSERT(crHashtableNumElements(pGlobal->contextMuralTable) == crHashtableNumElements(cr_server.contextTable));
+    CRASSERT(cMurals + Data.cAdditionalMurals <= crHashtableNumElements(cr_server.muralTable) - 1);
+    if (cMurals + Data.cAdditionalMurals < crHashtableNumElements(cr_server.muralTable) - 1)
+    {
+        crHashtableWalk(cr_server.muralTable, crVBoxServerBuildAdditionalWindowContextMapCB, &Data);
+        CRASSERT(cMurals + Data.cAdditionalMurals + crHashtableNumElements(pGlobal->additionalMuralContextTable) == crHashtableNumElements(cr_server.muralTable) - 1);
+    }
+
+    crFreeHashtable(Data.usedMuralTable, NULL);
+}
+
+static void crVBoxServerFBImageDataTerm(CRFBData *pData)
+{
+    GLuint i;
+    for (i = 0; i < pData->cElements; ++i)
+    {
+        CRFBDataElement * pEl = &pData->aElements[i];
+        if (pEl->pvData)
+        {
+            crFree(pEl->pvData);
+            /* sanity */
+            pEl->pvData = NULL;
+        }
+    }
+    pData->cElements = 0;
+}
+
+static int crVBoxAddFBDataElement(CRFBData *pData, GLint idFBO, GLenum enmBuffer, GLint width, GLint height, GLenum enmFormat, GLenum enmType)
+{
+    CRFBDataElement *pEl;
+
+    AssertCompile(sizeof (GLfloat) == 4);
+    AssertCompile(sizeof (GLuint) == 4);
+
+    pEl = &pData->aElements[pData->cElements];
+    pEl->idFBO = idFBO;
+    pEl->enmBuffer = enmBuffer;
+    pEl->posX = 0;
+    pEl->posY = 0;
+    pEl->width = width;
+    pEl->height = height;
+    pEl->enmFormat = enmFormat;
+    pEl->enmType = enmType;
+    pEl->cbData = width * height * 4;
+
+    pEl->pvData = crCalloc(pEl->cbData);
+    if (!pEl->pvData)
+    {
+        crVBoxServerFBImageDataTerm(pData);
+        crWarning(": crCalloc failed");
+        return VERR_NO_MEMORY;
+    }
+
+    ++pData->cElements;
+
+    return VINF_SUCCESS;
+}
+
+/* Add framebuffer image elements arrording to SSM version. Please refer to cr_version.h
+ * in order to distinguish between versions. */
+static int crVBoxServerFBImageDataInitEx(CRFBData *pData, CRContextInfo *pCtxInfo, CRMuralInfo *pMural, GLboolean fWrite, uint32_t version, GLuint overrideWidth, GLuint overrideHeight)
+{
+    CRContext *pContext;
+    GLuint i;
+    GLfloat *pF;
+    GLuint width;
+    GLuint height;
+    int rc;
+
+    crMemset(pData, 0, sizeof (*pData));
+
+    pContext = pCtxInfo->pContext;
+
+    /* the version should be always actual when we do reads,
+     * i.e. it could differ on writes when snapshot is getting loaded */
+    CRASSERT(fWrite || version == SHCROGL_SSM_VERSION);
+
+    width = overrideWidth ? overrideWidth : pMural->width;
+    height = overrideHeight ? overrideHeight : pMural->height;
+
+    if (!width || !height)
+        return VINF_SUCCESS;
+
+    if (pMural)
+    {
+        if (fWrite)
+        {
+            if (!pContext->framebufferobject.drawFB)
+                pData->idOverrrideFBO = CR_SERVER_FBO_FOR_IDX(pMural, pMural->iCurDrawBuffer);
+        }
+        else
+        {
+            if (!pContext->framebufferobject.readFB)
+                pData->idOverrrideFBO = CR_SERVER_FBO_FOR_IDX(pMural, pMural->iCurReadBuffer);
+        }
+    }
+
+    pData->u32Version = version;
+
+    pData->cElements = 0;
+
+    rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0,
+        pData->aElements[1].idFBO ? GL_COLOR_ATTACHMENT0 : GL_FRONT, width, height, GL_RGBA, GL_UNSIGNED_BYTE);
+    AssertReturn(rc == VINF_SUCCESS, rc);
+
+    /* There is a lot of code that assumes we have double buffering, just assert here to print a warning in the log
+     * so that we know that something irregular is going on. */
+    CRASSERT(pCtxInfo->CreateInfo.requestedVisualBits & CR_DOUBLE_BIT);
+
+    if ((   pCtxInfo->CreateInfo.requestedVisualBits & CR_DOUBLE_BIT)
+         || version < SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL) /* <- Older version had a typo which lead to back always being used,
+                                                                      *    no matter what the visual bits are. */
+    {
+        rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_BB_IDX(pMural)] : 0,
+            pData->aElements[1].idFBO ? GL_COLOR_ATTACHMENT0 : GL_BACK, width, height, GL_RGBA, GL_UNSIGNED_BYTE);
+        AssertReturn(rc == VINF_SUCCESS, rc);
+    }
+
+    if (version < SHCROGL_SSM_VERSION_WITH_SAVED_DEPTH_STENCIL_BUFFER)
+        return VINF_SUCCESS;
+
+    if (version < SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL)
+    {
+        rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0,
+            pMural ? pMural->idDepthStencilRB : 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT);
+        AssertReturn(rc == VINF_SUCCESS, rc);
+
+        /* Init to default depth value, just in case. "pData->cElements - 1" because we incremented counter in crVBoxAddFBDataElement(). */
+        pF = (GLfloat*)pData->aElements[pData->cElements - 1].pvData;
+        for (i = 0; i < width * height; ++i)
+            pF[i] = 1.;
+
+        rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0,
+            pMural ? pMural->idDepthStencilRB : 0, width, height, GL_STENCIL_INDEX, GL_UNSIGNED_INT);
+        AssertReturn(rc == VINF_SUCCESS, rc);
+
+        return VINF_SUCCESS;
+    }
+
+    if (version < SHCROGL_SSM_VERSION_WITH_SEPARATE_DEPTH_STENCIL_BUFFERS)
+    {
+        /* Use GL_DEPTH_STENCIL only in case if both CR_STENCIL_BIT and CR_DEPTH_BIT specified. */
+        if (   (pCtxInfo->CreateInfo.requestedVisualBits & CR_STENCIL_BIT)
+            && (pCtxInfo->CreateInfo.requestedVisualBits & CR_DEPTH_BIT))
+        {
+            rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0, 0,
+                width, height, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
+            AssertReturn(rc == VINF_SUCCESS, rc);
+        }
+
+        return VINF_SUCCESS;
+    }
+
+    /* Current SSM verion (SHCROGL_SSM_VERSION_WITH_SEPARATE_DEPTH_STENCIL_BUFFERS). */
+
+    if (pCtxInfo->CreateInfo.requestedVisualBits & CR_DEPTH_BIT)
+    {
+        rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0,
+            pMural ? pMural->idDepthStencilRB : 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT);
+        AssertReturn(rc == VINF_SUCCESS, rc);
+
+        /* Init to default depth value, just in case. "pData->cElements - 1" because we incremented counter in crVBoxAddFBDataElement(). */
+        pF = (GLfloat*)pData->aElements[pData->cElements - 1].pvData;
+        for (i = 0; i < width * height; ++i)
+            pF[i] = 1.;
+    }
+
+    if (pCtxInfo->CreateInfo.requestedVisualBits & CR_STENCIL_BIT)
+    {
+        rc = crVBoxAddFBDataElement(pData, pMural && pMural->fRedirected ? pMural->aidFBOs[CR_SERVER_FBO_FB_IDX(pMural)] : 0,
+            pMural ? pMural->idDepthStencilRB : 0, width, height, GL_STENCIL_INDEX, GL_UNSIGNED_INT);
+        AssertReturn(rc == VINF_SUCCESS, rc);
+    }
+
+    return VINF_SUCCESS;
+}
+
+static int crVBoxServerSaveFBImage(PSSMHANDLE pSSM)
+{
+    CRContextInfo *pCtxInfo;
+    CRContext *pContext;
+    CRMuralInfo *pMural;
+    int32_t rc;
+    GLuint i;
+    struct
+    {
+        CRFBData data;
+        CRFBDataElement buffer[3]; /* CRFBData::aElements[1] + buffer[3] gives 4: back, front, depth and stencil  */
+    } Data;
+
+    Assert(sizeof (Data) >= RT_UOFFSETOF(CRFBData, aElements[4]));
+
+    pCtxInfo = cr_server.currentCtxInfo;
+    pContext = pCtxInfo->pContext;
+    pMural = pCtxInfo->currentMural;
+
+    rc = crVBoxServerFBImageDataInitEx(&Data.data, pCtxInfo, pMural, GL_FALSE, SHCROGL_SSM_VERSION, 0, 0);
+    if (!RT_SUCCESS(rc))
+    {
+        crWarning("crVBoxServerFBImageDataInit failed rc %d", rc);
+        return rc;
+    }
+
+    rc = crStateAcquireFBImage(pContext, &Data.data);
+    AssertRCReturn(rc, rc);
+
+    for (i = 0; i < Data.data.cElements; ++i)
+    {
+        CRFBDataElement * pEl = &Data.data.aElements[i];
+        rc = SSMR3PutMem(pSSM, pEl->pvData, pEl->cbData);
+        AssertRCReturn(rc, rc);
+    }
+
+    crVBoxServerFBImageDataTerm(&Data.data);
+
+    return VINF_SUCCESS;
+}
+
+#define CRSERVER_ASSERTRC_RETURN_VOID(_rc) do { \
+        if(!RT_SUCCESS((_rc))) { \
+            AssertFailed(); \
+            return; \
+        } \
+    } while (0)
+
+static void crVBoxServerSaveAdditionalMuralsCB(unsigned long key, void *data1, void *data2)
+{
+    CRContextInfo *pContextInfo = (CRContextInfo *) data1;
+    PCRVBOX_SAVE_STATE_GLOBAL pData = (PCRVBOX_SAVE_STATE_GLOBAL)data2;
+    CRMuralInfo *pMural = (CRMuralInfo*)crHashtableSearch(cr_server.muralTable, key);
+    PSSMHANDLE pSSM = pData->pSSM;
+    CRbitvalue initialCtxUsage[CR_MAX_BITARRAY];
+    CRMuralInfo *pInitialCurMural = pContextInfo->currentMural;
+
+    crMemcpy(initialCtxUsage, pMural->ctxUsage, sizeof (initialCtxUsage));
+
+    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
+
+    pData->rc = SSMR3PutMem(pSSM, &key, sizeof(key));
+    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
+
+    pData->rc = SSMR3PutMem(pSSM, &pContextInfo->CreateInfo.externalID, sizeof(pContextInfo->CreateInfo.externalID));
+    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
+
+    crServerPerformMakeCurrent(pMural, pContextInfo);
+
+    pData->rc = crVBoxServerSaveFBImage(pSSM);
+
+    /* restore the reference data, we synchronize it with the HW state in a later crServerPerformMakeCurrent call */
+    crMemcpy(pMural->ctxUsage, initialCtxUsage, sizeof (initialCtxUsage));
+    pContextInfo->currentMural = pInitialCurMural;
+
+    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
+}
+
+static void crVBoxServerSaveContextStateCB(unsigned long key, void *data1, void *data2)
+{
+    CRContextInfo *pContextInfo = (CRContextInfo *) data1;
+    CRContext *pContext = pContextInfo->pContext;
+    PCRVBOX_SAVE_STATE_GLOBAL pData = (PCRVBOX_SAVE_STATE_GLOBAL)data2;
+    PSSMHANDLE pSSM = pData->pSSM;
+    CRMuralInfo *pMural = (CRMuralInfo*)crHashtableSearch(pData->contextMuralTable, key);
+    CRMuralInfo *pContextCurrentMural = pContextInfo->currentMural;
+    const int32_t i32Dummy = 0;
+
+    AssertCompile(sizeof (i32Dummy) == sizeof (pMural->CreateInfo.externalID));
+    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
+
+    CRASSERT(pContext && pSSM);
+    CRASSERT(pMural);
+    CRASSERT(pMural->CreateInfo.externalID);
+
+    /* We could have skipped saving the key and use similar callback to load context states back,
+     * but there's no guarantee we'd traverse hashtable in same order after loading.
+     */
+    pData->rc = SSMR3PutMem(pSSM, &key, sizeof(key));
+    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
+
+#ifdef DEBUG_misha
+    {
+            unsigned long id;
+            if (!crHashtableGetDataKey(cr_server.contextTable, pContextInfo, &id))
+                crWarning("No client id for server ctx %d", pContextInfo->CreateInfo.externalID);
+            else
+                CRASSERT(id == key);
+    }
+#endif
+
+#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
+    if (pContextInfo->currentMural
+            || crHashtableSearch(cr_server.muralTable, pMural->CreateInfo.externalID) /* <- this is not a dummy mural */
+            )
+    {
+        CRASSERT(pMural->CreateInfo.externalID);
+        CRASSERT(!crHashtableSearch(cr_server.dummyMuralTable, pMural->CreateInfo.externalID));
+        pData->rc = SSMR3PutMem(pSSM, &pMural->CreateInfo.externalID, sizeof(pMural->CreateInfo.externalID));
+    }
+    else
+    {
+        /* this is a dummy mural */
+        CRASSERT(!pMural->width);
+        CRASSERT(!pMural->height);
+        CRASSERT(crHashtableSearch(cr_server.dummyMuralTable, pMural->CreateInfo.externalID));
+        pData->rc = SSMR3PutMem(pSSM, &i32Dummy, sizeof(pMural->CreateInfo.externalID));
+    }
+    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
+
+    CRASSERT(CR_STATE_SHAREDOBJ_USAGE_IS_SET(pMural, pContext));
+    CRASSERT(pContextInfo->currentMural == pMural || !pContextInfo->currentMural);
+    CRASSERT(cr_server.curClient);
+
+    crServerPerformMakeCurrent(pMural, pContextInfo);
+#endif
+
+    pData->rc = crStateSaveContext(pContext, pSSM);
+    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
+
+    pData->rc = crVBoxServerSaveFBImage(pSSM);
+    CRSERVER_ASSERTRC_RETURN_VOID(pData->rc);
+
+    /* restore the initial current mural */
+    pContextInfo->currentMural = pContextCurrentMural;
+}
+
+static uint32_t g_hackVBoxServerSaveLoadCallsLeft = 0;
+
+static int32_t crVBoxServerSaveStatePerform(PSSMHANDLE pSSM)
+{
+    int32_t  rc, i;
+    uint32_t ui32;
+    GLboolean b;
+    unsigned long key;
+    GLenum err;
+#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
+    CRClient *curClient;
+    CRMuralInfo *curMural = NULL;
+    CRContextInfo *curCtxInfo = NULL;
+#endif
+    CRVBOX_SAVE_STATE_GLOBAL Data;
+
+    crMemset(&Data, 0, sizeof (Data));
+
+#if 0
+    crVBoxServerCheckConsistency();
+#endif
+
+    /* We shouldn't be called if there's no clients at all*/
+    CRASSERT(cr_server.numClients > 0);
+
+    /** @todo it's hack atm */
+    /* We want to be called only once to save server state but atm we're being called from svcSaveState
+     * for every connected client (e.g. guest opengl application)
+     */
+    if (!cr_server.bIsInSavingState) /* It's first call */
+    {
+        cr_server.bIsInSavingState = GL_TRUE;
+
+        /* Store number of clients */
+        rc = SSMR3PutU32(pSSM, (uint32_t) cr_server.numClients);
+        AssertRCReturn(rc, rc);
+
+        /* we get called only once for CrCmd case, so disable the hack */
+        g_hackVBoxServerSaveLoadCallsLeft = cr_server.fCrCmdEnabled ? 1 : cr_server.numClients;
+    }
+
+    g_hackVBoxServerSaveLoadCallsLeft--;
+
+    /* Do nothing until we're being called last time */
+    if (g_hackVBoxServerSaveLoadCallsLeft>0)
+    {
+        return VINF_SUCCESS;
+    }
+
+#ifdef DEBUG_misha
+#define CR_DBG_STR_STATE_SAVE_START "VBox.Cr.StateSaveStart"
+#define CR_DBG_STR_STATE_SAVE_STOP "VBox.Cr.StateSaveStop"
+
+    if (cr_server.head_spu->dispatch_table.StringMarkerGREMEDY)
+        cr_server.head_spu->dispatch_table.StringMarkerGREMEDY(sizeof (CR_DBG_STR_STATE_SAVE_START), CR_DBG_STR_STATE_SAVE_START);
+#endif
+
+    /* Save rendering contexts creation info */
+    ui32 = crHashtableNumElements(cr_server.contextTable);
+    rc = SSMR3PutU32(pSSM, (uint32_t) ui32);
+    AssertRCReturn(rc, rc);
+    crHashtableWalk(cr_server.contextTable, crVBoxServerSaveCreateInfoFromCtxInfoCB, pSSM);
+
+#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
+    curClient = cr_server.curClient;
+    /* Save current win and ctx IDs, as we'd rebind contexts when saving textures */
+    if (curClient)
+    {
+        curCtxInfo = cr_server.curClient->currentCtxInfo;
+        curMural = cr_server.curClient->currentMural;
+    }
+    else if (cr_server.numClients)
+    {
+        cr_server.curClient = cr_server.clients[0];
+    }
+#endif
+
+    /* first save windows info */
+    /* Save windows creation info */
+    ui32 = crHashtableNumElements(cr_server.muralTable);
+    /* There should be default mural always */
+    CRASSERT(ui32>=1);
+    rc = SSMR3PutU32(pSSM, (uint32_t) ui32-1);
+    AssertRCReturn(rc, rc);
+    crHashtableWalk(cr_server.muralTable, crVBoxServerSaveCreateInfoFromMuralInfoCB, pSSM);
+
+    /* Save cr_server.muralTable
+     * @todo we don't need it all, just geometry info actually
+     */
+    rc = SSMR3PutU32(pSSM, (uint32_t) ui32-1);
+    AssertRCReturn(rc, rc);
+    crHashtableWalk(cr_server.muralTable, crVBoxServerSaveMuralCB, pSSM);
+
+    /* we need to save front & backbuffer data for each mural first create a context -> mural association */
+    crVBoxServerBuildSaveStateGlobal(&Data);
+
+    rc = crStateSaveGlobals(pSSM);
+    AssertRCReturn(rc, rc);
+
+    Data.pSSM = pSSM;
+    /* Save contexts state tracker data */
+    /** @todo For now just some blind data dumps,
+     * but I've a feeling those should be saved/restored in a very strict sequence to
+     * allow diff_api to work correctly.
+     * Should be tested more with multiply guest opengl apps working when saving VM snapshot.
+     */
+    crHashtableWalk(cr_server.contextTable, crVBoxServerSaveContextStateCB, &Data);
+    AssertRCReturn(Data.rc, Data.rc);
+
+    ui32 = crHashtableNumElements(Data.additionalMuralContextTable);
+    rc = SSMR3PutU32(pSSM, (uint32_t) ui32);
+    AssertRCReturn(rc, rc);
+
+    crHashtableWalk(Data.additionalMuralContextTable, crVBoxServerSaveAdditionalMuralsCB, &Data);
+    AssertRCReturn(Data.rc, Data.rc);
+
+#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE
+    cr_server.curClient = curClient;
+    /* Restore original win and ctx IDs*/
+    if (curClient && curMural && curCtxInfo)
+    {
+        crServerPerformMakeCurrent(curMural, curCtxInfo);
+    }
+    else
+    {
+        cr_server.bForceMakeCurrentOnClientSwitch = GL_TRUE;
+    }
+#endif
+
+    /* Save clients info */
+    for (i = 0; i < cr_server.numClients; i++)
+    {
+        if (cr_server.clients[i] && cr_server.clients[i]->conn)
+        {
+            CRClient *pClient = cr_server.clients[i];
+
+            rc = SSMR3PutU32(pSSM, pClient->conn->u32ClientID);
+            AssertRCReturn(rc, rc);
+
+            rc = SSMR3PutU32(pSSM, pClient->conn->vMajor);
+            AssertRCReturn(rc, rc);
+
+            rc = SSMR3PutU32(pSSM, pClient->conn->vMinor);
+            AssertRCReturn(rc, rc);
+
+            rc = SSMR3PutMem(pSSM, pClient, sizeof(*pClient));
+            AssertRCReturn(rc, rc);
+
+            if (pClient->currentCtxInfo && pClient->currentCtxInfo->pContext && pClient->currentContextNumber > 0)
+            {
+                b = crHashtableGetDataKey(cr_server.contextTable, pClient->currentCtxInfo, &key);
+                CRASSERT(b);
+                rc = SSMR3PutMem(pSSM, &key, sizeof(key));
+                AssertRCReturn(rc, rc);
+            }
+
+            if (pClient->currentMural && pClient->currentWindow > 0)
+            {
+                b = crHashtableGetDataKey(cr_server.muralTable, pClient->currentMural, &key);
+                CRASSERT(b);
+                rc = SSMR3PutMem(pSSM, &key, sizeof(key));
+                AssertRCReturn(rc, rc);
+            }
+        }
+    }
+
+    rc = crServerPendSaveState(pSSM);
+    AssertRCReturn(rc, rc);
+
+    rc = CrPMgrSaveState(pSSM);
+    AssertRCReturn(rc, rc);
+
+    /* all context gl error states should have now be synced with chromium erro states,
+     * reset the error if any */
+    while ((err = cr_server.head_spu->dispatch_table.GetError()) != GL_NO_ERROR)
+        crWarning("crServer: glGetError %d after saving snapshot", err);
+
+    cr_server.bIsInSavingState = GL_FALSE;
+
+#ifdef DEBUG_misha
+    if (cr_server.head_spu->dispatch_table.StringMarkerGREMEDY)
+        cr_server.head_spu->dispatch_table.StringMarkerGREMEDY(sizeof (CR_DBG_STR_STATE_SAVE_STOP), CR_DBG_STR_STATE_SAVE_STOP);
+#endif
+
+    return VINF_SUCCESS;
+}
+
+DECLEXPORT(int32_t) crVBoxServerSaveState(PSSMHANDLE pSSM)
+{
+    if (cr_server.fCrCmdEnabled)
+    {
+        WARN(("we should not be called with cmd enabled!"));
+        return VERR_INTERNAL_ERROR;
+    }
+
+    return crVBoxServerSaveStatePerform(pSSM);
+}
+
+static DECLCALLBACK(CRContext*) crVBoxServerGetContextCB(void* pvData)
+{
+    CRContextInfo* pContextInfo = (CRContextInfo*)pvData;
+    CRASSERT(pContextInfo);
+    CRASSERT(pContextInfo->pContext);
+    return pContextInfo->pContext;
+}
+
+typedef struct CR_SERVER_LOADSTATE_READER
+{
+    PSSMHANDLE pSSM;
+    uint32_t cbBuffer;
+    uint32_t cbData;
+    uint32_t offData;
+    uint8_t *pu8Buffer;
+} CR_SERVER_LOADSTATE_READER;
+
+static void crServerLsrInit(CR_SERVER_LOADSTATE_READER *pReader, PSSMHANDLE pSSM)
+{
+    memset(pReader, 0, sizeof (*pReader));
+    pReader->pSSM = pSSM;
+}
+
+static void crServerLsrTerm(CR_SERVER_LOADSTATE_READER *pReader)
+{
+    if (pReader->pu8Buffer)
+        RTMemFree(pReader->pu8Buffer);
+
+    /* sanity */
+    memset(pReader, 0, sizeof (*pReader));
+}
+
+static int crServerLsrDataGetMem(CR_SERVER_LOADSTATE_READER *pReader, void *pvBuffer, uint32_t cbBuffer)
+{
+    int rc = VINF_SUCCESS;
+    uint32_t cbRemaining = cbBuffer;
+    if (pReader->cbData)
+    {
+        uint8_t cbData = RT_MIN(pReader->cbData, cbBuffer);
+        memcpy(pvBuffer, pReader->pu8Buffer + pReader->offData, cbData);
+        pReader->cbData -= cbData;
+        pReader->offData += cbData;
+
+        cbRemaining -= cbData;
+        pvBuffer = ((uint8_t*)pvBuffer) + cbData;
+    }
+
+    if (cbRemaining)
+    {
+        rc = SSMR3GetMem(pReader->pSSM, pvBuffer, cbRemaining);
+        AssertRC(rc);
+    }
+
+    return rc;
+}
+
+static int crServerLsrDataGetU32(CR_SERVER_LOADSTATE_READER *pReader, uint32_t *pu32)
+{
+    return crServerLsrDataGetMem(pReader, pu32, sizeof (*pu32));
+}
+
+static int crServerLsrDataPutMem(CR_SERVER_LOADSTATE_READER *pReader, void *pvBuffer, uint32_t cbBuffer)
+{
+    if (!pReader->cbData && pReader->cbBuffer >= cbBuffer)
+    {
+        pReader->offData = 0;
+        pReader->cbData = cbBuffer;
+        memcpy(pReader->pu8Buffer, pvBuffer, cbBuffer);
+    }
+    else if (pReader->offData >= cbBuffer)
+    {
+        pReader->offData -= cbBuffer;
+        pReader->cbData += cbBuffer;
+        memcpy(pReader->pu8Buffer + pReader->offData, pvBuffer, cbBuffer);
+    }
+    else
+    {
+        uint8_t *pu8Buffer = pReader->pu8Buffer;
+
+        pReader->pu8Buffer = (uint8_t*)RTMemAlloc(cbBuffer + pReader->cbData);
+        if (!pReader->pu8Buffer)
+        {
+            crWarning("failed to allocate mem %d", cbBuffer + pReader->cbData);
+            return VERR_NO_MEMORY;
+        }
+
+        memcpy(pReader->pu8Buffer, pvBuffer, cbBuffer);
+        if (pu8Buffer)
+        {
+            memcpy(pReader->pu8Buffer + cbBuffer, pu8Buffer + pReader->offData, pReader->cbData);
+            RTMemFree(pu8Buffer);
+        }
+        else
+        {
+            Assert(!pReader->cbData);
+        }
+        pReader->offData = 0;
+        pReader->cbData += cbBuffer;
+    }
+
+    return VINF_SUCCESS;
+}
+
+/* data to be skipped */
+
+typedef struct CR_SERVER_BUGGY_MURAL_DATA_2
+{
+    void*ListHead_pNext;
+    void*ListHead_pPrev;
+    uint32_t cEntries;
+} CR_SERVER_BUGGY_MURAL_DATA_2;
+typedef struct CR_SERVER_BUGGY_MURAL_DATA_1
+{
+    /* VBOXVR_COMPOSITOR_ENTRY Ce; */
+    void*Ce_Node_pNext;
+    void*Ce_Node_pPrev;
+    CR_SERVER_BUGGY_MURAL_DATA_2 Vr;
+    /* VBOXVR_TEXTURE Tex; */
+    uint32_t Tex_width;
+    uint32_t Tex_height;
+    uint32_t Tex_target;
+    uint32_t Tex_hwid;
+    /* RTPOINT Pos; */
+    uint32_t Pos_x;
+    uint32_t Pos_y;
+    uint32_t fChanged;
+    uint32_t cRects;
+    void* paSrcRects;
+    void* paDstRects;
+} CR_SERVER_BUGGY_MURAL_DATA_1;
+
+typedef struct CR_SERVER_BUGGY_MURAL_DATA_4
+{
+    uint32_t                   u32Magic;
+    int32_t                    cLockers;
+    RTNATIVETHREAD             NativeThreadOwner;
+    int32_t                    cNestings;
+    uint32_t                            fFlags;
+    void*                          EventSem;
+    R3R0PTRTYPE(PRTLOCKVALRECEXCL)      pValidatorRec;
+    RTHCPTR                             Alignment;
+} CR_SERVER_BUGGY_MURAL_DATA_4;
+
+typedef struct CR_SERVER_BUGGY_MURAL_DATA_3
+{
+    void*Compositor_List_pNext;
+    void*Compositor_List_pPrev;
+    void*Compositor_pfnEntryRemoved;
+    float StretchX;
+    float StretchY;
+    uint32_t cRects;
+    uint32_t cRectsBuffer;
+    void*paSrcRects;
+    void*paDstRects;
+    CR_SERVER_BUGGY_MURAL_DATA_4 CritSect;
+} CR_SERVER_BUGGY_MURAL_DATA_3;
+
+typedef struct CR_SERVER_BUGGY_MURAL_DATA
+{
+    uint8_t fRootVrOn;
+    CR_SERVER_BUGGY_MURAL_DATA_1 RootVrCEntry;
+    CR_SERVER_BUGGY_MURAL_DATA_3 RootVrCompositor;
+} CR_SERVER_BUGGY_MURAL_DATA;
+
+AssertCompile(sizeof (CR_SERVER_BUGGY_MURAL_DATA) < sizeof (CRClient));
+
+static int32_t crVBoxServerLoadMurals(CR_SERVER_LOADSTATE_READER *pReader, uint32_t version)
+{
+    unsigned long key;
+    uint32_t ui, uiNumElems;
+    bool fBuggyMuralData = false;
+    /* Load windows */
+    int32_t rc = crServerLsrDataGetU32(pReader, &uiNumElems);
+    AssertLogRelRCReturn(rc, rc);
+    for (ui=0; ui<uiNumElems; ++ui)
+    {
+        CRCreateInfo_t createInfo;
+        char psz[200];
+        GLint winID;
+        unsigned long key;
+
+        rc = crServerLsrDataGetMem(pReader, &key, sizeof(key));
+        AssertLogRelRCReturn(rc, rc);
+        rc = crServerLsrDataGetMem(pReader, &createInfo, sizeof(createInfo));
+        AssertLogRelRCReturn(rc, rc);
+
+        CRASSERT(!pReader->cbData);
+
+        if (createInfo.pszDpyName)
+        {
+            rc = SSMR3GetStrZEx(pReader->pSSM, psz, 200, NULL);
+            AssertLogRelRCReturn(rc, rc);
+            createInfo.pszDpyName = psz;
+        }
+
+        winID = crServerDispatchWindowCreateEx(createInfo.pszDpyName, createInfo.visualBits, key);
+        CRASSERT((int64_t)winID == (int64_t)key);
+    }
+
+    /* Load cr_server.muralTable */
+    rc = SSMR3GetU32(pReader->pSSM, &uiNumElems);
+    AssertLogRelRCReturn(rc, rc);
+    for (ui=0; ui<uiNumElems; ++ui)
+    {
+        CRMuralInfo muralInfo;
+        CRMuralInfo *pActualMural = NULL;
+
+        rc = crServerLsrDataGetMem(pReader, &key, sizeof(key));
+        AssertLogRelRCReturn(rc, rc);
+        rc = crServerLsrDataGetMem(pReader, &muralInfo, RT_UOFFSETOF(CRMuralInfo, CreateInfo));
+        AssertLogRelRCReturn(rc, rc);
+
+        if (version <= SHCROGL_SSM_VERSION_BEFORE_FRONT_DRAW_TRACKING)
+            muralInfo.bFbDraw = GL_TRUE;
+
+        if (!ui && version == SHCROGL_SSM_VERSION_WITH_BUGGY_MURAL_INFO)
+        {
+            /* Lookahead buffer used to determine whether the data erroneously stored root visible regions data */
+            union
+            {
+                void * apv[1];
+                CR_SERVER_BUGGY_MURAL_DATA Data;
+                /* need to chak spuWindow, so taking the offset of filed following it*/
+                uint8_t au8[RT_UOFFSETOF(CRMuralInfo, screenId)];
+                RTRECT aVisRects[sizeof (CR_SERVER_BUGGY_MURAL_DATA) / sizeof (RTRECT)];
+            } LaBuf;
+
+            do {
+                /* first value is bool (uint8_t) value followed by pointer-size-based alignment.
+                 * the mural memory is zero-initialized initially, so we can be sure the padding is zeroed */
+                rc = crServerLsrDataGetMem(pReader, &LaBuf, sizeof (LaBuf));
+                AssertLogRelRCReturn(rc, rc);
+                if (LaBuf.apv[0] != NULL && LaBuf.apv[0] != ((void *)(uintptr_t)1))
+                    break;
+
+                /* check that the pointers are either valid or NULL */
+                if(LaBuf.Data.RootVrCEntry.Ce_Node_pNext && !RT_VALID_PTR(LaBuf.Data.RootVrCEntry.Ce_Node_pNext))
+                    break;
+                if(LaBuf.Data.RootVrCEntry.Ce_Node_pPrev && !RT_VALID_PTR(LaBuf.Data.RootVrCEntry.Ce_Node_pPrev))
+                    break;
+                if(LaBuf.Data.RootVrCEntry.Vr.ListHead_pNext && !RT_VALID_PTR(LaBuf.Data.RootVrCEntry.Vr.ListHead_pNext))
+                    break;
+                if(LaBuf.Data.RootVrCEntry.Vr.ListHead_pPrev && !RT_VALID_PTR(LaBuf.Data.RootVrCEntry.Vr.ListHead_pPrev))
+                    break;
+
+                /* the entry can can be the only one within the (mural) compositor,
+                 * so its compositor entry node can either contain NULL pNext and pPrev,
+                 * or both of them pointing to compositor's list head */
+                if (LaBuf.Data.RootVrCEntry.Ce_Node_pNext != LaBuf.Data.RootVrCEntry.Ce_Node_pPrev)
+                    break;
+
+                /* can either both or none be NULL */
+                if (!LaBuf.Data.RootVrCEntry.Ce_Node_pNext != !LaBuf.Data.RootVrCEntry.Ce_Node_pPrev)
+                    break;
+
+                if (!LaBuf.Data.fRootVrOn)
+                {
+                    if (LaBuf.Data.RootVrCEntry.Ce_Node_pNext || LaBuf.Data.RootVrCEntry.Ce_Node_pPrev)
+                        break;
+
+                    /* either non-initialized (zeroed) or empty list */
+                    if (LaBuf.Data.RootVrCEntry.Vr.ListHead_pNext != LaBuf.Data.RootVrCEntry.Vr.ListHead_pPrev)
+                        break;
+
+                    if (LaBuf.Data.RootVrCEntry.Vr.cEntries)
+                        break;
+                }
+                else
+                {
+                    /* the entry should be initialized */
+                    if (!LaBuf.Data.RootVrCEntry.Vr.ListHead_pNext)
+                        break;
+                    if (!LaBuf.Data.RootVrCEntry.Vr.ListHead_pPrev)
+                        break;
+
+                    if (LaBuf.Data.RootVrCEntry.Vr.cEntries)
+                    {
+                        /* entry should be in compositor list*/
+                        if (LaBuf.Data.RootVrCEntry.Ce_Node_pPrev == NULL)
+                            break;
+                        CRASSERT(LaBuf.Data.RootVrCEntry.Ce_Node_pNext);
+                    }
+                    else
+                    {
+                        /* entry should NOT be in compositor list*/
+                        if (LaBuf.Data.RootVrCEntry.Ce_Node_pPrev != NULL)
+                            break;
+                        CRASSERT(!LaBuf.Data.RootVrCEntry.Ce_Node_pNext);
+                    }
+                }
+
+                /* fExpectPtr == true, the valid pointer values should not match possible mural width/height/position */
+                fBuggyMuralData = true;
+                break;
+
+            } while (0);
+
+            rc = crServerLsrDataPutMem(pReader, &LaBuf, sizeof (LaBuf));
+            AssertLogRelRCReturn(rc, rc);
+        }
+
+        if (fBuggyMuralData)
+        {
+            CR_SERVER_BUGGY_MURAL_DATA Tmp;
+            rc = crServerLsrDataGetMem(pReader, &Tmp, sizeof (Tmp));
+            AssertLogRelRCReturn(rc, rc);
+        }
+
+        if (muralInfo.pVisibleRects)
+        {
+            muralInfo.pVisibleRects = (GLint *)crAlloc(4*sizeof(GLint)*muralInfo.cVisibleRects);
+            if (!muralInfo.pVisibleRects)
+            {
+                return VERR_NO_MEMORY;
+            }
+
+            rc = crServerLsrDataGetMem(pReader, muralInfo.pVisibleRects, 4*sizeof(GLint)*muralInfo.cVisibleRects);
+            AssertLogRelRCReturn(rc, rc);
+        }
+
+        pActualMural = (CRMuralInfo *)crHashtableSearch(cr_server.muralTable, key);
+        CRASSERT(pActualMural);
+
+        if (version >= SHCROGL_SSM_VERSION_WITH_WINDOW_CTX_USAGE)
+        {
+            rc = crServerLsrDataGetMem(pReader, pActualMural->ctxUsage, sizeof (pActualMural->ctxUsage));
+            CRASSERT(rc == VINF_SUCCESS);
+        }
+
+        /* Restore windows geometry info */
+        crServerDispatchWindowSize(key, muralInfo.width, muralInfo.height);
+        crServerDispatchWindowPosition(key, muralInfo.gX, muralInfo.gY);
+        /* Same workaround as described in stub.c:stubUpdateWindowVisibileRegions for compiz on a freshly booted VM*/
+        if (muralInfo.bReceivedRects)
+        {
+            crServerDispatchWindowVisibleRegion(key, muralInfo.cVisibleRects, muralInfo.pVisibleRects);
+        }
+        crServerDispatchWindowShow(key, muralInfo.bVisible);
+
+        if (muralInfo.pVisibleRects)
+        {
+            crFree(muralInfo.pVisibleRects);
+        }
+    }
+
+    CRASSERT(RT_SUCCESS(rc));
+    return VINF_SUCCESS;
+}
+
+static int crVBoxServerLoadFBImage(PSSMHANDLE pSSM, uint32_t version,
+        CRContextInfo* pContextInfo, CRMuralInfo *pMural)
+{
+    CRContext *pContext = pContextInfo->pContext;
+    int32_t rc = VINF_SUCCESS;
+    GLuint i;
+    /* can apply the data right away */
+    struct
+    {
+        CRFBData data;
+        CRFBDataElement buffer[3]; /* CRFBData::aElements[1] + buffer[3] gives 4: back, front, depth and stencil  */
+    } Data;
+
+    Assert(sizeof (Data) >= RT_UOFFSETOF(CRFBData, aElements[4]));
+
+    if (version >= SHCROGL_SSM_VERSION_WITH_SAVED_DEPTH_STENCIL_BUFFER)
+    {
+        if (!pMural->width || !pMural->height)
+            return VINF_SUCCESS;
+
+        rc = crVBoxServerFBImageDataInitEx(&Data.data, pContextInfo, pMural, GL_TRUE, version, 0, 0);
+        if (!RT_SUCCESS(rc))
+        {
+            crWarning("crVBoxServerFBImageDataInit failed rc %d", rc);
+            return rc;
+        }
+    }
+    else
+    {
+        GLint storedWidth, storedHeight;
+
+        if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA)
+        {
+            CRASSERT(cr_server.currentCtxInfo == pContextInfo);
+            CRASSERT(cr_server.currentMural == pMural);
+            storedWidth = pMural->width;
+            storedHeight = pMural->height;
+        }
+        else
+        {
+            storedWidth = pContext->buffer.storedWidth;
+            storedHeight = pContext->buffer.storedHeight;
+        }
+
+        if (!storedWidth || !storedHeight)
+            return VINF_SUCCESS;
+
+        rc = crVBoxServerFBImageDataInitEx(&Data.data, pContextInfo, pMural, GL_TRUE, version, storedWidth, storedHeight);
+        if (!RT_SUCCESS(rc))
+        {
+            crWarning("crVBoxServerFBImageDataInit failed rc %d", rc);
+            return rc;
+        }
+    }
+
+    CRASSERT(Data.data.cElements);
+
+    for (i = 0; i < Data.data.cElements; ++i)
+    {
+        CRFBDataElement * pEl = &Data.data.aElements[i];
+        rc = SSMR3GetMem(pSSM, pEl->pvData, pEl->cbData);
+        AssertLogRelRCReturn(rc, rc);
+    }
+
+    if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA)
+    {
+        CRBufferState *pBuf = &pContext->buffer;
+        /* can apply the data right away */
+        CRASSERT(cr_server.currentCtxInfo == &cr_server.MainContextInfo);
+        CRASSERT(cr_server.currentMural);
+
+        cr_server.head_spu->dispatch_table.MakeCurrent( pMural->spuWindow,
+                                                                0,
+                                                                pContextInfo->SpuContext >= 0
+                                                                    ? pContextInfo->SpuContext
+                                                                      : cr_server.MainContextInfo.SpuContext);
+        crStateApplyFBImage(pContext, &Data.data);
+        CRASSERT(!pBuf->pFrontImg);
+        CRASSERT(!pBuf->pBackImg);
+        crVBoxServerFBImageDataTerm(&Data.data);
+
+        crServerPresentFBO(pMural);
+
+        CRASSERT(cr_server.currentMural);
+        cr_server.head_spu->dispatch_table.MakeCurrent( cr_server.currentMural->spuWindow,
+                                                                    0,
+                                                                    cr_server.currentCtxInfo->SpuContext >= 0
+                                                                        ? cr_server.currentCtxInfo->SpuContext
+                                                                          : cr_server.MainContextInfo.SpuContext);
+    }
+    else
+    {
+        CRBufferState *pBuf = &pContext->buffer;
+        CRASSERT(!pBuf->pFrontImg);
+        CRASSERT(!pBuf->pBackImg);
+        CRASSERT(Data.data.cElements); /* <- older versions always saved front and back, and we filtered out the null-sized buffers above */
+
+        if (Data.data.cElements)
+        {
+            CRFBData *pLazyData = (CRFBData *)crAlloc(RT_UOFFSETOF_DYN(CRFBData, aElements[Data.data.cElements]));
+            if (!RT_SUCCESS(rc))
+            {
+                crVBoxServerFBImageDataTerm(&Data.data);
+                crWarning("crAlloc failed");
+                return VERR_NO_MEMORY;
+            }
+
+            crMemcpy(pLazyData, &Data.data, RT_UOFFSETOF_DYN(CRFBData, aElements[Data.data.cElements]));
+            pBuf->pFrontImg = pLazyData;
+        }
+    }
+
+    CRASSERT(RT_SUCCESS(rc));
+    return VINF_SUCCESS;
+}
+
+static int32_t crVBoxServerLoadStatePerform(PSSMHANDLE pSSM, uint32_t version)
+{
+    int32_t  rc, i;
+    uint32_t ui, uiNumElems;
+    unsigned long key;
+    GLenum err;
+    CR_SERVER_LOADSTATE_READER Reader;
+
+    if (!cr_server.bIsInLoadingState)
+    {
+        /* AssertRCReturn(...) will leave us in loading state, but it doesn't matter as we'd be failing anyway */
+        cr_server.bIsInLoadingState = GL_TRUE;
+
+        /* Read number of clients */
+        rc = SSMR3GetU32(pSSM, &g_hackVBoxServerSaveLoadCallsLeft);
+        AssertLogRelRCReturn(rc, rc);
+
+        Assert(g_hackVBoxServerSaveLoadCallsLeft);
+        /* we get called only once for CrCmd */
+        if (cr_server.fCrCmdEnabled)
+            g_hackVBoxServerSaveLoadCallsLeft = 1;
+    }
+
+    g_hackVBoxServerSaveLoadCallsLeft--;
+
+    /* Do nothing until we're being called last time */
+    if (g_hackVBoxServerSaveLoadCallsLeft>0)
+    {
+        return VINF_SUCCESS;
+    }
+
+    if (version < SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS)
+    {
+        return VERR_SSM_DATA_UNIT_FORMAT_CHANGED;
+    }
+
+    crServerLsrInit(&Reader, pSSM);
+
+#ifdef DEBUG_misha
+#define CR_DBG_STR_STATE_LOAD_START "VBox.Cr.StateLoadStart"
+#define CR_DBG_STR_STATE_LOAD_STOP "VBox.Cr.StateLoadStop"
+
+    if (cr_server.head_spu->dispatch_table.StringMarkerGREMEDY)
+        cr_server.head_spu->dispatch_table.StringMarkerGREMEDY(sizeof (CR_DBG_STR_STATE_LOAD_START), CR_DBG_STR_STATE_LOAD_START);
+#endif
+
+    /* Load and recreate rendering contexts */
+    rc = SSMR3GetU32(pSSM, &uiNumElems);
+    AssertLogRelRCReturn(rc, rc);
+    for (ui = 0; ui < uiNumElems; ++ui)
+    {
+        CRCreateInfo_t createInfo;
+        char psz[200];
+        GLint ctxID;
+        CRContextInfo* pContextInfo;
+        CRContext* pContext;
+
+        rc = SSMR3GetMem(pSSM, &key, sizeof(key));
+        AssertLogRelRCReturn(rc, rc);
+        rc = SSMR3GetMem(pSSM, &createInfo, sizeof(createInfo));
+        AssertLogRelRCReturn(rc, rc);
+
+        if (createInfo.pszDpyName)
+        {
+            rc = SSMR3GetStrZEx(pSSM, psz, 200, NULL);
+            AssertLogRelRCReturn(rc, rc);
+            createInfo.pszDpyName = psz;
+        }
+
+        ctxID = crServerDispatchCreateContextEx(createInfo.pszDpyName, createInfo.visualBits, 0, key, createInfo.externalID /* <-saved state stores internal id here*/);
+        CRASSERT((int64_t)ctxID == (int64_t)key);
+
+        pContextInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, key);
+        CRASSERT(pContextInfo);
+        CRASSERT(pContextInfo->pContext);
+        pContext = pContextInfo->pContext;
+        pContext->shared->id=-1;
+    }
+
+    if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA)
+    {
+        CRASSERT(!Reader.pu8Buffer);
+        /* we have a mural data here */
+        rc = crVBoxServerLoadMurals(&Reader, version);
+        AssertLogRelRCReturn(rc, rc);
+        CRASSERT(!Reader.pu8Buffer);
+    }
+
+    if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA && uiNumElems)
+    {
+        /* set the current client to allow doing crServerPerformMakeCurrent later */
+        CRASSERT(cr_server.numClients);
+        cr_server.curClient = cr_server.clients[0];
+    }
+
+    rc = crStateLoadGlobals(pSSM, version);
+    AssertLogRelRCReturn(rc, rc);
+
+    if (uiNumElems)
+    {
+        /* ensure we have main context set up as current */
+        CRMuralInfo *pMural;
+        CRASSERT(cr_server.MainContextInfo.SpuContext > 0);
+        CRASSERT(!cr_server.currentCtxInfo);
+        CRASSERT(!cr_server.currentMural);
+        pMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
+        CRASSERT(pMural);
+        crServerPerformMakeCurrent(pMural, &cr_server.MainContextInfo);
+    }
+
+    /* Restore context state data */
+    for (ui=0; ui<uiNumElems; ++ui)
+    {
+        CRContextInfo* pContextInfo;
+        CRContext *pContext;
+        CRMuralInfo *pMural = NULL;
+        int32_t winId = 0;
+
+        rc = SSMR3GetMem(pSSM, &key, sizeof(key));
+        AssertLogRelRCReturn(rc, rc);
+
+        pContextInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, key);
+        CRASSERT(pContextInfo);
+        CRASSERT(pContextInfo->pContext);
+        pContext = pContextInfo->pContext;
+
+        if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA)
+        {
+            rc = SSMR3GetMem(pSSM, &winId, sizeof(winId));
+            AssertLogRelRCReturn(rc, rc);
+
+            if (winId)
+            {
+                pMural = (CRMuralInfo*)crHashtableSearch(cr_server.muralTable, winId);
+                CRASSERT(pMural);
+            }
+            else
+            {
+                /* null winId means a dummy mural, get it */
+                pMural = crServerGetDummyMural(pContextInfo->CreateInfo.realVisualBits);
+                CRASSERT(pMural);
+            }
+        }
+
+        rc = crStateLoadContext(pContext, cr_server.contextTable, crVBoxServerGetContextCB, pSSM, version);
+        AssertLogRelRCReturn(rc, rc);
+
+        /*Restore front/back buffer images*/
+        rc = crVBoxServerLoadFBImage(pSSM, version, pContextInfo, pMural);
+        AssertLogRelRCReturn(rc, rc);
+    }
+
+    if (version > SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA)
+    {
+        CRContextInfo *pContextInfo;
+        CRMuralInfo *pMural;
+        GLint ctxId;
+
+        rc = SSMR3GetU32(pSSM, &uiNumElems);
+        AssertLogRelRCReturn(rc, rc);
+        for (ui=0; ui<uiNumElems; ++ui)
+        {
+            CRbitvalue initialCtxUsage[CR_MAX_BITARRAY];
+            CRMuralInfo *pInitialCurMural;
+
+            rc = SSMR3GetMem(pSSM, &key, sizeof(key));
+            AssertLogRelRCReturn(rc, rc);
+
+            rc = SSMR3GetMem(pSSM, &ctxId, sizeof(ctxId));
+            AssertLogRelRCReturn(rc, rc);
+
+            pMural = (CRMuralInfo*)crHashtableSearch(cr_server.muralTable, key);
+            CRASSERT(pMural);
+            if (ctxId)
+            {
+                pContextInfo = (CRContextInfo *)crHashtableSearch(cr_server.contextTable, ctxId);
+                CRASSERT(pContextInfo);
+            }
+            else
+                pContextInfo =  &cr_server.MainContextInfo;
+
+            crMemcpy(initialCtxUsage, pMural->ctxUsage, sizeof (initialCtxUsage));
+            pInitialCurMural = pContextInfo->currentMural;
+
+            rc = crVBoxServerLoadFBImage(pSSM, version, pContextInfo, pMural);
+            AssertLogRelRCReturn(rc, rc);
+
+            /* restore the reference data, we synchronize it with the HW state in a later crServerPerformMakeCurrent call */
+            crMemcpy(pMural->ctxUsage, initialCtxUsage, sizeof (initialCtxUsage));
+            pContextInfo->currentMural = pInitialCurMural;
+        }
+
+        CRASSERT(!uiNumElems || cr_server.currentCtxInfo == &cr_server.MainContextInfo);
+
+        cr_server.curClient = NULL;
+        cr_server.bForceMakeCurrentOnClientSwitch = GL_TRUE;
+    }
+    else
+    {
+        CRServerFreeIDsPool_t dummyIdsPool;
+
+        CRASSERT(!Reader.pu8Buffer);
+
+        /* we have a mural data here */
+        rc = crVBoxServerLoadMurals(&Reader, version);
+        AssertLogRelRCReturn(rc, rc);
+
+        /* not used any more, just read it out and ignore */
+        rc = crServerLsrDataGetMem(&Reader, &dummyIdsPool, sizeof(dummyIdsPool));
+        CRASSERT(rc == VINF_SUCCESS);
+    }
+
+    /* Load clients info */
+    for (i = 0; i < cr_server.numClients; i++)
+    {
+        if (cr_server.clients[i] && cr_server.clients[i]->conn)
+        {
+            CRClient *pClient = cr_server.clients[i];
+            CRClient client;
+            unsigned long ctxID=-1, winID=-1;
+
+            rc = crServerLsrDataGetU32(&Reader, &ui);
+            AssertLogRelRCReturn(rc, rc);
+            /* If this assert fires, then we should search correct client in the list first*/
+            CRASSERT(ui == pClient->conn->u32ClientID);
+
+            if (version>=4)
+            {
+                rc = crServerLsrDataGetU32(&Reader, &pClient->conn->vMajor);
+                AssertLogRelRCReturn(rc, rc);
+
+                rc = crServerLsrDataGetU32(&Reader, &pClient->conn->vMinor);
+                AssertLogRelRCReturn(rc, rc);
+            }
+
+            rc = crServerLsrDataGetMem(&Reader, &client, sizeof(client));
+            CRASSERT(rc == VINF_SUCCESS);
+
+            client.conn = pClient->conn;
+            /* We can't reassign client number, as we'd get wrong results in TranslateTextureID
+             * and fail to bind old textures.
+             */
+            /*client.number = pClient->number;*/
+            *pClient = client;
+
+            pClient->currentContextNumber = -1;
+            pClient->currentCtxInfo = &cr_server.MainContextInfo;
+            pClient->currentMural = NULL;
+            pClient->currentWindow = -1;
+
+            cr_server.curClient = pClient;
+
+            if (client.currentCtxInfo && client.currentContextNumber > 0)
+            {
+                rc = crServerLsrDataGetMem(&Reader, &ctxID, sizeof(ctxID));
+                AssertLogRelRCReturn(rc, rc);
+                client.currentCtxInfo = (CRContextInfo*) crHashtableSearch(cr_server.contextTable, ctxID);
+                CRASSERT(client.currentCtxInfo);
+                CRASSERT(client.currentCtxInfo->pContext);
+                //pClient->currentCtx = client.currentCtx;
+                //pClient->currentContextNumber = ctxID;
+            }
+
+            if (client.currentMural && client.currentWindow > 0)
+            {
+                rc = crServerLsrDataGetMem(&Reader, &winID, sizeof(winID));
+                AssertLogRelRCReturn(rc, rc);
+                client.currentMural = (CRMuralInfo*) crHashtableSearch(cr_server.muralTable, winID);
+                CRASSERT(client.currentMural);
+                //pClient->currentMural = client.currentMural;
+                //pClient->currentWindow = winID;
+            }
+
+            CRASSERT(!Reader.cbData);
+
+            /* Restore client active context and window */
+            crServerDispatchMakeCurrent(winID, 0, ctxID);
+        }
+    }
+
+    cr_server.curClient = NULL;
+
+    rc = crServerPendLoadState(pSSM, version);
+    AssertLogRelRCReturn(rc, rc);
+
+    if (version >= SHCROGL_SSM_VERSION_WITH_SCREEN_INFO)
+    {
+        rc = CrPMgrLoadState(pSSM, version);
+        AssertLogRelRCReturn(rc, rc);
+    }
+
+    while ((err = cr_server.head_spu->dispatch_table.GetError()) != GL_NO_ERROR)
+        crWarning("crServer: glGetError %d after loading snapshot", err);
+
+    cr_server.bIsInLoadingState = GL_FALSE;
+
+#ifdef DEBUG_misha
+    if (cr_server.head_spu->dispatch_table.StringMarkerGREMEDY)
+        cr_server.head_spu->dispatch_table.StringMarkerGREMEDY(sizeof (CR_DBG_STR_STATE_LOAD_STOP), CR_DBG_STR_STATE_LOAD_STOP);
+#endif
+
+    CRASSERT(!Reader.cbData);
+    crServerLsrTerm(&Reader);
+
+    return VINF_SUCCESS;
+}
+
+DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version)
+{
+    if (cr_server.fCrCmdEnabled)
+    {
+        WARN(("CrCmd enabled"));
+        return VERR_INTERNAL_ERROR;
+    }
+
+    return crVBoxServerLoadStatePerform(pSSM, version);
+}
+
+#define SCREEN(i) (cr_server.screen[i])
+#define MAPPED(screen) ((screen).winID != 0)
+
+extern DECLEXPORT(void) crServerVBoxSetNotifyEventCB(PFNCRSERVERNOTIFYEVENT pfnCb)
+{
+    cr_server.pfnNotifyEventCB = pfnCb;
+}
+
+void crVBoxServerNotifyEvent(int32_t idScreen, uint32_t uEvent, void* pvData, uint32_t cbData)
+{
+    /* this is something unexpected, but just in case */
+    if (idScreen >= cr_server.screenCount)
+    {
+        crWarning("invalid screen id %d", idScreen);
+        return;
+    }
+
+    cr_server.pfnNotifyEventCB(idScreen, uEvent, pvData, cbData);
+}
+
+void crServerWindowReparent(CRMuralInfo *pMural)
+{
+    pMural->fHasParentWindow = !!cr_server.screen[pMural->screenId].winID;
+
+    renderspuReparentWindow(pMural->spuWindow);
+}
+
+DECLEXPORT(void) crServerSetUnscaledHiDPI(bool fEnable)
+{
+    renderspuSetUnscaledHiDPI(fEnable);
+}
+
+static void crVBoxServerReparentMuralCB(unsigned long key, void *data1, void *data2)
+{
+    CRMuralInfo *pMI = (CRMuralInfo*) data1;
+    int *sIndex = (int*) data2;
+
+    if (pMI->screenId == *sIndex)
+    {
+        crServerWindowReparent(pMI);
+    }
+}
+
+DECLEXPORT(int32_t) crVBoxServerSetScreenCount(int sCount)
+{
+    int i;
+
+    if (sCount > CR_MAX_GUEST_MONITORS)
+        return VERR_INVALID_PARAMETER;
+
+    /*Shouldn't happen yet, but to be safe in future*/
+    for (i = 0; i < cr_server.screenCount; /*++i - unreachable code*/)
+    {
+        if (MAPPED(SCREEN(i)))
+            WARN(("Screen count is changing, but screen[%i] is still mapped", i));
+        return VERR_NOT_IMPLEMENTED;
+    }
+
+    cr_server.screenCount = sCount;
+
+    for (i=0; i<sCount; ++i)
+    {
+        SCREEN(i).winID = 0;
+    }
+
+    return VINF_SUCCESS;
+}
+
+DECLEXPORT(int32_t) crVBoxServerUnmapScreen(int sIndex)
+{
+    crDebug("crVBoxServerUnmapScreen(%i)", sIndex);
+
+    if (sIndex<0 || sIndex>=cr_server.screenCount)
+        return VERR_INVALID_PARAMETER;
+
+    if (MAPPED(SCREEN(sIndex)))
+    {
+        SCREEN(sIndex).winID = 0;
+        renderspuSetWindowId(0);
+
+        crHashtableWalk(cr_server.muralTable, crVBoxServerReparentMuralCB, &sIndex);
+
+        crHashtableWalk(cr_server.dummyMuralTable, crVBoxServerReparentMuralCB, &sIndex);
+
+        CrPMgrScreenChanged((uint32_t)sIndex);
+    }
+
+    renderspuSetWindowId(SCREEN(0).winID);
+
+    return VINF_SUCCESS;
+}
+
+DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID)
+{
+    crDebug("crVBoxServerMapScreen(%i) [%i,%i:%u,%u %x]", sIndex, x, y, w, h, winID);
+
+    if (sIndex<0 || sIndex>=cr_server.screenCount)
+        return VERR_INVALID_PARAMETER;
+
+    if (MAPPED(SCREEN(sIndex)) && SCREEN(sIndex).winID!=winID)
+    {
+        crDebug("Mapped screen[%i] is being remapped.", sIndex);
+        crVBoxServerUnmapScreen(sIndex);
+    }
+
+    SCREEN(sIndex).winID = winID;
+    SCREEN(sIndex).x = x;
+    SCREEN(sIndex).y = y;
+    SCREEN(sIndex).w = w;
+    SCREEN(sIndex).h = h;
+
+    renderspuSetWindowId(SCREEN(sIndex).winID);
+    crHashtableWalk(cr_server.muralTable, crVBoxServerReparentMuralCB, &sIndex);
+
+    crHashtableWalk(cr_server.dummyMuralTable, crVBoxServerReparentMuralCB, &sIndex);
+    renderspuSetWindowId(SCREEN(0).winID);
+
+#ifndef WINDOWS
+    /*Restore FB content for clients, which have current window on a screen being remapped*/
+    {
+        GLint i;
+
+        for (i = 0; i < cr_server.numClients; i++)
+        {
+            cr_server.curClient = cr_server.clients[i];
+            if (cr_server.curClient->currentCtxInfo
+                && cr_server.curClient->currentCtxInfo->pContext
+                && (cr_server.curClient->currentCtxInfo->pContext->buffer.pFrontImg)
+                && cr_server.curClient->currentMural
+                && cr_server.curClient->currentMural->screenId == sIndex
+                && cr_server.curClient->currentCtxInfo->pContext->buffer.storedHeight == h
+                && cr_server.curClient->currentCtxInfo->pContext->buffer.storedWidth == w)
+            {
+                int clientWindow = cr_server.curClient->currentWindow;
+                int clientContext = cr_server.curClient->currentContextNumber;
+                CRFBData *pLazyData = (CRFBData *)cr_server.curClient->currentCtxInfo->pContext->buffer.pFrontImg;
+
+                if (clientWindow && clientWindow != cr_server.currentWindow)
+                {
+                    crServerDispatchMakeCurrent(clientWindow, 0, clientContext);
+                }
+
+                crStateApplyFBImage(cr_server.curClient->currentCtxInfo->pContext, pLazyData);
+                crStateFreeFBImageLegacy(cr_server.curClient->currentCtxInfo->pContext);
+            }
+        }
+        cr_server.curClient = NULL;
+    }
+#endif
+
+    CrPMgrScreenChanged((uint32_t)sIndex);
+
+    return VINF_SUCCESS;
+}
+
+DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, const RTRECT *pRects)
+{
+    int32_t rc = VINF_SUCCESS;
+    GLboolean fOldRootVrOn = cr_server.fRootVrOn;
+
+    /* non-zero rects pointer indicate rects are present and switched on
+     * i.e. cRects==0 and pRects!=NULL means root visible regioning is ON and there are no visible regions,
+     * while pRects==NULL means root visible regioning is OFF, i.e. everything is visible */
+    if (pRects)
+    {
+        crMemset(&cr_server.RootVrCurPoint, 0, sizeof (cr_server.RootVrCurPoint));
+        rc = VBoxVrListRectsSet(&cr_server.RootVr, cRects, pRects, NULL);
+        if (!RT_SUCCESS(rc))
+        {
+            crWarning("VBoxVrListRectsSet failed! rc %d", rc);
+            return rc;
+        }
+
+        cr_server.fRootVrOn = GL_TRUE;
+    }
+    else
+    {
+        if (!cr_server.fRootVrOn)
+            return VINF_SUCCESS;
+
+        VBoxVrListClear(&cr_server.RootVr);
+
+        cr_server.fRootVrOn = GL_FALSE;
+    }
+
+    if (!fOldRootVrOn != !cr_server.fRootVrOn)
+    {
+        rc = CrPMgrModeRootVr(RT_BOOL(cr_server.fRootVrOn));
+        if (!RT_SUCCESS(rc))
+        {
+            crWarning("CrPMgrModeRootVr failed rc %d", rc);
+            return rc;
+        }
+    }
+    else if (cr_server.fRootVrOn)
+    {
+        rc = CrPMgrRootVrUpdate();
+        if (!RT_SUCCESS(rc))
+        {
+            crWarning("CrPMgrRootVrUpdate failed rc %d", rc);
+            return rc;
+        }
+    }
+
+    return VINF_SUCCESS;
+}
+
+DECLEXPORT(int32_t) crVBoxServerSetOffscreenRendering(GLboolean value)
+{
+    return CrPMgrModeVrdp(RT_BOOL(value));
+}
+
+DECLEXPORT(int32_t) crVBoxServerOutputRedirectSet(const CROutputRedirect *pCallbacks)
+{
+    /* No need for a synchronization as this is single threaded. */
+    if (pCallbacks)
+    {
+        cr_server.outputRedirect = *pCallbacks;
+    }
+    else
+    {
+        memset (&cr_server.outputRedirect, 0, sizeof (cr_server.outputRedirect));
+    }
+
+    return VINF_SUCCESS;
+}
+
+DECLEXPORT(int32_t) crVBoxServerSetScreenViewport(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h)
+{
+    CRScreenViewportInfo *pViewport;
+    RTRECT NewRect;
+    int rc;
+
+    crDebug("crVBoxServerSetScreenViewport(%i)", sIndex);
+
+    if (sIndex<0 || sIndex>=cr_server.screenCount)
+    {
+        crWarning("crVBoxServerSetScreenViewport: invalid screen id %d", sIndex);
+        return VERR_INVALID_PARAMETER;
+    }
+
+    NewRect.xLeft = x;
+    NewRect.yTop = y;
+    NewRect.xRight = x + w;
+    NewRect.yBottom = y + h;
+
+    pViewport = &cr_server.screenVieport[sIndex];
+    /*always do viewport updates no matter whether the rectangle actually changes,
+     * this is needed to ensure window is adjusted properly on OSX */
+    pViewport->Rect = NewRect;
+    rc = CrPMgrViewportUpdate((uint32_t)sIndex);
+    if (!RT_SUCCESS(rc))
+    {
+        crWarning("CrPMgrViewportUpdate failed %d", rc);
+        return rc;
+    }
+
+    return VINF_SUCCESS;
+}
+
+static void crVBoxServerDeleteMuralCb(unsigned long key, void *data1, void *data2)
+{
+    CRHashTable *h = (CRHashTable*)data2;
+    CRMuralInfo *m = (CRMuralInfo *) data1;
+    if (m->spuWindow == CR_RENDER_DEFAULT_WINDOW_ID)
+        return;
+
+    crHashtableDelete(h, key, NULL);
+    crServerMuralTerm(m);
+    crFree(m);
+}
+
+static void crVBoxServerDefaultContextClear()
+{
+    HCR_FRAMEBUFFER hFb;
+    int rc = CrPMgrDisable();
+    if (RT_FAILURE(rc))
+    {
+        WARN(("CrPMgrDisable failed %d", rc));
+        return;
+    }
+
+    for (hFb = CrPMgrFbGetFirstEnabled(); hFb; hFb = CrPMgrFbGetNextEnabled(hFb))
+    {
+        int rc = CrFbUpdateBegin(hFb);
+        if (RT_SUCCESS(rc))
+        {
+            CrFbRegionsClear(hFb);
+            CrFbUpdateEnd(hFb);
+        }
+        else
+            WARN(("CrFbUpdateBegin failed %d", rc));
+    }
+
+    cr_server.head_spu->dispatch_table.MakeCurrent(0, 0, 0);
+    crStateCleanupCurrent();
+
+    /* note: we need to clean all contexts, since otherwise renderspu leanup won't work,
+     * i.e. renderspu would need to clean up its own internal windows, it won't be able to do that if
+     * some those windows is associated with any context.  */
+    if (cr_server.MainContextInfo.SpuContext)
+    {
+        cr_server.head_spu->dispatch_table.DestroyContext(cr_server.MainContextInfo.SpuContext);
+        crStateDestroyContext(cr_server.MainContextInfo.pContext);
+        if (cr_server.MainContextInfo.CreateInfo.pszDpyName)
+            crFree(cr_server.MainContextInfo.CreateInfo.pszDpyName);
+
+        memset(&cr_server.MainContextInfo, 0, sizeof (cr_server.MainContextInfo));
+    }
+
+    cr_server.firstCallCreateContext = GL_TRUE;
+    cr_server.firstCallMakeCurrent = GL_TRUE;
+    cr_server.bForceMakeCurrentOnClientSwitch = GL_FALSE;
+
+    CRASSERT(!cr_server.curClient);
+
+    cr_server.currentCtxInfo = NULL;
+    cr_server.currentWindow = 0;
+    cr_server.currentNativeWindow = 0;
+    cr_server.currentMural = NULL;
+
+    crStateDestroy();
+//    crStateCleanupCurrent();
+
+    if (CrBltIsInitialized(&cr_server.Blitter))
+    {
+        CrBltTerm(&cr_server.Blitter);
+        Assert(!CrBltIsInitialized(&cr_server.Blitter));
+    }
+
+    crHashtableWalk(cr_server.dummyMuralTable, crVBoxServerDeleteMuralCb, cr_server.dummyMuralTable);
+
+    cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_RENDERTHREAD_INFORM, 0);
+}
+
+static void crVBoxServerDefaultContextSet()
+{
+    cr_server.head_spu->dispatch_table.ChromiumParameteriCR(GL_HH_RENDERTHREAD_INFORM, 1);
+
+    CRASSERT(!cr_server.MainContextInfo.SpuContext);
+
+//    crStateSetCurrent(NULL);
+    crStateInit();
+    crStateDiffAPI( &(cr_server.head_spu->dispatch_table) );
+
+    CrPMgrEnable();
+}
+
+#ifdef VBOX_WITH_CRHGSMI
+
+/** @todo RT_UNTRUSTED_VOLATILE_GUEST   */
+static int32_t crVBoxServerCmdVbvaCrCmdProcess(VBOXCMDVBVA_CRCMD_CMD const RT_UNTRUSTED_VOLATILE_GUEST *pCmdTodo, uint32_t cbCmd)
+{
+    VBOXCMDVBVA_CRCMD_CMD const *pCmd = (VBOXCMDVBVA_CRCMD_CMD const *)pCmdTodo;
+    int32_t rc;
+    uint32_t cBuffers = pCmd->cBuffers;
+    uint32_t cParams;
+    uint32_t cbHdr;
+    CRVBOXHGSMIHDR *pHdr;
+    uint32_t u32Function;
+    uint32_t u32ClientID;
+    CRClient *pClient;
+
+    if (!g_pvVRamBase)
+    {
+        WARN(("g_pvVRamBase is not initialized"));
+        return VERR_INVALID_STATE;
+    }
+
+    if (!cBuffers)
+    {
+        WARN(("zero buffers passed in!"));
+        return VERR_INVALID_PARAMETER;
+    }
+
+    cParams = cBuffers-1;
+
+    if (cbCmd < RT_UOFFSETOF_DYN(VBOXCMDVBVA_CRCMD_CMD, aBuffers[cBuffers]))
+    {
+        WARN(("invalid buffer size"));
+        return VERR_INVALID_PARAMETER;
+    }
+
+    cbHdr = pCmd->aBuffers[0].cbBuffer;
+    pHdr = VBOXCRHGSMI_PTR_SAFE(pCmd->aBuffers[0].offBuffer, cbHdr, CRVBOXHGSMIHDR);
+    if (!pHdr)
+    {
+        WARN(("invalid header buffer!"));
+        return VERR_INVALID_PARAMETER;
+    }
+
+    if (cbHdr < sizeof (*pHdr))
+    {
+        WARN(("invalid header buffer size!"));
+        return VERR_INVALID_PARAMETER;
+    }
+
+    u32Function = pHdr->u32Function;
+    u32ClientID = pHdr->u32ClientID;
+
+    switch (u32Function)
+    {
+        case SHCRGL_GUEST_FN_WRITE:
+        {
+            Log(("svcCall: SHCRGL_GUEST_FN_WRITE\n"));
+
+            /** @todo Verify  */
+            if (cParams == 1)
+            {
+                CRVBOXHGSMIWRITE* pFnCmd = (CRVBOXHGSMIWRITE*)pHdr;
+                const VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1];
+                /* Fetch parameters. */
+                uint32_t cbBuffer = pBuf->cbBuffer;
+                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
+
+                if (cbHdr < sizeof (*pFnCmd))
+                {
+                    WARN(("invalid write cmd buffer size!"));
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                CRASSERT(cbBuffer);
+                if (!pBuffer)
+                {
+                    WARN(("invalid buffer data received from guest!"));
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                rc = crVBoxServerClientGet(u32ClientID, &pClient);
+                if (RT_FAILURE(rc))
+                {
+                    WARN(("crVBoxServerClientGet failed %d", rc));
+                    break;
+                }
+
+                /* This should never fire unless we start to multithread */
+                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+                pClient->conn->pBuffer = pBuffer;
+                pClient->conn->cbBuffer = cbBuffer;
+                CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, false);
+                crVBoxServerInternalClientWriteRead(pClient);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+                return VINF_SUCCESS;
+            }
+
+            WARN(("invalid number of args"));
+            rc = VERR_INVALID_PARAMETER;
+            break;
+        }
+
+        case SHCRGL_GUEST_FN_INJECT:
+        {
+            WARN(("svcCall: SHCRGL_GUEST_FN_INJECT\n"));
+
+            /** @todo Verify  */
+            if (cParams == 1)
+            {
+                CRVBOXHGSMIINJECT *pFnCmd = (CRVBOXHGSMIINJECT*)pHdr;
+                /* Fetch parameters. */
+                uint32_t u32InjectClientID = pFnCmd->u32ClientID;
+                const VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1];
+                uint32_t cbBuffer = pBuf->cbBuffer;
+                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
+
+                if (cbHdr < sizeof (*pFnCmd))
+                {
+                    WARN(("invalid inject cmd buffer size!"));
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                CRASSERT(cbBuffer);
+                if (!pBuffer)
+                {
+                    WARN(("invalid buffer data received from guest!"));
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                rc = crVBoxServerClientGet(u32InjectClientID, &pClient);
+                if (RT_FAILURE(rc))
+                {
+                    WARN(("crVBoxServerClientGet failed %d", rc));
+                    break;
+                }
+
+                /* This should never fire unless we start to multithread */
+                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+                pClient->conn->pBuffer = pBuffer;
+                pClient->conn->cbBuffer = cbBuffer;
+                CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, false);
+                crVBoxServerInternalClientWriteRead(pClient);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+                return VINF_SUCCESS;
+            }
+
+            WARN(("invalid number of args"));
+            rc = VERR_INVALID_PARAMETER;
+            break;
+        }
+
+        case SHCRGL_GUEST_FN_READ:
+        {
+            Log(("svcCall: SHCRGL_GUEST_FN_READ\n"));
+
+            /** @todo Verify  */
+            if (cParams == 1)
+            {
+                CRVBOXHGSMIREAD *pFnCmd = (CRVBOXHGSMIREAD*)pHdr;
+                const VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1];
+                /* Fetch parameters. */
+                uint32_t cbBuffer = pBuf->cbBuffer;
+                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
+
+                if (cbHdr < sizeof (*pFnCmd))
+                {
+                    WARN(("invalid read cmd buffer size!"));
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                if (!pBuffer)
+                {
+                    WARN(("invalid buffer data received from guest!"));
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                rc = crVBoxServerClientGet(u32ClientID, &pClient);
+                if (RT_FAILURE(rc))
+                {
+                    WARN(("crVBoxServerClientGet failed %d", rc));
+                    break;
+                }
+
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+                rc = crVBoxServerInternalClientRead(pClient, pBuffer, &cbBuffer);
+
+                /* Return the required buffer size always */
+                pFnCmd->cbBuffer = cbBuffer;
+
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+                /* the read command is never pended, complete it right away */
+                if (RT_FAILURE(rc))
+                {
+                    WARN(("crVBoxServerInternalClientRead failed %d", rc));
+                    break;
+                }
+
+                break;
+            }
+
+            crWarning("invalid number of args");
+            rc = VERR_INVALID_PARAMETER;
+            break;
+        }
+
+        case SHCRGL_GUEST_FN_WRITE_READ:
+        {
+            Log(("svcCall: SHCRGL_GUEST_FN_WRITE_READ\n"));
+
+            /** @todo Verify  */
+            if (cParams == 2)
+            {
+                CRVBOXHGSMIWRITEREAD *pFnCmd = (CRVBOXHGSMIWRITEREAD*)pHdr;
+                const VBOXCMDVBVA_CRCMD_BUFFER *pBuf = &pCmd->aBuffers[1];
+                const VBOXCMDVBVA_CRCMD_BUFFER *pWbBuf = &pCmd->aBuffers[2];
+
+                /* Fetch parameters. */
+                uint32_t cbBuffer = pBuf->cbBuffer;
+                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
+
+                uint32_t cbWriteback = pWbBuf->cbBuffer;
+                char *pWriteback  = VBOXCRHGSMI_PTR_SAFE(pWbBuf->offBuffer, cbWriteback, char);
+
+                if (cbHdr < sizeof (*pFnCmd))
+                {
+                    WARN(("invalid write_read cmd buffer size!"));
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                CRASSERT(cbBuffer);
+                if (!pBuffer)
+                {
+                    WARN(("invalid write buffer data received from guest!"));
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                CRASSERT(cbWriteback);
+                if (!pWriteback)
+                {
+                    WARN(("invalid writeback buffer data received from guest!"));
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                rc = crVBoxServerClientGet(u32ClientID, &pClient);
+                if (RT_FAILURE(rc))
+                {
+                    WARN(("crVBoxServerClientGet failed %d", rc));
+                    break;
+                }
+
+                /* This should never fire unless we start to multithread */
+                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+                pClient->conn->pBuffer = pBuffer;
+                pClient->conn->cbBuffer = cbBuffer;
+                CRVBOXHGSMI_CMDDATA_SETWB(&pClient->conn->CmdData, pCmd, pHdr, pWriteback, cbWriteback, &pFnCmd->cbWriteback, false);
+                crVBoxServerInternalClientWriteRead(pClient);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+                return VINF_SUCCESS;
+            }
+
+            crWarning("invalid number of args");
+            rc = VERR_INVALID_PARAMETER;
+            break;
+        }
+
+        case SHCRGL_GUEST_FN_SET_VERSION:
+        {
+            WARN(("SHCRGL_GUEST_FN_SET_VERSION: invalid function"));
+            rc = VERR_NOT_IMPLEMENTED;
+            break;
+        }
+
+        case SHCRGL_GUEST_FN_SET_PID:
+        {
+            WARN(("SHCRGL_GUEST_FN_SET_PID: invalid function"));
+            rc = VERR_NOT_IMPLEMENTED;
+            break;
+        }
+
+        default:
+        {
+            WARN(("invalid function, %d", u32Function));
+            rc = VERR_NOT_IMPLEMENTED;
+            break;
+        }
+
+    }
+
+    pHdr->result = rc;
+
+    return VINF_SUCCESS;
+}
+
+static DECLCALLBACK(int) crVBoxCrCmdEnable(HVBOXCRCMDSVR hSvr, VBOXCRCMD_SVRENABLE_INFO *pInfo)
+{
+    Assert(!cr_server.fCrCmdEnabled);
+    Assert(!cr_server.numClients);
+
+    cr_server.CrCmdClientInfo = *pInfo;
+
+    crVBoxServerDefaultContextSet();
+
+    cr_server.fCrCmdEnabled = GL_TRUE;
+
+    crInfo("crCmd ENABLED");
+
+    return VINF_SUCCESS;
+}
+
+static DECLCALLBACK(int) crVBoxCrCmdDisable(HVBOXCRCMDSVR hSvr)
+{
+    Assert(cr_server.fCrCmdEnabled);
+
+    crVBoxServerRemoveAllClients();
+
+    CrHTableEmpty(&cr_server.clientTable);
+
+    crVBoxServerDefaultContextClear();
+
+    memset(&cr_server.CrCmdClientInfo, 0, sizeof (cr_server.CrCmdClientInfo));
+
+    cr_server.fCrCmdEnabled = GL_FALSE;
+
+    crInfo("crCmd DISABLED");
+
+    return VINF_SUCCESS;
+}
+
+static DECLCALLBACK(int) crVBoxCrCmdHostCtl(HVBOXCRCMDSVR hSvr, uint8_t* pCmd, uint32_t cbCmd)
+{
+    return crVBoxServerHostCtl((VBOXCRCMDCTL*)pCmd, cbCmd);
+}
+
+static int crVBoxCrDisconnect(uint32_t u32Client)
+{
+    CRClient *pClient = (CRClient*)CrHTableRemove(&cr_server.clientTable, u32Client);
+    if (!pClient)
+    {
+        WARN(("invalid client id"));
+        return VERR_INVALID_PARAMETER;
+    }
+
+    crVBoxServerRemoveClientObj(pClient);
+
+    return VINF_SUCCESS;
+}
+
+static int crVBoxCrConnectEx(VBOXCMDVBVA_3DCTL_CONNECT RT_UNTRUSTED_VOLATILE_GUEST *pConnect, uint32_t u32ClientId)
+{
+    CRClient *pClient;
+    int rc;
+    uint32_t const uMajorVersion = pConnect->u32MajorVersion;
+    uint32_t const uMinorVersion = pConnect->u32MinorVersion;
+    uint64_t const uPid          = pConnect->u64Pid;
+    RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
+
+    if (u32ClientId == CRHTABLE_HANDLE_INVALID)
+    {
+        /* allocate client id */
+        u32ClientId =  CrHTablePut(&cr_server.clientTable, (void *)(uintptr_t)1);
+        if (u32ClientId == CRHTABLE_HANDLE_INVALID)
+        {
+            WARN(("CrHTablePut failed"));
+            return VERR_NO_MEMORY;
+        }
+    }
+
+    rc = crVBoxServerAddClientObj(u32ClientId, &pClient);
+    if (RT_SUCCESS(rc))
+    {
+        rc = crVBoxServerClientObjSetVersion(pClient, uMajorVersion, uMinorVersion);
+        if (RT_SUCCESS(rc))
+        {
+            rc = crVBoxServerClientObjSetPID(pClient, uPid);
+            if (RT_SUCCESS(rc))
+            {
+                rc = CrHTablePutToSlot(&cr_server.clientTable, u32ClientId, pClient);
+                if (RT_SUCCESS(rc))
+                {
+                    pConnect->Hdr.u32CmdClientId = u32ClientId;
+                    return VINF_SUCCESS;
+                }
+                WARN(("CrHTablePutToSlot failed %d", rc));
+            }
+            else
+                WARN(("crVBoxServerClientObjSetPID failed %d", rc));
+        }
+        else
+            WARN(("crVBoxServerClientObjSetVersion failed %d", rc));
+
+        crVBoxServerRemoveClientObj(pClient);
+    }
+    else
+        WARN(("crVBoxServerAddClientObj failed %d", rc));
+
+    CrHTableRemove(&cr_server.clientTable, u32ClientId);
+
+    return rc;
+}
+
+static int crVBoxCrConnect(VBOXCMDVBVA_3DCTL_CONNECT RT_UNTRUSTED_VOLATILE_GUEST *pConnect)
+{
+    return crVBoxCrConnectEx(pConnect, CRHTABLE_HANDLE_INVALID);
+}
+
+/**
+ * @interface_method_impl{VBOXCRCMD_SVRINFO,pfnGuestCtl}
+ */
+static DECLCALLBACK(int) crVBoxCrCmdGuestCtl(HVBOXCRCMDSVR hSvr, uint8_t RT_UNTRUSTED_VOLATILE_GUEST *pbCmd, uint32_t cbCmd)
+{
+    /*
+     * Toplevel input validation.
+     */
+    ASSERT_GUEST_LOGREL_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_3DCTL), VERR_INVALID_PARAMETER);
+    {
+        VBOXCMDVBVA_3DCTL RT_UNTRUSTED_VOLATILE_GUEST *pCtl = (VBOXCMDVBVA_3DCTL RT_UNTRUSTED_VOLATILE_GUEST*)pbCmd;
+        const uint32_t uType = pCtl->u32Type;
+        RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
+
+        ASSERT_GUEST_LOGREL_RETURN(   uType == VBOXCMDVBVA3DCTL_TYPE_CMD
+                                   || uType == VBOXCMDVBVA3DCTL_TYPE_CONNECT
+                                   || uType == VBOXCMDVBVA3DCTL_TYPE_DISCONNECT
+                                   , VERR_INVALID_PARAMETER);
+        RT_UNTRUSTED_VALIDATED_FENCE();
+
+        /*
+         * Call worker abd process the request.
+         */
+        switch (uType)
+        {
+            case VBOXCMDVBVA3DCTL_TYPE_CMD:
+                ASSERT_GUEST_LOGREL_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_3DCTL_CMD), VERR_INVALID_PARAMETER);
+                {
+                    VBOXCMDVBVA_3DCTL_CMD RT_UNTRUSTED_VOLATILE_GUEST *p3DCmd
+                        = (VBOXCMDVBVA_3DCTL_CMD RT_UNTRUSTED_VOLATILE_GUEST *)pbCmd;
+                    return crVBoxCrCmdCmd(NULL, &p3DCmd->Cmd, cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_3DCTL_CMD, Cmd));
+                }
+
+            case VBOXCMDVBVA3DCTL_TYPE_CONNECT:
+                ASSERT_GUEST_LOGREL_RETURN(cbCmd == sizeof(VBOXCMDVBVA_3DCTL_CONNECT), VERR_INVALID_PARAMETER);
+                return crVBoxCrConnect((VBOXCMDVBVA_3DCTL_CONNECT RT_UNTRUSTED_VOLATILE_GUEST *)pCtl);
+
+            case VBOXCMDVBVA3DCTL_TYPE_DISCONNECT:
+                ASSERT_GUEST_LOGREL_RETURN(cbCmd == sizeof(VBOXCMDVBVA_3DCTL), VERR_INVALID_PARAMETER);
+                {
+                    uint32_t idClient = pCtl->u32CmdClientId;
+                    RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
+                    return crVBoxCrDisconnect(idClient);
+                }
+
+            default:
+                AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE);
+        }
+    }
+}
+
+static DECLCALLBACK(int) crVBoxCrCmdResize(HVBOXCRCMDSVR hSvr, const struct VBVAINFOSCREEN *pScreen, const uint32_t *pTargetMap)
+{
+    CRASSERT(cr_server.fCrCmdEnabled);
+    return CrPMgrResize(pScreen, NULL, pTargetMap);
+}
+
+static const char* gszVBoxOGLSSMMagic = "***OpenGL state data***";
+
+static int crVBoxCrCmdSaveClients(PSSMHANDLE pSSM)
+{
+    int i;
+    int rc = SSMR3PutU32(pSSM, cr_server.numClients);
+    AssertRCReturn(rc, rc);
+
+    for (i = 0; i < cr_server.numClients; i++)
+    {
+        CRClient * pClient = cr_server.clients[i];
+        Assert(pClient);
+
+        rc = SSMR3PutU32(pSSM, pClient->conn->u32ClientID);
+        AssertRCReturn(rc, rc);
+        rc = SSMR3PutU32(pSSM, pClient->conn->vMajor);
+        AssertRCReturn(rc, rc);
+        rc = SSMR3PutU32(pSSM, pClient->conn->vMinor);
+        AssertRCReturn(rc, rc);
+        rc = SSMR3PutU64(pSSM, pClient->pid);
+        AssertRCReturn(rc, rc);
+    }
+
+    return VINF_SUCCESS;
+}
+
+static int crVBoxCrCmdLoadClients(PSSMHANDLE pSSM, uint32_t u32Version)
+{
+    uint32_t i;
+    uint32_t u32;
+    VBOXCMDVBVA_3DCTL_CONNECT Connect;
+    int rc = SSMR3GetU32(pSSM, &u32);
+    AssertLogRelRCReturn(rc, rc);
+
+    for (i = 0; i < u32; i++)
+    {
+        uint32_t u32ClientID;
+        Connect.Hdr.u32Type = VBOXCMDVBVA3DCTL_TYPE_CONNECT;
+        Connect.Hdr.u32CmdClientId = 0;
+
+        rc = SSMR3GetU32(pSSM, &u32ClientID);
+        AssertLogRelRCReturn(rc, rc);
+        rc = SSMR3GetU32(pSSM, &Connect.u32MajorVersion);
+        AssertLogRelRCReturn(rc, rc);
+        rc = SSMR3GetU32(pSSM, &Connect.u32MinorVersion);
+        AssertLogRelRCReturn(rc, rc);
+        rc = SSMR3GetU64(pSSM, &Connect.u64Pid);
+        AssertLogRelRCReturn(rc, rc);
+
+        rc = crVBoxCrConnectEx(&Connect, u32ClientID);
+        AssertLogRelRCReturn(rc, rc);
+    }
+
+    return VINF_SUCCESS;
+}
+
+static DECLCALLBACK(int) crVBoxCrCmdSaveState(HVBOXCRCMDSVR hSvr, PSSMHANDLE pSSM)
+{
+    int rc = VINF_SUCCESS;
+
+    Assert(cr_server.fCrCmdEnabled);
+
+    /* Start*/
+    rc = SSMR3PutStrZ(pSSM, gszVBoxOGLSSMMagic);
+    AssertRCReturn(rc, rc);
+
+    if (!cr_server.numClients)
+    {
+        rc = SSMR3PutU32(pSSM, 0);
+        AssertRCReturn(rc, rc);
+
+        rc = SSMR3PutStrZ(pSSM, gszVBoxOGLSSMMagic);
+        AssertRCReturn(rc, rc);
+
+        return VINF_SUCCESS;
+    }
+
+    rc = SSMR3PutU32(pSSM, 1);
+    AssertRCReturn(rc, rc);
+
+    /* Version */
+    rc = SSMR3PutU32(pSSM, (uint32_t) SHCROGL_SSM_VERSION);
+    AssertRCReturn(rc, rc);
+
+    rc = crVBoxCrCmdSaveClients(pSSM);
+    AssertRCReturn(rc, rc);
+
+    /* The state itself */
+    rc = crVBoxServerSaveStatePerform(pSSM);
+    AssertRCReturn(rc, rc);
+
+    /* Save svc buffers info */
+    {
+        rc = SSMR3PutU32(pSSM, 0);
+        AssertRCReturn(rc, rc);
+
+        rc = SSMR3PutU32(pSSM, 0);
+        AssertRCReturn(rc, rc);
+    }
+
+    /* End */
+    rc = SSMR3PutStrZ(pSSM, gszVBoxOGLSSMMagic);
+    AssertRCReturn(rc, rc);
+
+    return VINF_SUCCESS;
+}
+
+static DECLCALLBACK(int) crVBoxCrCmdLoadState(HVBOXCRCMDSVR hSvr, PSSMHANDLE pSSM, uint32_t u32Version)
+{
+    int rc = VINF_SUCCESS;
+
+    char szBuf[2000];
+    uint32_t ui32;
+
+    Assert(cr_server.fCrCmdEnabled);
+
+    /* Start of data */
+    rc = SSMR3GetStrZEx(pSSM, szBuf, sizeof(szBuf), NULL);
+    AssertLogRelRCReturn(rc, rc);
+    AssertLogRelMsgReturn(!strcmp(gszVBoxOGLSSMMagic, szBuf), ("Unexpected data1: '%s'\n", szBuf), VERR_SSM_UNEXPECTED_DATA);
+
+    /* num clients */
+    rc = SSMR3GetU32(pSSM, &ui32);
+    AssertLogRelRCReturn(rc, rc);
+
+    if (!ui32)
+    {
+        /* no clients, dummy stub */
+        rc = SSMR3GetStrZEx(pSSM, szBuf, sizeof(szBuf), NULL);
+        AssertLogRelRCReturn(rc, rc);
+        AssertLogRelMsgReturn(!strcmp(gszVBoxOGLSSMMagic, szBuf), ("Unexpected data2: '%s'\n", szBuf), VERR_SSM_UNEXPECTED_DATA);
+
+        return VINF_SUCCESS;
+    }
+    AssertLogRelMsgReturn(ui32 == 1, ("Invalid client count: %#x\n", ui32), VERR_SSM_UNEXPECTED_DATA);
+
+    /* Version */
+    rc = SSMR3GetU32(pSSM, &ui32);
+    AssertLogRelRCReturn(rc, rc);
+    AssertLogRelMsgReturn(ui32 >= SHCROGL_SSM_VERSION_CRCMD, ("Unexpected version: %#x\n", ui32), VERR_SSM_UNEXPECTED_DATA);
+
+    rc = crVBoxCrCmdLoadClients(pSSM, u32Version);
+    AssertLogRelRCReturn(rc, rc);
+
+    /* The state itself */
+    rc = crVBoxServerLoadStatePerform(pSSM, ui32);
+    AssertLogRelRCReturn(rc, rc);
+
+    /* Save svc buffers info */
+    {
+        rc = SSMR3GetU32(pSSM, &ui32);
+        AssertLogRelRCReturn(rc, rc);
+        AssertLogRelMsgReturn(ui32 == 0, ("Unexpected data3: %#x\n", ui32), VERR_SSM_UNEXPECTED_DATA);
+
+        rc = SSMR3GetU32(pSSM, &ui32);
+        AssertLogRelRCReturn(rc, rc);
+        AssertLogRelMsgReturn(ui32 == 0, ("Unexpected data4: %#x\n", ui32), VERR_SSM_UNEXPECTED_DATA);
+    }
+
+    /* End */
+    rc = SSMR3GetStrZEx(pSSM, szBuf, sizeof(szBuf), NULL);
+    AssertLogRelRCReturn(rc, rc);
+    AssertLogRelMsgReturn(!strcmp(gszVBoxOGLSSMMagic, szBuf), ("Unexpected data5: '%s'\n", szBuf), VERR_SSM_UNEXPECTED_DATA);
+
+    return VINF_SUCCESS;
+}
+
+
+/**
+ * @interface_method_impl{VBOXCRCMD_SVRINFO,pfnCmd}
+ */
+static DECLCALLBACK(int8_t) crVBoxCrCmdCmd(HVBOXCRCMDSVR hSvr,
+                                           const VBOXCMDVBVA_HDR RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd)
+{
+    uint8_t bOpcode = pCmd->u8OpCode;
+    RT_UNTRUSTED_NONVOLATILE_COPY_FENCE();
+    ASSERT_GUEST_LOGREL_MSG_RETURN(   bOpcode == VBOXCMDVBVA_OPTYPE_CRCMD
+                                   || bOpcode == VBOXCMDVBVA_OPTYPE_FLIP
+                                   || bOpcode == VBOXCMDVBVA_OPTYPE_BLT
+                                   || bOpcode == VBOXCMDVBVA_OPTYPE_CLRFILL,
+                                   ("%#x\n", bOpcode), -1);
+    RT_UNTRUSTED_VALIDATED_FENCE();
+
+    switch (bOpcode)
+    {
+        case VBOXCMDVBVA_OPTYPE_CRCMD:
+            ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_CRCMD), ("cbCmd=%u\n", cbCmd), -1);
+            {
+                VBOXCMDVBVA_CRCMD const RT_UNTRUSTED_VOLATILE_GUEST *pCrCmdDr
+                    = (VBOXCMDVBVA_CRCMD const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd;
+                VBOXCMDVBVA_CRCMD_CMD const RT_UNTRUSTED_VOLATILE_GUEST *pCrCmd = &pCrCmdDr->Cmd;
+                int rc = crVBoxServerCmdVbvaCrCmdProcess(pCrCmd, cbCmd - RT_UOFFSETOF(VBOXCMDVBVA_CRCMD, Cmd));
+                ASSERT_GUEST_LOGREL_RC_RETURN(rc, -1);
+                return 0;
+            }
+
+        case VBOXCMDVBVA_OPTYPE_FLIP:
+            ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= VBOXCMDVBVA_SIZEOF_FLIPSTRUCT_MIN, ("cbCmd=%u\n", cbCmd), -1);
+            {
+                VBOXCMDVBVA_FLIP const RT_UNTRUSTED_VOLATILE_GUEST *pFlip
+                    = (VBOXCMDVBVA_FLIP const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd;
+                return crVBoxServerCrCmdFlipProcess(pFlip, cbCmd);
+            }
+
+        case VBOXCMDVBVA_OPTYPE_BLT:
+            ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_BLT_HDR), ("cbCmd=%u\n", cbCmd), -1);
+            return crVBoxServerCrCmdBltProcess((VBOXCMDVBVA_BLT_HDR const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd, cbCmd);
+
+        case VBOXCMDVBVA_OPTYPE_CLRFILL:
+            ASSERT_GUEST_LOGREL_MSG_RETURN(cbCmd >= sizeof(VBOXCMDVBVA_CLRFILL_HDR), ("cbCmd=%u\n", cbCmd), -1);
+            return crVBoxServerCrCmdClrFillProcess((VBOXCMDVBVA_CLRFILL_HDR const RT_UNTRUSTED_VOLATILE_GUEST *)pCmd, cbCmd);
+
+        default:
+            AssertFailedReturn(-1);
+    }
+    /* not reached */
+}
+
+/* We moved all CrHgsmi command processing to crserverlib to keep the logic of dealing with CrHgsmi commands in one place.
+ *
+ * For now we need the notion of CrHgdmi commands in the crserver_lib to be able to complete it asynchronously once it is really processed.
+ * This help avoiding the "blocked-client" issues. The client is blocked if another client is doing begin-end stuff.
+ * For now we eliminated polling that could occur on block, which caused a higher-priority thread (in guest) polling for the blocked command complition
+ * to block the lower-priority thread trying to complete the blocking command.
+ * And removed extra memcpy done on blocked command arrival.
+ *
+ * In the future we will extend CrHgsmi functionality to maintain texture data directly in CrHgsmi allocation to avoid extra memcpy-ing with PBO,
+ * implement command completion and stuff necessary for GPU scheduling to work properly for WDDM Windows guests, etc.
+ *
+ * NOTE: it is ALWAYS responsibility of the crVBoxServerCrHgsmiCmd to complete the command!
+ * */
+
+
+int32_t crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd)
+{
+
+    int32_t rc;
+    uint32_t cBuffers = pCmd->cBuffers;
+    uint32_t cParams;
+    uint32_t cbHdr;
+    CRVBOXHGSMIHDR *pHdr;
+    uint32_t u32Function;
+    uint32_t u32ClientID;
+    CRClient *pClient;
+
+    if (!g_pvVRamBase)
+    {
+        WARN(("g_pvVRamBase is not initialized"));
+
+        crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_STATE);
+        return VINF_SUCCESS;
+    }
+
+    if (!cBuffers)
+    {
+        WARN(("zero buffers passed in!"));
+
+        crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER);
+        return VINF_SUCCESS;
+    }
+
+    cParams = cBuffers-1;
+
+    cbHdr = pCmd->aBuffers[0].cbBuffer;
+    pHdr = VBOXCRHGSMI_PTR_SAFE(pCmd->aBuffers[0].offBuffer, cbHdr, CRVBOXHGSMIHDR);
+    if (!pHdr)
+    {
+        WARN(("invalid header buffer!"));
+
+        crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER);
+        return VINF_SUCCESS;
+    }
+
+    if (cbHdr < sizeof (*pHdr))
+    {
+        WARN(("invalid header buffer size!"));
+
+        crServerCrHgsmiCmdComplete(pCmd, VERR_INVALID_PARAMETER);
+        return VINF_SUCCESS;
+    }
+
+    u32Function = pHdr->u32Function;
+    u32ClientID = pHdr->u32ClientID;
+
+    switch (u32Function)
+    {
+        case SHCRGL_GUEST_FN_WRITE:
+        {
+            Log(("svcCall: SHCRGL_GUEST_FN_WRITE\n"));
+
+            /** @todo Verify  */
+            if (cParams == 1)
+            {
+                CRVBOXHGSMIWRITE* pFnCmd = (CRVBOXHGSMIWRITE*)pHdr;
+                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
+                /* Fetch parameters. */
+                uint32_t cbBuffer = pBuf->cbBuffer;
+                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
+
+                if (cbHdr < sizeof (*pFnCmd))
+                {
+                    crWarning("invalid write cmd buffer size!");
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                CRASSERT(cbBuffer);
+                if (!pBuffer)
+                {
+                    crWarning("invalid buffer data received from guest!");
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                rc = crVBoxServerClientGet(u32ClientID, &pClient);
+                if (RT_FAILURE(rc))
+                {
+                    break;
+                }
+
+                /* This should never fire unless we start to multithread */
+                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+                pClient->conn->pBuffer = pBuffer;
+                pClient->conn->cbBuffer = cbBuffer;
+                CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, true);
+                crVBoxServerInternalClientWriteRead(pClient);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+                return VINF_SUCCESS;
+            }
+            else
+            {
+                crWarning("invalid number of args");
+                rc = VERR_INVALID_PARAMETER;
+                break;
+            }
+            break;
+        }
+
+        case SHCRGL_GUEST_FN_INJECT:
+        {
+            Log(("svcCall: SHCRGL_GUEST_FN_INJECT\n"));
+
+            /** @todo Verify  */
+            if (cParams == 1)
+            {
+                CRVBOXHGSMIINJECT *pFnCmd = (CRVBOXHGSMIINJECT*)pHdr;
+                /* Fetch parameters. */
+                uint32_t u32InjectClientID = pFnCmd->u32ClientID;
+                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
+                uint32_t cbBuffer = pBuf->cbBuffer;
+                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
+
+                if (cbHdr < sizeof (*pFnCmd))
+                {
+                    crWarning("invalid inject cmd buffer size!");
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                CRASSERT(cbBuffer);
+                if (!pBuffer)
+                {
+                    crWarning("invalid buffer data received from guest!");
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                rc = crVBoxServerClientGet(u32InjectClientID, &pClient);
+                if (RT_FAILURE(rc))
+                {
+                    break;
+                }
+
+                /* This should never fire unless we start to multithread */
+                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+                pClient->conn->pBuffer = pBuffer;
+                pClient->conn->cbBuffer = cbBuffer;
+                CRVBOXHGSMI_CMDDATA_SET(&pClient->conn->CmdData, pCmd, pHdr, true);
+                crVBoxServerInternalClientWriteRead(pClient);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+                return VINF_SUCCESS;
+            }
+
+            crWarning("invalid number of args");
+            rc = VERR_INVALID_PARAMETER;
+            break;
+        }
+
+        case SHCRGL_GUEST_FN_READ:
+        {
+            Log(("svcCall: SHCRGL_GUEST_FN_READ\n"));
+
+            /** @todo Verify  */
+            if (cParams == 1)
+            {
+                CRVBOXHGSMIREAD *pFnCmd = (CRVBOXHGSMIREAD*)pHdr;
+                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
+                /* Fetch parameters. */
+                uint32_t cbBuffer = pBuf->cbBuffer;
+                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
+
+                if (cbHdr < sizeof (*pFnCmd))
+                {
+                    crWarning("invalid read cmd buffer size!");
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+
+                if (!pBuffer)
+                {
+                    crWarning("invalid buffer data received from guest!");
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                rc = crVBoxServerClientGet(u32ClientID, &pClient);
+                if (RT_FAILURE(rc))
+                {
+                    break;
+                }
+
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+                rc = crVBoxServerInternalClientRead(pClient, pBuffer, &cbBuffer);
+
+                /* Return the required buffer size always */
+                pFnCmd->cbBuffer = cbBuffer;
+
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+                /* the read command is never pended, complete it right away */
+                pHdr->result = rc;
+
+                crServerCrHgsmiCmdComplete(pCmd, VINF_SUCCESS);
+                return VINF_SUCCESS;
+            }
+
+            crWarning("invalid number of args");
+            rc = VERR_INVALID_PARAMETER;
+            break;
+        }
+
+        case SHCRGL_GUEST_FN_WRITE_READ:
+        {
+            Log(("svcCall: SHCRGL_GUEST_FN_WRITE_READ\n"));
+
+            /** @todo Verify  */
+            if (cParams == 2)
+            {
+                CRVBOXHGSMIWRITEREAD *pFnCmd = (CRVBOXHGSMIWRITEREAD*)pHdr;
+                VBOXVDMACMD_CHROMIUM_BUFFER *pBuf = &pCmd->aBuffers[1];
+                VBOXVDMACMD_CHROMIUM_BUFFER *pWbBuf = &pCmd->aBuffers[2];
+
+                /* Fetch parameters. */
+                uint32_t cbBuffer = pBuf->cbBuffer;
+                uint8_t *pBuffer  = VBOXCRHGSMI_PTR_SAFE(pBuf->offBuffer, cbBuffer, uint8_t);
+
+                uint32_t cbWriteback = pWbBuf->cbBuffer;
+                char *pWriteback  = VBOXCRHGSMI_PTR_SAFE(pWbBuf->offBuffer, cbWriteback, char);
+
+                if (cbHdr < sizeof (*pFnCmd))
+                {
+                    crWarning("invalid write_read cmd buffer size!");
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+
+                CRASSERT(cbBuffer);
+                if (!pBuffer)
+                {
+                    crWarning("invalid write buffer data received from guest!");
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+
+                CRASSERT(cbWriteback);
+                if (!pWriteback)
+                {
+                    crWarning("invalid writeback buffer data received from guest!");
+                    rc = VERR_INVALID_PARAMETER;
+                    break;
+                }
+                rc = crVBoxServerClientGet(u32ClientID, &pClient);
+                if (RT_FAILURE(rc))
+                {
+                    pHdr->result = rc;
+                    crServerCrHgsmiCmdComplete(pCmd, VINF_SUCCESS);
+                    return rc;
+                }
+
+                /* This should never fire unless we start to multithread */
+                CRASSERT(pClient->conn->pBuffer==NULL && pClient->conn->cbBuffer==0);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+
+                pClient->conn->pBuffer = pBuffer;
+                pClient->conn->cbBuffer = cbBuffer;
+                CRVBOXHGSMI_CMDDATA_SETWB(&pClient->conn->CmdData, pCmd, pHdr, pWriteback, cbWriteback, &pFnCmd->cbWriteback, true);
+                crVBoxServerInternalClientWriteRead(pClient);
+                CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(&pClient->conn->CmdData);
+                return VINF_SUCCESS;
+            }
+
+            crWarning("invalid number of args");
+            rc = VERR_INVALID_PARAMETER;
+            break;
+        }
+
+        case SHCRGL_GUEST_FN_SET_VERSION:
+        {
+            WARN(("crVBoxServerCrHgsmiCmd, SHCRGL_GUEST_FN_SET_VERSION: invalid function"));
+            rc = VERR_NOT_IMPLEMENTED;
+            break;
+        }
+
+        case SHCRGL_GUEST_FN_SET_PID:
+        {
+            WARN(("crVBoxServerCrHgsmiCmd, SHCRGL_GUEST_FN_SET_PID: invalid function"));
+            rc = VERR_NOT_IMPLEMENTED;
+            break;
+        }
+
+        default:
+        {
+            WARN(("crVBoxServerCrHgsmiCmd: invalid functionm %d", u32Function));
+            rc = VERR_NOT_IMPLEMENTED;
+            break;
+        }
+
+    }
+
+    /* we can be on fail only here */
+    CRASSERT(RT_FAILURE(rc));
+    pHdr->result = rc;
+
+    crServerCrHgsmiCmdComplete(pCmd, VINF_SUCCESS);
+    return rc;
+
+}
+
+
+static DECLCALLBACK(bool) crVBoxServerHasDataForScreen(uint32_t u32ScreenID)
+{
+    HCR_FRAMEBUFFER hFb = CrPMgrFbGetEnabledForScreen(u32ScreenID);
+    if (hFb)
+        return CrFbHas3DData(hFb);
+
+    return false;
+}
+
+
+static DECLCALLBACK(bool) crVBoxServerHasData(void)
+{
+    HCR_FRAMEBUFFER hFb = CrPMgrFbGetFirstEnabled();
+    for (;
+            hFb;
+            hFb = CrPMgrFbGetNextEnabled(hFb))
+    {
+        if (CrFbHas3DData(hFb))
+            return true;
+    }
+
+    return false;
+}
+
+int32_t crVBoxServerCrHgsmiCtl(struct VBOXVDMACMD_CHROMIUM_CTL *pCtl, uint32_t cbCtl)
+{
+    int rc = VINF_SUCCESS;
+
+    switch (pCtl->enmType)
+    {
+        case VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP:
+        {
+            PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP pSetup = (PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP)pCtl;
+            g_pvVRamBase = (uint8_t*)pSetup->pvVRamBase;
+            g_cbVRam = pSetup->cbVRam;
+
+            g_pLed = pSetup->pLed;
+
+            cr_server.ClientInfo = pSetup->CrClientInfo;
+
+            pSetup->CrCmdServerInfo.hSvr = NULL;
+            pSetup->CrCmdServerInfo.pfnEnable = crVBoxCrCmdEnable;
+            pSetup->CrCmdServerInfo.pfnDisable = crVBoxCrCmdDisable;
+            pSetup->CrCmdServerInfo.pfnCmd = crVBoxCrCmdCmd;
+            pSetup->CrCmdServerInfo.pfnHostCtl = crVBoxCrCmdHostCtl;
+            pSetup->CrCmdServerInfo.pfnGuestCtl = crVBoxCrCmdGuestCtl;
+            pSetup->CrCmdServerInfo.pfnResize = crVBoxCrCmdResize;
+            pSetup->CrCmdServerInfo.pfnSaveState = crVBoxCrCmdSaveState;
+            pSetup->CrCmdServerInfo.pfnLoadState = crVBoxCrCmdLoadState;
+            rc = VINF_SUCCESS;
+            break;
+        }
+        case VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_BEGIN:
+        case VBOXVDMACMD_CHROMIUM_CTL_TYPE_SAVESTATE_END:
+            rc = VINF_SUCCESS;
+            break;
+        case VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP_MAINCB:
+        {
+            PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP_MAINCB pSetup = (PVBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP_MAINCB)pCtl;
+            g_hCrHgsmiCompletion = pSetup->hCompletion;
+            g_pfnCrHgsmiCompletion = pSetup->pfnCompletion;
+
+            pSetup->MainInterface.pfnHasData = crVBoxServerHasData;
+            pSetup->MainInterface.pfnHasDataForScreen = crVBoxServerHasDataForScreen;
+
+            rc = VINF_SUCCESS;
+            break;
+        }
+        default:
+            AssertMsgFailed(("invalid param %d", pCtl->enmType));
+            rc = VERR_INVALID_PARAMETER;
+    }
+
+    /* NOTE: Control commands can NEVER be pended here, this is why its a task of a caller (Main)
+     * to complete them accordingly.
+     * This approach allows using host->host and host->guest commands in the same way here
+     * making the command completion to be the responsibility of the command originator.
+     * E.g. ctl commands can be both Hgcm Host synchronous commands that do not require completion at all,
+     * or Hgcm Host Fast Call commands that do require completion. All this details are hidden here */
+    return rc;
+}
+
+static int crVBoxServerCrCmdDisablePostProcess(VBOXCRCMDCTL_HGCMENABLE_DATA *pData)
+{
+    int rc = VINF_SUCCESS;
+    uint8_t* pCtl;
+    uint32_t cbCtl;
+    HVBOXCRCMDCTL_REMAINING_HOST_COMMAND hRHCmd = pData->hRHCmd;
+    PFNVBOXCRCMDCTL_REMAINING_HOST_COMMAND pfnRHCmd = pData->pfnRHCmd;
+
+    Assert(!cr_server.fCrCmdEnabled);
+
+    if (cr_server.numClients)
+    {
+        WARN(("cr_server.numClients(%d) is not NULL", cr_server.numClients));
+        return VERR_INVALID_STATE;
+    }
+
+    for (pCtl = pfnRHCmd(hRHCmd, &cbCtl, rc); pCtl; pCtl = pfnRHCmd(hRHCmd, &cbCtl, rc))
+    {
+        rc = crVBoxCrCmdHostCtl(NULL, pCtl, cbCtl);
+    }
+
+    memset(&cr_server.DisableData, 0, sizeof (cr_server.DisableData));
+
+    return VINF_SUCCESS;
+}
+
+int32_t crVBoxServerHgcmEnable(VBOXCRCMDCTL_HGCMENABLE_DATA *pData)
+{
+    int rc = crVBoxServerCrCmdDisablePostProcess(pData);
+    if (RT_FAILURE(rc))
+    {
+        WARN(("crVBoxServerCrCmdDisablePostProcess failed %d", rc));
+        return rc;
+    }
+
+    crVBoxServerDefaultContextSet();
+
+    return VINF_SUCCESS;
+}
+
+int32_t crVBoxServerHgcmDisable(VBOXCRCMDCTL_HGCMDISABLE_DATA *pData)
+{
+    Assert(!cr_server.fCrCmdEnabled);
+
+    Assert(!cr_server.numClients);
+
+    crVBoxServerRemoveAllClients();
+
+    CRASSERT(!cr_server.numClients);
+
+    crVBoxServerDefaultContextClear();
+
+    cr_server.DisableData = *pData;
+
+    return VINF_SUCCESS;
+}
+
+#endif
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.c	(revision 78189)
+++ 	(revision )
@@ -1,2016 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-#include "cr_pixeldata.h"
-#ifdef VBOX_WITH_CRDUMPER
-# include "cr_dump.h"
-#endif
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchSelectBuffer( GLsizei size, GLuint *buffer )
-{
-    (void) size;
-    (void) buffer;
-    crError( "Unsupported network glSelectBuffer call." );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetChromiumParametervCR(GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values)
-{
-    GLubyte local_storage[4096];
-    GLint bytes = 0;
-    GLint cbType = 1; /* One byte by default. */
-
-    memset(local_storage, 0, sizeof(local_storage));
-
-    switch (type) {
-    case GL_BYTE:
-    case GL_UNSIGNED_BYTE:
-         cbType = sizeof(GLbyte);
-         break;
-    case GL_SHORT:
-    case GL_UNSIGNED_SHORT:
-         cbType = sizeof(GLshort);
-         break;
-    case GL_INT:
-    case GL_UNSIGNED_INT:
-         cbType = sizeof(GLint);
-         break;
-    case GL_FLOAT:
-         cbType = sizeof(GLfloat);
-         break;
-    case GL_DOUBLE:
-         cbType = sizeof(GLdouble);
-         break;
-    default:
-         crError("Bad type in crServerDispatchGetChromiumParametervCR");
-    }
-
-    if (count < 0) /* 'GLsizei' is usually an 'int'. */
-        count = 0;
-    else if ((size_t)count > sizeof(local_storage) / cbType)
-        count = sizeof(local_storage) / cbType;
-
-    bytes = count * cbType;
-
-    CRASSERT(bytes >= 0);
-    CRASSERT(bytes < 4096);
-
-    switch (target)
-    {
-        case GL_DBG_CHECK_BREAK_CR:
-        {
-            if (bytes > 0)
-            {
-                GLubyte *pbRc = local_storage;
-                GLuint *puRc = (GLuint *)(bytes >=4 ? local_storage : NULL);
-                int rc;
-                memset(local_storage, 0, bytes);
-                if (cr_server.RcToGuestOnce)
-                {
-                    rc = cr_server.RcToGuestOnce;
-                    cr_server.RcToGuestOnce = 0;
-                }
-                else
-                {
-                    rc = cr_server.RcToGuest;
-                }
-                if (puRc)
-                    *puRc = rc;
-                else
-                    *pbRc = !!rc;
-            }
-            else
-            {
-                crWarning("zero bytes for GL_DBG_CHECK_BREAK_CR");
-            }
-            break;
-        }
-        case GL_HH_SET_DEFAULT_SHARED_CTX:
-            WARN(("Recieved GL_HH_SET_DEFAULT_SHARED_CTX from guest, ignoring"));
-            break;
-        case GL_HH_SET_CLIENT_CALLOUT:
-            WARN(("Recieved GL_HH_SET_CLIENT_CALLOUT from guest, ignoring"));
-            break;
-        default:
-            cr_server.head_spu->dispatch_table.GetChromiumParametervCR( target, index, type, count, local_storage );
-            break;
-    }
-
-    crServerReturnValue( local_storage, bytes );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchChromiumParametervCR(GLenum target, GLenum type, GLsizei count, const GLvoid *values)
-{
-    CRMuralInfo *mural = cr_server.curClient->currentMural;
-    static int gather_connect_count = 0;
-
-    switch (target) {
-        case GL_SHARE_LISTS_CR:
-        {
-            CRContextInfo *pCtx[2];
-            GLint *ai32Values;
-            int i;
-            if (count != 2)
-            {
-                WARN(("GL_SHARE_LISTS_CR invalid cound %d", count));
-                return;
-            }
-
-            if (type != GL_UNSIGNED_INT && type != GL_INT)
-            {
-                WARN(("GL_SHARE_LISTS_CR invalid type %d", type));
-                return;
-            }
-
-            ai32Values = (GLint*)values;
-
-            for (i = 0; i < 2; ++i)
-            {
-                const int32_t val = ai32Values[i];
-
-                if (val == 0)
-                {
-                    WARN(("GL_SHARE_LISTS_CR invalid value[%d] %d", i, val));
-                    return;
-                }
-
-                pCtx[i] = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, val);
-                if (!pCtx[i])
-                {
-                    WARN(("GL_SHARE_LISTS_CR invalid pCtx1 for value[%d] %d", i, val));
-                    return;
-                }
-
-                if (!pCtx[i]->pContext)
-                {
-                    WARN(("GL_SHARE_LISTS_CR invalid pCtx1 pContext for value[%d] %d", i, val));
-                    return;
-                }
-            }
-
-            crStateShareLists(pCtx[0]->pContext, pCtx[1]->pContext);
-
-            break;
-        }
-
-    case GL_SET_MAX_VIEWPORT_CR:
-        {
-            GLint *maxDims = (GLint *)values;
-            cr_server.limits.maxViewportDims[0] = maxDims[0];
-            cr_server.limits.maxViewportDims[1] = maxDims[1];
-        }
-        break;
-
-    case GL_TILE_INFO_CR:
-        /* message from tilesort SPU to set new tile bounds */
-        {
-            GLint numTiles, muralWidth, muralHeight, server, tiles;
-            GLint *tileBounds;
-            CRASSERT(count >= 4);
-            CRASSERT((count - 4) % 4 == 0); /* must be multiple of four */
-            CRASSERT(type == GL_INT);
-            numTiles = (count - 4) / 4;
-            tileBounds = (GLint *) values;
-            server = tileBounds[0];
-            muralWidth = tileBounds[1];
-            muralHeight = tileBounds[2];
-            tiles = tileBounds[3];
-            CRASSERT(tiles == numTiles);
-            tileBounds += 4; /* skip over header values */
-            /*crServerNewMuralTiling(mural, muralWidth, muralHeight, numTiles, tileBounds);
-            mural->viewportValidated = GL_FALSE;*/
-        }
-        break;
-
-    case GL_GATHER_DRAWPIXELS_CR:
-        if (cr_server.only_swap_once && cr_server.curClient != cr_server.clients[0])
-            break;
-        cr_server.head_spu->dispatch_table.ChromiumParametervCR( target, type, count, values );
-        break;
-
-    case GL_GATHER_CONNECT_CR:
-        /*
-         * We want the last connect to go through,
-         * otherwise we might deadlock in CheckWindowSize()
-         * in the readback spu
-         */
-        gather_connect_count++;
-        if (cr_server.only_swap_once && (gather_connect_count != cr_server.numClients))
-        {
-            break;
-        }
-        cr_server.head_spu->dispatch_table.ChromiumParametervCR( target, type, count, values );
-        gather_connect_count = 0;
-        break;
-
-    case GL_SERVER_VIEW_MATRIX_CR:
-        /* Set this server's view matrix which will get premultiplied onto the
-         * modelview matrix.  For non-planar tilesort and stereo.
-         */
-        CRASSERT(count == 18);
-        CRASSERT(type == GL_FLOAT);
-        /* values[0] is the server index. Ignored here but used in tilesort SPU */
-        /* values[1] is the left/right eye index (0 or 1) */
-        {
-            const GLfloat *v = (const GLfloat *) values;
-            const int eye = v[1] == 0.0 ? 0 : 1;
-            crMatrixInitFromFloats(&cr_server.viewMatrix[eye], v + 2);
-
-            crDebug("Got GL_SERVER_VIEW_MATRIX_CR:\n"
-                            "  %f %f %f %f\n"
-                            "  %f %f %f %f\n"
-                            "  %f %f %f %f\n"
-                            "  %f %f %f %f",
-                            cr_server.viewMatrix[eye].m00,
-                            cr_server.viewMatrix[eye].m10,
-                            cr_server.viewMatrix[eye].m20,
-                            cr_server.viewMatrix[eye].m30,
-                            cr_server.viewMatrix[eye].m01,
-                            cr_server.viewMatrix[eye].m11,
-                            cr_server.viewMatrix[eye].m21,
-                            cr_server.viewMatrix[eye].m31,
-                            cr_server.viewMatrix[eye].m02,
-                            cr_server.viewMatrix[eye].m12,
-                            cr_server.viewMatrix[eye].m22,
-                            cr_server.viewMatrix[eye].m32,
-                            cr_server.viewMatrix[eye].m03,
-                            cr_server.viewMatrix[eye].m13,
-                            cr_server.viewMatrix[eye].m23,
-                            cr_server.viewMatrix[eye].m33);
-        }
-        cr_server.viewOverride = GL_TRUE;
-        break;
-
-    case GL_SERVER_PROJECTION_MATRIX_CR:
-        /* Set this server's projection matrix which will get replace the user's
-         * projection matrix.  For non-planar tilesort and stereo.
-         */
-        CRASSERT(count == 18);
-        CRASSERT(type == GL_FLOAT);
-        /* values[0] is the server index. Ignored here but used in tilesort SPU */
-        /* values[1] is the left/right eye index (0 or 1) */
-        {
-            const GLfloat *v = (const GLfloat *) values;
-            const int eye = v[1] == 0.0 ? 0 : 1;
-            crMatrixInitFromFloats(&cr_server.projectionMatrix[eye], v + 2);
-
-            crDebug("Got GL_SERVER_PROJECTION_MATRIX_CR:\n"
-                            "  %f %f %f %f\n"
-                            "  %f %f %f %f\n"
-                            "  %f %f %f %f\n"
-                            "  %f %f %f %f",
-                            cr_server.projectionMatrix[eye].m00,
-                            cr_server.projectionMatrix[eye].m10,
-                            cr_server.projectionMatrix[eye].m20,
-                            cr_server.projectionMatrix[eye].m30,
-                            cr_server.projectionMatrix[eye].m01,
-                            cr_server.projectionMatrix[eye].m11,
-                            cr_server.projectionMatrix[eye].m21,
-                            cr_server.projectionMatrix[eye].m31,
-                            cr_server.projectionMatrix[eye].m02,
-                            cr_server.projectionMatrix[eye].m12,
-                            cr_server.projectionMatrix[eye].m22,
-                            cr_server.projectionMatrix[eye].m32,
-                            cr_server.projectionMatrix[eye].m03,
-                            cr_server.projectionMatrix[eye].m13,
-                            cr_server.projectionMatrix[eye].m23,
-                            cr_server.projectionMatrix[eye].m33);
-
-            if (cr_server.projectionMatrix[eye].m33 == 0.0f) {
-                float x = cr_server.projectionMatrix[eye].m00;
-                float y = cr_server.projectionMatrix[eye].m11;
-                float a = cr_server.projectionMatrix[eye].m20;
-                float b = cr_server.projectionMatrix[eye].m21;
-                float c = cr_server.projectionMatrix[eye].m22;
-                float d = cr_server.projectionMatrix[eye].m32;
-                float znear = -d / (1.0f - c);
-                float zfar = (c - 1.0f) * znear / (c + 1.0f);
-                float left = znear * (a - 1.0f) / x;
-                float right = 2.0f * znear / x + left;
-                float bottom = znear * (b - 1.0f) / y;
-              float top = 2.0f * znear / y + bottom;
-              crDebug("Frustum: left, right, bottom, top, near, far: %f, %f, %f, %f, %f, %f", left, right, bottom, top, znear, zfar);
-            }
-            else {
-                /** @todo Add debug output for orthographic projection*/
-            }
-
-        }
-        cr_server.projectionOverride = GL_TRUE;
-        break;
-
-    case GL_HH_SET_TMPCTX_MAKE_CURRENT:
-        /*we should not receive it from the guest! */
-        break;
-
-    case GL_HH_SET_CLIENT_CALLOUT:
-        WARN(("Recieved GL_HH_SET_CLIENT_CALLOUT from guest, ignoring"));
-        break;
-
-    default:
-        /* Pass the parameter info to the head SPU */
-        cr_server.head_spu->dispatch_table.ChromiumParametervCR( target, type, count, values );
-        break;
-    }
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchChromiumParameteriCR(GLenum target, GLint value)
-{
-  switch (target) {
-    case GL_SHARE_CONTEXT_RESOURCES_CR:
-        crStateShareContext(value);
-        break;
-    case GL_RCUSAGE_TEXTURE_SET_CR:
-        crStateSetTextureUsed(value, GL_TRUE);
-        break;
-    case GL_RCUSAGE_TEXTURE_CLEAR_CR:
-        crStateSetTextureUsed(value, GL_FALSE);
-        break;
-    case GL_PIN_TEXTURE_SET_CR:
-        crStatePinTexture(value, GL_TRUE);
-        break;
-    case GL_PIN_TEXTURE_CLEAR_CR:
-        crStatePinTexture(value, GL_FALSE);
-        break;
-    case GL_SHARED_DISPLAY_LISTS_CR:
-        cr_server.sharedDisplayLists = value;
-        break;
-    case GL_SHARED_TEXTURE_OBJECTS_CR:
-        cr_server.sharedTextureObjects = value;
-        break;
-    case GL_SHARED_PROGRAMS_CR:
-        cr_server.sharedPrograms = value;
-        break;
-    case GL_SERVER_CURRENT_EYE_CR:
-        cr_server.currentEye = value ? 1 : 0;
-        break;
-    case GL_HOST_WND_CREATED_HIDDEN_CR:
-        cr_server.bWindowsInitiallyHidden = value ? 1 : 0;
-        break;
-    case GL_HH_SET_DEFAULT_SHARED_CTX:
-        WARN(("Recieved GL_HH_SET_DEFAULT_SHARED_CTX from guest, ignoring"));
-        break;
-    case GL_HH_RENDERTHREAD_INFORM:
-        WARN(("Recieved GL_HH_RENDERTHREAD_INFORM from guest, ignoring"));
-        break;
-    default:
-        /* Pass the parameter info to the head SPU */
-        cr_server.head_spu->dispatch_table.ChromiumParameteriCR( target, value );
-    }
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchChromiumParameterfCR(GLenum target, GLfloat value)
-{
-  switch (target) {
-    case GL_SHARED_DISPLAY_LISTS_CR:
-        cr_server.sharedDisplayLists = (int) value;
-        break;
-    case GL_SHARED_TEXTURE_OBJECTS_CR:
-        cr_server.sharedTextureObjects = (int) value;
-        break;
-    case GL_SHARED_PROGRAMS_CR:
-        cr_server.sharedPrograms = (int) value;
-        break;
-    default:
-        /* Pass the parameter info to the head SPU */
-        cr_server.head_spu->dispatch_table.ChromiumParameterfCR( target, value );
-    }
-}
-
-GLint crServerGenerateID(GLint *pCounter)
-{
-    return (*pCounter)++;
-}
-
-/*#define CR_DUMP_BLITS*/
-
-#ifdef CR_DUMP_BLITS
-static int blitnum=0;
-static int copynum=0;
-#endif
-
-# ifdef DEBUG_misha
-//# define CR_CHECK_BLITS
-#  include <iprt/assert.h>
-#  undef CRASSERT /* iprt assert's int3 are inlined that is why are more convenient to use since they can be easily disabled individually */
-#  define CRASSERT Assert
-# endif
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
-{
-    /** @todo pbo/fbo disabled for now as it's slower, check on other gpus*/
-    static int siHavePBO = 0;
-    static int siHaveFBO = 0;
-
-    if ((target!=GL_TEXTURE_2D) || (height>=0))
-    {
-        cr_server.head_spu->dispatch_table.CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
-
-#ifdef CR_DUMP_BLITS
-        {
-            SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
-            void *img;
-            GLint w, h;
-            char fname[200];
-
-            copynum++;
-
-            gl->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
-            gl->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
-
-            img = crAlloc(w*h*4);
-            CRASSERT(img);
-
-            gl->GetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, img);
-            sprintf(fname, "copy_blit%i_copy_%i.tga", blitnum, copynum);
-            crDumpNamedTGA(fname, w, h, img);
-            crFree(img);
-        }
-#endif
-    }
-    else /* negative height, means we have to Yinvert the source pixels while copying */
-    {
-        SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
-
-        if (siHavePBO<0)
-        {
-            const char *ext = (const char*)gl->GetString(GL_EXTENSIONS);
-            siHavePBO = crStrstr(ext, "GL_ARB_pixel_buffer_object") ? 1:0;
-        }
-
-        if (siHaveFBO<0)
-        {
-            const char *ext = (const char*)gl->GetString(GL_EXTENSIONS);
-            siHaveFBO = crStrstr(ext, "GL_EXT_framebuffer_object") ? 1:0;
-        }
-
-        if (siHavePBO==0 && siHaveFBO==0)
-        {
-#if 1
-            GLint dRow, sRow;
-            for (dRow=yoffset, sRow=y-height-1; dRow<yoffset-height; dRow++, sRow--)
-            {
-                gl->CopyTexSubImage2D(target, level, xoffset, dRow, x, sRow, width, 1);
-            }
-#else
-            {
-                GLint w, h, i;
-                char *img1, *img2, *sPtr, *dPtr;
-                CRContext *ctx = crStateGetCurrent();
-
-                w = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].width;
-                h = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].height;
-
-                img1 = crAlloc(4*w*h);
-                img2 = crAlloc(4*width*(-height));
-                CRASSERT(img1 && img2);
-
-                gl->CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, -height);
-                gl->GetTexImage(target, level, GL_RGBA, GL_UNSIGNED_BYTE, img1);
-
-                sPtr=img1+4*xoffset+4*w*yoffset;
-                dPtr=img2+4*width*(-height-1);
-
-                for (i=0; i<-height; ++i)
-                {
-                    crMemcpy(dPtr, sPtr, 4*width);
-                    sPtr += 4*w;
-                    dPtr -= 4*width;
-                }
-
-                gl->TexSubImage2D(target, level, xoffset, yoffset, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, img2);
-
-                crFree(img1);
-                crFree(img2);
-            }
-#endif
-        }
-        else if (siHaveFBO==1) /** @todo more states to set and restore here*/
-        {
-            GLuint tID, fboID;
-            GLenum status;
-            CRContext *ctx = crStateGetCurrent();
-
-            gl->GenTextures(1, &tID);
-            gl->BindTexture(target, tID);
-            gl->CopyTexImage2D(target, level, GL_RGBA, x, y, width, -height, 0);
-            gl->GenFramebuffersEXT(1, &fboID);
-            gl->BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID);
-            gl->FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target,
-                                        ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid, level);
-            status = gl->CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-            if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
-            {
-                crWarning("Framebuffer status 0x%x", status);
-            }
-
-            gl->Enable(target);
-            gl->PushAttrib(GL_VIEWPORT_BIT);
-            gl->Viewport(xoffset, yoffset, width, -height);
-            gl->MatrixMode(GL_PROJECTION);
-            gl->PushMatrix();
-            gl->LoadIdentity();
-            gl->MatrixMode(GL_MODELVIEW);
-	        gl->PushMatrix();
-            gl->LoadIdentity();
-
-            gl->Disable(GL_DEPTH_TEST);
-            gl->Disable(GL_CULL_FACE);
-            gl->Disable(GL_STENCIL_TEST);
-            gl->Disable(GL_SCISSOR_TEST);
-
-            gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-            gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-            gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-            gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-            gl->TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
-            gl->Begin(GL_QUADS);
-                gl->TexCoord2f(0.0f, 1.0f);
-                gl->Vertex2f(-1.0, -1.0);
-
-                gl->TexCoord2f(0.0f, 0.0f);
-                gl->Vertex2f(-1.0f, 1.0f);
-
-                gl->TexCoord2f(1.0f, 0.0f);
-                gl->Vertex2f(1.0f, 1.0f);
-
-                gl->TexCoord2f(1.0f, 1.0f);
-                gl->Vertex2f(1.0f, -1.0f);
-            gl->End();
-
-            gl->PopMatrix();
-            gl->MatrixMode(GL_PROJECTION);
-            gl->PopMatrix();
-            gl->PopAttrib();
-
-            gl->FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target, 0, level);
-            gl->BindFramebufferEXT(GL_FRAMEBUFFER_EXT, ctx->framebufferobject.drawFB ? ctx->framebufferobject.drawFB->hwid:0);
-            gl->BindTexture(target, ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid);
-            gl->DeleteFramebuffersEXT(1, &fboID);
-            gl->DeleteTextures(1, &tID);
-
-#if 0
-            {
-                GLint dRow, sRow, w, h;
-                void *img1, *img2;
-
-                w = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].width;
-                h = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].height;
-
-                img1 = crAlloc(4*w*h);
-                img2 = crAlloc(4*w*h);
-                CRASSERT(img1 && img2);
-
-                gl->GetTexImage(target, level, GL_BGRA, GL_UNSIGNED_BYTE, img1);
-
-
-                for (dRow=yoffset, sRow=y-height-1; dRow<yoffset-height; dRow++, sRow--)
-                {
-                    gl->CopyTexSubImage2D(target, level, xoffset, dRow, x, sRow, width, 1);
-                }
-
-                gl->GetTexImage(target, level, GL_BGRA, GL_UNSIGNED_BYTE, img2);
-
-                if (crMemcmp(img1, img2, 4*w*h))
-                {
-                    crDebug("MISMATCH! (%x, %i, ->%i,%i  <-%i, %i  [%ix%i])", target, level, xoffset, yoffset, x, y, width, height);
-                    crDumpTGA(w, h, img1);
-                    crDumpTGA(w, h, img2);
-                    DebugBreak();
-                }
-                crFree(img1);
-                crFree(img2);
-            }
-#endif
-        }
-        else
-        {
-            GLint dRow;
-            GLuint pboId, sRow;
-            CRContext *ctx = crStateGetCurrent();
-
-            gl->GenBuffersARB(1, &pboId);
-            gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboId);
-            gl->BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, -width*height*4, 0, GL_STATIC_COPY_ARB);
-
-#if 1
-            gl->ReadPixels(x, y, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
-            gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid);
-
-            gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboId);
-            for (dRow=yoffset, sRow=-height-1; dRow<yoffset-height; dRow++, sRow--)
-            {
-                gl->TexSubImage2D(target, level, xoffset, dRow, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)((uintptr_t)sRow*width*4));
-            }
-#else /*few times slower again*/
-            for (dRow=0, sRow=y-height-1; dRow<-height; dRow++, sRow--)
-            {
-                gl->ReadPixels(x, sRow, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)((uintptr_t)dRow*width*4));
-            }
-            gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid);
-
-            gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboId);
-            gl->TexSubImage2D(target, level, xoffset, yoffset, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
-#endif
-
-            gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, ctx->bufferobject.unpackBuffer->hwid);
-            gl->DeleteBuffersARB(1, &pboId);
-        }
-    }
-}
-
-#ifdef CR_CHECK_BLITS
-void crDbgFree(void *pvData)
-{
-    crFree(pvData);
-}
-
-void crDbgGetTexImage2D(GLint texTarget, GLint texName, GLvoid **ppvImage, GLint *pw, GLint *ph)
-{
-    SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
-    GLint ppb, pub, dstw, dsth, otex;
-    GLint pa, pr, psp, psr, ua, ur, usp, usr;
-    GLvoid *pvImage;
-    GLint rfb, dfb, rb, db;
-
-    gl->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
-    gl->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
-    gl->GetIntegerv(GL_READ_BUFFER, &rb);
-    gl->GetIntegerv(GL_DRAW_BUFFER, &db);
-
-    gl->BindFramebufferEXT(GL_READ_FRAMEBUFFER_BINDING_EXT, 0);
-    gl->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_BINDING_EXT, 0);
-    gl->ReadBuffer(GL_BACK);
-    gl->DrawBuffer(GL_BACK);
-
-    gl->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &ppb);
-    gl->GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &pub);
-    gl->GetIntegerv(GL_TEXTURE_BINDING_2D, &otex);
-
-    gl->GetIntegerv(GL_PACK_ROW_LENGTH, &pr);
-    gl->GetIntegerv(GL_PACK_ALIGNMENT, &pa);
-    gl->GetIntegerv(GL_PACK_SKIP_PIXELS, &psp);
-    gl->GetIntegerv(GL_PACK_SKIP_ROWS, &psr);
-
-    gl->GetIntegerv(GL_UNPACK_ROW_LENGTH, &ur);
-    gl->GetIntegerv(GL_UNPACK_ALIGNMENT, &ua);
-    gl->GetIntegerv(GL_UNPACK_SKIP_PIXELS, &usp);
-    gl->GetIntegerv(GL_UNPACK_SKIP_ROWS, &usr);
-
-    gl->BindTexture(texTarget, texName);
-    gl->GetTexLevelParameteriv(texTarget, 0, GL_TEXTURE_WIDTH, &dstw);
-    gl->GetTexLevelParameteriv(texTarget, 0, GL_TEXTURE_HEIGHT, &dsth);
-
-    gl->PixelStorei(GL_PACK_ROW_LENGTH, 0);
-    gl->PixelStorei(GL_PACK_ALIGNMENT, 1);
-    gl->PixelStorei(GL_PACK_SKIP_PIXELS, 0);
-    gl->PixelStorei(GL_PACK_SKIP_ROWS, 0);
-
-    gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-    gl->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    gl->PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
-    gl->PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
-
-    gl->BindBufferARB(GL_PIXEL_PACK_BUFFER, 0);
-    gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);
-
-    pvImage = crAlloc(4*dstw*dsth);
-    gl->GetTexImage(texTarget, 0, GL_BGRA, GL_UNSIGNED_BYTE, pvImage);
-
-    gl->BindTexture(texTarget, otex);
-
-    gl->PixelStorei(GL_PACK_ROW_LENGTH, pr);
-    gl->PixelStorei(GL_PACK_ALIGNMENT, pa);
-    gl->PixelStorei(GL_PACK_SKIP_PIXELS, psp);
-    gl->PixelStorei(GL_PACK_SKIP_ROWS, psr);
-
-    gl->PixelStorei(GL_UNPACK_ROW_LENGTH, ur);
-    gl->PixelStorei(GL_UNPACK_ALIGNMENT, ua);
-    gl->PixelStorei(GL_UNPACK_SKIP_PIXELS, usp);
-    gl->PixelStorei(GL_UNPACK_SKIP_ROWS, usr);
-
-    gl->BindBufferARB(GL_PIXEL_PACK_BUFFER, ppb);
-    gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER, pub);
-
-    gl->BindFramebufferEXT(GL_READ_FRAMEBUFFER_BINDING_EXT, rfb);
-    gl->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_BINDING_EXT, dfb);
-    gl->ReadBuffer(rb);
-    gl->DrawBuffer(db);
-
-    *ppvImage = pvImage;
-    *pw = dstw;
-    *ph = dsth;
-}
-
-DECLEXPORT(void) crDbgPrint(const char *format, ... )
-{
-    va_list args;
-    static char txt[8092];
-
-    va_start(args, format);
-    vsprintf(txt, format, args);
-    va_end(args);
-
-    OutputDebugString(txt);
-}
-
-void crDbgDumpImage2D(const char* pszDesc, const void *pvData, uint32_t width, uint32_t height, uint32_t bpp, uint32_t pitch)
-{
-    crDbgPrint("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">%s</exec>, ( !vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d )\n",
-            pvData, width, height, bpp, pitch,
-            pszDesc,
-            pvData, width, height, bpp, pitch);
-}
-
-void crDbgDumpTexImage2D(const char* pszDesc, GLint texTarget, GLint texName, GLboolean fBreak)
-{
-    GLvoid *pvImage;
-    GLint w, h;
-    crDbgGetTexImage2D(texTarget, texName, &pvImage, &w, &h);
-    crDbgPrint("%s target(%d), name(%d), width(%d), height(%d)", pszDesc, texTarget, texName, w, h);
-    crDbgDumpImage2D("texture data", pvImage, w, h, 32, (32 * w)/8);
-    if (fBreak)
-    {
-        CRASSERT(0);
-    }
-    crDbgFree(pvImage);
-}
-#endif
-
-PCR_BLITTER crServerVBoxBlitterGet()
-{
-    if (!CrBltIsInitialized(&cr_server.Blitter))
-    {
-        CR_BLITTER_CONTEXT Ctx;
-        int rc;
-        CRASSERT(cr_server.MainContextInfo.SpuContext);
-        Ctx.Base.id = cr_server.MainContextInfo.SpuContext;
-        Ctx.Base.visualBits = cr_server.MainContextInfo.CreateInfo.realVisualBits;
-        rc = CrBltInit(&cr_server.Blitter, &Ctx, true, true, NULL, &cr_server.TmpCtxDispatch);
-        if (RT_SUCCESS(rc))
-        {
-            CRASSERT(CrBltIsInitialized(&cr_server.Blitter));
-        }
-        else
-        {
-            crWarning("CrBltInit failed, rc %d", rc);
-            CRASSERT(!CrBltIsInitialized(&cr_server.Blitter));
-            return NULL;
-        }
-    }
-
-    if (!CrBltMuralGetCurrentInfo(&cr_server.Blitter)->Base.id)
-    {
-        CRMuralInfo *dummy = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
-        CR_BLITTER_WINDOW DummyInfo;
-        CRASSERT(dummy);
-        crServerVBoxBlitterWinInit(&DummyInfo, dummy);
-        CrBltMuralSetCurrentInfo(&cr_server.Blitter, &DummyInfo);
-    }
-
-    return &cr_server.Blitter;
-}
-
-PCR_BLITTER crServerVBoxBlitterGetInitialized()
-{
-    if (CrBltIsInitialized(&cr_server.Blitter))
-        return &cr_server.Blitter;
-    return NULL;
-}
-
-
-int crServerVBoxBlitterTexInit(CRContext *ctx, CRMuralInfo *mural, PVBOXVR_TEXTURE pTex, GLboolean fDraw)
-{
-    CRTextureObj *tobj;
-    CRFramebufferObjectState *pBuf = &ctx->framebufferobject;
-    GLenum enmBuf;
-    CRFBOAttachmentPoint *pAp;
-    GLuint idx;
-    CRTextureLevel *tl;
-    CRFramebufferObject *pFBO = fDraw ? pBuf->drawFB : pBuf->readFB;
-
-    if (!pFBO)
-    {
-        GLuint hwid;
-
-        if (!mural->fRedirected)
-        {
-            WARN(("mural not redirected!"));
-            return VERR_NOT_IMPLEMENTED;
-        }
-
-        enmBuf = fDraw ? ctx->buffer.drawBuffer : ctx->buffer.readBuffer;
-        switch (enmBuf)
-        {
-            case GL_BACK:
-            case GL_BACK_RIGHT:
-            case GL_BACK_LEFT:
-                hwid = mural->aidColorTexs[CR_SERVER_FBO_BB_IDX(mural)];
-                break;
-            case GL_FRONT:
-            case GL_FRONT_RIGHT:
-            case GL_FRONT_LEFT:
-                hwid = mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)];
-                break;
-            default:
-                WARN(("unsupported enum buf %d", enmBuf));
-                return VERR_NOT_IMPLEMENTED;
-                break;
-        }
-
-        if (!hwid)
-        {
-            crWarning("offscreen render tex hwid is null");
-            return VERR_INVALID_STATE;
-        }
-
-        pTex->width = mural->width;
-        pTex->height = mural->height;
-        pTex->target = GL_TEXTURE_2D;
-        pTex->hwid = hwid;
-        return VINF_SUCCESS;
-    }
-
-    enmBuf = fDraw ? pFBO->drawbuffer[0] : pFBO->readbuffer;
-    idx = enmBuf - GL_COLOR_ATTACHMENT0_EXT;
-    if (idx >= CR_MAX_COLOR_ATTACHMENTS)
-    {
-        crWarning("idx is invalid %d, using 0", idx);
-    }
-
-    pAp = &pFBO->color[idx];
-
-    if (!pAp->name)
-    {
-        crWarning("no collor draw attachment");
-        return VERR_INVALID_STATE;
-    }
-
-    if (pAp->level)
-    {
-        WARN(("non-zero level not implemented"));
-        return VERR_NOT_IMPLEMENTED;
-    }
-
-    tobj = (CRTextureObj*)crHashtableSearch(ctx->shared->textureTable, pAp->name);
-    if (!tobj)
-    {
-        crWarning("no texture object found for name %d", pAp->name);
-        return VERR_INVALID_STATE;
-    }
-
-    if (tobj->target != GL_TEXTURE_2D && tobj->target != GL_TEXTURE_RECTANGLE_NV)
-    {
-        WARN(("non-texture[rect|2d] not implemented"));
-        return VERR_NOT_IMPLEMENTED;
-    }
-
-    CRASSERT(tobj->hwid);
-
-    tl = tobj->level[0];
-    pTex->width = tl->width;
-    pTex->height = tl->height;
-    pTex->target = tobj->target;
-    pTex->hwid = tobj->hwid;
-
-    return VINF_SUCCESS;
-}
-
-int crServerVBoxBlitterBlitCurrentCtx(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
-        GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
-        GLbitfield mask, GLenum filter)
-{
-    PCR_BLITTER pBlitter;
-    CR_BLITTER_CONTEXT Ctx;
-    CRMuralInfo *mural;
-    CRContext *ctx = crStateGetCurrent();
-    PVBOXVR_TEXTURE pDrawTex, pReadTex;
-    VBOXVR_TEXTURE DrawTex, ReadTex;
-    int rc;
-    GLuint idDrawFBO, idReadFBO;
-    CR_BLITTER_WINDOW BltInfo;
-
-    if (mask != GL_COLOR_BUFFER_BIT)
-    {
-        WARN(("not supported blit mask %d", mask));
-        return VERR_NOT_IMPLEMENTED;
-    }
-
-    if (!cr_server.curClient)
-    {
-        crWarning("no current client");
-        return VERR_INVALID_STATE;
-    }
-    mural = cr_server.curClient->currentMural;
-    if (!mural)
-    {
-        crWarning("no current mural");
-        return VERR_INVALID_STATE;
-    }
-
-    rc = crServerVBoxBlitterTexInit(ctx, mural, &DrawTex, GL_TRUE);
-    if (RT_SUCCESS(rc))
-    {
-        pDrawTex = &DrawTex;
-    }
-    else
-    {
-        crWarning("crServerVBoxBlitterTexInit failed for draw");
-        return rc;
-    }
-
-    rc = crServerVBoxBlitterTexInit(ctx, mural, &ReadTex, GL_FALSE);
-    if (RT_SUCCESS(rc))
-    {
-        pReadTex = &ReadTex;
-    }
-    else
-    {
-//        crWarning("crServerVBoxBlitterTexInit failed for read");
-        return rc;
-    }
-
-    pBlitter = crServerVBoxBlitterGet();
-    if (!pBlitter)
-    {
-        crWarning("crServerVBoxBlitterGet failed");
-        return VERR_GENERAL_FAILURE;
-    }
-
-    crServerVBoxBlitterWinInit(&BltInfo, mural);
-
-    crServerVBoxBlitterCtxInit(&Ctx, cr_server.curClient->currentCtxInfo);
-
-    CrBltMuralSetCurrentInfo(pBlitter, &BltInfo);
-
-    idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
-    idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
-
-    crStateSwitchPrepare(NULL, ctx, idDrawFBO, idReadFBO);
-
-    rc = CrBltEnter(pBlitter);
-    if (RT_SUCCESS(rc))
-    {
-        RTRECT ReadRect, DrawRect;
-        ReadRect.xLeft = srcX0;
-        ReadRect.yTop = srcY0;
-        ReadRect.xRight = srcX1;
-        ReadRect.yBottom = srcY1;
-        DrawRect.xLeft = dstX0;
-        DrawRect.yTop = dstY0;
-        DrawRect.xRight = dstX1;
-        DrawRect.yBottom = dstY1;
-        CrBltBlitTexTex(pBlitter, pReadTex, &ReadRect, pDrawTex, &DrawRect, 1, CRBLT_FLAGS_FROM_FILTER(filter));
-        CrBltLeave(pBlitter);
-    }
-    else
-    {
-        crWarning("CrBltEnter failed rc %d", rc);
-    }
-
-    crStateSwitchPostprocess(ctx, NULL, idDrawFBO, idReadFBO);
-
-    return rc;
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
-                                   GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
-                                   GLbitfield mask, GLenum filter)
-{
-    CRContext *ctx = crStateGetCurrent();
-    bool fTryBlitter = false;
-#ifdef CR_CHECK_BLITS
-//    {
-        SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
-        GLint rfb=0, dfb=0, dtex=0, dlev=-1, rtex=0, rlev=-1, rb=0, db=0, ppb=0, pub=0, vp[4], otex, dstw, dsth;
-        GLint sdtex=0, srtex=0;
-        GLenum dStatus, rStatus;
-
-        CRTextureObj *tobj = 0;
-        CRTextureLevel *tl = 0;
-        GLint id, tuId, pbufId, pbufIdHw, ubufId, ubufIdHw, width, height, depth;
-
-        crDebug("===StateTracker===");
-        crDebug("Current TU: %i", ctx->texture.curTextureUnit);
-
-        tobj = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D;
-        CRASSERT(tobj);
-        tl = &tobj->level[0][0];
-        crDebug("Texture %i(hw %i), w=%i, h=%i", tobj->id, tobj->hwid, tl->width, tl->height, tl->depth);
-
-        if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
-        {
-            pbufId = ctx->bufferobject.packBuffer->hwid;
-        }
-        else
-        {
-            pbufId = 0;
-        }
-        crDebug("Pack BufferId %i", pbufId);
-
-        if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
-        {
-            ubufId = ctx->bufferobject.unpackBuffer->hwid;
-        }
-        else
-        {
-            ubufId = 0;
-        }
-        crDebug("Unpack BufferId %i", ubufId);
-
-        crDebug("===GPU===");
-        cr_server.head_spu->dispatch_table.GetIntegerv(GL_ACTIVE_TEXTURE, &tuId);
-        crDebug("Current TU: %i", tuId - GL_TEXTURE0_ARB);
-        CRASSERT(tuId - GL_TEXTURE0_ARB == ctx->texture.curTextureUnit);
-
-        cr_server.head_spu->dispatch_table.GetIntegerv(GL_TEXTURE_BINDING_2D, &id);
-        cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
-        cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
-        cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_DEPTH, &depth);
-        crDebug("Texture: %i, w=%i, h=%i, d=%i", id, width, height, depth);
-        CRASSERT(id == tobj->hwid);
-        CRASSERT(width == tl->width);
-        CRASSERT(height == tl->height);
-        CRASSERT(depth == tl->depth);
-
-        cr_server.head_spu->dispatch_table.GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &pbufIdHw);
-        crDebug("Hw Pack BufferId %i", pbufIdHw);
-        CRASSERT(pbufIdHw == pbufId);
-
-        cr_server.head_spu->dispatch_table.GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &ubufIdHw);
-        crDebug("Hw Unpack BufferId %i", ubufIdHw);
-        CRASSERT(ubufIdHw == ubufId);
-
-        gl->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
-        gl->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
-        gl->GetIntegerv(GL_READ_BUFFER, &rb);
-        gl->GetIntegerv(GL_DRAW_BUFFER, &db);
-
-        gl->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &ppb);
-        gl->GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &pub);
-
-        gl->GetIntegerv(GL_VIEWPORT, &vp[0]);
-
-        gl->GetIntegerv(GL_TEXTURE_BINDING_2D, &otex);
-
-        gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, &dtex);
-        gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT, &dlev);
-        dStatus = gl->CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
-
-        gl->GetFramebufferAttachmentParameterivEXT(GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, &rtex);
-        gl->GetFramebufferAttachmentParameterivEXT(GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT, &rlev);
-        rStatus = gl->CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER_EXT);
-
-        if (dtex)
-        {
-            CRASSERT(!dlev);
-        }
-
-        if (rtex)
-        {
-            CRASSERT(!rlev);
-        }
-
-        if (ctx->framebufferobject.drawFB)
-        {
-            CRASSERT(dfb);
-            CRASSERT(ctx->framebufferobject.drawFB->hwid == dfb);
-            CRASSERT(ctx->framebufferobject.drawFB->drawbuffer[0] == db);
-
-            CRASSERT(dStatus==GL_FRAMEBUFFER_COMPLETE_EXT);
-            CRASSERT(db==GL_COLOR_ATTACHMENT0_EXT);
-
-            CRASSERT(ctx->framebufferobject.drawFB->color[0].type == GL_TEXTURE);
-            CRASSERT(ctx->framebufferobject.drawFB->color[0].level == 0);
-            sdtex = ctx->framebufferobject.drawFB->color[0].name;
-            sdtex = crStateGetTextureHWID(sdtex);
-
-            CRASSERT(sdtex);
-        }
-        else
-        {
-            CRASSERT(!dfb);
-        }
-
-        if (ctx->framebufferobject.readFB)
-        {
-            CRASSERT(rfb);
-            CRASSERT(ctx->framebufferobject.readFB->hwid == rfb);
-
-            CRASSERT(rStatus==GL_FRAMEBUFFER_COMPLETE_EXT);
-
-            CRASSERT(ctx->framebufferobject.readFB->color[0].type == GL_TEXTURE);
-            CRASSERT(ctx->framebufferobject.readFB->color[0].level == 0);
-            srtex = ctx->framebufferobject.readFB->color[0].name;
-            srtex = crStateGetTextureHWID(srtex);
-
-            CRASSERT(srtex);
-        }
-        else
-        {
-            CRASSERT(!rfb);
-        }
-
-        CRASSERT(sdtex == dtex);
-        CRASSERT(srtex == rtex);
-
-//        crDbgDumpTexImage2D("==> src tex:", GL_TEXTURE_2D, rtex, true);
-//        crDbgDumpTexImage2D("==> dst tex:", GL_TEXTURE_2D, dtex, true);
-
-//    }
-#endif
-#ifdef CR_DUMP_BLITS
-    SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
-    GLint rfb=0, dfb=0, dtex=0, dlev=-1, rb=0, db=0, ppb=0, pub=0, vp[4], otex, dstw, dsth;
-    GLenum status;
-    char fname[200];
-    void *img;
-
-    blitnum++;
-
-    crDebug("[%i]BlitFramebufferEXT(%i, %i, %i, %i, %i, %i, %i, %i, %x, %x)", blitnum, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-    crDebug("%i, %i <-> %i, %i", srcX1-srcX0, srcY1-srcY0, dstX1-dstX0, dstY1-dstY0);
-
-    gl->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
-    gl->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
-    gl->GetIntegerv(GL_READ_BUFFER, &rb);
-    gl->GetIntegerv(GL_DRAW_BUFFER, &db);
-
-    gl->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &ppb);
-    gl->GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &pub);
-
-    gl->GetIntegerv(GL_VIEWPORT, &vp[0]);
-
-    gl->GetIntegerv(GL_TEXTURE_BINDING_2D, &otex);
-
-    CRASSERT(!rfb && dfb);
-    gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, &dtex);
-    gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT, &dlev);
-    status = gl->CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
-
-    CRASSERT(status==GL_FRAMEBUFFER_COMPLETE_EXT
-             && db==GL_COLOR_ATTACHMENT0_EXT
-             && (rb==GL_FRONT || rb==GL_BACK)
-             && !rfb && dfb && dtex && !dlev
-             && !ppb && !pub);
-
-    crDebug("Src[rb 0x%x, fbo %i] Dst[db 0x%x, fbo %i(0x%x), tex %i.%i]", rb, rfb, db, dfb, status, dtex, dlev);
-    crDebug("Viewport [%i, %i, %i, %i]", vp[0], vp[1], vp[2], vp[3]);
-
-    gl->PixelStorei(GL_PACK_ROW_LENGTH, 0);
-    gl->PixelStorei(GL_PACK_ALIGNMENT, 1);
-    gl->PixelStorei(GL_PACK_SKIP_PIXELS, 0);
-    gl->PixelStorei(GL_PACK_SKIP_ROWS, 0);
-
-    gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
-    gl->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
-    gl->PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
-    gl->PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
-
-    gl->BindTexture(GL_TEXTURE_2D, dtex);
-    gl->GetTexLevelParameteriv(GL_TEXTURE_2D, dlev, GL_TEXTURE_WIDTH, &dstw);
-    gl->GetTexLevelParameteriv(GL_TEXTURE_2D, dlev, GL_TEXTURE_HEIGHT, &dsth);
-    gl->BindTexture(GL_TEXTURE_2D, otex);
-    crDebug("Dst is %i, %i", dstw, dsth);
-
-    CRASSERT(vp[2]>=dstw && vp[3]>=dsth);
-    img = crAlloc(vp[2]*vp[3]*4);
-    CRASSERT(img);
-
-    gl->ReadPixels(0, 0, vp[2], vp[3], GL_BGRA, GL_UNSIGNED_BYTE, img);
-    sprintf(fname, "blit%iA_src.tga", blitnum);
-    crDumpNamedTGA(fname, vp[2], vp[3], img);
-
-    gl->BindTexture(GL_TEXTURE_2D, dtex);
-    gl->GetTexImage(GL_TEXTURE_2D, dlev, GL_BGRA, GL_UNSIGNED_BYTE, img);
-    sprintf(fname, "blit%iB_dst.tga", blitnum);
-    crDumpNamedTGA(fname, dstw, dsth, img);
-    gl->BindTexture(GL_TEXTURE_2D, otex);
-#endif
-
-    if (srcY0 > srcY1)
-    {
-        /* work around Intel driver bug on Linux host  */
-        if (1 || dstY0 > dstY1)
-        {
-            /* use srcY1 < srcY2 && dstY1 < dstY2 whenever possible to avoid GPU driver bugs */
-            int32_t tmp = srcY0;
-            srcY0 = srcY1;
-            srcY1 = tmp;
-            tmp = dstY0;
-            dstY0 = dstY1;
-            dstY1 = tmp;
-        }
-    }
-
-    if (srcX0 > srcX1)
-    {
-        if (dstX0 > dstX1)
-        {
-            /* use srcX1 < srcX2 && dstX1 < dstX2 whenever possible to avoid GPU driver bugs */
-            int32_t tmp = srcX0;
-            srcX0 = srcX1;
-            srcX1 = tmp;
-            tmp = dstX0;
-            dstX0 = dstX1;
-            dstX1 = tmp;
-        }
-    }
-
-    if (cr_server.fBlitterMode)
-    {
-        fTryBlitter = true;
-    }
-
-    if (fTryBlitter)
-    {
-        int rc = crServerVBoxBlitterBlitCurrentCtx(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-        if (RT_SUCCESS(rc))
-            goto my_exit;
-    }
-
-    if (ctx->viewport.scissorTest)
-        cr_server.head_spu->dispatch_table.Disable(GL_SCISSOR_TEST);
-
-    cr_server.head_spu->dispatch_table.BlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1,
-                                                          dstX0, dstY0, dstX1, dstY1,
-                                                          mask, filter);
-
-    if (ctx->viewport.scissorTest)
-        cr_server.head_spu->dispatch_table.Enable(GL_SCISSOR_TEST);
-
-
-my_exit:
-
-//#ifdef CR_CHECK_BLITS
-//    crDbgDumpTexImage2D("<== src tex:", GL_TEXTURE_2D, rtex, true);
-//    crDbgDumpTexImage2D("<== dst tex:", GL_TEXTURE_2D, dtex, true);
-//#endif
-#ifdef CR_DUMP_BLITS
-    gl->BindTexture(GL_TEXTURE_2D, dtex);
-    gl->GetTexImage(GL_TEXTURE_2D, dlev, GL_BGRA, GL_UNSIGNED_BYTE, img);
-    sprintf(fname, "blit%iC_res.tga", blitnum);
-    crDumpNamedTGA(fname, dstw, dsth, img);
-    gl->BindTexture(GL_TEXTURE_2D, otex);
-    crFree(img);
-#endif
-    return;
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDrawBuffer( GLenum mode )
-{
-    crStateDrawBuffer( mode );
-
-    if (!crStateGetCurrent()->framebufferobject.drawFB)
-    {
-        if (mode == GL_FRONT || mode == GL_FRONT_LEFT || mode == GL_FRONT_RIGHT)
-            cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
-
-        if (crServerIsRedirectedToFBO()
-                && cr_server.curClient->currentMural->aidFBOs[0])
-        {
-            CRMuralInfo *mural = cr_server.curClient->currentMural;
-            GLint iBufferNeeded = -1;
-            switch (mode)
-            {
-                case GL_BACK:
-                case GL_BACK_LEFT:
-                case GL_BACK_RIGHT:
-                    mode = GL_COLOR_ATTACHMENT0;
-                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
-                    break;
-                case GL_FRONT:
-                case GL_FRONT_LEFT:
-                case GL_FRONT_RIGHT:
-                    mode = GL_COLOR_ATTACHMENT0;
-                    iBufferNeeded = CR_SERVER_FBO_FB_IDX(mural);
-                    break;
-                case GL_NONE:
-                    crDebug("DrawBuffer: GL_NONE");
-                    break;
-                case GL_AUX0:
-                    crDebug("DrawBuffer: GL_AUX0");
-                    break;
-                case GL_AUX1:
-                    crDebug("DrawBuffer: GL_AUX1");
-                    break;
-                case GL_AUX2:
-                    crDebug("DrawBuffer: GL_AUX2");
-                    break;
-                case GL_AUX3:
-                    crDebug("DrawBuffer: GL_AUX3");
-                    break;
-                case GL_LEFT:
-                    crWarning("DrawBuffer: GL_LEFT not supported properly");
-                    mode = GL_COLOR_ATTACHMENT0;
-                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
-                    break;
-                case GL_RIGHT:
-                    crWarning("DrawBuffer: GL_RIGHT not supported properly");
-                    mode = GL_COLOR_ATTACHMENT0;
-                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
-                    break;
-                case GL_FRONT_AND_BACK:
-                    crWarning("DrawBuffer: GL_FRONT_AND_BACK not supported properly");
-                    mode = GL_COLOR_ATTACHMENT0;
-                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
-                    break;
-                default:
-                    crWarning("DrawBuffer: unexpected mode! 0x%x", mode);
-                    iBufferNeeded = mural->iCurDrawBuffer;
-                    break;
-            }
-
-            if (iBufferNeeded != mural->iCurDrawBuffer)
-            {
-                mural->iCurDrawBuffer = iBufferNeeded;
-                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, iBufferNeeded));
-            }
-        }
-    }
-
-    cr_server.head_spu->dispatch_table.DrawBuffer( mode );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDrawBuffers( GLsizei n, const GLenum* bufs )
-{
-    if (n == 1)
-    {
-        crServerDispatchDrawBuffer( bufs[0] );
-    }
-    else
-    {
-        /** @todo State tracker. */
-        cr_server.head_spu->dispatch_table.DrawBuffers( n, bufs );
-    }
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchReadBuffer( GLenum mode )
-{
-    crStateReadBuffer( mode );
-
-    if (crServerIsRedirectedToFBO()
-            && cr_server.curClient->currentMural->aidFBOs[0]
-            && !crStateGetCurrent()->framebufferobject.readFB)
-    {
-        CRMuralInfo *mural = cr_server.curClient->currentMural;
-        GLint iBufferNeeded = -1;
-        switch (mode)
-        {
-            case GL_BACK:
-            case GL_BACK_LEFT:
-            case GL_BACK_RIGHT:
-                mode = GL_COLOR_ATTACHMENT0;
-                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
-                break;
-            case GL_FRONT:
-            case GL_FRONT_LEFT:
-            case GL_FRONT_RIGHT:
-                mode = GL_COLOR_ATTACHMENT0;
-                iBufferNeeded = CR_SERVER_FBO_FB_IDX(mural);
-                break;
-            case GL_NONE:
-                crDebug("ReadBuffer: GL_NONE");
-                break;
-            case GL_AUX0:
-                crDebug("ReadBuffer: GL_AUX0");
-                break;
-            case GL_AUX1:
-                crDebug("ReadBuffer: GL_AUX1");
-                break;
-            case GL_AUX2:
-                crDebug("ReadBuffer: GL_AUX2");
-                break;
-            case GL_AUX3:
-                crDebug("ReadBuffer: GL_AUX3");
-                break;
-            case GL_LEFT:
-                crWarning("ReadBuffer: GL_LEFT not supported properly");
-                mode = GL_COLOR_ATTACHMENT0;
-                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
-                break;
-            case GL_RIGHT:
-                crWarning("ReadBuffer: GL_RIGHT not supported properly");
-                mode = GL_COLOR_ATTACHMENT0;
-                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
-                break;
-            case GL_FRONT_AND_BACK:
-                crWarning("ReadBuffer: GL_FRONT_AND_BACK not supported properly");
-                mode = GL_COLOR_ATTACHMENT0;
-                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
-                break;
-            default:
-                crWarning("ReadBuffer: unexpected mode! 0x%x", mode);
-                iBufferNeeded = mural->iCurDrawBuffer;
-                break;
-        }
-
-        Assert(CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
-        if (iBufferNeeded != mural->iCurReadBuffer)
-        {
-            mural->iCurReadBuffer = iBufferNeeded;
-            cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, iBufferNeeded));
-        }
-    }
-    cr_server.head_spu->dispatch_table.ReadBuffer( mode );
-}
-
-GLenum SERVER_DISPATCH_APIENTRY crServerDispatchGetError( void )
-{
-    GLenum retval, err;
-    CRContext *ctx = crStateGetCurrent();
-    retval = ctx->error;
-
-    err = cr_server.head_spu->dispatch_table.GetError();
-    if (retval == GL_NO_ERROR)
-        retval = err;
-    else
-        ctx->error = GL_NO_ERROR;
-
-    /* our impl has a single error flag, so we just loop here to reset all error flags to no_error */
-    while (err != GL_NO_ERROR)
-        err = cr_server.head_spu->dispatch_table.GetError();
-
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerMakeTmpCtxCurrent( GLint window, GLint nativeWindow, GLint context )
-{
-    CRContext *pCtx = crStateGetCurrent();
-    CRContext *pCurCtx = NULL;
-    GLuint idDrawFBO = 0, idReadFBO = 0;
-    int fDoPrePostProcess = 0;
-
-    if (pCtx)
-    {
-        CRMuralInfo *pCurrentMural = cr_server.currentMural;
-
-        pCurCtx = cr_server.currentCtxInfo ? cr_server.currentCtxInfo->pContext : cr_server.MainContextInfo.pContext;
-        Assert(pCurCtx == pCtx);
-
-        if (!context)
-        {
-            if (pCurrentMural)
-            {
-                Assert(cr_server.currentCtxInfo);
-                context = cr_server.currentCtxInfo->SpuContext > 0 ? cr_server.currentCtxInfo->SpuContext : cr_server.MainContextInfo.SpuContext;
-                window = pCurrentMural->spuWindow;
-            }
-            else
-            {
-                CRMuralInfo * pDummy;
-                Assert(!cr_server.currentCtxInfo);
-                pDummy = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
-                context = cr_server.MainContextInfo.SpuContext;
-                window = pDummy->spuWindow;
-            }
-
-
-            fDoPrePostProcess = -1;
-        }
-        else
-        {
-            fDoPrePostProcess = 1;
-        }
-
-        if (pCurrentMural)
-        {
-            idDrawFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurDrawBuffer);
-            idReadFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurReadBuffer);
-        }
-        else
-        {
-            idDrawFBO = 0;
-            idReadFBO = 0;
-        }
-    }
-    else
-    {
-        /* this is a GUI thread, so no need to do anything here */
-    }
-
-    if (fDoPrePostProcess > 0)
-        crStateSwitchPrepare(NULL, pCurCtx, idDrawFBO, idReadFBO);
-
-    cr_server.head_spu->dispatch_table.MakeCurrent( window, nativeWindow, context);
-
-    if (fDoPrePostProcess < 0)
-        crStateSwitchPostprocess(pCurCtx, NULL, idDrawFBO, idReadFBO);
-}
-
-void crServerInitTmpCtxDispatch()
-{
-    MakeCurrentFunc_t pfnMakeCurrent;
-
-    crSPUInitDispatchTable(&cr_server.TmpCtxDispatch);
-    crSPUCopyDispatchTable(&cr_server.TmpCtxDispatch, &cr_server.head_spu->dispatch_table);
-    cr_server.TmpCtxDispatch.MakeCurrent = crServerMakeTmpCtxCurrent;
-
-    pfnMakeCurrent = crServerMakeTmpCtxCurrent;
-    cr_server.head_spu->dispatch_table.ChromiumParametervCR(GL_HH_SET_TMPCTX_MAKE_CURRENT, GL_BYTE, sizeof (void*), &pfnMakeCurrent);
-
-}
-
-/* dump stuff */
-#ifdef VBOX_WITH_CRSERVER_DUMPER
-
-# ifndef VBOX_WITH_CRDUMPER
-#  error "VBOX_WITH_CRDUMPER undefined!"
-# endif
-
-/* first four bits are buffer dump config
- * second four bits are texture dump config
- * config flags:
- * 1 - blit on enter
- * 2 - blit on exit
- *
- *
- * Example:
- *
- * 0x03 - dump buffer on enter and exit
- * 0x22 - dump texture and buffer on exit */
-
-int64_t g_CrDbgDumpPid = 0;
-unsigned long g_CrDbgDumpEnabled = 0;
-unsigned long g_CrDbgDumpDraw = 0
-#if 0
-        | CR_SERVER_DUMP_F_COMPILE_SHADER
-        | CR_SERVER_DUMP_F_LINK_PROGRAM
-#endif
-        ;
-#if 0
-        | CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
-        | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
-        | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER
-        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER
-        | CR_SERVER_DUMP_F_DRAW_TEX_ENTER
-        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER
-        | CR_SERVER_DUMP_F_DRAW_STATE_ENTER
-        | CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER
-        | CR_SERVER_DUMP_F_DRAWEL
-        | CR_SERVER_DUMP_F_SHADER_SOURCE
-        ;
-#endif
-unsigned long g_CrDbgDumpDrawFramesSettings = CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
-        | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
-        | CR_SERVER_DUMP_F_DRAW_TEX_ENTER
-        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER
-        | CR_SERVER_DUMP_F_COMPILE_SHADER
-        | CR_SERVER_DUMP_F_LINK_PROGRAM
-        | CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER;
-unsigned long g_CrDbgDumpDrawFramesAppliedSettings = 0;
-unsigned long g_CrDbgDumpDrawFramesSavedInitSettings = 0;
-unsigned long g_CrDbgDumpDrawFramesCount = 0;
-
-uint32_t g_CrDbgDumpDrawCount = 0;
-uint32_t g_CrDbgDumpDumpOnCount = 10;
-uint32_t g_CrDbgDumpDumpOnCountEnabled = 0;
-uint32_t g_CrDbgDumpDumpOnCountPerform = 0;
-uint32_t g_CrDbgDumpDrawFlags = CR_SERVER_DUMP_F_COMPILE_SHADER
-        | CR_SERVER_DUMP_F_SHADER_SOURCE
-        | CR_SERVER_DUMP_F_COMPILE_SHADER
-        | CR_SERVER_DUMP_F_LINK_PROGRAM
-        | CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
-        | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
-        | CR_SERVER_DUMP_F_DRAW_TEX_ENTER
-        | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER
-        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER
-        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER
-        | CR_SERVER_DUMP_F_DRAW_STATE_ENTER
-        | CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER
-        | CR_SERVER_DUMP_F_DRAWEL
-        | CR_SERVER_DUMP_F_TEXPRESENT;
-
-void crServerDumpCheckTerm()
-{
-    if (!CrBltIsInitialized(&cr_server.RecorderBlitter))
-        return;
-
-    CrBltTerm(&cr_server.RecorderBlitter);
-}
-
-int crServerDumpCheckInit()
-{
-    int rc;
-    CR_BLITTER_WINDOW BltWin;
-    CR_BLITTER_CONTEXT BltCtx;
-    CRMuralInfo *pBlitterMural;
-
-    if (!CrBltIsInitialized(&cr_server.RecorderBlitter))
-    {
-        pBlitterMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
-        if (!pBlitterMural)
-        {
-            crWarning("crServerGetDummyMural failed");
-            return VERR_GENERAL_FAILURE;
-        }
-
-        crServerVBoxBlitterWinInit(&BltWin, pBlitterMural);
-        crServerVBoxBlitterCtxInit(&BltCtx, &cr_server.MainContextInfo);
-
-        rc = CrBltInit(&cr_server.RecorderBlitter, &BltCtx, true, true, NULL, &cr_server.TmpCtxDispatch);
-        if (!RT_SUCCESS(rc))
-        {
-            crWarning("CrBltInit failed rc %d", rc);
-            return rc;
-        }
-
-        rc = CrBltMuralSetCurrentInfo(&cr_server.RecorderBlitter, &BltWin);
-        if (!RT_SUCCESS(rc))
-        {
-            crWarning("CrBltMuralSetCurrentInfo failed rc %d", rc);
-            return rc;
-        }
-    }
-
-#if 0
-    crDmpDbgPrintInit(&cr_server.DbgPrintDumper);
-    cr_server.pDumper = &cr_server.DbgPrintDumper.Base;
-#else
-    if (!crDmpHtmlIsInited(&cr_server.HtmlDumper))
-    {
-        static int cCounter = 0;
-//    crDmpHtmlInit(&cr_server.HtmlDumper, "S:\\projects\\virtualbox\\3d\\dumps\\1", "index.html");
-        crDmpHtmlInitF(&cr_server.HtmlDumper, "/Users/oracle-mac/vbox/dump/1", "index%d.html", cCounter);
-        cr_server.pDumper = &cr_server.HtmlDumper.Base;
-        ++cCounter;
-    }
-#endif
-
-    crRecInit(&cr_server.Recorder, &cr_server.RecorderBlitter, &cr_server.TmpCtxDispatch, cr_server.pDumper);
-    return VINF_SUCCESS;
-}
-
-void crServerDumpShader(GLint id)
-{
-    CRContext *ctx = crStateGetCurrent();
-    crRecDumpShader(&cr_server.Recorder, ctx, id, 0);
-}
-
-void crServerDumpProgram(GLint id)
-{
-    CRContext *ctx = crStateGetCurrent();
-    crRecDumpProgram(&cr_server.Recorder, ctx, id, 0);
-}
-
-void crServerDumpCurrentProgram()
-{
-    CRContext *ctx = crStateGetCurrent();
-    crRecDumpCurrentProgram(&cr_server.Recorder, ctx);
-}
-
-void crServerDumpRecompileDumpCurrentProgram()
-{
-    crDmpStrF(cr_server.Recorder.pDumper, "==Dump(1)==");
-    crServerRecompileCurrentProgram();
-    crServerDumpCurrentProgramUniforms();
-    crServerDumpCurrentProgramAttribs();
-    crDmpStrF(cr_server.Recorder.pDumper, "Done Dump(1)");
-    crServerRecompileCurrentProgram();
-    crDmpStrF(cr_server.Recorder.pDumper, "Dump(2)");
-    crServerRecompileCurrentProgram();
-    crServerDumpCurrentProgramUniforms();
-    crServerDumpCurrentProgramAttribs();
-    crDmpStrF(cr_server.Recorder.pDumper, "Done Dump(2)");
-}
-
-void crServerRecompileCurrentProgram()
-{
-    CRContext *ctx = crStateGetCurrent();
-    crRecRecompileCurrentProgram(&cr_server.Recorder, ctx);
-}
-
-void crServerDumpCurrentProgramUniforms()
-{
-    CRContext *ctx = crStateGetCurrent();
-    crDmpStrF(cr_server.Recorder.pDumper, "==Uniforms==");
-    crRecDumpCurrentProgramUniforms(&cr_server.Recorder, ctx);
-    crDmpStrF(cr_server.Recorder.pDumper, "==Done Uniforms==");
-}
-
-void crServerDumpCurrentProgramAttribs()
-{
-    CRContext *ctx = crStateGetCurrent();
-    crDmpStrF(cr_server.Recorder.pDumper, "==Attribs==");
-    crRecDumpCurrentProgramAttribs(&cr_server.Recorder, ctx);
-    crDmpStrF(cr_server.Recorder.pDumper, "==Done Attribs==");
-}
-
-void crServerDumpState()
-{
-    CRContext *ctx = crStateGetCurrent();
-    crRecDumpGlGetState(&cr_server.Recorder, ctx);
-    crRecDumpGlEnableState(&cr_server.Recorder, ctx);
-}
-
-void crServerDumpDrawel(const char*pszFormat, ...)
-{
-    CRContext *ctx = crStateGetCurrent();
-    va_list pArgList;
-    va_start(pArgList, pszFormat);
-    crRecDumpVertAttrV(&cr_server.Recorder, ctx, pszFormat, pArgList);
-    va_end(pArgList);
-}
-
-void crServerDumpDrawelv(GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal)
-{
-    CRContext *ctx = crStateGetCurrent();
-    crRecDumpVertAttrv(&cr_server.Recorder, ctx, idx, pszElFormat, cbEl, pvVal, cVal);
-}
-
-void crServerDumpBuffer(int idx)
-{
-    CRContextInfo *pCtxInfo = cr_server.currentCtxInfo;
-    CRContext *ctx = crStateGetCurrent();
-    GLint idFBO;
-    GLint idTex;
-    VBOXVR_TEXTURE RedirTex;
-    int rc = crServerDumpCheckInit();
-    idx = idx >= 0 ? idx : crServerMuralFBOIdxFromBufferName(cr_server.currentMural, pCtxInfo->pContext->buffer.drawBuffer);
-    if (!RT_SUCCESS(rc))
-    {
-        crWarning("crServerDumpCheckInit failed, rc %d", rc);
-        return;
-    }
-
-    if (idx < 0)
-    {
-        crWarning("neg idx, unsupported");
-        return;
-    }
-
-    idFBO = CR_SERVER_FBO_FOR_IDX(cr_server.currentMural, idx);
-    idTex = CR_SERVER_FBO_TEX_FOR_IDX(cr_server.currentMural, idx);
-
-    RedirTex.width = cr_server.currentMural->fboWidth;
-    RedirTex.height = cr_server.currentMural->fboHeight;
-    RedirTex.target = GL_TEXTURE_2D;
-    RedirTex.hwid = idTex;
-
-    crRecDumpBuffer(&cr_server.Recorder, ctx, idFBO, idTex ? &RedirTex : NULL);
-}
-
-void crServerDumpTexture(const VBOXVR_TEXTURE *pTex)
-{
-    CRContextInfo *pCtxInfo = cr_server.currentCtxInfo;
-    CR_BLITTER_WINDOW BltWin;
-    CR_BLITTER_CONTEXT BltCtx;
-    CRContext *ctx = crStateGetCurrent();
-    int rc = crServerDumpCheckInit();
-    if (!RT_SUCCESS(rc))
-    {
-        crWarning("crServerDumpCheckInit failed, rc %d", rc);
-        return;
-    }
-
-    crServerVBoxBlitterWinInit(&BltWin, cr_server.currentMural);
-    crServerVBoxBlitterCtxInit(&BltCtx, pCtxInfo);
-
-    crRecDumpTextureF(&cr_server.Recorder, pTex, &BltCtx, &BltWin, "Tex (%d x %d), hwid (%d) target %#x", pTex->width, pTex->height, pTex->hwid, pTex->target);
-}
-
-void crServerDumpTextures()
-{
-    CRContextInfo *pCtxInfo = cr_server.currentCtxInfo;
-    CRContext *ctx = crStateGetCurrent();
-    int rc = crServerDumpCheckInit();
-    if (!RT_SUCCESS(rc))
-    {
-        crWarning("crServerDumpCheckInit failed, rc %d", rc);
-        return;
-    }
-
-    crRecDumpTextures(&cr_server.Recorder, ctx);
-}
-
-void crServerDumpFilterOpLeave(unsigned long event, CR_DUMPER *pDumper)
-{
-    if (CR_SERVER_DUMP_F_DRAW_LEAVE_ALL & event)
-    {
-        g_CrDbgDumpDumpOnCountPerform = 0;
-    }
-}
-
-bool crServerDumpFilterOpEnter(unsigned long event, CR_DUMPER *pDumper)
-{
-    if ((CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER & event)
-            || (CR_SERVER_DUMP_F_TEXPRESENT & event))
-    {
-        if (g_CrDbgDumpDumpOnCountEnabled == 1)
-            g_CrDbgDumpDumpOnCountEnabled = 2;
-        else if (g_CrDbgDumpDumpOnCountEnabled)
-        {
-            g_CrDbgDumpDumpOnCountEnabled = 0;
-            if (cr_server.pDumper == &cr_server.HtmlDumper.Base)
-            {
-                crDmpHtmlTerm(&cr_server.HtmlDumper);
-                cr_server.pDumper = NULL;
-            }
-        }
-
-        g_CrDbgDumpDrawCount = 0;
-    }
-    else if (CR_SERVER_DUMP_F_DRAW_ENTER_ALL & event)
-    {
-        if (g_CrDbgDumpDumpOnCountEnabled == 2)
-        {
-            if (g_CrDbgDumpDumpOnCount == g_CrDbgDumpDrawCount)
-            {
-                g_CrDbgDumpDumpOnCountPerform = 1;
-            }
-            ++g_CrDbgDumpDrawCount;
-        }
-    }
-    if (g_CrDbgDumpDumpOnCountPerform)
-    {
-        if (g_CrDbgDumpDrawFlags & event)
-            return true;
-    }
-    return CR_SERVER_DUMP_DEFAULT_FILTER_OP(event);
-}
-
-bool crServerDumpFilterDmp(unsigned long event, CR_DUMPER *pDumper)
-{
-    if (g_CrDbgDumpDumpOnCountPerform)
-    {
-        if (g_CrDbgDumpDrawFlags & event)
-            return true;
-    }
-    return CR_SERVER_DUMP_DEFAULT_FILTER_DMP(event);
-}
-
-void crServerDumpFramesCheck()
-{
-    if (!g_CrDbgDumpDrawFramesCount)
-        return;
-
-    if (!g_CrDbgDumpDrawFramesAppliedSettings)
-    {
-        if (!g_CrDbgDumpDrawFramesSettings)
-        {
-            crWarning("g_CrDbgDumpDrawFramesSettings is NULL, bump will not be started");
-            g_CrDbgDumpDrawFramesCount = 0;
-            return;
-        }
-
-        g_CrDbgDumpDrawFramesSavedInitSettings = g_CrDbgDumpDraw;
-        g_CrDbgDumpDrawFramesAppliedSettings = g_CrDbgDumpDrawFramesSettings;
-        g_CrDbgDumpDraw = g_CrDbgDumpDrawFramesSettings;
-        crDmpStrF(cr_server.Recorder.pDumper, "***Starting draw dump for %d frames, settings(0x%x)", g_CrDbgDumpDrawFramesCount, g_CrDbgDumpDraw);
-        return;
-    }
-
-    --g_CrDbgDumpDrawFramesCount;
-
-    if (!g_CrDbgDumpDrawFramesCount)
-    {
-        crDmpStrF(cr_server.Recorder.pDumper, "***Stop draw dump");
-        g_CrDbgDumpDraw = g_CrDbgDumpDrawFramesSavedInitSettings;
-        g_CrDbgDumpDrawFramesAppliedSettings = 0;
-    }
-}
-#endif
-
-GLvoid crServerSpriteCoordReplEnable(GLboolean fEnable)
-{
-    CRContext *g = crStateGetCurrent();
-    CRTextureState *t = &(g->texture);
-    GLuint curTextureUnit = t->curTextureUnit;
-    GLuint curTextureUnitRestore = curTextureUnit;
-    GLuint i;
-
-    for (i = 0; i < g->limits.maxTextureUnits; ++i)
-    {
-        if (g->point.coordReplacement[i])
-        {
-            if (i != curTextureUnit)
-            {
-                curTextureUnit = i;
-                cr_server.head_spu->dispatch_table.ActiveTextureARB( i + GL_TEXTURE0_ARB );
-            }
-
-            cr_server.head_spu->dispatch_table.TexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, (GLint)fEnable);
-        }
-    }
-
-    if (curTextureUnit != curTextureUnitRestore)
-    {
-        cr_server.head_spu->dispatch_table.ActiveTextureARB( curTextureUnitRestore + GL_TEXTURE0_ARB );
-    }
-}
-
-GLvoid SERVER_DISPATCH_APIENTRY crServerDispatchDrawArrays(GLenum mode, GLint first, GLsizei count)
-{
-#ifdef DEBUG
-    GLenum status = cr_server.head_spu->dispatch_table.CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
-    Assert(GL_FRAMEBUFFER_COMPLETE == status);
-#endif
-    if (mode == GL_POINTS)
-        crServerSpriteCoordReplEnable(GL_TRUE);
-    CR_SERVER_DUMP_DRAW_ENTER();
-    CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.DrawArrays(mode, first, count););
-    CR_SERVER_DUMP_DRAW_LEAVE();
-    if (mode == GL_POINTS)
-        crServerSpriteCoordReplEnable(GL_FALSE);
-}
-
-GLvoid SERVER_DISPATCH_APIENTRY crServerDispatchDrawElements(GLenum mode,  GLsizei count,  GLenum type,  const GLvoid * indices)
-{
-#ifdef DEBUG
-    GLenum status = cr_server.head_spu->dispatch_table.CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
-    Assert(GL_FRAMEBUFFER_COMPLETE == status);
-#endif
-    if (mode == GL_POINTS)
-        crServerSpriteCoordReplEnable(GL_TRUE);
-    CR_SERVER_DUMP_DRAW_ENTER();
-    CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.DrawElements(mode, count, type, indices););
-    CR_SERVER_DUMP_DRAW_LEAVE();
-    if (mode == GL_POINTS)
-        crServerSpriteCoordReplEnable(GL_FALSE);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchEnd( void )
-{
-    CRContext *g = crStateGetCurrent();
-    GLenum mode = g->current.mode;
-
-    crStateEnd();
-    cr_server.head_spu->dispatch_table.End();
-
-    CR_SERVER_DUMP_DRAW_LEAVE();
-
-    if (mode == GL_POINTS)
-        crServerSpriteCoordReplEnable(GL_FALSE);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchBegin(GLenum mode)
-{
-#ifdef DEBUG
-    CRContext *ctx = crStateGetCurrent();
-    SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
-
-    if (ctx->program.vpProgramBinding)
-    {
-        AssertRelease(ctx->program.currentVertexProgram);
-
-        if (ctx->program.currentVertexProgram->isARBprogram)
-        {
-            GLint pid=-1;
-            gl->GetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &pid);
-
-            if (pid != ctx->program.currentVertexProgram->id)
-            {
-                crWarning("pid(%d) != ctx->program.currentVertexProgram->id(%d)", pid, ctx->program.currentVertexProgram->id);
-            }
-            AssertRelease(pid == ctx->program.currentVertexProgram->id);
-        }
-        else
-        {
-            GLint pid=-1;
-
-            gl->GetIntegerv(GL_VERTEX_PROGRAM_BINDING_NV, &pid);
-            if (pid != ctx->program.currentVertexProgram->id)
-            {
-                crWarning("pid(%d) != ctx->program.currentVertexProgram->id(%d)", pid, ctx->program.currentVertexProgram->id);
-            }
-            AssertRelease(pid == ctx->program.currentVertexProgram->id);
-        }
-    }
-    else if (ctx->glsl.activeProgram)
-    {
-        GLint pid=-1;
-
-        gl->GetIntegerv(GL_CURRENT_PROGRAM, &pid);
-        //crDebug("pid %i, state: id %i, hwid %i", pid, ctx->glsl.activeProgram->id, ctx->glsl.activeProgram->hwid);
-        if (pid != ctx->glsl.activeProgram->hwid)
-        {
-            crWarning("pid(%d) != ctx->glsl.activeProgram->hwid(%d)", pid, ctx->glsl.activeProgram->hwid);
-        }
-        AssertRelease(pid == ctx->glsl.activeProgram->hwid);
-    }
-#endif
-
-    if (mode == GL_POINTS)
-        crServerSpriteCoordReplEnable(GL_TRUE);
-
-    CR_SERVER_DUMP_DRAW_ENTER();
-
-    crStateBegin(mode);
-    cr_server.head_spu->dispatch_table.Begin(mode);
-}
-
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_misc.cpp	(revision 78190)
@@ -0,0 +1,2016 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "cr_string.h"
+#include "cr_pixeldata.h"
+#ifdef VBOX_WITH_CRDUMPER
+# include "cr_dump.h"
+#endif
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchSelectBuffer( GLsizei size, GLuint *buffer )
+{
+    (void) size;
+    (void) buffer;
+    crError( "Unsupported network glSelectBuffer call." );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetChromiumParametervCR(GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values)
+{
+    GLubyte local_storage[4096];
+    GLint bytes = 0;
+    GLint cbType = 1; /* One byte by default. */
+
+    memset(local_storage, 0, sizeof(local_storage));
+
+    switch (type) {
+    case GL_BYTE:
+    case GL_UNSIGNED_BYTE:
+         cbType = sizeof(GLbyte);
+         break;
+    case GL_SHORT:
+    case GL_UNSIGNED_SHORT:
+         cbType = sizeof(GLshort);
+         break;
+    case GL_INT:
+    case GL_UNSIGNED_INT:
+         cbType = sizeof(GLint);
+         break;
+    case GL_FLOAT:
+         cbType = sizeof(GLfloat);
+         break;
+    case GL_DOUBLE:
+         cbType = sizeof(GLdouble);
+         break;
+    default:
+         crError("Bad type in crServerDispatchGetChromiumParametervCR");
+    }
+
+    if (count < 0) /* 'GLsizei' is usually an 'int'. */
+        count = 0;
+    else if ((size_t)count > sizeof(local_storage) / cbType)
+        count = sizeof(local_storage) / cbType;
+
+    bytes = count * cbType;
+
+    CRASSERT(bytes >= 0);
+    CRASSERT(bytes < 4096);
+
+    switch (target)
+    {
+        case GL_DBG_CHECK_BREAK_CR:
+        {
+            if (bytes > 0)
+            {
+                GLubyte *pbRc = local_storage;
+                GLuint *puRc = (GLuint *)(bytes >=4 ? local_storage : NULL);
+                int rc;
+                memset(local_storage, 0, bytes);
+                if (cr_server.RcToGuestOnce)
+                {
+                    rc = cr_server.RcToGuestOnce;
+                    cr_server.RcToGuestOnce = 0;
+                }
+                else
+                {
+                    rc = cr_server.RcToGuest;
+                }
+                if (puRc)
+                    *puRc = rc;
+                else
+                    *pbRc = !!rc;
+            }
+            else
+            {
+                crWarning("zero bytes for GL_DBG_CHECK_BREAK_CR");
+            }
+            break;
+        }
+        case GL_HH_SET_DEFAULT_SHARED_CTX:
+            WARN(("Recieved GL_HH_SET_DEFAULT_SHARED_CTX from guest, ignoring"));
+            break;
+        case GL_HH_SET_CLIENT_CALLOUT:
+            WARN(("Recieved GL_HH_SET_CLIENT_CALLOUT from guest, ignoring"));
+            break;
+        default:
+            cr_server.head_spu->dispatch_table.GetChromiumParametervCR( target, index, type, count, local_storage );
+            break;
+    }
+
+    crServerReturnValue( local_storage, bytes );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchChromiumParametervCR(GLenum target, GLenum type, GLsizei count, const GLvoid *values)
+{
+    CRMuralInfo *mural = cr_server.curClient->currentMural;
+    static int gather_connect_count = 0;
+
+    switch (target) {
+        case GL_SHARE_LISTS_CR:
+        {
+            CRContextInfo *pCtx[2];
+            GLint *ai32Values;
+            int i;
+            if (count != 2)
+            {
+                WARN(("GL_SHARE_LISTS_CR invalid cound %d", count));
+                return;
+            }
+
+            if (type != GL_UNSIGNED_INT && type != GL_INT)
+            {
+                WARN(("GL_SHARE_LISTS_CR invalid type %d", type));
+                return;
+            }
+
+            ai32Values = (GLint*)values;
+
+            for (i = 0; i < 2; ++i)
+            {
+                const int32_t val = ai32Values[i];
+
+                if (val == 0)
+                {
+                    WARN(("GL_SHARE_LISTS_CR invalid value[%d] %d", i, val));
+                    return;
+                }
+
+                pCtx[i] = (CRContextInfo *) crHashtableSearch(cr_server.contextTable, val);
+                if (!pCtx[i])
+                {
+                    WARN(("GL_SHARE_LISTS_CR invalid pCtx1 for value[%d] %d", i, val));
+                    return;
+                }
+
+                if (!pCtx[i]->pContext)
+                {
+                    WARN(("GL_SHARE_LISTS_CR invalid pCtx1 pContext for value[%d] %d", i, val));
+                    return;
+                }
+            }
+
+            crStateShareLists(pCtx[0]->pContext, pCtx[1]->pContext);
+
+            break;
+        }
+
+    case GL_SET_MAX_VIEWPORT_CR:
+        {
+            GLint *maxDims = (GLint *)values;
+            cr_server.limits.maxViewportDims[0] = maxDims[0];
+            cr_server.limits.maxViewportDims[1] = maxDims[1];
+        }
+        break;
+
+    case GL_TILE_INFO_CR:
+        /* message from tilesort SPU to set new tile bounds */
+        {
+            GLint numTiles, muralWidth, muralHeight, server, tiles;
+            GLint *tileBounds;
+            CRASSERT(count >= 4);
+            CRASSERT((count - 4) % 4 == 0); /* must be multiple of four */
+            CRASSERT(type == GL_INT);
+            numTiles = (count - 4) / 4;
+            tileBounds = (GLint *) values;
+            server = tileBounds[0];
+            muralWidth = tileBounds[1];
+            muralHeight = tileBounds[2];
+            tiles = tileBounds[3];
+            CRASSERT(tiles == numTiles);
+            tileBounds += 4; /* skip over header values */
+            /*crServerNewMuralTiling(mural, muralWidth, muralHeight, numTiles, tileBounds);
+            mural->viewportValidated = GL_FALSE;*/
+        }
+        break;
+
+    case GL_GATHER_DRAWPIXELS_CR:
+        if (cr_server.only_swap_once && cr_server.curClient != cr_server.clients[0])
+            break;
+        cr_server.head_spu->dispatch_table.ChromiumParametervCR( target, type, count, values );
+        break;
+
+    case GL_GATHER_CONNECT_CR:
+        /*
+         * We want the last connect to go through,
+         * otherwise we might deadlock in CheckWindowSize()
+         * in the readback spu
+         */
+        gather_connect_count++;
+        if (cr_server.only_swap_once && (gather_connect_count != cr_server.numClients))
+        {
+            break;
+        }
+        cr_server.head_spu->dispatch_table.ChromiumParametervCR( target, type, count, values );
+        gather_connect_count = 0;
+        break;
+
+    case GL_SERVER_VIEW_MATRIX_CR:
+        /* Set this server's view matrix which will get premultiplied onto the
+         * modelview matrix.  For non-planar tilesort and stereo.
+         */
+        CRASSERT(count == 18);
+        CRASSERT(type == GL_FLOAT);
+        /* values[0] is the server index. Ignored here but used in tilesort SPU */
+        /* values[1] is the left/right eye index (0 or 1) */
+        {
+            const GLfloat *v = (const GLfloat *) values;
+            const int eye = v[1] == 0.0 ? 0 : 1;
+            crMatrixInitFromFloats(&cr_server.viewMatrix[eye], v + 2);
+
+            crDebug("Got GL_SERVER_VIEW_MATRIX_CR:\n"
+                            "  %f %f %f %f\n"
+                            "  %f %f %f %f\n"
+                            "  %f %f %f %f\n"
+                            "  %f %f %f %f",
+                            cr_server.viewMatrix[eye].m00,
+                            cr_server.viewMatrix[eye].m10,
+                            cr_server.viewMatrix[eye].m20,
+                            cr_server.viewMatrix[eye].m30,
+                            cr_server.viewMatrix[eye].m01,
+                            cr_server.viewMatrix[eye].m11,
+                            cr_server.viewMatrix[eye].m21,
+                            cr_server.viewMatrix[eye].m31,
+                            cr_server.viewMatrix[eye].m02,
+                            cr_server.viewMatrix[eye].m12,
+                            cr_server.viewMatrix[eye].m22,
+                            cr_server.viewMatrix[eye].m32,
+                            cr_server.viewMatrix[eye].m03,
+                            cr_server.viewMatrix[eye].m13,
+                            cr_server.viewMatrix[eye].m23,
+                            cr_server.viewMatrix[eye].m33);
+        }
+        cr_server.viewOverride = GL_TRUE;
+        break;
+
+    case GL_SERVER_PROJECTION_MATRIX_CR:
+        /* Set this server's projection matrix which will get replace the user's
+         * projection matrix.  For non-planar tilesort and stereo.
+         */
+        CRASSERT(count == 18);
+        CRASSERT(type == GL_FLOAT);
+        /* values[0] is the server index. Ignored here but used in tilesort SPU */
+        /* values[1] is the left/right eye index (0 or 1) */
+        {
+            const GLfloat *v = (const GLfloat *) values;
+            const int eye = v[1] == 0.0 ? 0 : 1;
+            crMatrixInitFromFloats(&cr_server.projectionMatrix[eye], v + 2);
+
+            crDebug("Got GL_SERVER_PROJECTION_MATRIX_CR:\n"
+                            "  %f %f %f %f\n"
+                            "  %f %f %f %f\n"
+                            "  %f %f %f %f\n"
+                            "  %f %f %f %f",
+                            cr_server.projectionMatrix[eye].m00,
+                            cr_server.projectionMatrix[eye].m10,
+                            cr_server.projectionMatrix[eye].m20,
+                            cr_server.projectionMatrix[eye].m30,
+                            cr_server.projectionMatrix[eye].m01,
+                            cr_server.projectionMatrix[eye].m11,
+                            cr_server.projectionMatrix[eye].m21,
+                            cr_server.projectionMatrix[eye].m31,
+                            cr_server.projectionMatrix[eye].m02,
+                            cr_server.projectionMatrix[eye].m12,
+                            cr_server.projectionMatrix[eye].m22,
+                            cr_server.projectionMatrix[eye].m32,
+                            cr_server.projectionMatrix[eye].m03,
+                            cr_server.projectionMatrix[eye].m13,
+                            cr_server.projectionMatrix[eye].m23,
+                            cr_server.projectionMatrix[eye].m33);
+
+            if (cr_server.projectionMatrix[eye].m33 == 0.0f) {
+                float x = cr_server.projectionMatrix[eye].m00;
+                float y = cr_server.projectionMatrix[eye].m11;
+                float a = cr_server.projectionMatrix[eye].m20;
+                float b = cr_server.projectionMatrix[eye].m21;
+                float c = cr_server.projectionMatrix[eye].m22;
+                float d = cr_server.projectionMatrix[eye].m32;
+                float znear = -d / (1.0f - c);
+                float zfar = (c - 1.0f) * znear / (c + 1.0f);
+                float left = znear * (a - 1.0f) / x;
+                float right = 2.0f * znear / x + left;
+                float bottom = znear * (b - 1.0f) / y;
+              float top = 2.0f * znear / y + bottom;
+              crDebug("Frustum: left, right, bottom, top, near, far: %f, %f, %f, %f, %f, %f", left, right, bottom, top, znear, zfar);
+            }
+            else {
+                /** @todo Add debug output for orthographic projection*/
+            }
+
+        }
+        cr_server.projectionOverride = GL_TRUE;
+        break;
+
+    case GL_HH_SET_TMPCTX_MAKE_CURRENT:
+        /*we should not receive it from the guest! */
+        break;
+
+    case GL_HH_SET_CLIENT_CALLOUT:
+        WARN(("Recieved GL_HH_SET_CLIENT_CALLOUT from guest, ignoring"));
+        break;
+
+    default:
+        /* Pass the parameter info to the head SPU */
+        cr_server.head_spu->dispatch_table.ChromiumParametervCR( target, type, count, values );
+        break;
+    }
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchChromiumParameteriCR(GLenum target, GLint value)
+{
+  switch (target) {
+    case GL_SHARE_CONTEXT_RESOURCES_CR:
+        crStateShareContext(value);
+        break;
+    case GL_RCUSAGE_TEXTURE_SET_CR:
+        crStateSetTextureUsed(value, GL_TRUE);
+        break;
+    case GL_RCUSAGE_TEXTURE_CLEAR_CR:
+        crStateSetTextureUsed(value, GL_FALSE);
+        break;
+    case GL_PIN_TEXTURE_SET_CR:
+        crStatePinTexture(value, GL_TRUE);
+        break;
+    case GL_PIN_TEXTURE_CLEAR_CR:
+        crStatePinTexture(value, GL_FALSE);
+        break;
+    case GL_SHARED_DISPLAY_LISTS_CR:
+        cr_server.sharedDisplayLists = value;
+        break;
+    case GL_SHARED_TEXTURE_OBJECTS_CR:
+        cr_server.sharedTextureObjects = value;
+        break;
+    case GL_SHARED_PROGRAMS_CR:
+        cr_server.sharedPrograms = value;
+        break;
+    case GL_SERVER_CURRENT_EYE_CR:
+        cr_server.currentEye = value ? 1 : 0;
+        break;
+    case GL_HOST_WND_CREATED_HIDDEN_CR:
+        cr_server.bWindowsInitiallyHidden = value ? 1 : 0;
+        break;
+    case GL_HH_SET_DEFAULT_SHARED_CTX:
+        WARN(("Recieved GL_HH_SET_DEFAULT_SHARED_CTX from guest, ignoring"));
+        break;
+    case GL_HH_RENDERTHREAD_INFORM:
+        WARN(("Recieved GL_HH_RENDERTHREAD_INFORM from guest, ignoring"));
+        break;
+    default:
+        /* Pass the parameter info to the head SPU */
+        cr_server.head_spu->dispatch_table.ChromiumParameteriCR( target, value );
+    }
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchChromiumParameterfCR(GLenum target, GLfloat value)
+{
+  switch (target) {
+    case GL_SHARED_DISPLAY_LISTS_CR:
+        cr_server.sharedDisplayLists = (int) value;
+        break;
+    case GL_SHARED_TEXTURE_OBJECTS_CR:
+        cr_server.sharedTextureObjects = (int) value;
+        break;
+    case GL_SHARED_PROGRAMS_CR:
+        cr_server.sharedPrograms = (int) value;
+        break;
+    default:
+        /* Pass the parameter info to the head SPU */
+        cr_server.head_spu->dispatch_table.ChromiumParameterfCR( target, value );
+    }
+}
+
+GLint crServerGenerateID(GLint *pCounter)
+{
+    return (*pCounter)++;
+}
+
+/*#define CR_DUMP_BLITS*/
+
+#ifdef CR_DUMP_BLITS
+static int blitnum=0;
+static int copynum=0;
+#endif
+
+# ifdef DEBUG_misha
+//# define CR_CHECK_BLITS
+#  include <iprt/assert.h>
+#  undef CRASSERT /* iprt assert's int3 are inlined that is why are more convenient to use since they can be easily disabled individually */
+#  define CRASSERT Assert
+# endif
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+    /** @todo pbo/fbo disabled for now as it's slower, check on other gpus*/
+    static int siHavePBO = 0;
+    static int siHaveFBO = 0;
+
+    if ((target!=GL_TEXTURE_2D) || (height>=0))
+    {
+        cr_server.head_spu->dispatch_table.CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
+
+#ifdef CR_DUMP_BLITS
+        {
+            SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
+            void *img;
+            GLint w, h;
+            char fname[200];
+
+            copynum++;
+
+            gl->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
+            gl->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
+
+            img = crAlloc(w*h*4);
+            CRASSERT(img);
+
+            gl->GetTexImage(GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, img);
+            sprintf(fname, "copy_blit%i_copy_%i.tga", blitnum, copynum);
+            crDumpNamedTGA(fname, w, h, img);
+            crFree(img);
+        }
+#endif
+    }
+    else /* negative height, means we have to Yinvert the source pixels while copying */
+    {
+        SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
+
+        if (siHavePBO<0)
+        {
+            const char *ext = (const char*)gl->GetString(GL_EXTENSIONS);
+            siHavePBO = crStrstr(ext, "GL_ARB_pixel_buffer_object") ? 1:0;
+        }
+
+        if (siHaveFBO<0)
+        {
+            const char *ext = (const char*)gl->GetString(GL_EXTENSIONS);
+            siHaveFBO = crStrstr(ext, "GL_EXT_framebuffer_object") ? 1:0;
+        }
+
+        if (siHavePBO==0 && siHaveFBO==0)
+        {
+#if 1
+            GLint dRow, sRow;
+            for (dRow=yoffset, sRow=y-height-1; dRow<yoffset-height; dRow++, sRow--)
+            {
+                gl->CopyTexSubImage2D(target, level, xoffset, dRow, x, sRow, width, 1);
+            }
+#else
+            {
+                GLint w, h, i;
+                char *img1, *img2, *sPtr, *dPtr;
+                CRContext *ctx = crStateGetCurrent();
+
+                w = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].width;
+                h = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].height;
+
+                img1 = crAlloc(4*w*h);
+                img2 = crAlloc(4*width*(-height));
+                CRASSERT(img1 && img2);
+
+                gl->CopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, -height);
+                gl->GetTexImage(target, level, GL_RGBA, GL_UNSIGNED_BYTE, img1);
+
+                sPtr=img1+4*xoffset+4*w*yoffset;
+                dPtr=img2+4*width*(-height-1);
+
+                for (i=0; i<-height; ++i)
+                {
+                    crMemcpy(dPtr, sPtr, 4*width);
+                    sPtr += 4*w;
+                    dPtr -= 4*width;
+                }
+
+                gl->TexSubImage2D(target, level, xoffset, yoffset, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, img2);
+
+                crFree(img1);
+                crFree(img2);
+            }
+#endif
+        }
+        else if (siHaveFBO==1) /** @todo more states to set and restore here*/
+        {
+            GLuint tID, fboID;
+            GLenum status;
+            CRContext *ctx = crStateGetCurrent();
+
+            gl->GenTextures(1, &tID);
+            gl->BindTexture(target, tID);
+            gl->CopyTexImage2D(target, level, GL_RGBA, x, y, width, -height, 0);
+            gl->GenFramebuffersEXT(1, &fboID);
+            gl->BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboID);
+            gl->FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target,
+                                        ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid, level);
+            status = gl->CheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+            if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
+            {
+                crWarning("Framebuffer status 0x%x", status);
+            }
+
+            gl->Enable(target);
+            gl->PushAttrib(GL_VIEWPORT_BIT);
+            gl->Viewport(xoffset, yoffset, width, -height);
+            gl->MatrixMode(GL_PROJECTION);
+            gl->PushMatrix();
+            gl->LoadIdentity();
+            gl->MatrixMode(GL_MODELVIEW);
+	        gl->PushMatrix();
+            gl->LoadIdentity();
+
+            gl->Disable(GL_DEPTH_TEST);
+            gl->Disable(GL_CULL_FACE);
+            gl->Disable(GL_STENCIL_TEST);
+            gl->Disable(GL_SCISSOR_TEST);
+
+            gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+            gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+            gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+            gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+            gl->TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+
+            gl->Begin(GL_QUADS);
+                gl->TexCoord2f(0.0f, 1.0f);
+                gl->Vertex2f(-1.0, -1.0);
+
+                gl->TexCoord2f(0.0f, 0.0f);
+                gl->Vertex2f(-1.0f, 1.0f);
+
+                gl->TexCoord2f(1.0f, 0.0f);
+                gl->Vertex2f(1.0f, 1.0f);
+
+                gl->TexCoord2f(1.0f, 1.0f);
+                gl->Vertex2f(1.0f, -1.0f);
+            gl->End();
+
+            gl->PopMatrix();
+            gl->MatrixMode(GL_PROJECTION);
+            gl->PopMatrix();
+            gl->PopAttrib();
+
+            gl->FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target, 0, level);
+            gl->BindFramebufferEXT(GL_FRAMEBUFFER_EXT, ctx->framebufferobject.drawFB ? ctx->framebufferobject.drawFB->hwid:0);
+            gl->BindTexture(target, ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->hwid);
+            gl->DeleteFramebuffersEXT(1, &fboID);
+            gl->DeleteTextures(1, &tID);
+
+#if 0
+            {
+                GLint dRow, sRow, w, h;
+                void *img1, *img2;
+
+                w = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].width;
+                h = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D->level[0][level].height;
+
+                img1 = crAlloc(4*w*h);
+                img2 = crAlloc(4*w*h);
+                CRASSERT(img1 && img2);
+
+                gl->GetTexImage(target, level, GL_BGRA, GL_UNSIGNED_BYTE, img1);
+
+
+                for (dRow=yoffset, sRow=y-height-1; dRow<yoffset-height; dRow++, sRow--)
+                {
+                    gl->CopyTexSubImage2D(target, level, xoffset, dRow, x, sRow, width, 1);
+                }
+
+                gl->GetTexImage(target, level, GL_BGRA, GL_UNSIGNED_BYTE, img2);
+
+                if (crMemcmp(img1, img2, 4*w*h))
+                {
+                    crDebug("MISMATCH! (%x, %i, ->%i,%i  <-%i, %i  [%ix%i])", target, level, xoffset, yoffset, x, y, width, height);
+                    crDumpTGA(w, h, img1);
+                    crDumpTGA(w, h, img2);
+                    DebugBreak();
+                }
+                crFree(img1);
+                crFree(img2);
+            }
+#endif
+        }
+        else
+        {
+            GLint dRow;
+            GLuint pboId, sRow;
+            CRContext *ctx = crStateGetCurrent();
+
+            gl->GenBuffersARB(1, &pboId);
+            gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboId);
+            gl->BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, -width*height*4, 0, GL_STATIC_COPY_ARB);
+
+#if 1
+            gl->ReadPixels(x, y, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+            gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid);
+
+            gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboId);
+            for (dRow=yoffset, sRow=-height-1; dRow<yoffset-height; dRow++, sRow--)
+            {
+                gl->TexSubImage2D(target, level, xoffset, dRow, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)((uintptr_t)sRow*width*4));
+            }
+#else /*few times slower again*/
+            for (dRow=0, sRow=y-height-1; dRow<-height; dRow++, sRow--)
+            {
+                gl->ReadPixels(x, sRow, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, (void*)((uintptr_t)dRow*width*4));
+            }
+            gl->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, ctx->bufferobject.packBuffer->hwid);
+
+            gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pboId);
+            gl->TexSubImage2D(target, level, xoffset, yoffset, width, -height, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+#endif
+
+            gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, ctx->bufferobject.unpackBuffer->hwid);
+            gl->DeleteBuffersARB(1, &pboId);
+        }
+    }
+}
+
+#ifdef CR_CHECK_BLITS
+void crDbgFree(void *pvData)
+{
+    crFree(pvData);
+}
+
+void crDbgGetTexImage2D(GLint texTarget, GLint texName, GLvoid **ppvImage, GLint *pw, GLint *ph)
+{
+    SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
+    GLint ppb, pub, dstw, dsth, otex;
+    GLint pa, pr, psp, psr, ua, ur, usp, usr;
+    GLvoid *pvImage;
+    GLint rfb, dfb, rb, db;
+
+    gl->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
+    gl->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
+    gl->GetIntegerv(GL_READ_BUFFER, &rb);
+    gl->GetIntegerv(GL_DRAW_BUFFER, &db);
+
+    gl->BindFramebufferEXT(GL_READ_FRAMEBUFFER_BINDING_EXT, 0);
+    gl->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_BINDING_EXT, 0);
+    gl->ReadBuffer(GL_BACK);
+    gl->DrawBuffer(GL_BACK);
+
+    gl->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &ppb);
+    gl->GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &pub);
+    gl->GetIntegerv(GL_TEXTURE_BINDING_2D, &otex);
+
+    gl->GetIntegerv(GL_PACK_ROW_LENGTH, &pr);
+    gl->GetIntegerv(GL_PACK_ALIGNMENT, &pa);
+    gl->GetIntegerv(GL_PACK_SKIP_PIXELS, &psp);
+    gl->GetIntegerv(GL_PACK_SKIP_ROWS, &psr);
+
+    gl->GetIntegerv(GL_UNPACK_ROW_LENGTH, &ur);
+    gl->GetIntegerv(GL_UNPACK_ALIGNMENT, &ua);
+    gl->GetIntegerv(GL_UNPACK_SKIP_PIXELS, &usp);
+    gl->GetIntegerv(GL_UNPACK_SKIP_ROWS, &usr);
+
+    gl->BindTexture(texTarget, texName);
+    gl->GetTexLevelParameteriv(texTarget, 0, GL_TEXTURE_WIDTH, &dstw);
+    gl->GetTexLevelParameteriv(texTarget, 0, GL_TEXTURE_HEIGHT, &dsth);
+
+    gl->PixelStorei(GL_PACK_ROW_LENGTH, 0);
+    gl->PixelStorei(GL_PACK_ALIGNMENT, 1);
+    gl->PixelStorei(GL_PACK_SKIP_PIXELS, 0);
+    gl->PixelStorei(GL_PACK_SKIP_ROWS, 0);
+
+    gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+    gl->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    gl->PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+    gl->PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+
+    gl->BindBufferARB(GL_PIXEL_PACK_BUFFER, 0);
+    gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);
+
+    pvImage = crAlloc(4*dstw*dsth);
+    gl->GetTexImage(texTarget, 0, GL_BGRA, GL_UNSIGNED_BYTE, pvImage);
+
+    gl->BindTexture(texTarget, otex);
+
+    gl->PixelStorei(GL_PACK_ROW_LENGTH, pr);
+    gl->PixelStorei(GL_PACK_ALIGNMENT, pa);
+    gl->PixelStorei(GL_PACK_SKIP_PIXELS, psp);
+    gl->PixelStorei(GL_PACK_SKIP_ROWS, psr);
+
+    gl->PixelStorei(GL_UNPACK_ROW_LENGTH, ur);
+    gl->PixelStorei(GL_UNPACK_ALIGNMENT, ua);
+    gl->PixelStorei(GL_UNPACK_SKIP_PIXELS, usp);
+    gl->PixelStorei(GL_UNPACK_SKIP_ROWS, usr);
+
+    gl->BindBufferARB(GL_PIXEL_PACK_BUFFER, ppb);
+    gl->BindBufferARB(GL_PIXEL_UNPACK_BUFFER, pub);
+
+    gl->BindFramebufferEXT(GL_READ_FRAMEBUFFER_BINDING_EXT, rfb);
+    gl->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_BINDING_EXT, dfb);
+    gl->ReadBuffer(rb);
+    gl->DrawBuffer(db);
+
+    *ppvImage = pvImage;
+    *pw = dstw;
+    *ph = dsth;
+}
+
+DECLEXPORT(void) crDbgPrint(const char *format, ... )
+{
+    va_list args;
+    static char txt[8092];
+
+    va_start(args, format);
+    vsprintf(txt, format, args);
+    va_end(args);
+
+    OutputDebugString(txt);
+}
+
+void crDbgDumpImage2D(const char* pszDesc, const void *pvData, uint32_t width, uint32_t height, uint32_t bpp, uint32_t pitch)
+{
+    crDbgPrint("<?dml?><exec cmd=\"!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d\">%s</exec>, ( !vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d )\n",
+            pvData, width, height, bpp, pitch,
+            pszDesc,
+            pvData, width, height, bpp, pitch);
+}
+
+void crDbgDumpTexImage2D(const char* pszDesc, GLint texTarget, GLint texName, GLboolean fBreak)
+{
+    GLvoid *pvImage;
+    GLint w, h;
+    crDbgGetTexImage2D(texTarget, texName, &pvImage, &w, &h);
+    crDbgPrint("%s target(%d), name(%d), width(%d), height(%d)", pszDesc, texTarget, texName, w, h);
+    crDbgDumpImage2D("texture data", pvImage, w, h, 32, (32 * w)/8);
+    if (fBreak)
+    {
+        CRASSERT(0);
+    }
+    crDbgFree(pvImage);
+}
+#endif
+
+PCR_BLITTER crServerVBoxBlitterGet()
+{
+    if (!CrBltIsInitialized(&cr_server.Blitter))
+    {
+        CR_BLITTER_CONTEXT Ctx;
+        int rc;
+        CRASSERT(cr_server.MainContextInfo.SpuContext);
+        Ctx.Base.id = cr_server.MainContextInfo.SpuContext;
+        Ctx.Base.visualBits = cr_server.MainContextInfo.CreateInfo.realVisualBits;
+        rc = CrBltInit(&cr_server.Blitter, &Ctx, true, true, NULL, &cr_server.TmpCtxDispatch);
+        if (RT_SUCCESS(rc))
+        {
+            CRASSERT(CrBltIsInitialized(&cr_server.Blitter));
+        }
+        else
+        {
+            crWarning("CrBltInit failed, rc %d", rc);
+            CRASSERT(!CrBltIsInitialized(&cr_server.Blitter));
+            return NULL;
+        }
+    }
+
+    if (!CrBltMuralGetCurrentInfo(&cr_server.Blitter)->Base.id)
+    {
+        CRMuralInfo *dummy = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
+        CR_BLITTER_WINDOW DummyInfo;
+        CRASSERT(dummy);
+        crServerVBoxBlitterWinInit(&DummyInfo, dummy);
+        CrBltMuralSetCurrentInfo(&cr_server.Blitter, &DummyInfo);
+    }
+
+    return &cr_server.Blitter;
+}
+
+PCR_BLITTER crServerVBoxBlitterGetInitialized()
+{
+    if (CrBltIsInitialized(&cr_server.Blitter))
+        return &cr_server.Blitter;
+    return NULL;
+}
+
+
+int crServerVBoxBlitterTexInit(CRContext *ctx, CRMuralInfo *mural, PVBOXVR_TEXTURE pTex, GLboolean fDraw)
+{
+    CRTextureObj *tobj;
+    CRFramebufferObjectState *pBuf = &ctx->framebufferobject;
+    GLenum enmBuf;
+    CRFBOAttachmentPoint *pAp;
+    GLuint idx;
+    CRTextureLevel *tl;
+    CRFramebufferObject *pFBO = fDraw ? pBuf->drawFB : pBuf->readFB;
+
+    if (!pFBO)
+    {
+        GLuint hwid;
+
+        if (!mural->fRedirected)
+        {
+            WARN(("mural not redirected!"));
+            return VERR_NOT_IMPLEMENTED;
+        }
+
+        enmBuf = fDraw ? ctx->buffer.drawBuffer : ctx->buffer.readBuffer;
+        switch (enmBuf)
+        {
+            case GL_BACK:
+            case GL_BACK_RIGHT:
+            case GL_BACK_LEFT:
+                hwid = mural->aidColorTexs[CR_SERVER_FBO_BB_IDX(mural)];
+                break;
+            case GL_FRONT:
+            case GL_FRONT_RIGHT:
+            case GL_FRONT_LEFT:
+                hwid = mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)];
+                break;
+            default:
+                WARN(("unsupported enum buf %d", enmBuf));
+                return VERR_NOT_IMPLEMENTED;
+                break;
+        }
+
+        if (!hwid)
+        {
+            crWarning("offscreen render tex hwid is null");
+            return VERR_INVALID_STATE;
+        }
+
+        pTex->width = mural->width;
+        pTex->height = mural->height;
+        pTex->target = GL_TEXTURE_2D;
+        pTex->hwid = hwid;
+        return VINF_SUCCESS;
+    }
+
+    enmBuf = fDraw ? pFBO->drawbuffer[0] : pFBO->readbuffer;
+    idx = enmBuf - GL_COLOR_ATTACHMENT0_EXT;
+    if (idx >= CR_MAX_COLOR_ATTACHMENTS)
+    {
+        crWarning("idx is invalid %d, using 0", idx);
+    }
+
+    pAp = &pFBO->color[idx];
+
+    if (!pAp->name)
+    {
+        crWarning("no collor draw attachment");
+        return VERR_INVALID_STATE;
+    }
+
+    if (pAp->level)
+    {
+        WARN(("non-zero level not implemented"));
+        return VERR_NOT_IMPLEMENTED;
+    }
+
+    tobj = (CRTextureObj*)crHashtableSearch(ctx->shared->textureTable, pAp->name);
+    if (!tobj)
+    {
+        crWarning("no texture object found for name %d", pAp->name);
+        return VERR_INVALID_STATE;
+    }
+
+    if (tobj->target != GL_TEXTURE_2D && tobj->target != GL_TEXTURE_RECTANGLE_NV)
+    {
+        WARN(("non-texture[rect|2d] not implemented"));
+        return VERR_NOT_IMPLEMENTED;
+    }
+
+    CRASSERT(tobj->hwid);
+
+    tl = tobj->level[0];
+    pTex->width = tl->width;
+    pTex->height = tl->height;
+    pTex->target = tobj->target;
+    pTex->hwid = tobj->hwid;
+
+    return VINF_SUCCESS;
+}
+
+int crServerVBoxBlitterBlitCurrentCtx(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+        GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+        GLbitfield mask, GLenum filter)
+{
+    PCR_BLITTER pBlitter;
+    CR_BLITTER_CONTEXT Ctx;
+    CRMuralInfo *mural;
+    CRContext *ctx = crStateGetCurrent();
+    PVBOXVR_TEXTURE pDrawTex, pReadTex;
+    VBOXVR_TEXTURE DrawTex, ReadTex;
+    int rc;
+    GLuint idDrawFBO, idReadFBO;
+    CR_BLITTER_WINDOW BltInfo;
+
+    if (mask != GL_COLOR_BUFFER_BIT)
+    {
+        WARN(("not supported blit mask %d", mask));
+        return VERR_NOT_IMPLEMENTED;
+    }
+
+    if (!cr_server.curClient)
+    {
+        crWarning("no current client");
+        return VERR_INVALID_STATE;
+    }
+    mural = cr_server.curClient->currentMural;
+    if (!mural)
+    {
+        crWarning("no current mural");
+        return VERR_INVALID_STATE;
+    }
+
+    rc = crServerVBoxBlitterTexInit(ctx, mural, &DrawTex, GL_TRUE);
+    if (RT_SUCCESS(rc))
+    {
+        pDrawTex = &DrawTex;
+    }
+    else
+    {
+        crWarning("crServerVBoxBlitterTexInit failed for draw");
+        return rc;
+    }
+
+    rc = crServerVBoxBlitterTexInit(ctx, mural, &ReadTex, GL_FALSE);
+    if (RT_SUCCESS(rc))
+    {
+        pReadTex = &ReadTex;
+    }
+    else
+    {
+//        crWarning("crServerVBoxBlitterTexInit failed for read");
+        return rc;
+    }
+
+    pBlitter = crServerVBoxBlitterGet();
+    if (!pBlitter)
+    {
+        crWarning("crServerVBoxBlitterGet failed");
+        return VERR_GENERAL_FAILURE;
+    }
+
+    crServerVBoxBlitterWinInit(&BltInfo, mural);
+
+    crServerVBoxBlitterCtxInit(&Ctx, cr_server.curClient->currentCtxInfo);
+
+    CrBltMuralSetCurrentInfo(pBlitter, &BltInfo);
+
+    idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
+    idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
+
+    crStateSwitchPrepare(NULL, ctx, idDrawFBO, idReadFBO);
+
+    rc = CrBltEnter(pBlitter);
+    if (RT_SUCCESS(rc))
+    {
+        RTRECT ReadRect, DrawRect;
+        ReadRect.xLeft = srcX0;
+        ReadRect.yTop = srcY0;
+        ReadRect.xRight = srcX1;
+        ReadRect.yBottom = srcY1;
+        DrawRect.xLeft = dstX0;
+        DrawRect.yTop = dstY0;
+        DrawRect.xRight = dstX1;
+        DrawRect.yBottom = dstY1;
+        CrBltBlitTexTex(pBlitter, pReadTex, &ReadRect, pDrawTex, &DrawRect, 1, CRBLT_FLAGS_FROM_FILTER(filter));
+        CrBltLeave(pBlitter);
+    }
+    else
+    {
+        crWarning("CrBltEnter failed rc %d", rc);
+    }
+
+    crStateSwitchPostprocess(ctx, NULL, idDrawFBO, idReadFBO);
+
+    return rc;
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+                                   GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+                                   GLbitfield mask, GLenum filter)
+{
+    CRContext *ctx = crStateGetCurrent();
+    bool fTryBlitter = false;
+#ifdef CR_CHECK_BLITS
+//    {
+        SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
+        GLint rfb=0, dfb=0, dtex=0, dlev=-1, rtex=0, rlev=-1, rb=0, db=0, ppb=0, pub=0, vp[4], otex, dstw, dsth;
+        GLint sdtex=0, srtex=0;
+        GLenum dStatus, rStatus;
+
+        CRTextureObj *tobj = 0;
+        CRTextureLevel *tl = 0;
+        GLint id, tuId, pbufId, pbufIdHw, ubufId, ubufIdHw, width, height, depth;
+
+        crDebug("===StateTracker===");
+        crDebug("Current TU: %i", ctx->texture.curTextureUnit);
+
+        tobj = ctx->texture.unit[ctx->texture.curTextureUnit].currentTexture2D;
+        CRASSERT(tobj);
+        tl = &tobj->level[0][0];
+        crDebug("Texture %i(hw %i), w=%i, h=%i", tobj->id, tobj->hwid, tl->width, tl->height, tl->depth);
+
+        if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
+        {
+            pbufId = ctx->bufferobject.packBuffer->hwid;
+        }
+        else
+        {
+            pbufId = 0;
+        }
+        crDebug("Pack BufferId %i", pbufId);
+
+        if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
+        {
+            ubufId = ctx->bufferobject.unpackBuffer->hwid;
+        }
+        else
+        {
+            ubufId = 0;
+        }
+        crDebug("Unpack BufferId %i", ubufId);
+
+        crDebug("===GPU===");
+        cr_server.head_spu->dispatch_table.GetIntegerv(GL_ACTIVE_TEXTURE, &tuId);
+        crDebug("Current TU: %i", tuId - GL_TEXTURE0_ARB);
+        CRASSERT(tuId - GL_TEXTURE0_ARB == ctx->texture.curTextureUnit);
+
+        cr_server.head_spu->dispatch_table.GetIntegerv(GL_TEXTURE_BINDING_2D, &id);
+        cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
+        cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
+        cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_DEPTH, &depth);
+        crDebug("Texture: %i, w=%i, h=%i, d=%i", id, width, height, depth);
+        CRASSERT(id == tobj->hwid);
+        CRASSERT(width == tl->width);
+        CRASSERT(height == tl->height);
+        CRASSERT(depth == tl->depth);
+
+        cr_server.head_spu->dispatch_table.GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &pbufIdHw);
+        crDebug("Hw Pack BufferId %i", pbufIdHw);
+        CRASSERT(pbufIdHw == pbufId);
+
+        cr_server.head_spu->dispatch_table.GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &ubufIdHw);
+        crDebug("Hw Unpack BufferId %i", ubufIdHw);
+        CRASSERT(ubufIdHw == ubufId);
+
+        gl->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
+        gl->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
+        gl->GetIntegerv(GL_READ_BUFFER, &rb);
+        gl->GetIntegerv(GL_DRAW_BUFFER, &db);
+
+        gl->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &ppb);
+        gl->GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &pub);
+
+        gl->GetIntegerv(GL_VIEWPORT, &vp[0]);
+
+        gl->GetIntegerv(GL_TEXTURE_BINDING_2D, &otex);
+
+        gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, &dtex);
+        gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT, &dlev);
+        dStatus = gl->CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
+
+        gl->GetFramebufferAttachmentParameterivEXT(GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, &rtex);
+        gl->GetFramebufferAttachmentParameterivEXT(GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT, &rlev);
+        rStatus = gl->CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER_EXT);
+
+        if (dtex)
+        {
+            CRASSERT(!dlev);
+        }
+
+        if (rtex)
+        {
+            CRASSERT(!rlev);
+        }
+
+        if (ctx->framebufferobject.drawFB)
+        {
+            CRASSERT(dfb);
+            CRASSERT(ctx->framebufferobject.drawFB->hwid == dfb);
+            CRASSERT(ctx->framebufferobject.drawFB->drawbuffer[0] == db);
+
+            CRASSERT(dStatus==GL_FRAMEBUFFER_COMPLETE_EXT);
+            CRASSERT(db==GL_COLOR_ATTACHMENT0_EXT);
+
+            CRASSERT(ctx->framebufferobject.drawFB->color[0].type == GL_TEXTURE);
+            CRASSERT(ctx->framebufferobject.drawFB->color[0].level == 0);
+            sdtex = ctx->framebufferobject.drawFB->color[0].name;
+            sdtex = crStateGetTextureHWID(sdtex);
+
+            CRASSERT(sdtex);
+        }
+        else
+        {
+            CRASSERT(!dfb);
+        }
+
+        if (ctx->framebufferobject.readFB)
+        {
+            CRASSERT(rfb);
+            CRASSERT(ctx->framebufferobject.readFB->hwid == rfb);
+
+            CRASSERT(rStatus==GL_FRAMEBUFFER_COMPLETE_EXT);
+
+            CRASSERT(ctx->framebufferobject.readFB->color[0].type == GL_TEXTURE);
+            CRASSERT(ctx->framebufferobject.readFB->color[0].level == 0);
+            srtex = ctx->framebufferobject.readFB->color[0].name;
+            srtex = crStateGetTextureHWID(srtex);
+
+            CRASSERT(srtex);
+        }
+        else
+        {
+            CRASSERT(!rfb);
+        }
+
+        CRASSERT(sdtex == dtex);
+        CRASSERT(srtex == rtex);
+
+//        crDbgDumpTexImage2D("==> src tex:", GL_TEXTURE_2D, rtex, true);
+//        crDbgDumpTexImage2D("==> dst tex:", GL_TEXTURE_2D, dtex, true);
+
+//    }
+#endif
+#ifdef CR_DUMP_BLITS
+    SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
+    GLint rfb=0, dfb=0, dtex=0, dlev=-1, rb=0, db=0, ppb=0, pub=0, vp[4], otex, dstw, dsth;
+    GLenum status;
+    char fname[200];
+    void *img;
+
+    blitnum++;
+
+    crDebug("[%i]BlitFramebufferEXT(%i, %i, %i, %i, %i, %i, %i, %i, %x, %x)", blitnum, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+    crDebug("%i, %i <-> %i, %i", srcX1-srcX0, srcY1-srcY0, dstX1-dstX0, dstY1-dstY0);
+
+    gl->GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
+    gl->GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
+    gl->GetIntegerv(GL_READ_BUFFER, &rb);
+    gl->GetIntegerv(GL_DRAW_BUFFER, &db);
+
+    gl->GetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &ppb);
+    gl->GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, &pub);
+
+    gl->GetIntegerv(GL_VIEWPORT, &vp[0]);
+
+    gl->GetIntegerv(GL_TEXTURE_BINDING_2D, &otex);
+
+    CRASSERT(!rfb && dfb);
+    gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT, &dtex);
+    gl->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT, &dlev);
+    status = gl->CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
+
+    CRASSERT(status==GL_FRAMEBUFFER_COMPLETE_EXT
+             && db==GL_COLOR_ATTACHMENT0_EXT
+             && (rb==GL_FRONT || rb==GL_BACK)
+             && !rfb && dfb && dtex && !dlev
+             && !ppb && !pub);
+
+    crDebug("Src[rb 0x%x, fbo %i] Dst[db 0x%x, fbo %i(0x%x), tex %i.%i]", rb, rfb, db, dfb, status, dtex, dlev);
+    crDebug("Viewport [%i, %i, %i, %i]", vp[0], vp[1], vp[2], vp[3]);
+
+    gl->PixelStorei(GL_PACK_ROW_LENGTH, 0);
+    gl->PixelStorei(GL_PACK_ALIGNMENT, 1);
+    gl->PixelStorei(GL_PACK_SKIP_PIXELS, 0);
+    gl->PixelStorei(GL_PACK_SKIP_ROWS, 0);
+
+    gl->PixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+    gl->PixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    gl->PixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+    gl->PixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+
+    gl->BindTexture(GL_TEXTURE_2D, dtex);
+    gl->GetTexLevelParameteriv(GL_TEXTURE_2D, dlev, GL_TEXTURE_WIDTH, &dstw);
+    gl->GetTexLevelParameteriv(GL_TEXTURE_2D, dlev, GL_TEXTURE_HEIGHT, &dsth);
+    gl->BindTexture(GL_TEXTURE_2D, otex);
+    crDebug("Dst is %i, %i", dstw, dsth);
+
+    CRASSERT(vp[2]>=dstw && vp[3]>=dsth);
+    img = crAlloc(vp[2]*vp[3]*4);
+    CRASSERT(img);
+
+    gl->ReadPixels(0, 0, vp[2], vp[3], GL_BGRA, GL_UNSIGNED_BYTE, img);
+    sprintf(fname, "blit%iA_src.tga", blitnum);
+    crDumpNamedTGA(fname, vp[2], vp[3], img);
+
+    gl->BindTexture(GL_TEXTURE_2D, dtex);
+    gl->GetTexImage(GL_TEXTURE_2D, dlev, GL_BGRA, GL_UNSIGNED_BYTE, img);
+    sprintf(fname, "blit%iB_dst.tga", blitnum);
+    crDumpNamedTGA(fname, dstw, dsth, img);
+    gl->BindTexture(GL_TEXTURE_2D, otex);
+#endif
+
+    if (srcY0 > srcY1)
+    {
+        /* work around Intel driver bug on Linux host  */
+        if (1 || dstY0 > dstY1)
+        {
+            /* use srcY1 < srcY2 && dstY1 < dstY2 whenever possible to avoid GPU driver bugs */
+            int32_t tmp = srcY0;
+            srcY0 = srcY1;
+            srcY1 = tmp;
+            tmp = dstY0;
+            dstY0 = dstY1;
+            dstY1 = tmp;
+        }
+    }
+
+    if (srcX0 > srcX1)
+    {
+        if (dstX0 > dstX1)
+        {
+            /* use srcX1 < srcX2 && dstX1 < dstX2 whenever possible to avoid GPU driver bugs */
+            int32_t tmp = srcX0;
+            srcX0 = srcX1;
+            srcX1 = tmp;
+            tmp = dstX0;
+            dstX0 = dstX1;
+            dstX1 = tmp;
+        }
+    }
+
+    if (cr_server.fBlitterMode)
+    {
+        fTryBlitter = true;
+    }
+
+    if (fTryBlitter)
+    {
+        int rc = crServerVBoxBlitterBlitCurrentCtx(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
+        if (RT_SUCCESS(rc))
+            goto my_exit;
+    }
+
+    if (ctx->viewport.scissorTest)
+        cr_server.head_spu->dispatch_table.Disable(GL_SCISSOR_TEST);
+
+    cr_server.head_spu->dispatch_table.BlitFramebufferEXT(srcX0, srcY0, srcX1, srcY1,
+                                                          dstX0, dstY0, dstX1, dstY1,
+                                                          mask, filter);
+
+    if (ctx->viewport.scissorTest)
+        cr_server.head_spu->dispatch_table.Enable(GL_SCISSOR_TEST);
+
+
+my_exit:
+
+//#ifdef CR_CHECK_BLITS
+//    crDbgDumpTexImage2D("<== src tex:", GL_TEXTURE_2D, rtex, true);
+//    crDbgDumpTexImage2D("<== dst tex:", GL_TEXTURE_2D, dtex, true);
+//#endif
+#ifdef CR_DUMP_BLITS
+    gl->BindTexture(GL_TEXTURE_2D, dtex);
+    gl->GetTexImage(GL_TEXTURE_2D, dlev, GL_BGRA, GL_UNSIGNED_BYTE, img);
+    sprintf(fname, "blit%iC_res.tga", blitnum);
+    crDumpNamedTGA(fname, dstw, dsth, img);
+    gl->BindTexture(GL_TEXTURE_2D, otex);
+    crFree(img);
+#endif
+    return;
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDrawBuffer( GLenum mode )
+{
+    crStateDrawBuffer( mode );
+
+    if (!crStateGetCurrent()->framebufferobject.drawFB)
+    {
+        if (mode == GL_FRONT || mode == GL_FRONT_LEFT || mode == GL_FRONT_RIGHT)
+            cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
+
+        if (crServerIsRedirectedToFBO()
+                && cr_server.curClient->currentMural->aidFBOs[0])
+        {
+            CRMuralInfo *mural = cr_server.curClient->currentMural;
+            GLint iBufferNeeded = -1;
+            switch (mode)
+            {
+                case GL_BACK:
+                case GL_BACK_LEFT:
+                case GL_BACK_RIGHT:
+                    mode = GL_COLOR_ATTACHMENT0;
+                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
+                    break;
+                case GL_FRONT:
+                case GL_FRONT_LEFT:
+                case GL_FRONT_RIGHT:
+                    mode = GL_COLOR_ATTACHMENT0;
+                    iBufferNeeded = CR_SERVER_FBO_FB_IDX(mural);
+                    break;
+                case GL_NONE:
+                    crDebug("DrawBuffer: GL_NONE");
+                    break;
+                case GL_AUX0:
+                    crDebug("DrawBuffer: GL_AUX0");
+                    break;
+                case GL_AUX1:
+                    crDebug("DrawBuffer: GL_AUX1");
+                    break;
+                case GL_AUX2:
+                    crDebug("DrawBuffer: GL_AUX2");
+                    break;
+                case GL_AUX3:
+                    crDebug("DrawBuffer: GL_AUX3");
+                    break;
+                case GL_LEFT:
+                    crWarning("DrawBuffer: GL_LEFT not supported properly");
+                    mode = GL_COLOR_ATTACHMENT0;
+                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
+                    break;
+                case GL_RIGHT:
+                    crWarning("DrawBuffer: GL_RIGHT not supported properly");
+                    mode = GL_COLOR_ATTACHMENT0;
+                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
+                    break;
+                case GL_FRONT_AND_BACK:
+                    crWarning("DrawBuffer: GL_FRONT_AND_BACK not supported properly");
+                    mode = GL_COLOR_ATTACHMENT0;
+                    iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
+                    break;
+                default:
+                    crWarning("DrawBuffer: unexpected mode! 0x%x", mode);
+                    iBufferNeeded = mural->iCurDrawBuffer;
+                    break;
+            }
+
+            if (iBufferNeeded != mural->iCurDrawBuffer)
+            {
+                mural->iCurDrawBuffer = iBufferNeeded;
+                cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, iBufferNeeded));
+            }
+        }
+    }
+
+    cr_server.head_spu->dispatch_table.DrawBuffer( mode );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDrawBuffers( GLsizei n, const GLenum* bufs )
+{
+    if (n == 1)
+    {
+        crServerDispatchDrawBuffer( bufs[0] );
+    }
+    else
+    {
+        /** @todo State tracker. */
+        cr_server.head_spu->dispatch_table.DrawBuffers( n, bufs );
+    }
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchReadBuffer( GLenum mode )
+{
+    crStateReadBuffer( mode );
+
+    if (crServerIsRedirectedToFBO()
+            && cr_server.curClient->currentMural->aidFBOs[0]
+            && !crStateGetCurrent()->framebufferobject.readFB)
+    {
+        CRMuralInfo *mural = cr_server.curClient->currentMural;
+        GLint iBufferNeeded = -1;
+        switch (mode)
+        {
+            case GL_BACK:
+            case GL_BACK_LEFT:
+            case GL_BACK_RIGHT:
+                mode = GL_COLOR_ATTACHMENT0;
+                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
+                break;
+            case GL_FRONT:
+            case GL_FRONT_LEFT:
+            case GL_FRONT_RIGHT:
+                mode = GL_COLOR_ATTACHMENT0;
+                iBufferNeeded = CR_SERVER_FBO_FB_IDX(mural);
+                break;
+            case GL_NONE:
+                crDebug("ReadBuffer: GL_NONE");
+                break;
+            case GL_AUX0:
+                crDebug("ReadBuffer: GL_AUX0");
+                break;
+            case GL_AUX1:
+                crDebug("ReadBuffer: GL_AUX1");
+                break;
+            case GL_AUX2:
+                crDebug("ReadBuffer: GL_AUX2");
+                break;
+            case GL_AUX3:
+                crDebug("ReadBuffer: GL_AUX3");
+                break;
+            case GL_LEFT:
+                crWarning("ReadBuffer: GL_LEFT not supported properly");
+                mode = GL_COLOR_ATTACHMENT0;
+                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
+                break;
+            case GL_RIGHT:
+                crWarning("ReadBuffer: GL_RIGHT not supported properly");
+                mode = GL_COLOR_ATTACHMENT0;
+                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
+                break;
+            case GL_FRONT_AND_BACK:
+                crWarning("ReadBuffer: GL_FRONT_AND_BACK not supported properly");
+                mode = GL_COLOR_ATTACHMENT0;
+                iBufferNeeded = CR_SERVER_FBO_BB_IDX(mural);
+                break;
+            default:
+                crWarning("ReadBuffer: unexpected mode! 0x%x", mode);
+                iBufferNeeded = mural->iCurDrawBuffer;
+                break;
+        }
+
+        Assert(CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
+        if (iBufferNeeded != mural->iCurReadBuffer)
+        {
+            mural->iCurReadBuffer = iBufferNeeded;
+            cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, iBufferNeeded));
+        }
+    }
+    cr_server.head_spu->dispatch_table.ReadBuffer( mode );
+}
+
+GLenum SERVER_DISPATCH_APIENTRY crServerDispatchGetError( void )
+{
+    GLenum retval, err;
+    CRContext *ctx = crStateGetCurrent();
+    retval = ctx->error;
+
+    err = cr_server.head_spu->dispatch_table.GetError();
+    if (retval == GL_NO_ERROR)
+        retval = err;
+    else
+        ctx->error = GL_NO_ERROR;
+
+    /* our impl has a single error flag, so we just loop here to reset all error flags to no_error */
+    while (err != GL_NO_ERROR)
+        err = cr_server.head_spu->dispatch_table.GetError();
+
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerMakeTmpCtxCurrent( GLint window, GLint nativeWindow, GLint context )
+{
+    CRContext *pCtx = crStateGetCurrent();
+    CRContext *pCurCtx = NULL;
+    GLuint idDrawFBO = 0, idReadFBO = 0;
+    int fDoPrePostProcess = 0;
+
+    if (pCtx)
+    {
+        CRMuralInfo *pCurrentMural = cr_server.currentMural;
+
+        pCurCtx = cr_server.currentCtxInfo ? cr_server.currentCtxInfo->pContext : cr_server.MainContextInfo.pContext;
+        Assert(pCurCtx == pCtx);
+
+        if (!context)
+        {
+            if (pCurrentMural)
+            {
+                Assert(cr_server.currentCtxInfo);
+                context = cr_server.currentCtxInfo->SpuContext > 0 ? cr_server.currentCtxInfo->SpuContext : cr_server.MainContextInfo.SpuContext;
+                window = pCurrentMural->spuWindow;
+            }
+            else
+            {
+                CRMuralInfo * pDummy;
+                Assert(!cr_server.currentCtxInfo);
+                pDummy = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
+                context = cr_server.MainContextInfo.SpuContext;
+                window = pDummy->spuWindow;
+            }
+
+
+            fDoPrePostProcess = -1;
+        }
+        else
+        {
+            fDoPrePostProcess = 1;
+        }
+
+        if (pCurrentMural)
+        {
+            idDrawFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurDrawBuffer);
+            idReadFBO = CR_SERVER_FBO_FOR_IDX(pCurrentMural, pCurrentMural->iCurReadBuffer);
+        }
+        else
+        {
+            idDrawFBO = 0;
+            idReadFBO = 0;
+        }
+    }
+    else
+    {
+        /* this is a GUI thread, so no need to do anything here */
+    }
+
+    if (fDoPrePostProcess > 0)
+        crStateSwitchPrepare(NULL, pCurCtx, idDrawFBO, idReadFBO);
+
+    cr_server.head_spu->dispatch_table.MakeCurrent( window, nativeWindow, context);
+
+    if (fDoPrePostProcess < 0)
+        crStateSwitchPostprocess(pCurCtx, NULL, idDrawFBO, idReadFBO);
+}
+
+void crServerInitTmpCtxDispatch()
+{
+    MakeCurrentFunc_t pfnMakeCurrent;
+
+    crSPUInitDispatchTable(&cr_server.TmpCtxDispatch);
+    crSPUCopyDispatchTable(&cr_server.TmpCtxDispatch, &cr_server.head_spu->dispatch_table);
+    cr_server.TmpCtxDispatch.MakeCurrent = crServerMakeTmpCtxCurrent;
+
+    pfnMakeCurrent = crServerMakeTmpCtxCurrent;
+    cr_server.head_spu->dispatch_table.ChromiumParametervCR(GL_HH_SET_TMPCTX_MAKE_CURRENT, GL_BYTE, sizeof (void*), &pfnMakeCurrent);
+
+}
+
+/* dump stuff */
+#ifdef VBOX_WITH_CRSERVER_DUMPER
+
+# ifndef VBOX_WITH_CRDUMPER
+#  error "VBOX_WITH_CRDUMPER undefined!"
+# endif
+
+/* first four bits are buffer dump config
+ * second four bits are texture dump config
+ * config flags:
+ * 1 - blit on enter
+ * 2 - blit on exit
+ *
+ *
+ * Example:
+ *
+ * 0x03 - dump buffer on enter and exit
+ * 0x22 - dump texture and buffer on exit */
+
+int64_t g_CrDbgDumpPid = 0;
+unsigned long g_CrDbgDumpEnabled = 0;
+unsigned long g_CrDbgDumpDraw = 0
+#if 0
+        | CR_SERVER_DUMP_F_COMPILE_SHADER
+        | CR_SERVER_DUMP_F_LINK_PROGRAM
+#endif
+        ;
+#if 0
+        | CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
+        | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
+        | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER
+        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER
+        | CR_SERVER_DUMP_F_DRAW_TEX_ENTER
+        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER
+        | CR_SERVER_DUMP_F_DRAW_STATE_ENTER
+        | CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER
+        | CR_SERVER_DUMP_F_DRAWEL
+        | CR_SERVER_DUMP_F_SHADER_SOURCE
+        ;
+#endif
+unsigned long g_CrDbgDumpDrawFramesSettings = CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
+        | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
+        | CR_SERVER_DUMP_F_DRAW_TEX_ENTER
+        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER
+        | CR_SERVER_DUMP_F_COMPILE_SHADER
+        | CR_SERVER_DUMP_F_LINK_PROGRAM
+        | CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER;
+unsigned long g_CrDbgDumpDrawFramesAppliedSettings = 0;
+unsigned long g_CrDbgDumpDrawFramesSavedInitSettings = 0;
+unsigned long g_CrDbgDumpDrawFramesCount = 0;
+
+uint32_t g_CrDbgDumpDrawCount = 0;
+uint32_t g_CrDbgDumpDumpOnCount = 10;
+uint32_t g_CrDbgDumpDumpOnCountEnabled = 0;
+uint32_t g_CrDbgDumpDumpOnCountPerform = 0;
+uint32_t g_CrDbgDumpDrawFlags = CR_SERVER_DUMP_F_COMPILE_SHADER
+        | CR_SERVER_DUMP_F_SHADER_SOURCE
+        | CR_SERVER_DUMP_F_COMPILE_SHADER
+        | CR_SERVER_DUMP_F_LINK_PROGRAM
+        | CR_SERVER_DUMP_F_DRAW_BUFF_ENTER
+        | CR_SERVER_DUMP_F_DRAW_BUFF_LEAVE
+        | CR_SERVER_DUMP_F_DRAW_TEX_ENTER
+        | CR_SERVER_DUMP_F_DRAW_PROGRAM_UNIFORMS_ENTER
+        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ATTRIBS_ENTER
+        | CR_SERVER_DUMP_F_DRAW_PROGRAM_ENTER
+        | CR_SERVER_DUMP_F_DRAW_STATE_ENTER
+        | CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER
+        | CR_SERVER_DUMP_F_DRAWEL
+        | CR_SERVER_DUMP_F_TEXPRESENT;
+
+void crServerDumpCheckTerm()
+{
+    if (!CrBltIsInitialized(&cr_server.RecorderBlitter))
+        return;
+
+    CrBltTerm(&cr_server.RecorderBlitter);
+}
+
+int crServerDumpCheckInit()
+{
+    int rc;
+    CR_BLITTER_WINDOW BltWin;
+    CR_BLITTER_CONTEXT BltCtx;
+    CRMuralInfo *pBlitterMural;
+
+    if (!CrBltIsInitialized(&cr_server.RecorderBlitter))
+    {
+        pBlitterMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
+        if (!pBlitterMural)
+        {
+            crWarning("crServerGetDummyMural failed");
+            return VERR_GENERAL_FAILURE;
+        }
+
+        crServerVBoxBlitterWinInit(&BltWin, pBlitterMural);
+        crServerVBoxBlitterCtxInit(&BltCtx, &cr_server.MainContextInfo);
+
+        rc = CrBltInit(&cr_server.RecorderBlitter, &BltCtx, true, true, NULL, &cr_server.TmpCtxDispatch);
+        if (!RT_SUCCESS(rc))
+        {
+            crWarning("CrBltInit failed rc %d", rc);
+            return rc;
+        }
+
+        rc = CrBltMuralSetCurrentInfo(&cr_server.RecorderBlitter, &BltWin);
+        if (!RT_SUCCESS(rc))
+        {
+            crWarning("CrBltMuralSetCurrentInfo failed rc %d", rc);
+            return rc;
+        }
+    }
+
+#if 0
+    crDmpDbgPrintInit(&cr_server.DbgPrintDumper);
+    cr_server.pDumper = &cr_server.DbgPrintDumper.Base;
+#else
+    if (!crDmpHtmlIsInited(&cr_server.HtmlDumper))
+    {
+        static int cCounter = 0;
+//    crDmpHtmlInit(&cr_server.HtmlDumper, "S:\\projects\\virtualbox\\3d\\dumps\\1", "index.html");
+        crDmpHtmlInitF(&cr_server.HtmlDumper, "/Users/oracle-mac/vbox/dump/1", "index%d.html", cCounter);
+        cr_server.pDumper = &cr_server.HtmlDumper.Base;
+        ++cCounter;
+    }
+#endif
+
+    crRecInit(&cr_server.Recorder, &cr_server.RecorderBlitter, &cr_server.TmpCtxDispatch, cr_server.pDumper);
+    return VINF_SUCCESS;
+}
+
+void crServerDumpShader(GLint id)
+{
+    CRContext *ctx = crStateGetCurrent();
+    crRecDumpShader(&cr_server.Recorder, ctx, id, 0);
+}
+
+void crServerDumpProgram(GLint id)
+{
+    CRContext *ctx = crStateGetCurrent();
+    crRecDumpProgram(&cr_server.Recorder, ctx, id, 0);
+}
+
+void crServerDumpCurrentProgram()
+{
+    CRContext *ctx = crStateGetCurrent();
+    crRecDumpCurrentProgram(&cr_server.Recorder, ctx);
+}
+
+void crServerDumpRecompileDumpCurrentProgram()
+{
+    crDmpStrF(cr_server.Recorder.pDumper, "==Dump(1)==");
+    crServerRecompileCurrentProgram();
+    crServerDumpCurrentProgramUniforms();
+    crServerDumpCurrentProgramAttribs();
+    crDmpStrF(cr_server.Recorder.pDumper, "Done Dump(1)");
+    crServerRecompileCurrentProgram();
+    crDmpStrF(cr_server.Recorder.pDumper, "Dump(2)");
+    crServerRecompileCurrentProgram();
+    crServerDumpCurrentProgramUniforms();
+    crServerDumpCurrentProgramAttribs();
+    crDmpStrF(cr_server.Recorder.pDumper, "Done Dump(2)");
+}
+
+void crServerRecompileCurrentProgram()
+{
+    CRContext *ctx = crStateGetCurrent();
+    crRecRecompileCurrentProgram(&cr_server.Recorder, ctx);
+}
+
+void crServerDumpCurrentProgramUniforms()
+{
+    CRContext *ctx = crStateGetCurrent();
+    crDmpStrF(cr_server.Recorder.pDumper, "==Uniforms==");
+    crRecDumpCurrentProgramUniforms(&cr_server.Recorder, ctx);
+    crDmpStrF(cr_server.Recorder.pDumper, "==Done Uniforms==");
+}
+
+void crServerDumpCurrentProgramAttribs()
+{
+    CRContext *ctx = crStateGetCurrent();
+    crDmpStrF(cr_server.Recorder.pDumper, "==Attribs==");
+    crRecDumpCurrentProgramAttribs(&cr_server.Recorder, ctx);
+    crDmpStrF(cr_server.Recorder.pDumper, "==Done Attribs==");
+}
+
+void crServerDumpState()
+{
+    CRContext *ctx = crStateGetCurrent();
+    crRecDumpGlGetState(&cr_server.Recorder, ctx);
+    crRecDumpGlEnableState(&cr_server.Recorder, ctx);
+}
+
+void crServerDumpDrawel(const char*pszFormat, ...)
+{
+    CRContext *ctx = crStateGetCurrent();
+    va_list pArgList;
+    va_start(pArgList, pszFormat);
+    crRecDumpVertAttrV(&cr_server.Recorder, ctx, pszFormat, pArgList);
+    va_end(pArgList);
+}
+
+void crServerDumpDrawelv(GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal)
+{
+    CRContext *ctx = crStateGetCurrent();
+    crRecDumpVertAttrv(&cr_server.Recorder, ctx, idx, pszElFormat, cbEl, pvVal, cVal);
+}
+
+void crServerDumpBuffer(int idx)
+{
+    CRContextInfo *pCtxInfo = cr_server.currentCtxInfo;
+    CRContext *ctx = crStateGetCurrent();
+    GLint idFBO;
+    GLint idTex;
+    VBOXVR_TEXTURE RedirTex;
+    int rc = crServerDumpCheckInit();
+    idx = idx >= 0 ? idx : crServerMuralFBOIdxFromBufferName(cr_server.currentMural, pCtxInfo->pContext->buffer.drawBuffer);
+    if (!RT_SUCCESS(rc))
+    {
+        crWarning("crServerDumpCheckInit failed, rc %d", rc);
+        return;
+    }
+
+    if (idx < 0)
+    {
+        crWarning("neg idx, unsupported");
+        return;
+    }
+
+    idFBO = CR_SERVER_FBO_FOR_IDX(cr_server.currentMural, idx);
+    idTex = CR_SERVER_FBO_TEX_FOR_IDX(cr_server.currentMural, idx);
+
+    RedirTex.width = cr_server.currentMural->fboWidth;
+    RedirTex.height = cr_server.currentMural->fboHeight;
+    RedirTex.target = GL_TEXTURE_2D;
+    RedirTex.hwid = idTex;
+
+    crRecDumpBuffer(&cr_server.Recorder, ctx, idFBO, idTex ? &RedirTex : NULL);
+}
+
+void crServerDumpTexture(const VBOXVR_TEXTURE *pTex)
+{
+    CRContextInfo *pCtxInfo = cr_server.currentCtxInfo;
+    CR_BLITTER_WINDOW BltWin;
+    CR_BLITTER_CONTEXT BltCtx;
+    CRContext *ctx = crStateGetCurrent();
+    int rc = crServerDumpCheckInit();
+    if (!RT_SUCCESS(rc))
+    {
+        crWarning("crServerDumpCheckInit failed, rc %d", rc);
+        return;
+    }
+
+    crServerVBoxBlitterWinInit(&BltWin, cr_server.currentMural);
+    crServerVBoxBlitterCtxInit(&BltCtx, pCtxInfo);
+
+    crRecDumpTextureF(&cr_server.Recorder, pTex, &BltCtx, &BltWin, "Tex (%d x %d), hwid (%d) target %#x", pTex->width, pTex->height, pTex->hwid, pTex->target);
+}
+
+void crServerDumpTextures()
+{
+    CRContextInfo *pCtxInfo = cr_server.currentCtxInfo;
+    CRContext *ctx = crStateGetCurrent();
+    int rc = crServerDumpCheckInit();
+    if (!RT_SUCCESS(rc))
+    {
+        crWarning("crServerDumpCheckInit failed, rc %d", rc);
+        return;
+    }
+
+    crRecDumpTextures(&cr_server.Recorder, ctx);
+}
+
+void crServerDumpFilterOpLeave(unsigned long event, CR_DUMPER *pDumper)
+{
+    if (CR_SERVER_DUMP_F_DRAW_LEAVE_ALL & event)
+    {
+        g_CrDbgDumpDumpOnCountPerform = 0;
+    }
+}
+
+bool crServerDumpFilterOpEnter(unsigned long event, CR_DUMPER *pDumper)
+{
+    if ((CR_SERVER_DUMP_F_SWAPBUFFERS_ENTER & event)
+            || (CR_SERVER_DUMP_F_TEXPRESENT & event))
+    {
+        if (g_CrDbgDumpDumpOnCountEnabled == 1)
+            g_CrDbgDumpDumpOnCountEnabled = 2;
+        else if (g_CrDbgDumpDumpOnCountEnabled)
+        {
+            g_CrDbgDumpDumpOnCountEnabled = 0;
+            if (cr_server.pDumper == &cr_server.HtmlDumper.Base)
+            {
+                crDmpHtmlTerm(&cr_server.HtmlDumper);
+                cr_server.pDumper = NULL;
+            }
+        }
+
+        g_CrDbgDumpDrawCount = 0;
+    }
+    else if (CR_SERVER_DUMP_F_DRAW_ENTER_ALL & event)
+    {
+        if (g_CrDbgDumpDumpOnCountEnabled == 2)
+        {
+            if (g_CrDbgDumpDumpOnCount == g_CrDbgDumpDrawCount)
+            {
+                g_CrDbgDumpDumpOnCountPerform = 1;
+            }
+            ++g_CrDbgDumpDrawCount;
+        }
+    }
+    if (g_CrDbgDumpDumpOnCountPerform)
+    {
+        if (g_CrDbgDumpDrawFlags & event)
+            return true;
+    }
+    return CR_SERVER_DUMP_DEFAULT_FILTER_OP(event);
+}
+
+bool crServerDumpFilterDmp(unsigned long event, CR_DUMPER *pDumper)
+{
+    if (g_CrDbgDumpDumpOnCountPerform)
+    {
+        if (g_CrDbgDumpDrawFlags & event)
+            return true;
+    }
+    return CR_SERVER_DUMP_DEFAULT_FILTER_DMP(event);
+}
+
+void crServerDumpFramesCheck()
+{
+    if (!g_CrDbgDumpDrawFramesCount)
+        return;
+
+    if (!g_CrDbgDumpDrawFramesAppliedSettings)
+    {
+        if (!g_CrDbgDumpDrawFramesSettings)
+        {
+            crWarning("g_CrDbgDumpDrawFramesSettings is NULL, bump will not be started");
+            g_CrDbgDumpDrawFramesCount = 0;
+            return;
+        }
+
+        g_CrDbgDumpDrawFramesSavedInitSettings = g_CrDbgDumpDraw;
+        g_CrDbgDumpDrawFramesAppliedSettings = g_CrDbgDumpDrawFramesSettings;
+        g_CrDbgDumpDraw = g_CrDbgDumpDrawFramesSettings;
+        crDmpStrF(cr_server.Recorder.pDumper, "***Starting draw dump for %d frames, settings(0x%x)", g_CrDbgDumpDrawFramesCount, g_CrDbgDumpDraw);
+        return;
+    }
+
+    --g_CrDbgDumpDrawFramesCount;
+
+    if (!g_CrDbgDumpDrawFramesCount)
+    {
+        crDmpStrF(cr_server.Recorder.pDumper, "***Stop draw dump");
+        g_CrDbgDumpDraw = g_CrDbgDumpDrawFramesSavedInitSettings;
+        g_CrDbgDumpDrawFramesAppliedSettings = 0;
+    }
+}
+#endif
+
+GLvoid crServerSpriteCoordReplEnable(GLboolean fEnable)
+{
+    CRContext *g = crStateGetCurrent();
+    CRTextureState *t = &(g->texture);
+    GLuint curTextureUnit = t->curTextureUnit;
+    GLuint curTextureUnitRestore = curTextureUnit;
+    GLuint i;
+
+    for (i = 0; i < g->limits.maxTextureUnits; ++i)
+    {
+        if (g->point.coordReplacement[i])
+        {
+            if (i != curTextureUnit)
+            {
+                curTextureUnit = i;
+                cr_server.head_spu->dispatch_table.ActiveTextureARB( i + GL_TEXTURE0_ARB );
+            }
+
+            cr_server.head_spu->dispatch_table.TexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, (GLint)fEnable);
+        }
+    }
+
+    if (curTextureUnit != curTextureUnitRestore)
+    {
+        cr_server.head_spu->dispatch_table.ActiveTextureARB( curTextureUnitRestore + GL_TEXTURE0_ARB );
+    }
+}
+
+GLvoid SERVER_DISPATCH_APIENTRY crServerDispatchDrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+#ifdef DEBUG
+    GLenum status = cr_server.head_spu->dispatch_table.CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
+    Assert(GL_FRAMEBUFFER_COMPLETE == status);
+#endif
+    if (mode == GL_POINTS)
+        crServerSpriteCoordReplEnable(GL_TRUE);
+    CR_SERVER_DUMP_DRAW_ENTER();
+    CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.DrawArrays(mode, first, count););
+    CR_SERVER_DUMP_DRAW_LEAVE();
+    if (mode == GL_POINTS)
+        crServerSpriteCoordReplEnable(GL_FALSE);
+}
+
+GLvoid SERVER_DISPATCH_APIENTRY crServerDispatchDrawElements(GLenum mode,  GLsizei count,  GLenum type,  const GLvoid * indices)
+{
+#ifdef DEBUG
+    GLenum status = cr_server.head_spu->dispatch_table.CheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT);
+    Assert(GL_FRAMEBUFFER_COMPLETE == status);
+#endif
+    if (mode == GL_POINTS)
+        crServerSpriteCoordReplEnable(GL_TRUE);
+    CR_SERVER_DUMP_DRAW_ENTER();
+    CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.DrawElements(mode, count, type, indices););
+    CR_SERVER_DUMP_DRAW_LEAVE();
+    if (mode == GL_POINTS)
+        crServerSpriteCoordReplEnable(GL_FALSE);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchEnd( void )
+{
+    CRContext *g = crStateGetCurrent();
+    GLenum mode = g->current.mode;
+
+    crStateEnd();
+    cr_server.head_spu->dispatch_table.End();
+
+    CR_SERVER_DUMP_DRAW_LEAVE();
+
+    if (mode == GL_POINTS)
+        crServerSpriteCoordReplEnable(GL_FALSE);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchBegin(GLenum mode)
+{
+#ifdef DEBUG
+    CRContext *ctx = crStateGetCurrent();
+    SPUDispatchTable *gl = &cr_server.head_spu->dispatch_table;
+
+    if (ctx->program.vpProgramBinding)
+    {
+        AssertRelease(ctx->program.currentVertexProgram);
+
+        if (ctx->program.currentVertexProgram->isARBprogram)
+        {
+            GLint pid=-1;
+            gl->GetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_BINDING_ARB, &pid);
+
+            if (pid != ctx->program.currentVertexProgram->id)
+            {
+                crWarning("pid(%d) != ctx->program.currentVertexProgram->id(%d)", pid, ctx->program.currentVertexProgram->id);
+            }
+            AssertRelease(pid == ctx->program.currentVertexProgram->id);
+        }
+        else
+        {
+            GLint pid=-1;
+
+            gl->GetIntegerv(GL_VERTEX_PROGRAM_BINDING_NV, &pid);
+            if (pid != ctx->program.currentVertexProgram->id)
+            {
+                crWarning("pid(%d) != ctx->program.currentVertexProgram->id(%d)", pid, ctx->program.currentVertexProgram->id);
+            }
+            AssertRelease(pid == ctx->program.currentVertexProgram->id);
+        }
+    }
+    else if (ctx->glsl.activeProgram)
+    {
+        GLint pid=-1;
+
+        gl->GetIntegerv(GL_CURRENT_PROGRAM, &pid);
+        //crDebug("pid %i, state: id %i, hwid %i", pid, ctx->glsl.activeProgram->id, ctx->glsl.activeProgram->hwid);
+        if (pid != ctx->glsl.activeProgram->hwid)
+        {
+            crWarning("pid(%d) != ctx->glsl.activeProgram->hwid(%d)", pid, ctx->glsl.activeProgram->hwid);
+        }
+        AssertRelease(pid == ctx->glsl.activeProgram->hwid);
+    }
+#endif
+
+    if (mode == GL_POINTS)
+        crServerSpriteCoordReplEnable(GL_TRUE);
+
+    CR_SERVER_DUMP_DRAW_ENTER();
+
+    crStateBegin(mode);
+    cr_server.head_spu->dispatch_table.Begin(mode);
+}
+
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_occlude.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_occlude.c	(revision 78189)
+++ 	(revision )
@@ -1,37 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "chromium.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "server_dispatch.h"
-#include "server.h"
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchGenQueriesARB(GLsizei n, GLuint *queries)
-{
-    GLuint *local_queries;
-    (void) queries;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchGenQueriesARB: parameter 'n' is out of range");
-        return;
-    }
-
-    local_queries = (GLuint *)crCalloc(n * sizeof(*local_queries));
-
-    if (!local_queries)
-    {
-        crError("crServerDispatchGenQueriesARB: out of memory");
-        return;
-    }
-
-    cr_server.head_spu->dispatch_table.GenQueriesARB( n, local_queries );
-
-    crServerReturnValue( local_queries, n * sizeof(*local_queries) );
-    crFree( local_queries );
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_occlude.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_occlude.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_occlude.cpp	(revision 78190)
@@ -0,0 +1,37 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "chromium.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "server_dispatch.h"
+#include "server.h"
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchGenQueriesARB(GLsizei n, GLuint *queries)
+{
+    GLuint *local_queries;
+    (void) queries;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchGenQueriesARB: parameter 'n' is out of range");
+        return;
+    }
+
+    local_queries = (GLuint *)crCalloc(n * sizeof(*local_queries));
+
+    if (!local_queries)
+    {
+        crError("crServerDispatchGenQueriesARB: out of memory");
+        return;
+    }
+
+    cr_server.head_spu->dispatch_table.GenQueriesARB( n, local_queries );
+
+    crServerReturnValue( local_queries, n * sizeof(*local_queries) );
+    crFree( local_queries );
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_papi.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_papi.c	(revision 78189)
+++ 	(revision )
@@ -1,276 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "state/cr_statetypes.h"
-
-#define DEBUG_BARRIERS 1
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchBarrierCreateCR( GLuint name, GLuint count )
-{
-	CRServerBarrier *barrier;
-#if DEBUG_BARRIERS
-	char debug_buf[4096];
-#endif
-
-	if (cr_server.ignore_papi)
-	{
-		cr_server.head_spu->dispatch_table.BarrierCreateCR( name, count );
-		return;
-	}
-
-	barrier = (CRServerBarrier *) crHashtableSearch( cr_server.barriers, name );
-
-#if DEBUG_BARRIERS
-	sprintf( debug_buf, "BarrierCreateCR( %d, %d )", name, count );
-	cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
-#endif
-
-	if (count > CR_MAX_CLIENTS)
-		count = CR_MAX_CLIENTS;
-
-	if (count == 0)
-	{
-		count = cr_server.numClients;
-#if DEBUG_BARRIERS
-		sprintf( debug_buf, "changing count to %d", count );
-		cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
-#endif
-	}
-
-
-	/* we use maxBarrierCount in Clear() and SwapBuffers() and also use it
-	 * in __getNextClient() for deadlock detection.  The issue is that all
-	 * the existing clients may be blocked, but we might soon get another
-	 * client connection to break the apparent deadlock.
-	 */
-	if (count > cr_server.maxBarrierCount)
-		cr_server.maxBarrierCount = count;
-
-	if ( barrier == NULL )
-	{
-		barrier = (CRServerBarrier *) crAlloc( sizeof(*barrier) );
-		barrier->count = count;
-		barrier->num_waiting = 0;
-		barrier->waiting = (RunQueue **) 
-			crAlloc( count * sizeof(*(barrier->waiting)) );
-
-		crHashtableAdd( cr_server.barriers, name, barrier );
-#if DEBUG_BARRIERS
-		sprintf( debug_buf, "This was a new barrier!" );
-		cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
-#endif
-	}
-	else
-	{
-		/* HACK -- this allows everybody to create a barrier, and all
-           but the first creation are ignored, assuming the count
-           match. */
-#if DEBUG_BARRIERS
-		sprintf( debug_buf, "I already knew about this barrier." );
-		cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
-#endif
-		if ( barrier->count != count )
-		{
-#if DEBUG_BARRIERS
-			sprintf( debug_buf, "And someone messed up the count!." );
-			cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
-#endif
-			crError( "Barrier name=%u created with count=%u, but already "
-						 "exists with count=%u", name, count, barrier->count );
-		}
-	}
-
-	if (cr_server.debug_barriers)
-		crDebug("crserver: BarrierCreate(id=%d, count=%d)", name, barrier->count);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchBarrierDestroyCR( GLuint name )
-{
-	if (cr_server.ignore_papi)
-	{
-		cr_server.head_spu->dispatch_table.BarrierDestroyCR( name );
-		return;
-	}
-
-	crError( "NO BARRIER DESTROY FOR YOU!  (name=%u)", name );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchBarrierExecCR( GLuint name )
-{
-	CRServerBarrier *barrier;
-#if DEBUG_BARRIERS
-	char debug_buf[4096];
-#endif
-
-	if (cr_server.ignore_papi)
-	{
-		cr_server.head_spu->dispatch_table.BarrierExecCR( name );
-		return;
-	}
-
-	barrier = (CRServerBarrier *) crHashtableSearch( cr_server.barriers, name );
-	if ( barrier == NULL )
-	{
-		crError( "crServerDispatchBarrierExec: No such barrier: %d", name );
-	}
-
-#if DEBUG_BARRIERS
-	sprintf( debug_buf, "BarrierExec( %d )", name );
-	cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
-	sprintf( debug_buf, "num_waiting = %d", barrier->num_waiting );
-	cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
-#endif
-
-	barrier->waiting[barrier->num_waiting++] = cr_server.run_queue;
-
-	cr_server.run_queue->blocked = 1;
-
-	if ( barrier->num_waiting == barrier->count )
-	{
-		GLuint i;
-
-		if (cr_server.debug_barriers)
-			crDebug("crserver: BarrierExec(client=%p, id=%d, num_waiting=%d/%d) - release",
-							cr_server.curClient, name, barrier->num_waiting,
-							barrier->count);
-
-		for ( i = 0; i < barrier->count; i++ )
-		{
-			barrier->waiting[i]->blocked = 0;
-		}
-		barrier->num_waiting = 0;
-	}
-	else if (cr_server.debug_barriers)
-		crDebug("crserver: BarrierExec(client=%p, id=%d, num_waiting=%d/%d) - block",
-						cr_server.curClient, name, barrier->num_waiting,
-						barrier->count);
-
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphoreCreateCR( GLuint name, GLuint count )
-{
-	CRServerSemaphore *sema;
-
-	if (cr_server.ignore_papi)
-	{
-		cr_server.head_spu->dispatch_table.SemaphoreCreateCR( name, count );
-		return;
-	}
-
-	sema = crHashtableSearch(cr_server.semaphores, name);
-	if (sema)
-		return; /* already created */
-
-	sema = (CRServerSemaphore *) crAlloc( sizeof( *sema ) );
-	crHashtableAdd( cr_server.semaphores, name, sema );
-	sema->count = count;
-	sema->waiting = sema->tail = NULL;
-	if (cr_server.debug_barriers)
-		crDebug("crserver: SemaphoreCreate(id=%d, count=%d)", name, count);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphoreDestroyCR( GLuint name )
-{
-	if (cr_server.ignore_papi)
-	{
-		cr_server.head_spu->dispatch_table.SemaphoreDestroyCR( name );
-		return;
-	}
-
-	crError( "NO DESTROY FOR YOU! (name=%u)", name );
-}
-
-/* Semaphore wait */
-void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphorePCR( GLuint name )
-{
-	CRServerSemaphore *sema;
-
-	if (cr_server.ignore_papi)
-	{
-		cr_server.head_spu->dispatch_table.SemaphorePCR( name );
-		return;
-	}
-
-	sema = (CRServerSemaphore *) crHashtableSearch( cr_server.semaphores, name );
-	if (!sema)
-	{
-		crError( "No such semaphore: %d", name );
-	}
-	if (sema->count)
-	{
-		/* go */
-		if (cr_server.debug_barriers)
-			crDebug("crserver: SemaphoreP(client=%p, id=%d, count=%d) decrement to %d",
-							cr_server.curClient, name, sema->count, sema->count - 1);
-		sema->count--;
-	}
-	else
-	{
-		/* block */
-		wqnode *node;
-		if (cr_server.debug_barriers)
-			crDebug("crserver: SemaphoreP(client=%p, id=%d, count=%d) - block.",
-							cr_server.curClient, name, sema->count);
-		cr_server.run_queue->blocked = 1;
-		node = (wqnode *) crAlloc( sizeof( *node ) );
-		node->q = cr_server.run_queue;
-		node->next = NULL;
-		if (sema->tail)
-		{
-			sema->tail->next = node;
-		}
-		else
-		{
-			sema->waiting = node;
-		}
-		sema->tail = node;
-	}
-}
-
-/* Semaphore signal */
-void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphoreVCR( GLuint name )
-{
-	CRServerSemaphore *sema;
-
-	if (cr_server.ignore_papi)
-	{
-		cr_server.head_spu->dispatch_table.SemaphoreVCR( name );
-		return;
-	}
-
-	sema = (CRServerSemaphore *) crHashtableSearch( cr_server.semaphores, name );
-	if (!sema)
-	{
-		crError( "No such semaphore: %d", name );
-	}
-	if (sema->waiting)
-	{
-		wqnode *temp = sema->waiting;
-		if (cr_server.debug_barriers)
-			crDebug("crserver: SemaphoreV(client=%p, id=%d, count=%d) - unblock.",
-							cr_server.curClient, name, sema->count);
-		/* unblock one waiter */
-		temp->q->blocked = 0;
-		sema->waiting = temp->next;
-		crFree( temp );
-		if (!sema->waiting)
-		{
-			sema->tail = NULL;
-		}
-	}
-	else
-	{
-		/* nobody's waiting */
-		if (cr_server.debug_barriers)
-			crDebug("crserver: SemaphoreV(client=%p, id=%d, count=%d) - increment to %d",
-							cr_server.curClient, name, sema->count, sema->count + 1);
-		sema->count++;
-	}
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_papi.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_papi.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_papi.cpp	(revision 78190)
@@ -0,0 +1,279 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "state/cr_statetypes.h"
+
+#define DEBUG_BARRIERS 1
+#ifdef DEBUG_BARRIERS
+# include <stdio.h>
+#endif
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchBarrierCreateCR( GLuint name, GLuint count )
+{
+	CRServerBarrier *barrier;
+#if DEBUG_BARRIERS
+	char debug_buf[4096];
+#endif
+
+	if (cr_server.ignore_papi)
+	{
+		cr_server.head_spu->dispatch_table.BarrierCreateCR( name, count );
+		return;
+	}
+
+	barrier = (CRServerBarrier *) crHashtableSearch( cr_server.barriers, name );
+
+#if DEBUG_BARRIERS
+	sprintf( debug_buf, "BarrierCreateCR( %d, %d )", name, count );
+	cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
+#endif
+
+	if (count > CR_MAX_CLIENTS)
+		count = CR_MAX_CLIENTS;
+
+	if (count == 0)
+	{
+		count = cr_server.numClients;
+#if DEBUG_BARRIERS
+		sprintf( debug_buf, "changing count to %d", count );
+		cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
+#endif
+	}
+
+
+	/* we use maxBarrierCount in Clear() and SwapBuffers() and also use it
+	 * in __getNextClient() for deadlock detection.  The issue is that all
+	 * the existing clients may be blocked, but we might soon get another
+	 * client connection to break the apparent deadlock.
+	 */
+	if (count > cr_server.maxBarrierCount)
+		cr_server.maxBarrierCount = count;
+
+	if ( barrier == NULL )
+	{
+		barrier = (CRServerBarrier *) crAlloc( sizeof(*barrier) );
+		barrier->count = count;
+		barrier->num_waiting = 0;
+		barrier->waiting = (RunQueue **) 
+			crAlloc( count * sizeof(*(barrier->waiting)) );
+
+		crHashtableAdd( cr_server.barriers, name, barrier );
+#if DEBUG_BARRIERS
+		sprintf( debug_buf, "This was a new barrier!" );
+		cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
+#endif
+	}
+	else
+	{
+		/* HACK -- this allows everybody to create a barrier, and all
+           but the first creation are ignored, assuming the count
+           match. */
+#if DEBUG_BARRIERS
+		sprintf( debug_buf, "I already knew about this barrier." );
+		cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
+#endif
+		if ( barrier->count != count )
+		{
+#if DEBUG_BARRIERS
+			sprintf( debug_buf, "And someone messed up the count!." );
+			cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
+#endif
+			crError( "Barrier name=%u created with count=%u, but already "
+						 "exists with count=%u", name, count, barrier->count );
+		}
+	}
+
+	if (cr_server.debug_barriers)
+		crDebug("crserver: BarrierCreate(id=%d, count=%d)", name, barrier->count);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchBarrierDestroyCR( GLuint name )
+{
+	if (cr_server.ignore_papi)
+	{
+		cr_server.head_spu->dispatch_table.BarrierDestroyCR( name );
+		return;
+	}
+
+	crError( "NO BARRIER DESTROY FOR YOU!  (name=%u)", name );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchBarrierExecCR( GLuint name )
+{
+	CRServerBarrier *barrier;
+#if DEBUG_BARRIERS
+	char debug_buf[4096];
+#endif
+
+	if (cr_server.ignore_papi)
+	{
+		cr_server.head_spu->dispatch_table.BarrierExecCR( name );
+		return;
+	}
+
+	barrier = (CRServerBarrier *) crHashtableSearch( cr_server.barriers, name );
+	if ( barrier == NULL )
+	{
+		crError( "crServerDispatchBarrierExec: No such barrier: %d", name );
+	}
+
+#if DEBUG_BARRIERS
+	sprintf( debug_buf, "BarrierExec( %d )", name );
+	cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
+	sprintf( debug_buf, "num_waiting = %d", barrier->num_waiting );
+	cr_server.head_spu->dispatch_table.ChromiumParametervCR( GL_PRINT_STRING_CR, GL_UNSIGNED_BYTE, sizeof(debug_buf), debug_buf );
+#endif
+
+	barrier->waiting[barrier->num_waiting++] = cr_server.run_queue;
+
+	cr_server.run_queue->blocked = 1;
+
+	if ( barrier->num_waiting == barrier->count )
+	{
+		GLuint i;
+
+		if (cr_server.debug_barriers)
+			crDebug("crserver: BarrierExec(client=%p, id=%d, num_waiting=%d/%d) - release",
+							cr_server.curClient, name, barrier->num_waiting,
+							barrier->count);
+
+		for ( i = 0; i < barrier->count; i++ )
+		{
+			barrier->waiting[i]->blocked = 0;
+		}
+		barrier->num_waiting = 0;
+	}
+	else if (cr_server.debug_barriers)
+		crDebug("crserver: BarrierExec(client=%p, id=%d, num_waiting=%d/%d) - block",
+						cr_server.curClient, name, barrier->num_waiting,
+						barrier->count);
+
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphoreCreateCR( GLuint name, GLuint count )
+{
+	CRServerSemaphore *sema;
+
+	if (cr_server.ignore_papi)
+	{
+		cr_server.head_spu->dispatch_table.SemaphoreCreateCR( name, count );
+		return;
+	}
+
+	sema = (CRServerSemaphore *)crHashtableSearch(cr_server.semaphores, name);
+	if (sema)
+		return; /* already created */
+
+	sema = (CRServerSemaphore *) crAlloc( sizeof( *sema ) );
+	crHashtableAdd( cr_server.semaphores, name, sema );
+	sema->count = count;
+	sema->waiting = sema->tail = NULL;
+	if (cr_server.debug_barriers)
+		crDebug("crserver: SemaphoreCreate(id=%d, count=%d)", name, count);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphoreDestroyCR( GLuint name )
+{
+	if (cr_server.ignore_papi)
+	{
+		cr_server.head_spu->dispatch_table.SemaphoreDestroyCR( name );
+		return;
+	}
+
+	crError( "NO DESTROY FOR YOU! (name=%u)", name );
+}
+
+/* Semaphore wait */
+void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphorePCR( GLuint name )
+{
+	CRServerSemaphore *sema;
+
+	if (cr_server.ignore_papi)
+	{
+		cr_server.head_spu->dispatch_table.SemaphorePCR( name );
+		return;
+	}
+
+	sema = (CRServerSemaphore *) crHashtableSearch( cr_server.semaphores, name );
+	if (!sema)
+	{
+		crError( "No such semaphore: %d", name );
+	}
+	if (sema->count)
+	{
+		/* go */
+		if (cr_server.debug_barriers)
+			crDebug("crserver: SemaphoreP(client=%p, id=%d, count=%d) decrement to %d",
+							cr_server.curClient, name, sema->count, sema->count - 1);
+		sema->count--;
+	}
+	else
+	{
+		/* block */
+		wqnode *node;
+		if (cr_server.debug_barriers)
+			crDebug("crserver: SemaphoreP(client=%p, id=%d, count=%d) - block.",
+							cr_server.curClient, name, sema->count);
+		cr_server.run_queue->blocked = 1;
+		node = (wqnode *) crAlloc( sizeof( *node ) );
+		node->q = cr_server.run_queue;
+		node->next = NULL;
+		if (sema->tail)
+		{
+			sema->tail->next = node;
+		}
+		else
+		{
+			sema->waiting = node;
+		}
+		sema->tail = node;
+	}
+}
+
+/* Semaphore signal */
+void SERVER_DISPATCH_APIENTRY crServerDispatchSemaphoreVCR( GLuint name )
+{
+	CRServerSemaphore *sema;
+
+	if (cr_server.ignore_papi)
+	{
+		cr_server.head_spu->dispatch_table.SemaphoreVCR( name );
+		return;
+	}
+
+	sema = (CRServerSemaphore *) crHashtableSearch( cr_server.semaphores, name );
+	if (!sema)
+	{
+		crError( "No such semaphore: %d", name );
+	}
+	if (sema->waiting)
+	{
+		wqnode *temp = sema->waiting;
+		if (cr_server.debug_barriers)
+			crDebug("crserver: SemaphoreV(client=%p, id=%d, count=%d) - unblock.",
+							cr_server.curClient, name, sema->count);
+		/* unblock one waiter */
+		temp->q->blocked = 0;
+		sema->waiting = temp->next;
+		crFree( temp );
+		if (!sema->waiting)
+		{
+			sema->tail = NULL;
+		}
+	}
+	else
+	{
+		/* nobody's waiting */
+		if (cr_server.debug_barriers)
+			crDebug("crserver: SemaphoreV(client=%p, id=%d, count=%d) - increment to %d",
+							cr_server.curClient, name, sema->count, sema->count + 1);
+		sema->count++;
+	}
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_projmatrix.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_projmatrix.c	(revision 78189)
+++ 	(revision )
@@ -1,402 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_error.h"
-#include "state/cr_statetypes.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-
-/*
- * This file provides implementations of the basic OpenGL matrix functions.
- * We often need to twiddle with their operation in order to make tilesorting
- * and non-planar projections work.
- */
-
-
-
-/*
- * Determine which view and projection matrices to use when in stereo mode.
- * Return 0 = left eye, 1 = right eye.
- */
-int crServerGetCurrentEye(void)
-{
-    if (cr_server.currentEye != -1) {
-        /* current eye was specified by tilesort SPU */
-        return cr_server.currentEye;
-    }
-    else {
-        /* we have a quad-buffered window and we're watching glDrawBuffer */
-        GLenum drawBuffer = cr_server.curClient->currentCtxInfo->pContext->buffer.drawBuffer;
-        int eye = drawBuffer == GL_BACK_RIGHT || drawBuffer == GL_FRONT_RIGHT
-            || drawBuffer == GL_RIGHT;
-        return eye;
-    }
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchLoadMatrixf( const GLfloat *m )
-{
-    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
-    const CRMuralInfo *mural = cr_server.curClient->currentMural;
-
-    crStateLoadMatrixf( m );
-
-    if (matMode == GL_MODELVIEW && cr_server.viewOverride) {
-        int eye = crServerGetCurrentEye();
-        crServerApplyViewMatrix(&cr_server.viewMatrix[eye]);
-    }
-    else {
-        cr_server.head_spu->dispatch_table.LoadMatrixf( m );
-    }
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchLoadMatrixd( const GLdouble *m )
-{
-    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
-    const CRMuralInfo *mural = cr_server.curClient->currentMural;
-
-    crStateLoadMatrixd( m );
-
-    if (matMode == GL_MODELVIEW && cr_server.viewOverride) {
-        int eye = crServerGetCurrentEye();
-        crServerApplyViewMatrix(&cr_server.viewMatrix[eye]);
-    }
-    else {
-        cr_server.head_spu->dispatch_table.LoadMatrixd( m );
-    }
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchMultMatrixf( const GLfloat *m )
-{
-    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
-
-    if (matMode == GL_PROJECTION && cr_server.projectionOverride) {
-        /* load the overriding projection matrix */
-        int eye = crServerGetCurrentEye();
-        crStateLoadMatrix( &cr_server.projectionMatrix[eye] );
-    }
-    else {
-        /* the usual case */
-        crStateMultMatrixf( m );
-        cr_server.head_spu->dispatch_table.MultMatrixf( m );
-    }
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchMultMatrixd( const GLdouble *m )
-{
-    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
-
-    if (matMode == GL_PROJECTION && cr_server.projectionOverride) {
-        /* load the overriding projection matrix */
-        int eye = crServerGetCurrentEye();
-        crStateLoadMatrix( &cr_server.projectionMatrix[eye] );
-    }
-    else {
-        /* the usual case */
-        crStateMultMatrixd( m );
-        cr_server.head_spu->dispatch_table.MultMatrixd( m );
-    }
-}
-
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchLoadIdentity( void )
-{
-    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
-    const CRMuralInfo *mural = cr_server.curClient->currentMural;
-
-    crStateLoadIdentity();
-
-    if (matMode == GL_MODELVIEW && cr_server.viewOverride) {
-        int eye = crServerGetCurrentEye();
-        crServerApplyViewMatrix(&cr_server.viewMatrix[eye]);
-    }
-    else {
-        cr_server.head_spu->dispatch_table.LoadIdentity( );
-    }
-}
-
-
-
-/*
- * The following code is used to deal with vertex programs.
- * Basically, vertex programs might not directly use the usual
- * OpenGL projection matrix to project vertices from eye coords to
- * clip coords.
- *
- * If you're using Cg then the vertex programs it generates will have
- * some comments that we can scan to figure out which program parameters
- * contain the projection matrix.
- * In this case, look at the Cg program code for a string like
- * "ModelViewProj".  Then set the crserver's 'vertprog_projection_param'
- * config option to this name.
- *
- * If you're not using Cg, you may have to tell Chromium which program
- * parameters contain the projection matrix.
- * In this case, look at the OpenGL application's vertex program code to
- * determine which program parameters contain the projection matrix.
- * Then set the crserver's 'vertprog_projection_param' config option to
- * the number of the parameter which holds the first row of the matrix.
- *
- * Yup, this is complicated.
- *
- */
-
-
-static void matmul(GLfloat r[16], const GLfloat p[16], const GLfloat q[16])
-{
-    GLfloat tmp[16];
-    int i, j, k;
-    for (i = 0; i < 4; i++) {
-        for (j = 0; j < 4; j++) {
-            GLfloat dot = 0.0;
-            for (k = 0; k < 4; k++) {
-                dot += p[i+4*k] * q[k+4*j];
-            }
-            tmp[i+4*j] = dot;
-        }
-    }
-    for (i = 0; i < 16; i++)
-        r[i] = tmp[i];
-}
-
-
-static CRServerProgram *
-LookupProgram(GLuint id)
-{
-    CRServerProgram *prog = crHashtableSearch(cr_server.programTable, id);
-    if (!prog) {
-        prog = (CRServerProgram *) crAlloc(sizeof(CRServerProgram));
-        if (!prog)
-            return NULL;
-        prog->id = id;
-        prog->projParamStart = cr_server.vpProjectionMatrixParameter;
-        crHashtableAdd(cr_server.programTable, id, prog);
-    }
-    return prog;
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
-#if 0
-    if (target == GL_VERTEX_PROGRAM_ARB) {
-        CRServerProgram *prog = LookupProgram(cr_server.currentProgram);
-
-        if (prog && prog->projParamStart != -1) {
-            if (index >= (GLuint) prog->projParamStart && index <= (GLuint) prog->projParamStart + 3) {
-                /* save the parameters as rows in the matrix */
-                const int i = index - prog->projParamStart;
-                prog->projMat[4*0+i] = x;
-                prog->projMat[4*1+i] = y;
-                prog->projMat[4*2+i] = z;
-                prog->projMat[4*3+i] = w;
-            }
-
-            /* When we get the 4th row (row==3) of the projection matrix we can
-             * then pre-multiply it by the base matrix and update the program
-             * parameters with the new matrix.
-             */
-            if (index == (GLuint) (prog->projParamStart + 3)) {
-                const CRMuralInfo *mural = cr_server.curClient->currentMural;
-                const GLfloat *baseMat = (const GLfloat *) &(mural->extents[mural->curExtent].baseProjection);
-                int i;
-                GLfloat mat[16];
-
-                /* pre-mult the projection matrix by the base projection */
-                matmul(mat, baseMat, prog->projMat);
-                /* update the program parameters with the new matrix */
-                for (i = 0; i < 4; i++) {
-                    cr_server.head_spu->dispatch_table.ProgramLocalParameter4fARB(target, index + i - 3, mat[4*0+i], mat[4*1+i], mat[4*2+i], mat[4*3+i]);
-                }
-                return;  /* done */
-            }
-        }
-    }
-#endif
-
-    /* if we get here, pass the call through unchanged */
-    cr_server.head_spu->dispatch_table.ProgramLocalParameter4fARB(target, index, x, y, z, w);
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
-{
-    crServerDispatchProgramLocalParameter4fARB(target, index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchProgramParameter4fNV(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
-#if 0
-    if (target == GL_VERTEX_PROGRAM_NV) {
-        CRServerProgram *prog = LookupProgram(cr_server.currentProgram);
-
-        if (prog && prog->projParamStart != -1) {
-            if (index >= (GLuint) prog->projParamStart && index <= (GLuint) prog->projParamStart + 3) {
-                /* save the parameters as rows in the matrix */
-                const int i = index - prog->projParamStart;
-                prog->projMat[4*0+i] = x;
-                prog->projMat[4*1+i] = y;
-                prog->projMat[4*2+i] = z;
-                prog->projMat[4*3+i] = w;
-            }
-
-            /* When we get the 4th row (row==3) of the projection matrix we can
-             * then pre-multiply it by the base matrix and update the program
-             * parameters with the new matrix.
-             */
-            if (index == (GLuint) (prog->projParamStart + 3)) {
-                const CRMuralInfo *mural = cr_server.curClient->currentMural;
-                const GLfloat *baseMat = (const GLfloat *) &(mural->extents[mural->curExtent].baseProjection);
-                int i;
-                GLfloat mat[16];
-
-                /* pre-mult the projection matrix by the base projection */
-                matmul(mat, baseMat, prog->projMat);
-                /* update the program parameters with the new matrix */
-                for (i = 0; i < 4; i++) {
-                    cr_server.head_spu->dispatch_table.ProgramParameter4fNV(target, index + i - 3, mat[4*0+i], mat[4*1+i], mat[4*2+i], mat[4*3+i]);
-                }
-                return; /* done */
-            }
-        }
-    }
-#endif
-
-    /* if we get here, pass the call through unchanged */
-    cr_server.head_spu->dispatch_table.ProgramParameter4fNV(target, index, x, y, z, w);
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchProgramParameter4dNV(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
-{
-    crServerDispatchProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string)
-{
-    if (target == GL_VERTEX_PROGRAM_ARB &&
-            cr_server.vpProjectionMatrixVariable != NULL) {
-        /* scan the program string looking for 'vertprog_projection'
-         * If the program was generated by Cg, the info we want will look
-         * something like this:
-         * #var float4x4 ModelViewProj :  : c[0], 4 : 1 : 1
-         */
-        CRServerProgram *prog = LookupProgram(cr_server.currentProgram);
-        CRASSERT(prog);
-        if (prog) {
-            const char *varPos, *paramPos;
-            varPos = crStrstr((const char *) string, cr_server.vpProjectionMatrixVariable);
-            if (varPos) {
-                 paramPos = crStrstr(varPos, "c[");
-                 if (paramPos) {
-                        char number[10];
-                        int i = 0;
-                        paramPos += 2;  /* skip "c[" */
-                        while (crIsDigit(paramPos[i])) {
-                             number[i] = paramPos[i];
-                             i++;
-                        }
-                        number[i] = 0;
-                        prog->projParamStart = crStrToInt(number);
-                 }
-            }
-            else {
-                 crWarning("Didn't find %s parameter in vertex program string",
-                                     cr_server.vpProjectionMatrixVariable);
-            }
-        }
-    }
-
-    /* pass through */
-    crStateProgramStringARB(target, format, len, string);
-    cr_server.head_spu->dispatch_table.ProgramStringARB(target, format, len, string);
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte *string)
-{
-    if (target == GL_VERTEX_PROGRAM_NV &&
-            cr_server.vpProjectionMatrixVariable != NULL) {
-        /* scan the program string looking for 'vertprog_projection'
-         * If the program was generated by Cg, the info we want will look
-         * something like this:
-         * #var float4x4 ModelViewProj :  : c[0], 4 : 1 : 1
-         */
-        CRServerProgram *prog = LookupProgram(id);
-        CRASSERT(prog);
-        if (prog) {
-            const char *varPos, *paramPos;
-            varPos = crStrstr((const char *) string, cr_server.vpProjectionMatrixVariable);
-            if (varPos) {
-                 paramPos = crStrstr(varPos, "c[");
-                 if (paramPos) {
-                        char number[10];
-                        int i = 0;
-                        paramPos += 2;  /* skip "c[" */
-                        while (crIsDigit(paramPos[i])) {
-                             number[i] = paramPos[i];
-                             i++;
-                        }
-                        number[i] = 0;
-                        prog->projParamStart = crStrToInt(number);
-                 }
-            }
-            else {
-                 crWarning("Didn't find %s parameter in vertex program string",
-                                     cr_server.vpProjectionMatrixVariable);
-            }
-        }
-    }
-
-    /* pass through */
-    crStateLoadProgramNV(target, id, len, string);
-    cr_server.head_spu->dispatch_table.LoadProgramNV(target, id, len, string);
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchBindProgramARB(GLenum target, GLuint id)
-{
-    id = crServerTranslateProgramID(id);
-
-    if (target == GL_VERTEX_PROGRAM_ARB) {
-        CRServerProgram *prog = LookupProgram(id);
-        (void) prog;
-        cr_server.currentProgram = id;
-    }
-
-    /* pass through */
-    crStateBindProgramARB(target, id);
-    cr_server.head_spu->dispatch_table.BindProgramARB(target, id);
-}
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchBindProgramNV(GLenum target, GLuint id)
-{
-    if (target == GL_VERTEX_PROGRAM_NV) {
-        CRServerProgram *prog = LookupProgram(id);
-        (void) prog;
-        cr_server.currentProgram = id;
-    }
-    /* pass through */
-    crStateBindProgramNV(target, id);
-    cr_server.head_spu->dispatch_table.BindProgramNV(target, id);
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_projmatrix.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_projmatrix.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_projmatrix.cpp	(revision 78190)
@@ -0,0 +1,402 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_error.h"
+#include "state/cr_statetypes.h"
+#include "cr_mem.h"
+#include "cr_string.h"
+
+/*
+ * This file provides implementations of the basic OpenGL matrix functions.
+ * We often need to twiddle with their operation in order to make tilesorting
+ * and non-planar projections work.
+ */
+
+
+
+/*
+ * Determine which view and projection matrices to use when in stereo mode.
+ * Return 0 = left eye, 1 = right eye.
+ */
+int crServerGetCurrentEye(void)
+{
+    if (cr_server.currentEye != -1) {
+        /* current eye was specified by tilesort SPU */
+        return cr_server.currentEye;
+    }
+    else {
+        /* we have a quad-buffered window and we're watching glDrawBuffer */
+        GLenum drawBuffer = cr_server.curClient->currentCtxInfo->pContext->buffer.drawBuffer;
+        int eye = drawBuffer == GL_BACK_RIGHT || drawBuffer == GL_FRONT_RIGHT
+            || drawBuffer == GL_RIGHT;
+        return eye;
+    }
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchLoadMatrixf( const GLfloat *m )
+{
+    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
+    const CRMuralInfo *mural = cr_server.curClient->currentMural;
+
+    crStateLoadMatrixf( m );
+
+    if (matMode == GL_MODELVIEW && cr_server.viewOverride) {
+        int eye = crServerGetCurrentEye();
+        crServerApplyViewMatrix(&cr_server.viewMatrix[eye]);
+    }
+    else {
+        cr_server.head_spu->dispatch_table.LoadMatrixf( m );
+    }
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchLoadMatrixd( const GLdouble *m )
+{
+    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
+    const CRMuralInfo *mural = cr_server.curClient->currentMural;
+
+    crStateLoadMatrixd( m );
+
+    if (matMode == GL_MODELVIEW && cr_server.viewOverride) {
+        int eye = crServerGetCurrentEye();
+        crServerApplyViewMatrix(&cr_server.viewMatrix[eye]);
+    }
+    else {
+        cr_server.head_spu->dispatch_table.LoadMatrixd( m );
+    }
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchMultMatrixf( const GLfloat *m )
+{
+    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
+
+    if (matMode == GL_PROJECTION && cr_server.projectionOverride) {
+        /* load the overriding projection matrix */
+        int eye = crServerGetCurrentEye();
+        crStateLoadMatrix( &cr_server.projectionMatrix[eye] );
+    }
+    else {
+        /* the usual case */
+        crStateMultMatrixf( m );
+        cr_server.head_spu->dispatch_table.MultMatrixf( m );
+    }
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchMultMatrixd( const GLdouble *m )
+{
+    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
+
+    if (matMode == GL_PROJECTION && cr_server.projectionOverride) {
+        /* load the overriding projection matrix */
+        int eye = crServerGetCurrentEye();
+        crStateLoadMatrix( &cr_server.projectionMatrix[eye] );
+    }
+    else {
+        /* the usual case */
+        crStateMultMatrixd( m );
+        cr_server.head_spu->dispatch_table.MultMatrixd( m );
+    }
+}
+
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchLoadIdentity( void )
+{
+    const GLenum matMode = cr_server.curClient->currentCtxInfo->pContext->transform.matrixMode;
+    const CRMuralInfo *mural = cr_server.curClient->currentMural;
+
+    crStateLoadIdentity();
+
+    if (matMode == GL_MODELVIEW && cr_server.viewOverride) {
+        int eye = crServerGetCurrentEye();
+        crServerApplyViewMatrix(&cr_server.viewMatrix[eye]);
+    }
+    else {
+        cr_server.head_spu->dispatch_table.LoadIdentity( );
+    }
+}
+
+
+
+/*
+ * The following code is used to deal with vertex programs.
+ * Basically, vertex programs might not directly use the usual
+ * OpenGL projection matrix to project vertices from eye coords to
+ * clip coords.
+ *
+ * If you're using Cg then the vertex programs it generates will have
+ * some comments that we can scan to figure out which program parameters
+ * contain the projection matrix.
+ * In this case, look at the Cg program code for a string like
+ * "ModelViewProj".  Then set the crserver's 'vertprog_projection_param'
+ * config option to this name.
+ *
+ * If you're not using Cg, you may have to tell Chromium which program
+ * parameters contain the projection matrix.
+ * In this case, look at the OpenGL application's vertex program code to
+ * determine which program parameters contain the projection matrix.
+ * Then set the crserver's 'vertprog_projection_param' config option to
+ * the number of the parameter which holds the first row of the matrix.
+ *
+ * Yup, this is complicated.
+ *
+ */
+
+
+static void matmul(GLfloat r[16], const GLfloat p[16], const GLfloat q[16])
+{
+    GLfloat tmp[16];
+    int i, j, k;
+    for (i = 0; i < 4; i++) {
+        for (j = 0; j < 4; j++) {
+            GLfloat dot = 0.0;
+            for (k = 0; k < 4; k++) {
+                dot += p[i+4*k] * q[k+4*j];
+            }
+            tmp[i+4*j] = dot;
+        }
+    }
+    for (i = 0; i < 16; i++)
+        r[i] = tmp[i];
+}
+
+
+static CRServerProgram *
+LookupProgram(GLuint id)
+{
+    CRServerProgram *prog = (CRServerProgram *)crHashtableSearch(cr_server.programTable, id);
+    if (!prog) {
+        prog = (CRServerProgram *) crAlloc(sizeof(CRServerProgram));
+        if (!prog)
+            return NULL;
+        prog->id = id;
+        prog->projParamStart = cr_server.vpProjectionMatrixParameter;
+        crHashtableAdd(cr_server.programTable, id, prog);
+    }
+    return prog;
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+#if 0
+    if (target == GL_VERTEX_PROGRAM_ARB) {
+        CRServerProgram *prog = LookupProgram(cr_server.currentProgram);
+
+        if (prog && prog->projParamStart != -1) {
+            if (index >= (GLuint) prog->projParamStart && index <= (GLuint) prog->projParamStart + 3) {
+                /* save the parameters as rows in the matrix */
+                const int i = index - prog->projParamStart;
+                prog->projMat[4*0+i] = x;
+                prog->projMat[4*1+i] = y;
+                prog->projMat[4*2+i] = z;
+                prog->projMat[4*3+i] = w;
+            }
+
+            /* When we get the 4th row (row==3) of the projection matrix we can
+             * then pre-multiply it by the base matrix and update the program
+             * parameters with the new matrix.
+             */
+            if (index == (GLuint) (prog->projParamStart + 3)) {
+                const CRMuralInfo *mural = cr_server.curClient->currentMural;
+                const GLfloat *baseMat = (const GLfloat *) &(mural->extents[mural->curExtent].baseProjection);
+                int i;
+                GLfloat mat[16];
+
+                /* pre-mult the projection matrix by the base projection */
+                matmul(mat, baseMat, prog->projMat);
+                /* update the program parameters with the new matrix */
+                for (i = 0; i < 4; i++) {
+                    cr_server.head_spu->dispatch_table.ProgramLocalParameter4fARB(target, index + i - 3, mat[4*0+i], mat[4*1+i], mat[4*2+i], mat[4*3+i]);
+                }
+                return;  /* done */
+            }
+        }
+    }
+#endif
+
+    /* if we get here, pass the call through unchanged */
+    cr_server.head_spu->dispatch_table.ProgramLocalParameter4fARB(target, index, x, y, z, w);
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+    crServerDispatchProgramLocalParameter4fARB(target, index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchProgramParameter4fNV(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+#if 0
+    if (target == GL_VERTEX_PROGRAM_NV) {
+        CRServerProgram *prog = LookupProgram(cr_server.currentProgram);
+
+        if (prog && prog->projParamStart != -1) {
+            if (index >= (GLuint) prog->projParamStart && index <= (GLuint) prog->projParamStart + 3) {
+                /* save the parameters as rows in the matrix */
+                const int i = index - prog->projParamStart;
+                prog->projMat[4*0+i] = x;
+                prog->projMat[4*1+i] = y;
+                prog->projMat[4*2+i] = z;
+                prog->projMat[4*3+i] = w;
+            }
+
+            /* When we get the 4th row (row==3) of the projection matrix we can
+             * then pre-multiply it by the base matrix and update the program
+             * parameters with the new matrix.
+             */
+            if (index == (GLuint) (prog->projParamStart + 3)) {
+                const CRMuralInfo *mural = cr_server.curClient->currentMural;
+                const GLfloat *baseMat = (const GLfloat *) &(mural->extents[mural->curExtent].baseProjection);
+                int i;
+                GLfloat mat[16];
+
+                /* pre-mult the projection matrix by the base projection */
+                matmul(mat, baseMat, prog->projMat);
+                /* update the program parameters with the new matrix */
+                for (i = 0; i < 4; i++) {
+                    cr_server.head_spu->dispatch_table.ProgramParameter4fNV(target, index + i - 3, mat[4*0+i], mat[4*1+i], mat[4*2+i], mat[4*3+i]);
+                }
+                return; /* done */
+            }
+        }
+    }
+#endif
+
+    /* if we get here, pass the call through unchanged */
+    cr_server.head_spu->dispatch_table.ProgramParameter4fNV(target, index, x, y, z, w);
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchProgramParameter4dNV(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+    crServerDispatchProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid *string)
+{
+    if (target == GL_VERTEX_PROGRAM_ARB &&
+            cr_server.vpProjectionMatrixVariable != NULL) {
+        /* scan the program string looking for 'vertprog_projection'
+         * If the program was generated by Cg, the info we want will look
+         * something like this:
+         * #var float4x4 ModelViewProj :  : c[0], 4 : 1 : 1
+         */
+        CRServerProgram *prog = LookupProgram(cr_server.currentProgram);
+        CRASSERT(prog);
+        if (prog) {
+            const char *varPos, *paramPos;
+            varPos = crStrstr((const char *) string, cr_server.vpProjectionMatrixVariable);
+            if (varPos) {
+                 paramPos = crStrstr(varPos, "c[");
+                 if (paramPos) {
+                        char number[10];
+                        int i = 0;
+                        paramPos += 2;  /* skip "c[" */
+                        while (crIsDigit(paramPos[i])) {
+                             number[i] = paramPos[i];
+                             i++;
+                        }
+                        number[i] = 0;
+                        prog->projParamStart = crStrToInt(number);
+                 }
+            }
+            else {
+                 crWarning("Didn't find %s parameter in vertex program string",
+                                     cr_server.vpProjectionMatrixVariable);
+            }
+        }
+    }
+
+    /* pass through */
+    crStateProgramStringARB(target, format, len, string);
+    cr_server.head_spu->dispatch_table.ProgramStringARB(target, format, len, string);
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte *string)
+{
+    if (target == GL_VERTEX_PROGRAM_NV &&
+            cr_server.vpProjectionMatrixVariable != NULL) {
+        /* scan the program string looking for 'vertprog_projection'
+         * If the program was generated by Cg, the info we want will look
+         * something like this:
+         * #var float4x4 ModelViewProj :  : c[0], 4 : 1 : 1
+         */
+        CRServerProgram *prog = LookupProgram(id);
+        CRASSERT(prog);
+        if (prog) {
+            const char *varPos, *paramPos;
+            varPos = crStrstr((const char *) string, cr_server.vpProjectionMatrixVariable);
+            if (varPos) {
+                 paramPos = crStrstr(varPos, "c[");
+                 if (paramPos) {
+                        char number[10];
+                        int i = 0;
+                        paramPos += 2;  /* skip "c[" */
+                        while (crIsDigit(paramPos[i])) {
+                             number[i] = paramPos[i];
+                             i++;
+                        }
+                        number[i] = 0;
+                        prog->projParamStart = crStrToInt(number);
+                 }
+            }
+            else {
+                 crWarning("Didn't find %s parameter in vertex program string",
+                                     cr_server.vpProjectionMatrixVariable);
+            }
+        }
+    }
+
+    /* pass through */
+    crStateLoadProgramNV(target, id, len, string);
+    cr_server.head_spu->dispatch_table.LoadProgramNV(target, id, len, string);
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchBindProgramARB(GLenum target, GLuint id)
+{
+    id = crServerTranslateProgramID(id);
+
+    if (target == GL_VERTEX_PROGRAM_ARB) {
+        CRServerProgram *prog = LookupProgram(id);
+        (void) prog;
+        cr_server.currentProgram = id;
+    }
+
+    /* pass through */
+    crStateBindProgramARB(target, id);
+    cr_server.head_spu->dispatch_table.BindProgramARB(target, id);
+}
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchBindProgramNV(GLenum target, GLuint id)
+{
+    if (target == GL_VERTEX_PROGRAM_NV) {
+        CRServerProgram *prog = LookupProgram(id);
+        (void) prog;
+        cr_server.currentProgram = id;
+    }
+    /* pass through */
+    crStateBindProgramNV(target, id);
+    cr_server.head_spu->dispatch_table.BindProgramNV(target, id);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_readpixels.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_readpixels.c	(revision 78189)
+++ 	(revision )
@@ -1,91 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_spu.h"
-#include "chromium.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "cr_net.h"
-#include "cr_pixeldata.h"
-#include "cr_unpack.h"
-#include "server_dispatch.h"
-#include "server.h"
-
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
-                           GLenum format, GLenum type, GLvoid *pixels)
-{
-    const GLint stride = READ_DATA( 24, GLint );
-    const GLint alignment = READ_DATA( 28, GLint );
-    const GLint skipRows = READ_DATA( 32, GLint );
-    const GLint skipPixels = READ_DATA( 36, GLint );
-    const GLint bytes_per_row = READ_DATA( 40, GLint );
-    const GLint rowLength = READ_DATA( 44, GLint );
-
-    CRASSERT(bytes_per_row > 0);
-
-#ifdef CR_ARB_pixel_buffer_object
-    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
-    {
-        GLvoid *pbo_offset;
-
-        /*pixels are actually a pointer to location of 8byte network pointer in hgcm buffer
-          regardless of guest/host bitness we're using only 4lower bytes as there're no
-          pbo>4gb (yet?)
-         */
-        pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)pixels));
-
-        cr_server.head_spu->dispatch_table.ReadPixels(x, y, width, height,
-                                                      format, type, pbo_offset);
-    }
-    else
-#endif
-    {
-        CRMessageReadPixels *rp;
-        uint32_t msg_len;
-
-        if (bytes_per_row <= 0 || height <= 0 || bytes_per_row > INT32_MAX / height)
-        {
-            crError("crServerDispatchReadPixels: parameters out of range");
-            return;
-        }
-
-        msg_len = sizeof(*rp) + (uint32_t)bytes_per_row * height;
-
-        rp = (CRMessageReadPixels *) crAlloc( msg_len );
-        if (!rp)
-        {
-            crError("crServerDispatchReadPixels: out of memory");
-            return;
-        }
-
-        /* Note: the ReadPixels data gets densely packed into the buffer
-         * (no skip pixels, skip rows, etc.  It's up to the receiver (pack spu,
-         * tilesort spu, etc) to apply the real PixelStore packing parameters.
-        */
-        cr_server.head_spu->dispatch_table.ReadPixels(x, y, width, height,
-                                                      format, type, rp + 1);
-
-        rp->header.type = CR_MESSAGE_READ_PIXELS;
-        rp->width = width;
-        rp->height = height;
-        rp->bytes_per_row = bytes_per_row;
-        rp->stride = stride;
-        rp->format = format;
-        rp->type = type;
-        rp->alignment = alignment;
-        rp->skipRows = skipRows;
-        rp->skipPixels = skipPixels;
-        rp->rowLength = rowLength;
-
-        /* <pixels> points to the 8-byte network pointer */
-        crMemcpy( &rp->pixels, pixels, sizeof(rp->pixels) );
-    
-        crNetSend( cr_server.curClient->conn, NULL, rp, msg_len );
-        crFree( rp );
-    }
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_readpixels.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_readpixels.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_readpixels.cpp	(revision 78190)
@@ -0,0 +1,94 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "cr_spu.h"
+#include "chromium.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "cr_net.h"
+#include "cr_pixeldata.h"
+#include "cr_unpack.h"
+#include "server_dispatch.h"
+#include "server.h"
+
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchReadPixels(GLint x, GLint y, GLsizei width, GLsizei height,
+                           GLenum format, GLenum type, GLvoid *pixels)
+{
+    CRASSERT(cr_server.pUnpackerState != NULL);
+    CHECK_BUFFER_SIZE_STATIC(cr_server.pUnpackerState, 44 + sizeof(GLint));
+
+    const GLint stride = READ_DATA(cr_server.pUnpackerState, 24, GLint );
+    const GLint alignment = READ_DATA(cr_server.pUnpackerState, 28, GLint );
+    const GLint skipRows = READ_DATA(cr_server.pUnpackerState, 32, GLint );
+    const GLint skipPixels = READ_DATA(cr_server.pUnpackerState, 36, GLint );
+    const GLint bytes_per_row = READ_DATA(cr_server.pUnpackerState, 40, GLint );
+    const GLint rowLength = READ_DATA(cr_server.pUnpackerState, 44, GLint );
+
+    CRASSERT(bytes_per_row > 0);
+
+#ifdef CR_ARB_pixel_buffer_object
+    if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB))
+    {
+        GLvoid *pbo_offset;
+
+        /*pixels are actually a pointer to location of 8byte network pointer in hgcm buffer
+          regardless of guest/host bitness we're using only 4lower bytes as there're no
+          pbo>4gb (yet?)
+         */
+        pbo_offset = (GLvoid*) ((uintptr_t) *((GLint*)pixels));
+
+        cr_server.head_spu->dispatch_table.ReadPixels(x, y, width, height,
+                                                      format, type, pbo_offset);
+    }
+    else
+#endif
+    {
+        CRMessageReadPixels *rp;
+        uint32_t msg_len;
+
+        if (bytes_per_row <= 0 || height <= 0 || bytes_per_row > INT32_MAX / height)
+        {
+            crError("crServerDispatchReadPixels: parameters out of range");
+            return;
+        }
+
+        msg_len = sizeof(*rp) + (uint32_t)bytes_per_row * height;
+
+        rp = (CRMessageReadPixels *) crAlloc( msg_len );
+        if (!rp)
+        {
+            crError("crServerDispatchReadPixels: out of memory");
+            return;
+        }
+
+        /* Note: the ReadPixels data gets densely packed into the buffer
+         * (no skip pixels, skip rows, etc.  It's up to the receiver (pack spu,
+         * tilesort spu, etc) to apply the real PixelStore packing parameters.
+        */
+        cr_server.head_spu->dispatch_table.ReadPixels(x, y, width, height,
+                                                      format, type, rp + 1);
+
+        rp->header.type = CR_MESSAGE_READ_PIXELS;
+        rp->width = width;
+        rp->height = height;
+        rp->bytes_per_row = bytes_per_row;
+        rp->stride = stride;
+        rp->format = format;
+        rp->type = type;
+        rp->alignment = alignment;
+        rp->skipRows = skipRows;
+        rp->skipPixels = skipPixels;
+        rp->rowLength = rowLength;
+
+        /* <pixels> points to the 8-byte network pointer */
+        crMemcpy( &rp->pixels, pixels, sizeof(rp->pixels) );
+    
+        crNetSend( cr_server.curClient->conn, NULL, rp, msg_len );
+        crFree( rp );
+    }
+}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_retval.py
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_retval.py	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_retval.py	(revision 78190)
@@ -30,9 +30,4 @@
         if (cr_server.bIsInLoadingState)
             return;
-
-        if (cr_server.curClient->conn->type == CR_FILE)
-        {
-            return;
-        }
 
         if (payload_len >= INT32_MAX - sizeof( *rb ))
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.c	(revision 78189)
+++ 	(revision )
@@ -1,934 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "server.h"
-#include "cr_unpack.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "server_dispatch.h"
-
-
-/**
- * Accept a new client connection, create a new CRClient and add to run queue.
- */
-void
-crServerAddNewClient(void)
-{
-    CRClient *newClient = (CRClient *) crCalloc(sizeof(CRClient));
-
-    if (newClient) {
-        newClient->spu_id = cr_server.client_spu_id;
-        newClient->conn = crNetAcceptClient( cr_server.protocol, NULL,
-                                                                                 cr_server.tcpip_port,
-                                                                                 cr_server.mtu, 1 );
-
-        newClient->currentCtxInfo = &cr_server.MainContextInfo;
-
-        /* add to array */
-        cr_server.clients[cr_server.numClients++] = newClient;
-
-        crServerAddToRunQueue( newClient );
-    }
-}
-
-
-/**
- * Check if client is in the run queue.
- */
-static GLboolean
-FindClientInQueue(CRClient *client)
-{
-    RunQueue *q = cr_server.run_queue;
-    while (q) {
-        if (q->client == client) {
-            return 1;
-        }
-        q = q->next;
-        if (q == cr_server.run_queue)
-            return 0; /* back head */
-    }
-    return 0;
-}
-
-
-#if 0
-static int
-PrintQueue(void)
-{
-    RunQueue *q = cr_server.run_queue;
-    int count = 0;
-    crDebug("Queue entries:");
-    while (q) {
-        count++;
-        crDebug("Entry: %p  client: %p", q, q->client);
-        q = q->next;
-        if (q == cr_server.run_queue)
-            return count;
-    }
-    return count;
-}
-#endif
-
-
-void crServerAddToRunQueue( CRClient *client )
-{
-    RunQueue *q = (RunQueue *) crAlloc( sizeof( *q ) );
-
-#ifdef VBOX_WITH_CRHGSMI
-    client->conn->pClient = client;
-    CRVBOXHGSMI_CMDDATA_CLEANUP(&client->conn->CmdData);
-#endif
-
-    /* give this client a unique number if needed */
-    if (!client->number) {
-        client->number = client->conn->u32ClientID;
-    }
-
-    crDebug("Adding client %p to the run queue", client);
-
-    if (FindClientInQueue(client)) {
-        crError("CRServer: client %p already in the queue!", client);
-    }
-
-    q->client = client;
-    q->blocked = 0;
-
-    if (!cr_server.run_queue)
-    {
-        /* adding to empty queue */
-        cr_server.run_queue = q;
-        q->next = q;
-        q->prev = q;
-    }
-    else
-    {
-        /* insert in doubly-linked list */
-        q->next = cr_server.run_queue->next;
-        cr_server.run_queue->next->prev = q;
-
-        q->prev = cr_server.run_queue;
-        cr_server.run_queue->next = q;
-    }
-}
-
-static void crServerCleanupClient(CRClient *client)
-{
-    int32_t pos;
-    CRClient *oldclient = cr_server.curClient;
-
-    cr_server.curClient = client;
-
-    /* Destroy any windows created by the client */
-    for (pos = 0; pos<CR_MAX_WINDOWS; pos++) 
-    {
-        if (client->windowList[pos])
-        {
-            cr_server.dispatch.WindowDestroy(client->windowList[pos]);
-        }
-    }
-
-    /* Check if we have context(s) made by this client left, could happen if client side code is lazy */
-    for (pos = 0; pos<CR_MAX_CONTEXTS; pos++) 
-    {
-        if (client->contextList[pos])
-        {
-            cr_server.dispatch.DestroyContext(client->contextList[pos]);
-        }
-    }
-
-    cr_server.curClient = oldclient;
-}
-
-static void crServerCleanupByPID(uint64_t pid)
-{
-    CRClientNode *pNode=cr_server.pCleanupClient, *pNext;
-
-    while (pNode)
-    {
-        if (pNode->pClient->pid==pid)
-        {
-            crServerCleanupClient(pNode->pClient);
-            crFree(pNode->pClient);
-            if (pNode->prev)
-            {
-                pNode->prev->next=pNode->next;
-            }
-            else
-            {
-                cr_server.pCleanupClient=pNode->next;
-            }
-            if (pNode->next)
-            {
-                pNode->next->prev = pNode->prev;
-            }
-
-            pNext=pNode->next;
-            crFree(pNode);
-            pNode=pNext;
-        }
-        else
-        {
-            pNode=pNode->next;
-        }
-    }
-}
-
-void
-crServerDeleteClient( CRClient *client )
-{
-    int i, j;
-    int cleanup=1;
-
-    crDebug("Deleting client %p (%d msgs left)", client, crNetNumMessages(client->conn));
-
-#if 0
-    if (crNetNumMessages(client->conn) > 0) {
-        crDebug("Delay destroying client: message still pending");
-        return;
-    }
-#endif
-
-    if (!FindClientInQueue(client)) {
-        /* this should never happen */
-        crError("CRServer: client %p not found in the queue!", client);
-    }
-
-    /* remove from clients[] array */
-    for (i = 0; i < cr_server.numClients; i++) {
-        if (cr_server.clients[i] == client) {
-            /* found it */
-            for (j = i; j < cr_server.numClients - 1; j++)
-                cr_server.clients[j] = cr_server.clients[j + 1];
-            cr_server.numClients--;
-            break;
-        }
-    }
-
-    /* check if there're any other guest threads in same process */
-    for (i=0; i < cr_server.numClients; i++)
-    {
-        if (cr_server.clients[i]->pid==client->pid)
-        {
-            cleanup=0;
-            break;
-        }
-    }
-
-    if (cleanup)
-    {
-        crServerCleanupClient(client);
-    }
-
-    /* remove from the run queue */
-    if (cr_server.run_queue)
-    {
-        RunQueue *q = cr_server.run_queue;
-        RunQueue *qStart = cr_server.run_queue; 
-        do {
-            if (q->client == client)
-            {
-                /* this test seems a bit excessive */
-                if ((q->next == q->prev) && (q->next == q) && (cr_server.run_queue == q))
-                {
-                    /* We're removing/deleting the only client */
-                    CRASSERT(cr_server.numClients == 0);
-                    crFree(q);
-                    cr_server.run_queue = NULL;
-                    cr_server.curClient = NULL;
-                    crDebug("Last client deleted - empty run queue.");
-                } 
-                else
-                {
-                    /* remove from doubly linked list and free the node */
-                    if (cr_server.curClient == q->client)
-                        cr_server.curClient = NULL;
-                    if (cr_server.run_queue == q)
-                        cr_server.run_queue = q->next;
-                    q->prev->next = q->next;
-                    q->next->prev = q->prev;
-                    crFree(q);
-                }
-                break;
-            }
-            q = q->next;
-        } while (q != qStart);
-    }
-
-    crNetFreeConnection(client->conn);
-    client->conn = NULL;
-
-    if (cleanup)
-    {
-        crServerCleanupByPID(client->pid);
-        crFree(client);
-    }
-    else
-    {
-        CRClientNode *pNode = (CRClientNode *)crAlloc(sizeof(CRClientNode));
-        if (!pNode)
-        {
-            crWarning("Not enough memory, forcing client cleanup");
-            crServerCleanupClient(client);
-            crServerCleanupByPID(client->pid);
-            crFree(client);
-            return;
-        }
-        pNode->pClient = client;
-        pNode->prev = NULL;
-        pNode->next = cr_server.pCleanupClient;
-        cr_server.pCleanupClient = pNode;
-    }
-
-    if (!cr_server.numClients)
-    {
-        /* if no clients, the guest driver may be unloaded,
-         * and thus the visible regions situation might not be under control anymore,
-         * so cleanup the 3D framebuffer data here
-         * @todo: what really should happen is that guest driver on unload
-         * posts some request to host that would copy the current framebuffer 3D data to the 2D buffer
-         * (i.e. to the memory used by the standard IFramebuffer API) */
-        HCR_FRAMEBUFFER hFb;
-        for (hFb = CrPMgrFbGetFirstEnabled(); hFb; hFb = CrPMgrFbGetNextEnabled(hFb))
-        {
-            int rc = CrFbUpdateBegin(hFb);
-            if (RT_SUCCESS(rc))
-            {
-                CrFbRegionsClear(hFb);
-                CrFbUpdateEnd(hFb);
-            }
-            else
-                WARN(("CrFbUpdateBegin failed %d", rc));
-        }
-    }
-}
-
-/**
- * Test if the given client is in the middle of a glBegin/End or
- * glNewList/EndList pair.
- * This is used to test if we can advance to the next client.
- * \return GL_TRUE if so, GL_FALSE otherwise.
- */
-GLboolean
-crServerClientInBeginEnd(const CRClient *client)
-{
-    if (client->currentCtxInfo
-            && client->currentCtxInfo->pContext
-            && (client->currentCtxInfo->pContext->lists.currentIndex != 0 ||
-             client->currentCtxInfo->pContext->current.inBeginEnd ||
-             client->currentCtxInfo->pContext->occlusion.currentQueryObject)) {
-        return GL_TRUE;
-    }
-    else {
-        return GL_FALSE;
-    }
-}
-
-
-/**
- * Find the next client in the run queue that's not blocked and has a
- * waiting message.
- * Check if all clients are blocked (on barriers, semaphores), if so we've
- * deadlocked!
- * If no clients have a waiting message, call crNetRecv to get something
- * if 'block' is true, else return NULL if 'block' if false.
- */
-static RunQueue *
-getNextClient(GLboolean block)
-{
-    while (1)
-    {
-        if (cr_server.run_queue) 
-        {
-            GLboolean all_blocked = GL_TRUE;
-            GLboolean done_something = GL_FALSE;
-            RunQueue *start = cr_server.run_queue;
-
-            /* check if this client's connection has gone away */
-            if (!cr_server.run_queue->client->conn
-                || (cr_server.run_queue->client->conn->type == CR_NO_CONNECTION
-                    && crNetNumMessages(cr_server.run_queue->client->conn) == 0)) 
-            {
-                crServerDeleteClient( cr_server.run_queue->client );
-                start = cr_server.run_queue;
-            }
- 
-            if (cr_server.run_queue == NULL) {
-                /* empty queue */
-                return NULL;
-            }
-
-            if (crServerClientInBeginEnd(cr_server.run_queue->client)) {
-                /* We _must_ service this client and no other.
-                 * If we've got a message waiting on this client's connection we'll
-                 * service it.  Else, return NULL.
-                 */
-                if (crNetNumMessages(cr_server.run_queue->client->conn) > 0)
-                    return cr_server.run_queue;
-                else
-                    return NULL;
-            }
-
-            /* loop over entries in run queue, looking for next one that's ready */
-            while (!done_something || cr_server.run_queue != start)
-            {
-                done_something = GL_TRUE;
-                if (!cr_server.run_queue->blocked)
-                {
-                    all_blocked = GL_FALSE;
-                }
-                if (!cr_server.run_queue->blocked
-                        && cr_server.run_queue->client->conn
-                        && crNetNumMessages(cr_server.run_queue->client->conn) > 0)
-                {
-                    /* OK, this client isn't blocked and has a queued message */
-                    return cr_server.run_queue;
-                }
-                cr_server.run_queue = cr_server.run_queue->next;
-            }
-
-            if (all_blocked)
-            {
-                 /* XXX crError is fatal?  Should this be an info/warning msg? */
-                crError( "crserver: DEADLOCK! (numClients=%d, all blocked)",
-                                 cr_server.numClients );
-                if (cr_server.numClients < (int) cr_server.maxBarrierCount) {
-                    crError("Waiting for more clients!!!");
-                    while (cr_server.numClients < (int) cr_server.maxBarrierCount) {
-                        crNetRecv();
-                    }
-                }
-            }
-        }
-
-        if (!block)
-             return NULL;
-
-        /* no one had any work, get some! */
-        crNetRecv();
-
-    } /* while */
-
-    /* UNREACHED */
-    /* return NULL; */
-}
-
-typedef struct CR_SERVER_PENDING_MSG
-{
-    RTLISTNODE Node;
-    uint32_t cbMsg;
-    CRMessage Msg;
-} CR_SERVER_PENDING_MSG;
-
-static int crServerPendMsg(CRConnection *conn, const CRMessage *msg, int cbMsg)
-{
-    CR_SERVER_PENDING_MSG *pMsg;
-
-    if (!cbMsg)
-    {
-        WARN(("cbMsg is null!"));
-        return VERR_INVALID_PARAMETER;
-    }
-
-    pMsg = (CR_SERVER_PENDING_MSG*)RTMemAlloc(cbMsg + RT_UOFFSETOF(CR_SERVER_PENDING_MSG, Msg));
-    if (!pMsg)
-    {
-        WARN(("RTMemAlloc failed"));
-        return VERR_NO_MEMORY;
-    }
-
-    pMsg->cbMsg = cbMsg;
-
-    memcpy(&pMsg->Msg, msg, cbMsg);
-
-    RTListAppend(&conn->PendingMsgList, &pMsg->Node);
-
-    return VINF_SUCCESS;
-}
-
-int crServerPendSaveState(PSSMHANDLE pSSM)
-{
-    int i, rc;
-
-    for (i = 0; i < cr_server.numClients; i++)
-    {
-        CR_SERVER_PENDING_MSG *pIter;
-        CRClient *pClient = cr_server.clients[i];
-        CRConnection *pConn;
-        if (!pClient || !pClient->conn)
-        {
-            WARN(("invalid client state"));
-            continue;
-        }
-
-        pConn = pClient->conn;
-
-        if (RTListIsEmpty(&pConn->PendingMsgList))
-            continue;
-
-        CRASSERT(pConn->u32ClientID);
-
-        rc = SSMR3PutU32(pSSM, pConn->u32ClientID);
-        AssertRCReturn(rc, rc);
-
-        RTListForEach(&pConn->PendingMsgList, pIter, CR_SERVER_PENDING_MSG, Node)
-        {
-            CRASSERT(pIter->cbMsg);
-
-            rc = SSMR3PutU32(pSSM, pIter->cbMsg);
-            AssertRCReturn(rc, rc);
-
-            rc = SSMR3PutMem(pSSM, &pIter->Msg, pIter->cbMsg);
-            AssertRCReturn(rc, rc);
-        }
-
-        rc = SSMR3PutU32(pSSM, 0);
-        AssertRCReturn(rc, rc);
-    }
-
-    rc = SSMR3PutU32(pSSM, 0);
-    AssertRCReturn(rc, rc);
-
-    return VINF_SUCCESS;
-}
-
-int crServerPendLoadState(PSSMHANDLE pSSM, uint32_t u32Version)
-{
-    int rc;
-    uint32_t u32;
-    CRClient *pClient;
-
-    if (u32Version < SHCROGL_SSM_VERSION_WITH_PEND_CMD_INFO)
-        return VINF_SUCCESS;
-
-    rc = SSMR3GetU32(pSSM, &u32);
-    AssertRCReturn(rc, rc);
-
-    if (!u32)
-        return VINF_SUCCESS;
-
-    do {
-        rc = crVBoxServerClientGet(u32, &pClient);
-        AssertRCReturn(rc, rc);
-
-        for(;;)
-        {
-            CR_SERVER_PENDING_MSG *pMsg;
-
-            rc = SSMR3GetU32(pSSM, &u32);
-            AssertRCReturn(rc, rc);
-
-            if (!u32)
-                break;
-
-            pMsg = (CR_SERVER_PENDING_MSG*)RTMemAlloc(u32 + RT_UOFFSETOF(CR_SERVER_PENDING_MSG, Msg));
-            if (!pMsg)
-            {
-                WARN(("RTMemAlloc failed"));
-                return VERR_NO_MEMORY;
-            }
-
-            pMsg->cbMsg = u32;
-            rc = SSMR3GetMem(pSSM, &pMsg->Msg, u32);
-            AssertRCReturn(rc, rc);
-
-            RTListAppend(&pClient->conn->PendingMsgList, &pMsg->Node);
-        }
-
-        rc = SSMR3GetU32(pSSM, &u32);
-        AssertRCReturn(rc, rc);
-    } while (u32);
-
-    rc = SSMR3GetU32(pSSM, &u32);
-    AssertRCReturn(rc, rc);
-
-    return VINF_SUCCESS;
-}
-
-static void crServerPendProcess(CRConnection *conn)
-{
-    CR_SERVER_PENDING_MSG *pIter, *pNext;
-
-    cr_server.fProcessingPendedCommands = GL_TRUE;
-
-    RTListForEachSafe(&conn->PendingMsgList, pIter, pNext, CR_SERVER_PENDING_MSG, Node)
-    {
-        CRMessage *msg = &pIter->Msg;
-        const CRMessageOpcodes *msg_opcodes;
-        int opcodeBytes;
-        const char *data_ptr, *data_ptr_end;
-
-        RTListNodeRemove(&pIter->Node);
-
-        CRASSERT(msg->header.type == CR_MESSAGE_OPCODES);
-
-        msg_opcodes = (const CRMessageOpcodes *) msg;
-        opcodeBytes = (msg_opcodes->numOpcodes + 3) & ~0x03;
-
-        data_ptr = (const char *) msg_opcodes + sizeof (CRMessageOpcodes) + opcodeBytes;
-        data_ptr_end = (const char *)msg_opcodes + pIter->cbMsg;
-
-        crUnpack(data_ptr,                 /* first command's operands */
-                 data_ptr_end,             /* first byte after command's operands*/
-                 data_ptr - 1,             /* first command's opcode */
-                 msg_opcodes->numOpcodes,  /* how many opcodes */
-                 &(cr_server.dispatch));   /* the CR dispatch table */
-
-        RTMemFree(pIter);
-    }
-
-    cr_server.fProcessingPendedCommands = GL_FALSE;
-}
-
-/**
- * This function takes the given message (which should be a buffer of
- * rendering commands) and executes it.
- */
-static void
-crServerDispatchMessage(CRConnection *conn, CRMessage *msg, int cbMsg)
-{
-    const CRMessageOpcodes *msg_opcodes;
-    int opcodeBytes;
-    const char *data_ptr, *data_ptr_end;
-#ifdef VBOX_WITH_CRHGSMI
-    PCRVBOXHGSMI_CMDDATA pCmdData = NULL;
-#endif
-    CR_UNPACK_BUFFER_TYPE enmType;
-    bool fUnpack = true;
-
-    if (msg->header.type == CR_MESSAGE_REDIR_PTR)
-    {
-#ifdef VBOX_WITH_CRHGSMI
-        pCmdData = &msg->redirptr.CmdData;
-#endif
-        msg = (CRMessage *) msg->redirptr.pMessage;
-    }
-
-    CRASSERT(msg->header.type == CR_MESSAGE_OPCODES);
-
-    msg_opcodes = (const CRMessageOpcodes *) msg;
-    opcodeBytes = (msg_opcodes->numOpcodes + 3) & ~0x03;
-
-#ifdef VBOXCR_LOGFPS
-    CRASSERT(cr_server.curClient && cr_server.curClient->conn && cr_server.curClient->conn->id == msg->header.conn_id);
-    cr_server.curClient->conn->opcodes_count += msg_opcodes->numOpcodes;
-#endif
-
-    data_ptr = (const char *) msg_opcodes + sizeof(CRMessageOpcodes) + opcodeBytes;
-    data_ptr_end = (const char *)msg_opcodes + cbMsg; // Pointer to the first byte after message data
-
-    enmType = crUnpackGetBufferType(data_ptr - 1,             /* first command's opcode */
-                msg_opcodes->numOpcodes  /* how many opcodes */);
-    switch (enmType)
-    {
-        case CR_UNPACK_BUFFER_TYPE_GENERIC:
-        {
-            if (RTListIsEmpty(&conn->PendingMsgList))
-                break;
-
-            if (RT_SUCCESS(crServerPendMsg(conn, msg, cbMsg)))
-            {
-                fUnpack = false;
-                break;
-            }
-
-            WARN(("crServerPendMsg failed"));
-            crServerPendProcess(conn);
-            break;
-        }
-        case CR_UNPACK_BUFFER_TYPE_CMDBLOCK_BEGIN:
-        {
-            if (RTListIsEmpty(&conn->PendingMsgList))
-            {
-                if (RT_SUCCESS(crServerPendMsg(conn, msg, cbMsg)))
-                {
-                    Assert(!RTListIsEmpty(&conn->PendingMsgList));
-                    fUnpack = false;
-                    break;
-                }
-                else
-                    WARN(("crServerPendMsg failed"));
-            }
-            else
-                WARN(("Pend List is NOT empty, drain the current list, and ignore this command"));
-
-            crServerPendProcess(conn);
-            break;
-        }
-        case CR_UNPACK_BUFFER_TYPE_CMDBLOCK_FLUSH: /* just flush for now */
-        {
-            CrPMgrClearRegionsGlobal(); /* clear regions to ensure we don't do MakeCurrent and friends */
-            crServerPendProcess(conn);
-            Assert(RTListIsEmpty(&conn->PendingMsgList));
-            break;
-        }
-        case CR_UNPACK_BUFFER_TYPE_CMDBLOCK_END:
-        {
-//            CRASSERT(!RTListIsEmpty(&conn->PendingMsgList));
-            crServerPendProcess(conn);
-            Assert(RTListIsEmpty(&conn->PendingMsgList));
-            break;
-        }
-        default:
-            WARN(("unsupported buffer type"));
-            break;
-    }
-
-    if (fUnpack)
-    {
-        crUnpack(data_ptr,                 /* first command's operands */
-                 data_ptr_end,             /* first byte after command's operands*/
-                 data_ptr - 1,             /* first command's opcode */
-                 msg_opcodes->numOpcodes,  /* how many opcodes */
-                 &(cr_server.dispatch));   /* the CR dispatch table */
-    }
-
-#ifdef VBOX_WITH_CRHGSMI
-    if (pCmdData)
-    {
-        int rc = VINF_SUCCESS;
-        CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(pCmdData);
-        if (CRVBOXHGSMI_CMDDATA_IS_SETWB(pCmdData))
-        {
-            uint32_t cbWriteback = pCmdData->cbWriteback;
-            rc = crVBoxServerInternalClientRead(conn->pClient, (uint8_t*)pCmdData->pWriteback, &cbWriteback);
-            Assert(rc == VINF_SUCCESS || rc == VERR_BUFFER_OVERFLOW);
-            *pCmdData->pcbWriteback = cbWriteback;
-        }
-        VBOXCRHGSMI_CMD_CHECK_COMPLETE(pCmdData, rc);
-    }
-#endif
-}
-
-
-typedef enum
-{
-  CLIENT_GONE = 1, /* the client has disconnected */
-  CLIENT_NEXT = 2, /* we can advance to next client */
-  CLIENT_MORE = 3  /* we need to keep servicing current client */
-} ClientStatus;
-
-
-/**
- * Process incoming/pending message for the given client (queue entry).
- * \return CLIENT_GONE if this client has gone away/exited,
- *         CLIENT_NEXT if we can advance to the next client
- *         CLIENT_MORE if we have to process more messages for this client. 
- */
-static ClientStatus
-crServerServiceClient(const RunQueue *qEntry)
-{
-    CRMessage *msg;
-    CRConnection *conn;
-
-    /* set current client pointer */
-    cr_server.curClient = qEntry->client;
-
-    conn = cr_server.run_queue->client->conn;
-
-    /* service current client as long as we can */
-    while (conn && conn->type != CR_NO_CONNECTION &&
-                 crNetNumMessages(conn) > 0) {
-        unsigned int len;
-
-        /*
-        crDebug("%d messages on %p",
-                        crNetNumMessages(conn), (void *) conn);
-        */
-
-        /* Don't use GetMessage, because we want to do our own crNetRecv() calls
-         * here ourself.
-         * Note that crNetPeekMessage() DOES remove the message from the queue
-         * if there is one.
-         */
-        len = crNetPeekMessage( conn, &msg );
-        CRASSERT(len > 0);
-        if (msg->header.type != CR_MESSAGE_OPCODES
-            && msg->header.type != CR_MESSAGE_REDIR_PTR) {
-            crError( "SPU %d sent me CRAP (type=0x%x)",
-                             cr_server.curClient->spu_id, msg->header.type );
-        }
-
-        /* Do the context switch here.  No sense in switching before we
-         * really have any work to process.  This is a no-op if we're
-         * not really switching contexts.
-         *
-         * XXX This isn't entirely sound.  The crStateMakeCurrent() call
-         * will compute the state difference and dispatch it using
-         * the head SPU's dispatch table.
-         *
-         * This is a problem if this is the first buffer coming in,
-         * and the head SPU hasn't had a chance to do a MakeCurrent()
-         * yet (likely because the MakeCurrent() command is in the
-         * buffer itself).
-         *
-         * At best, in this case, the functions are no-ops, and
-         * are essentially ignored by the SPU.  In the typical
-         * case, things aren't too bad; if the SPU just calls
-         * crState*() functions to update local state, everything
-         * will work just fine.
-         *
-         * In the worst (but unusual) case where a nontrivial
-         * SPU is at the head of a crserver's SPU chain (say,
-         * in a multiple-tiered "tilesort" arrangement, as
-         * seen in the "multitilesort.conf" configuration), the
-         * SPU may rely on state set during the MakeCurrent() that
-         * may not be present yet, because no MakeCurrent() has
-         * yet been dispatched.
-         *
-         * This headache will have to be revisited in the future;
-         * for now, SPUs that could head a crserver's SPU chain
-         * will have to detect the case that their functions are
-         * being called outside of a MakeCurrent(), and will have
-         * to handle the situation gracefully.  (This is currently
-         * the case with the "tilesort" SPU.)
-         */
-
-#if 0
-        crStateMakeCurrent( cr_server.curClient->currentCtx );
-#else
-        /* Check if the current window is the one that the client wants to
-         * draw into.  If not, dispatch a MakeCurrent to activate the proper
-         * window.
-         */
-        if (cr_server.curClient) {
-             int clientWindow = cr_server.curClient->currentWindow;
-             int clientContext = cr_server.curClient->currentContextNumber;
-             CRContextInfo *clientCtxInfo = cr_server.curClient->currentCtxInfo;
-             if (clientCtxInfo != cr_server.currentCtxInfo
-                     || clientWindow != cr_server.currentWindow
-                     || cr_server.bForceMakeCurrentOnClientSwitch) {
-                 crServerDispatchMakeCurrent(clientWindow, 0, clientContext);
-                 /*
-                 CRASSERT(cr_server.currentWindow == clientWindow);
-                 */
-             }
-        }
-#endif
-
-        /* Force scissor, viewport and projection matrix update in
-         * crServerSetOutputBounds().
-         */
-        cr_server.currentSerialNo = 0;
-
-        /* Commands get dispatched here */
-        crServerDispatchMessage( conn, msg, len );
-
-        crNetFree( conn, msg );
-
-        if (qEntry->blocked) {
-            /* Note/assert: we should not be inside a glBegin/End or glNewList/
-             * glEndList pair at this time!
-             */
-            CRASSERT(0);
-            return CLIENT_NEXT;
-        }
-
-    } /* while */
-
-    /*
-     * Check if client/connection is gone
-     */
-    if (!conn || conn->type == CR_NO_CONNECTION) {
-        crDebug("Delete client %p at %d", cr_server.run_queue->client, __LINE__);
-        crServerDeleteClient( cr_server.run_queue->client );
-        return CLIENT_GONE;
-    }
-
-    /*
-     * Determine if we can advance to next client.
-     * If we're currently inside a glBegin/End primitive or building a display
-     * list we can't service another client until we're done with the
-     * primitive/list.
-     */
-    if (crServerClientInBeginEnd(cr_server.curClient)) {
-        /* The next message has to come from the current client's connection. */
-        CRASSERT(!qEntry->blocked);
-        return CLIENT_MORE;
-    }
-    else {
-        /* get next client */
-        return CLIENT_NEXT;
-    }
-}
-
-
-
-/**
- * Check if any of the clients need servicing.
- * If so, service one client and return.
- * Else, just return.
- */
-void
-crServerServiceClients(void)
-{
-    RunQueue *q;
-
-    q = getNextClient(GL_FALSE); /* don't block */
-    while (q) 
-    {
-        ClientStatus stat = crServerServiceClient(q);
-        if (stat == CLIENT_NEXT && cr_server.run_queue->next) {
-            /* advance to next client */
-            cr_server.run_queue = cr_server.run_queue->next;
-        }
-        q = getNextClient(GL_FALSE);
-    }
-}
-
-
-
-
-/**
- * Main crserver loop.  Service connections from all connected clients.
- * XXX add a config option to specify whether the crserver
- * should exit when there's no more clients.
- */
-void
-crServerSerializeRemoteStreams(void)
-{
-    /*MSG msg;*/
-
-    while (cr_server.run_queue)
-    {
-        crServerServiceClients();
-        /*if (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
-        {
-            if (msg.message == WM_QUIT)
-            {
-                PostQuitMessage((int)msg.wParam);
-                break;
-            }
-            TranslateMessage( &msg );
-            DispatchMessage( &msg );
-        }*/
-    }
-}
-
-
-/**
- * This will be called by the network layer when it's received a new message.
- */
-int
-crServerRecv( CRConnection *conn, CRMessage *msg, unsigned int len )
-{
-    CRMessage *pRealMsg;
-    (void) len;
-
-    pRealMsg = (msg->header.type!=CR_MESSAGE_REDIR_PTR) ? msg : (CRMessage*) msg->redirptr.pMessage;
-
-    switch( pRealMsg->header.type )
-    {
-        /* Called when using multiple threads */
-        case CR_MESSAGE_NEWCLIENT:
-            crServerAddNewClient();
-            return 1; /* msg handled */
-        default:
-            /*crWarning( "Why is the crserver getting a message of type 0x%x?",
-                msg->header.type ); */
-            ;
-    }
-    return 0; /* not handled */
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_stream.cpp	(revision 78190)
@@ -0,0 +1,949 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "server.h"
+#include "cr_unpack.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "server_dispatch.h"
+
+
+/**
+ * Accept a new client connection, create a new CRClient and add to run queue.
+ */
+void
+crServerAddNewClient(void)
+{
+    CRClient *newClient = (CRClient *) crCalloc(sizeof(CRClient));
+
+    if (newClient) {
+        newClient->spu_id = cr_server.client_spu_id;
+        newClient->conn = crNetAcceptClient( cr_server.protocol, NULL,
+                                                                                 cr_server.tcpip_port,
+                                                                                 cr_server.mtu, 1 );
+
+        newClient->currentCtxInfo = &cr_server.MainContextInfo;
+
+        /* add to array */
+        cr_server.clients[cr_server.numClients++] = newClient;
+
+        crServerAddToRunQueue( newClient );
+    }
+}
+
+
+/**
+ * Check if client is in the run queue.
+ */
+static GLboolean
+FindClientInQueue(CRClient *client)
+{
+    RunQueue *q = cr_server.run_queue;
+    while (q) {
+        if (q->client == client) {
+            return 1;
+        }
+        q = q->next;
+        if (q == cr_server.run_queue)
+            return 0; /* back head */
+    }
+    return 0;
+}
+
+
+#if 0
+static int
+PrintQueue(void)
+{
+    RunQueue *q = cr_server.run_queue;
+    int count = 0;
+    crDebug("Queue entries:");
+    while (q) {
+        count++;
+        crDebug("Entry: %p  client: %p", q, q->client);
+        q = q->next;
+        if (q == cr_server.run_queue)
+            return count;
+    }
+    return count;
+}
+#endif
+
+
+void crServerAddToRunQueue( CRClient *client )
+{
+    RunQueue *q = (RunQueue *) crAlloc( sizeof( *q ) );
+
+#ifdef VBOX_WITH_CRHGSMI
+    client->conn->pClient = client;
+    CRVBOXHGSMI_CMDDATA_CLEANUP(&client->conn->CmdData);
+#endif
+
+    /* give this client a unique number if needed */
+    if (!client->number) {
+        client->number = client->conn->u32ClientID;
+    }
+
+    crDebug("Adding client %p to the run queue", client);
+
+    if (FindClientInQueue(client)) {
+        crError("CRServer: client %p already in the queue!", client);
+    }
+
+    q->client = client;
+    q->blocked = 0;
+
+    if (!cr_server.run_queue)
+    {
+        /* adding to empty queue */
+        cr_server.run_queue = q;
+        q->next = q;
+        q->prev = q;
+    }
+    else
+    {
+        /* insert in doubly-linked list */
+        q->next = cr_server.run_queue->next;
+        cr_server.run_queue->next->prev = q;
+
+        q->prev = cr_server.run_queue;
+        cr_server.run_queue->next = q;
+    }
+}
+
+static void crServerCleanupClient(CRClient *client)
+{
+    int32_t pos;
+    CRClient *oldclient = cr_server.curClient;
+
+    cr_server.curClient = client;
+
+    /* Destroy any windows created by the client */
+    for (pos = 0; pos<CR_MAX_WINDOWS; pos++) 
+    {
+        if (client->windowList[pos])
+        {
+            cr_server.dispatch.WindowDestroy(client->windowList[pos]);
+        }
+    }
+
+    /* Check if we have context(s) made by this client left, could happen if client side code is lazy */
+    for (pos = 0; pos<CR_MAX_CONTEXTS; pos++) 
+    {
+        if (client->contextList[pos])
+        {
+            cr_server.dispatch.DestroyContext(client->contextList[pos]);
+        }
+    }
+
+    cr_server.curClient = oldclient;
+}
+
+static void crServerCleanupByPID(uint64_t pid)
+{
+    CRClientNode *pNode=cr_server.pCleanupClient, *pNext;
+
+    while (pNode)
+    {
+        if (pNode->pClient->pid==pid)
+        {
+            crServerCleanupClient(pNode->pClient);
+            crFree(pNode->pClient);
+            if (pNode->prev)
+            {
+                pNode->prev->next=pNode->next;
+            }
+            else
+            {
+                cr_server.pCleanupClient=pNode->next;
+            }
+            if (pNode->next)
+            {
+                pNode->next->prev = pNode->prev;
+            }
+
+            pNext=pNode->next;
+            crFree(pNode);
+            pNode=pNext;
+        }
+        else
+        {
+            pNode=pNode->next;
+        }
+    }
+}
+
+void
+crServerDeleteClient( CRClient *client )
+{
+    int i, j;
+    int cleanup=1;
+
+    crDebug("Deleting client %p (%d msgs left)", client, crNetNumMessages(client->conn));
+
+#if 0
+    if (crNetNumMessages(client->conn) > 0) {
+        crDebug("Delay destroying client: message still pending");
+        return;
+    }
+#endif
+
+    if (!FindClientInQueue(client)) {
+        /* this should never happen */
+        crError("CRServer: client %p not found in the queue!", client);
+    }
+
+    /* remove from clients[] array */
+    for (i = 0; i < cr_server.numClients; i++) {
+        if (cr_server.clients[i] == client) {
+            /* found it */
+            for (j = i; j < cr_server.numClients - 1; j++)
+                cr_server.clients[j] = cr_server.clients[j + 1];
+            cr_server.numClients--;
+            break;
+        }
+    }
+
+    /* check if there're any other guest threads in same process */
+    for (i=0; i < cr_server.numClients; i++)
+    {
+        if (cr_server.clients[i]->pid==client->pid)
+        {
+            cleanup=0;
+            break;
+        }
+    }
+
+    if (cleanup)
+    {
+        crServerCleanupClient(client);
+    }
+
+    /* remove from the run queue */
+    if (cr_server.run_queue)
+    {
+        RunQueue *q = cr_server.run_queue;
+        RunQueue *qStart = cr_server.run_queue; 
+        do {
+            if (q->client == client)
+            {
+                /* this test seems a bit excessive */
+                if ((q->next == q->prev) && (q->next == q) && (cr_server.run_queue == q))
+                {
+                    /* We're removing/deleting the only client */
+                    CRASSERT(cr_server.numClients == 0);
+                    crFree(q);
+                    cr_server.run_queue = NULL;
+                    cr_server.curClient = NULL;
+                    crDebug("Last client deleted - empty run queue.");
+                } 
+                else
+                {
+                    /* remove from doubly linked list and free the node */
+                    if (cr_server.curClient == q->client)
+                        cr_server.curClient = NULL;
+                    if (cr_server.run_queue == q)
+                        cr_server.run_queue = q->next;
+                    q->prev->next = q->next;
+                    q->next->prev = q->prev;
+                    crFree(q);
+                }
+                break;
+            }
+            q = q->next;
+        } while (q != qStart);
+    }
+
+    crNetFreeConnection(client->conn);
+    client->conn = NULL;
+
+    if (cleanup)
+    {
+        crServerCleanupByPID(client->pid);
+        crFree(client);
+    }
+    else
+    {
+        CRClientNode *pNode = (CRClientNode *)crAlloc(sizeof(CRClientNode));
+        if (!pNode)
+        {
+            crWarning("Not enough memory, forcing client cleanup");
+            crServerCleanupClient(client);
+            crServerCleanupByPID(client->pid);
+            crFree(client);
+            return;
+        }
+        pNode->pClient = client;
+        pNode->prev = NULL;
+        pNode->next = cr_server.pCleanupClient;
+        cr_server.pCleanupClient = pNode;
+    }
+
+    if (!cr_server.numClients)
+    {
+        /* if no clients, the guest driver may be unloaded,
+         * and thus the visible regions situation might not be under control anymore,
+         * so cleanup the 3D framebuffer data here
+         * @todo: what really should happen is that guest driver on unload
+         * posts some request to host that would copy the current framebuffer 3D data to the 2D buffer
+         * (i.e. to the memory used by the standard IFramebuffer API) */
+        HCR_FRAMEBUFFER hFb;
+        for (hFb = CrPMgrFbGetFirstEnabled(); hFb; hFb = CrPMgrFbGetNextEnabled(hFb))
+        {
+            int rc = CrFbUpdateBegin(hFb);
+            if (RT_SUCCESS(rc))
+            {
+                CrFbRegionsClear(hFb);
+                CrFbUpdateEnd(hFb);
+            }
+            else
+                WARN(("CrFbUpdateBegin failed %d", rc));
+        }
+    }
+}
+
+/**
+ * Test if the given client is in the middle of a glBegin/End or
+ * glNewList/EndList pair.
+ * This is used to test if we can advance to the next client.
+ * \return GL_TRUE if so, GL_FALSE otherwise.
+ */
+GLboolean
+crServerClientInBeginEnd(const CRClient *client)
+{
+    if (client->currentCtxInfo
+            && client->currentCtxInfo->pContext
+            && (client->currentCtxInfo->pContext->lists.currentIndex != 0 ||
+             client->currentCtxInfo->pContext->current.inBeginEnd ||
+             client->currentCtxInfo->pContext->occlusion.currentQueryObject)) {
+        return GL_TRUE;
+    }
+    else {
+        return GL_FALSE;
+    }
+}
+
+
+/**
+ * Find the next client in the run queue that's not blocked and has a
+ * waiting message.
+ * Check if all clients are blocked (on barriers, semaphores), if so we've
+ * deadlocked!
+ * If no clients have a waiting message, call crNetRecv to get something
+ * if 'block' is true, else return NULL if 'block' if false.
+ */
+static RunQueue *
+getNextClient(GLboolean block)
+{
+    while (1)
+    {
+        if (cr_server.run_queue) 
+        {
+            GLboolean all_blocked = GL_TRUE;
+            GLboolean done_something = GL_FALSE;
+            RunQueue *start = cr_server.run_queue;
+
+            /* check if this client's connection has gone away */
+            if (!cr_server.run_queue->client->conn
+                || (cr_server.run_queue->client->conn->type == CR_NO_CONNECTION
+                    && crNetNumMessages(cr_server.run_queue->client->conn) == 0)) 
+            {
+                crServerDeleteClient( cr_server.run_queue->client );
+                start = cr_server.run_queue;
+            }
+ 
+            if (cr_server.run_queue == NULL) {
+                /* empty queue */
+                return NULL;
+            }
+
+            if (crServerClientInBeginEnd(cr_server.run_queue->client)) {
+                /* We _must_ service this client and no other.
+                 * If we've got a message waiting on this client's connection we'll
+                 * service it.  Else, return NULL.
+                 */
+                if (crNetNumMessages(cr_server.run_queue->client->conn) > 0)
+                    return cr_server.run_queue;
+                else
+                    return NULL;
+            }
+
+            /* loop over entries in run queue, looking for next one that's ready */
+            while (!done_something || cr_server.run_queue != start)
+            {
+                done_something = GL_TRUE;
+                if (!cr_server.run_queue->blocked)
+                {
+                    all_blocked = GL_FALSE;
+                }
+                if (!cr_server.run_queue->blocked
+                        && cr_server.run_queue->client->conn
+                        && crNetNumMessages(cr_server.run_queue->client->conn) > 0)
+                {
+                    /* OK, this client isn't blocked and has a queued message */
+                    return cr_server.run_queue;
+                }
+                cr_server.run_queue = cr_server.run_queue->next;
+            }
+
+            if (all_blocked)
+            {
+                 /* XXX crError is fatal?  Should this be an info/warning msg? */
+                crError( "crserver: DEADLOCK! (numClients=%d, all blocked)",
+                                 cr_server.numClients );
+                if (cr_server.numClients < (int) cr_server.maxBarrierCount) {
+                    crError("Waiting for more clients!!!");
+                    while (cr_server.numClients < (int) cr_server.maxBarrierCount) {
+                        crNetRecv();
+                    }
+                }
+            }
+        }
+
+        if (!block)
+             return NULL;
+
+        /* no one had any work, get some! */
+        crNetRecv();
+
+    } /* while */
+
+    /* UNREACHED */
+    /* return NULL; */
+}
+
+typedef struct CR_SERVER_PENDING_MSG
+{
+    RTLISTNODE Node;
+    uint32_t cbMsg;
+    CRMessage Msg;
+} CR_SERVER_PENDING_MSG;
+
+static int crServerPendMsg(CRConnection *conn, const CRMessage *msg, int cbMsg)
+{
+    CR_SERVER_PENDING_MSG *pMsg;
+
+    if (!cbMsg)
+    {
+        WARN(("cbMsg is null!"));
+        return VERR_INVALID_PARAMETER;
+    }
+
+    pMsg = (CR_SERVER_PENDING_MSG*)RTMemAlloc(cbMsg + RT_UOFFSETOF(CR_SERVER_PENDING_MSG, Msg));
+    if (!pMsg)
+    {
+        WARN(("RTMemAlloc failed"));
+        return VERR_NO_MEMORY;
+    }
+
+    pMsg->cbMsg = cbMsg;
+
+    memcpy(&pMsg->Msg, msg, cbMsg);
+
+    RTListAppend(&conn->PendingMsgList, &pMsg->Node);
+
+    return VINF_SUCCESS;
+}
+
+int crServerPendSaveState(PSSMHANDLE pSSM)
+{
+    int i, rc;
+
+    for (i = 0; i < cr_server.numClients; i++)
+    {
+        CR_SERVER_PENDING_MSG *pIter;
+        CRClient *pClient = cr_server.clients[i];
+        CRConnection *pConn;
+        if (!pClient || !pClient->conn)
+        {
+            WARN(("invalid client state"));
+            continue;
+        }
+
+        pConn = pClient->conn;
+
+        if (RTListIsEmpty(&pConn->PendingMsgList))
+            continue;
+
+        CRASSERT(pConn->u32ClientID);
+
+        rc = SSMR3PutU32(pSSM, pConn->u32ClientID);
+        AssertRCReturn(rc, rc);
+
+        RTListForEach(&pConn->PendingMsgList, pIter, CR_SERVER_PENDING_MSG, Node)
+        {
+            CRASSERT(pIter->cbMsg);
+
+            rc = SSMR3PutU32(pSSM, pIter->cbMsg);
+            AssertRCReturn(rc, rc);
+
+            rc = SSMR3PutMem(pSSM, &pIter->Msg, pIter->cbMsg);
+            AssertRCReturn(rc, rc);
+        }
+
+        rc = SSMR3PutU32(pSSM, 0);
+        AssertRCReturn(rc, rc);
+    }
+
+    rc = SSMR3PutU32(pSSM, 0);
+    AssertRCReturn(rc, rc);
+
+    return VINF_SUCCESS;
+}
+
+int crServerPendLoadState(PSSMHANDLE pSSM, uint32_t u32Version)
+{
+    int rc;
+    uint32_t u32;
+    CRClient *pClient;
+
+    if (u32Version < SHCROGL_SSM_VERSION_WITH_PEND_CMD_INFO)
+        return VINF_SUCCESS;
+
+    rc = SSMR3GetU32(pSSM, &u32);
+    AssertRCReturn(rc, rc);
+
+    if (!u32)
+        return VINF_SUCCESS;
+
+    do {
+        rc = crVBoxServerClientGet(u32, &pClient);
+        AssertRCReturn(rc, rc);
+
+        for(;;)
+        {
+            CR_SERVER_PENDING_MSG *pMsg;
+
+            rc = SSMR3GetU32(pSSM, &u32);
+            AssertRCReturn(rc, rc);
+
+            if (!u32)
+                break;
+
+            pMsg = (CR_SERVER_PENDING_MSG*)RTMemAlloc(u32 + RT_UOFFSETOF(CR_SERVER_PENDING_MSG, Msg));
+            if (!pMsg)
+            {
+                WARN(("RTMemAlloc failed"));
+                return VERR_NO_MEMORY;
+            }
+
+            pMsg->cbMsg = u32;
+            rc = SSMR3GetMem(pSSM, &pMsg->Msg, u32);
+            AssertRCReturn(rc, rc);
+
+            RTListAppend(&pClient->conn->PendingMsgList, &pMsg->Node);
+        }
+
+        rc = SSMR3GetU32(pSSM, &u32);
+        AssertRCReturn(rc, rc);
+    } while (u32);
+
+    rc = SSMR3GetU32(pSSM, &u32);
+    AssertRCReturn(rc, rc);
+
+    return VINF_SUCCESS;
+}
+
+static void crServerPendProcess(CRConnection *conn)
+{
+    CR_SERVER_PENDING_MSG *pIter, *pNext;
+
+    cr_server.fProcessingPendedCommands = GL_TRUE;
+
+    RTListForEachSafe(&conn->PendingMsgList, pIter, pNext, CR_SERVER_PENDING_MSG, Node)
+    {
+        CRMessage *msg = &pIter->Msg;
+        const CRMessageOpcodes *msg_opcodes;
+        int opcodeBytes;
+        const uint8_t *data_ptr, *data_ptr_end;
+
+        RTListNodeRemove(&pIter->Node);
+
+        CRASSERT(msg->header.type == CR_MESSAGE_OPCODES);
+
+        msg_opcodes = (const CRMessageOpcodes *) msg;
+        opcodeBytes = (msg_opcodes->numOpcodes + 3) & ~0x03;
+
+        data_ptr = (const uint8_t *) msg_opcodes + sizeof (CRMessageOpcodes) + opcodeBytes;
+        data_ptr_end = (const uint8_t *)msg_opcodes + pIter->cbMsg;
+
+        CrUnpackerState UnpackerState;
+        UnpackerState.pbOpcodes        = data_ptr - 1;
+        UnpackerState.cOpcodes         = msg_opcodes->numOpcodes;
+        UnpackerState.pbUnpackData     = data_ptr;
+        UnpackerState.cbUnpackDataLeft = data_ptr - data_ptr_end;
+        UnpackerState.pReturnPtr       = &cr_server.return_ptr;
+        UnpackerState.pWritebackPtr    = &cr_server.writeback_ptr;
+        UnpackerState.pDispatchTbl     = &(cr_server.dispatch);
+        UnpackerState.rcUnpack         = VINF_SUCCESS;
+
+        cr_server.pUnpackerState = &UnpackerState;
+        crUnpack(&UnpackerState);
+        cr_server.pUnpackerState = NULL;
+        RTMemFree(pIter);
+    }
+
+    cr_server.fProcessingPendedCommands = GL_FALSE;
+}
+
+/**
+ * This function takes the given message (which should be a buffer of
+ * rendering commands) and executes it.
+ */
+static void
+crServerDispatchMessage(CRConnection *conn, CRMessage *msg, int cbMsg)
+{
+    const CRMessageOpcodes *msg_opcodes;
+    int opcodeBytes;
+    const uint8_t *data_ptr, *data_ptr_end;
+#ifdef VBOX_WITH_CRHGSMI
+    PCRVBOXHGSMI_CMDDATA pCmdData = NULL;
+#endif
+    CR_UNPACK_BUFFER_TYPE enmType;
+    bool fUnpack = true;
+
+    if (msg->header.type == CR_MESSAGE_REDIR_PTR)
+    {
+#ifdef VBOX_WITH_CRHGSMI
+        pCmdData = &msg->redirptr.CmdData;
+#endif
+        msg = (CRMessage *) msg->redirptr.pMessage;
+    }
+
+    CRASSERT(msg->header.type == CR_MESSAGE_OPCODES);
+
+    msg_opcodes = (const CRMessageOpcodes *) msg;
+    opcodeBytes = (msg_opcodes->numOpcodes + 3) & ~0x03;
+
+#ifdef VBOXCR_LOGFPS
+    CRASSERT(cr_server.curClient && cr_server.curClient->conn && cr_server.curClient->conn->id == msg->header.conn_id);
+    cr_server.curClient->conn->opcodes_count += msg_opcodes->numOpcodes;
+#endif
+
+    data_ptr = (const uint8_t *) msg_opcodes + sizeof(CRMessageOpcodes) + opcodeBytes;
+    data_ptr_end = (const uint8_t *)msg_opcodes + cbMsg; // Pointer to the first byte after message data
+
+    enmType = crUnpackGetBufferType(data_ptr - 1,             /* first command's opcode */
+                msg_opcodes->numOpcodes  /* how many opcodes */);
+    switch (enmType)
+    {
+        case CR_UNPACK_BUFFER_TYPE_GENERIC:
+        {
+            if (RTListIsEmpty(&conn->PendingMsgList))
+                break;
+
+            if (RT_SUCCESS(crServerPendMsg(conn, msg, cbMsg)))
+            {
+                fUnpack = false;
+                break;
+            }
+
+            WARN(("crServerPendMsg failed"));
+            crServerPendProcess(conn);
+            break;
+        }
+        case CR_UNPACK_BUFFER_TYPE_CMDBLOCK_BEGIN:
+        {
+            if (RTListIsEmpty(&conn->PendingMsgList))
+            {
+                if (RT_SUCCESS(crServerPendMsg(conn, msg, cbMsg)))
+                {
+                    Assert(!RTListIsEmpty(&conn->PendingMsgList));
+                    fUnpack = false;
+                    break;
+                }
+                else
+                    WARN(("crServerPendMsg failed"));
+            }
+            else
+                WARN(("Pend List is NOT empty, drain the current list, and ignore this command"));
+
+            crServerPendProcess(conn);
+            break;
+        }
+        case CR_UNPACK_BUFFER_TYPE_CMDBLOCK_FLUSH: /* just flush for now */
+        {
+            CrPMgrClearRegionsGlobal(); /* clear regions to ensure we don't do MakeCurrent and friends */
+            crServerPendProcess(conn);
+            Assert(RTListIsEmpty(&conn->PendingMsgList));
+            break;
+        }
+        case CR_UNPACK_BUFFER_TYPE_CMDBLOCK_END:
+        {
+//            CRASSERT(!RTListIsEmpty(&conn->PendingMsgList));
+            crServerPendProcess(conn);
+            Assert(RTListIsEmpty(&conn->PendingMsgList));
+            break;
+        }
+        default:
+            WARN(("unsupported buffer type"));
+            break;
+    }
+
+    if (fUnpack)
+    {
+        CrUnpackerState UnpackerState;
+        UnpackerState.pbOpcodes        = data_ptr - 1;
+        UnpackerState.cOpcodes         = msg_opcodes->numOpcodes;
+        UnpackerState.pbUnpackData     = data_ptr;
+        UnpackerState.cbUnpackDataLeft = data_ptr - data_ptr_end;
+        UnpackerState.pReturnPtr       = &cr_server.return_ptr;
+        UnpackerState.pWritebackPtr    = &cr_server.writeback_ptr;
+        UnpackerState.pDispatchTbl     = &(cr_server.dispatch);
+        UnpackerState.rcUnpack         = VINF_SUCCESS;
+
+        cr_server.pUnpackerState = &UnpackerState;
+        crUnpack(&UnpackerState);
+        cr_server.pUnpackerState = NULL;
+    }
+
+#ifdef VBOX_WITH_CRHGSMI
+    if (pCmdData)
+    {
+        int rc = VINF_SUCCESS;
+        CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(pCmdData);
+        if (CRVBOXHGSMI_CMDDATA_IS_SETWB(pCmdData))
+        {
+            uint32_t cbWriteback = pCmdData->cbWriteback;
+            rc = crVBoxServerInternalClientRead(conn->pClient, (uint8_t*)pCmdData->pWriteback, &cbWriteback);
+            Assert(rc == VINF_SUCCESS || rc == VERR_BUFFER_OVERFLOW);
+            *pCmdData->pcbWriteback = cbWriteback;
+        }
+        VBOXCRHGSMI_CMD_CHECK_COMPLETE(pCmdData, rc);
+    }
+#endif
+}
+
+
+typedef enum
+{
+  CLIENT_GONE = 1, /* the client has disconnected */
+  CLIENT_NEXT = 2, /* we can advance to next client */
+  CLIENT_MORE = 3  /* we need to keep servicing current client */
+} ClientStatus;
+
+
+/**
+ * Process incoming/pending message for the given client (queue entry).
+ * \return CLIENT_GONE if this client has gone away/exited,
+ *         CLIENT_NEXT if we can advance to the next client
+ *         CLIENT_MORE if we have to process more messages for this client. 
+ */
+static ClientStatus
+crServerServiceClient(const RunQueue *qEntry)
+{
+    CRMessage *msg;
+    CRConnection *conn;
+
+    /* set current client pointer */
+    cr_server.curClient = qEntry->client;
+
+    conn = cr_server.run_queue->client->conn;
+
+    /* service current client as long as we can */
+    while (conn && conn->type != CR_NO_CONNECTION &&
+                 crNetNumMessages(conn) > 0) {
+        unsigned int len;
+
+        /*
+        crDebug("%d messages on %p",
+                        crNetNumMessages(conn), (void *) conn);
+        */
+
+        /* Don't use GetMessage, because we want to do our own crNetRecv() calls
+         * here ourself.
+         * Note that crNetPeekMessage() DOES remove the message from the queue
+         * if there is one.
+         */
+        len = crNetPeekMessage( conn, &msg );
+        CRASSERT(len > 0);
+        if (msg->header.type != CR_MESSAGE_OPCODES
+            && msg->header.type != CR_MESSAGE_REDIR_PTR) {
+            crError( "SPU %d sent me CRAP (type=0x%x)",
+                             cr_server.curClient->spu_id, msg->header.type );
+        }
+
+        /* Do the context switch here.  No sense in switching before we
+         * really have any work to process.  This is a no-op if we're
+         * not really switching contexts.
+         *
+         * XXX This isn't entirely sound.  The crStateMakeCurrent() call
+         * will compute the state difference and dispatch it using
+         * the head SPU's dispatch table.
+         *
+         * This is a problem if this is the first buffer coming in,
+         * and the head SPU hasn't had a chance to do a MakeCurrent()
+         * yet (likely because the MakeCurrent() command is in the
+         * buffer itself).
+         *
+         * At best, in this case, the functions are no-ops, and
+         * are essentially ignored by the SPU.  In the typical
+         * case, things aren't too bad; if the SPU just calls
+         * crState*() functions to update local state, everything
+         * will work just fine.
+         *
+         * In the worst (but unusual) case where a nontrivial
+         * SPU is at the head of a crserver's SPU chain (say,
+         * in a multiple-tiered "tilesort" arrangement, as
+         * seen in the "multitilesort.conf" configuration), the
+         * SPU may rely on state set during the MakeCurrent() that
+         * may not be present yet, because no MakeCurrent() has
+         * yet been dispatched.
+         *
+         * This headache will have to be revisited in the future;
+         * for now, SPUs that could head a crserver's SPU chain
+         * will have to detect the case that their functions are
+         * being called outside of a MakeCurrent(), and will have
+         * to handle the situation gracefully.  (This is currently
+         * the case with the "tilesort" SPU.)
+         */
+
+#if 0
+        crStateMakeCurrent( cr_server.curClient->currentCtx );
+#else
+        /* Check if the current window is the one that the client wants to
+         * draw into.  If not, dispatch a MakeCurrent to activate the proper
+         * window.
+         */
+        if (cr_server.curClient) {
+             int clientWindow = cr_server.curClient->currentWindow;
+             int clientContext = cr_server.curClient->currentContextNumber;
+             CRContextInfo *clientCtxInfo = cr_server.curClient->currentCtxInfo;
+             if (clientCtxInfo != cr_server.currentCtxInfo
+                     || clientWindow != cr_server.currentWindow
+                     || cr_server.bForceMakeCurrentOnClientSwitch) {
+                 crServerDispatchMakeCurrent(clientWindow, 0, clientContext);
+                 /*
+                 CRASSERT(cr_server.currentWindow == clientWindow);
+                 */
+             }
+        }
+#endif
+
+        /* Force scissor, viewport and projection matrix update in
+         * crServerSetOutputBounds().
+         */
+        cr_server.currentSerialNo = 0;
+
+        /* Commands get dispatched here */
+        crServerDispatchMessage( conn, msg, len );
+
+        crNetFree( conn, msg );
+
+        if (qEntry->blocked) {
+            /* Note/assert: we should not be inside a glBegin/End or glNewList/
+             * glEndList pair at this time!
+             */
+            CRASSERT(0);
+            return CLIENT_NEXT;
+        }
+
+    } /* while */
+
+    /*
+     * Check if client/connection is gone
+     */
+    if (!conn || conn->type == CR_NO_CONNECTION) {
+        crDebug("Delete client %p at %d", cr_server.run_queue->client, __LINE__);
+        crServerDeleteClient( cr_server.run_queue->client );
+        return CLIENT_GONE;
+    }
+
+    /*
+     * Determine if we can advance to next client.
+     * If we're currently inside a glBegin/End primitive or building a display
+     * list we can't service another client until we're done with the
+     * primitive/list.
+     */
+    if (crServerClientInBeginEnd(cr_server.curClient)) {
+        /* The next message has to come from the current client's connection. */
+        CRASSERT(!qEntry->blocked);
+        return CLIENT_MORE;
+    }
+    else {
+        /* get next client */
+        return CLIENT_NEXT;
+    }
+}
+
+
+
+/**
+ * Check if any of the clients need servicing.
+ * If so, service one client and return.
+ * Else, just return.
+ */
+void
+crServerServiceClients(void)
+{
+    RunQueue *q;
+
+    q = getNextClient(GL_FALSE); /* don't block */
+    while (q) 
+    {
+        ClientStatus stat = crServerServiceClient(q);
+        if (stat == CLIENT_NEXT && cr_server.run_queue->next) {
+            /* advance to next client */
+            cr_server.run_queue = cr_server.run_queue->next;
+        }
+        q = getNextClient(GL_FALSE);
+    }
+}
+
+
+
+
+/**
+ * Main crserver loop.  Service connections from all connected clients.
+ * XXX add a config option to specify whether the crserver
+ * should exit when there's no more clients.
+ */
+void
+crServerSerializeRemoteStreams(void)
+{
+    /*MSG msg;*/
+
+    while (cr_server.run_queue)
+    {
+        crServerServiceClients();
+        /*if (PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
+        {
+            if (msg.message == WM_QUIT)
+            {
+                PostQuitMessage((int)msg.wParam);
+                break;
+            }
+            TranslateMessage( &msg );
+            DispatchMessage( &msg );
+        }*/
+    }
+}
+
+
+/**
+ * This will be called by the network layer when it's received a new message.
+ */
+int
+crServerRecv( CRConnection *conn, CRMessage *msg, unsigned int len )
+{
+    CRMessage *pRealMsg;
+    (void) len;
+
+    pRealMsg = (msg->header.type!=CR_MESSAGE_REDIR_PTR) ? msg : (CRMessage*) msg->redirptr.pMessage;
+
+    switch( pRealMsg->header.type )
+    {
+        /* Called when using multiple threads */
+        case CR_MESSAGE_NEWCLIENT:
+            crServerAddNewClient();
+            return 1; /* msg handled */
+        default:
+            /*crWarning( "Why is the crserver getting a message of type 0x%x?",
+                msg->header.type ); */
+            ;
+    }
+    return 0; /* not handled */
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_texture.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_texture.c	(revision 78189)
+++ 	(revision )
@@ -1,327 +1,0 @@
-/* $Id$ */
-/** @file
- * VBox crOpenGL - teximage functions.
- */
-
-/*
- * Copyright (C) 2010-2019 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#include "chromium.h"
-#include "cr_error.h"
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_mem.h"
-
-#define CR_NOTHING()
-
-#define CR_CHECKPTR(name)                                   \
-    if (!realptr)                                           \
-    {                                                       \
-        crWarning(#name " with NULL ptr, ignored!");        \
-        return;                                             \
-    }
-
-#if !defined(CR_STATE_NO_TEXTURE_IMAGE_STORE)
-# define CR_FIXPTR() (uintptr_t) realptr += (uintptr_t) cr_server.head_spu->dispatch_table.MapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_READ_ONLY_ARB)
-#else
-# define CR_FIXPTR()
-#endif
-
-#if defined(CR_ARB_pixel_buffer_object)
-# define CR_CHECKBUFFER(name, checkptr)                     \
-    if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))   \
-    {                                                       \
-        CR_FIXPTR();                                        \
-    }                                                       \
-    else                                                    \
-    {                                                       \
-        checkptr                                            \
-    }
-#else
-# define CR_CHECKBUFFER(name, checkptr) checkptr
-#endif
-
-#if defined(CR_ARB_pixel_buffer_object) && !defined(CR_STATE_NO_TEXTURE_IMAGE_STORE)
-# define CR_FINISHBUFFER()                                                                  \
-    if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))                                   \
-    {                                                                                       \
-        if (!cr_server.head_spu->dispatch_table.UnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB)) \
-        {                                                                                   \
-            crWarning("UnmapBufferARB failed");                                             \
-        }                                                                                   \
-    }
-#else
-#define CR_FINISHBUFFER()
-#endif
-
-#define CR_FUNC_SUBIMAGE(name, def, call, ptrname)          \
-void SERVER_DISPATCH_APIENTRY                               \
-crServerDispatch##name def                                  \
-{                                                           \
-    const GLvoid *realptr = ptrname;                        \
-    CR_CHECKBUFFER(name, CR_CHECKPTR(name))                 \
-    crState##name call;                                     \
-    CR_FINISHBUFFER()                                       \
-    realptr = ptrname;                                      \
-    cr_server.head_spu->dispatch_table.name call;           \
-}
-
-#define CR_FUNC_IMAGE(name, def, call, ptrname)             \
-void SERVER_DISPATCH_APIENTRY                               \
-crServerDispatch##name def                                  \
-{                                                           \
-    const GLvoid *realptr = ptrname;                        \
-    CR_CHECKBUFFER(name, CR_NOTHING())                      \
-    crState##name call;                                     \
-    CR_FINISHBUFFER()                                       \
-    realptr = ptrname;                                      \
-    cr_server.head_spu->dispatch_table.name call;           \
-}
-
-#if defined(CR_ARB_texture_compression)
-CR_FUNC_SUBIMAGE(CompressedTexSubImage1DARB,
-    (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid * data),
-    (target, level, xoffset, width, format, imagesize, realptr), data)
-
-CR_FUNC_SUBIMAGE(CompressedTexSubImage2DARB,
-    (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid * data),
-    (target, level, xoffset, yoffset, width, height, format, imagesize, realptr), data)
-
-CR_FUNC_SUBIMAGE(CompressedTexSubImage3DARB,
-    (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid * data),
-    (target, level, xoffset, yoffset, zoffset, width, height, depth, format, imagesize, realptr), data)
-
-CR_FUNC_IMAGE(CompressedTexImage1DARB,
-    (GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid * data),
-    (target, level, internalFormat, width, border, imagesize, realptr), data)
-
-CR_FUNC_IMAGE(CompressedTexImage2DARB,
-    (GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid * data),
-    (target, level, internalFormat, width, height, border, imagesize, realptr), data)
-
-CR_FUNC_IMAGE(CompressedTexImage3DARB,
-    (GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid * data),
-    (target, level, internalFormat, width, height, depth, border, imagesize, realptr), data)
-#endif
-
-CR_FUNC_SUBIMAGE(TexSubImage1D,
-    (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels),
-    (target, level, xoffset, width, format, type, realptr), pixels)
-
-CR_FUNC_SUBIMAGE(TexSubImage2D,
-    (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels),
-    (target, level, xoffset, yoffset, width, height, format, type, realptr), pixels)
-
-CR_FUNC_SUBIMAGE(TexSubImage3D,
-    (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels),
-    (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, realptr), pixels)
-
-CR_FUNC_IMAGE(TexImage1D,
-    (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
-    (target, level, internalFormat, width, border, format, type, realptr), pixels)
-
-CR_FUNC_IMAGE(TexImage2D,
-    (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
-    (target, level, internalFormat, width, height, border, format, type, realptr), pixels)
-
-CR_FUNC_IMAGE(TexImage3D,
-    (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
-    (target, level, internalFormat, width, height, depth, border, format, type, realptr), pixels)
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchTexEnvf( GLenum target, GLenum pname, GLfloat param )
-{
-    crStateTexEnvf( target, pname, param );
-    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
-        CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.TexEnvf( target, pname, param ););
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchTexEnvfv( GLenum target, GLenum pname, const GLfloat * params )
-{
-    crStateTexEnvfv( target, pname, params );
-    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
-        CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.TexEnvfv( target, pname, params ););
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchTexEnvi( GLenum target, GLenum pname, GLint param )
-{
-    crStateTexEnvi( target, pname, param );
-    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
-        CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.TexEnvi( target, pname, param ););
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchTexEnviv( GLenum target, GLenum pname, const GLint * params )
-{
-    crStateTexEnviv( target, pname, params );
-    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
-        CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.TexEnviv( target, pname, params ););
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetTexEnvfv( GLenum target, GLenum pname, GLfloat * params )
-{
-    unsigned int cComponents = 0;
-    GLfloat local_params[4] = {0};
-    (void) params;
-    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
-        cr_server.head_spu->dispatch_table.GetTexEnvfv( target, pname, local_params );
-    else
-        crStateGetTexEnvfv( target, pname, local_params );
-
-    cComponents = RT_MIN(crStateHlpComponentsCount(pname), RT_ELEMENTS(local_params));
-    crServerReturnValue( &(local_params[0]), cComponents*sizeof (GLfloat) );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchGetTexEnviv( GLenum target, GLenum pname, GLint * params )
-{
-    unsigned int cComponents = 0;
-    GLint local_params[4] = {0};
-    (void) params;
-    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
-        cr_server.head_spu->dispatch_table.GetTexEnviv( target, pname, local_params );
-    else
-        crStateGetTexEnviv( target, pname, local_params );
-
-    cComponents = RT_MIN(crStateHlpComponentsCount(pname), RT_ELEMENTS(local_params));
-    crServerReturnValue( &(local_params[0]), cComponents*sizeof (GLint) );
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchBindTexture( GLenum target, GLuint texture )
-{
-    crStateBindTexture( target, texture );
-    cr_server.head_spu->dispatch_table.BindTexture(target, crStateGetTextureHWID(texture));
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteTextures( GLsizei n, const GLuint *textures)
-{
-    GLuint *newTextures;
-    GLint i;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchDeleteTextures: parameter 'n' is out of range");
-        return;
-    }
-
-    newTextures = (GLuint *)crAlloc(n * sizeof(GLuint));
-
-    if (!newTextures)
-    {
-        crError("crServerDispatchDeleteTextures: out of memory");
-        return;
-    }
-
-    for (i = 0; i < n; i++)
-    {
-        newTextures[i] = crStateGetTextureHWID(textures[i]);
-    }
-
-//    for (i = 0; i < n; ++i)
-//    {
-//        crDebug("DeleteTexture: %d, pid %d, ctx %d", textures[i], (uint32_t)cr_server.curClient->pid, cr_server.currentCtxInfo->pContext->id);
-//    }
-
-
-    crStateDeleteTextures(n, textures);
-    cr_server.head_spu->dispatch_table.DeleteTextures(n, newTextures);
-    crFree(newTextures);
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchPrioritizeTextures( GLsizei n, const GLuint * textures, const GLclampf * priorities )
-{
-    GLuint *newTextures;
-    GLint i;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchPrioritizeTextures: parameter 'n' is out of range");
-        return;
-    }
-
-    newTextures = (GLuint *)crAlloc(n * sizeof(GLuint));
-
-    if (!newTextures)
-    {
-        crError("crServerDispatchPrioritizeTextures: out of memory");
-        return;
-    }
-
-    crStatePrioritizeTextures(n, textures, priorities);
-
-    for (i = 0; i < n; i++)
-    {
-        newTextures[i] = crStateGetTextureHWID(textures[i]);
-    }
-
-    cr_server.head_spu->dispatch_table.PrioritizeTextures(n, newTextures, priorities);
-    crFree(newTextures);
-}
-
-
-/** @todo will fail for textures loaded from snapshot */
-GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsTexture( GLuint texture )
-{
-    GLboolean retval;
-    retval = cr_server.head_spu->dispatch_table.IsTexture(crStateGetTextureHWID(texture));
-    crServerReturnValue( &retval, sizeof(retval) );
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
-
-
-GLboolean SERVER_DISPATCH_APIENTRY
-crServerDispatchAreTexturesResident(GLsizei n, const GLuint *textures,
-                                    GLboolean *residences)
-{
-    GLboolean retval = GL_FALSE;
-    GLsizei i;
-    GLboolean *res;
-    GLuint *textures2;
-    (void) residences;
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
-    {
-        crError("crServerDispatchAreTexturesResident: parameter 'n' is out of range");
-        return GL_FALSE;
-    }
-
-    res = (GLboolean *)crCalloc(n * sizeof(GLboolean));
-    if (!res)
-    {
-        crError("crServerDispatchAreTexturesResident: out of memory");
-        return GL_FALSE;
-    }
-
-    textures2 = (GLuint *)crAlloc(n * sizeof(GLuint));
-
-    if (!textures2)
-    {
-        crError("crServerDispatchAreTexturesResident: out of memory");
-        crFree(res);
-        return GL_FALSE;
-    }
-
-    for (i = 0; i < n; i++)
-    {
-        textures2[i] = crStateGetTextureHWID(textures[i]);
-    }
-    retval = cr_server.head_spu->dispatch_table.AreTexturesResident(n, textures2, res);
-
-    crFree(textures2);
-
-    crServerReturnValue(res, n * sizeof(GLboolean));
-
-    crFree(res);
-
-    return retval; /* WILL PROBABLY BE IGNORED */
-}
-
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_texture.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_texture.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_texture.cpp	(revision 78190)
@@ -0,0 +1,327 @@
+/* $Id$ */
+/** @file
+ * VBox crOpenGL - teximage functions.
+ */
+
+/*
+ * Copyright (C) 2010-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include "chromium.h"
+#include "cr_error.h"
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_mem.h"
+
+#define CR_NOTHING()
+
+#define CR_CHECKPTR(name)                                   \
+    if (!realptr)                                           \
+    {                                                       \
+        crWarning(#name " with NULL ptr, ignored!");        \
+        return;                                             \
+    }
+
+#if !defined(CR_STATE_NO_TEXTURE_IMAGE_STORE)
+# define CR_FIXPTR() (uintptr_t) realptr += (uintptr_t) cr_server.head_spu->dispatch_table.MapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_READ_ONLY_ARB)
+#else
+# define CR_FIXPTR()
+#endif
+
+#if defined(CR_ARB_pixel_buffer_object)
+# define CR_CHECKBUFFER(name, checkptr)                     \
+    if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))   \
+    {                                                       \
+        CR_FIXPTR();                                        \
+    }                                                       \
+    else                                                    \
+    {                                                       \
+        checkptr                                            \
+    }
+#else
+# define CR_CHECKBUFFER(name, checkptr) checkptr
+#endif
+
+#if defined(CR_ARB_pixel_buffer_object) && !defined(CR_STATE_NO_TEXTURE_IMAGE_STORE)
+# define CR_FINISHBUFFER()                                                                  \
+    if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))                                   \
+    {                                                                                       \
+        if (!cr_server.head_spu->dispatch_table.UnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB)) \
+        {                                                                                   \
+            crWarning("UnmapBufferARB failed");                                             \
+        }                                                                                   \
+    }
+#else
+#define CR_FINISHBUFFER()
+#endif
+
+#define CR_FUNC_SUBIMAGE(name, def, call, ptrname)          \
+void SERVER_DISPATCH_APIENTRY                               \
+crServerDispatch##name def                                  \
+{                                                           \
+    const GLvoid *realptr = ptrname;                        \
+    CR_CHECKBUFFER(name, CR_CHECKPTR(name))                 \
+    crState##name call;                                     \
+    CR_FINISHBUFFER()                                       \
+    realptr = ptrname;                                      \
+    cr_server.head_spu->dispatch_table.name call;           \
+}
+
+#define CR_FUNC_IMAGE(name, def, call, ptrname)             \
+void SERVER_DISPATCH_APIENTRY                               \
+crServerDispatch##name def                                  \
+{                                                           \
+    const GLvoid *realptr = ptrname;                        \
+    CR_CHECKBUFFER(name, CR_NOTHING())                      \
+    crState##name call;                                     \
+    CR_FINISHBUFFER()                                       \
+    realptr = ptrname;                                      \
+    cr_server.head_spu->dispatch_table.name call;           \
+}
+
+#if defined(CR_ARB_texture_compression)
+CR_FUNC_SUBIMAGE(CompressedTexSubImage1DARB,
+    (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid * data),
+    (target, level, xoffset, width, format, imagesize, realptr), data)
+
+CR_FUNC_SUBIMAGE(CompressedTexSubImage2DARB,
+    (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid * data),
+    (target, level, xoffset, yoffset, width, height, format, imagesize, realptr), data)
+
+CR_FUNC_SUBIMAGE(CompressedTexSubImage3DARB,
+    (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid * data),
+    (target, level, xoffset, yoffset, zoffset, width, height, depth, format, imagesize, realptr), data)
+
+CR_FUNC_IMAGE(CompressedTexImage1DARB,
+    (GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid * data),
+    (target, level, internalFormat, width, border, imagesize, realptr), data)
+
+CR_FUNC_IMAGE(CompressedTexImage2DARB,
+    (GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid * data),
+    (target, level, internalFormat, width, height, border, imagesize, realptr), data)
+
+CR_FUNC_IMAGE(CompressedTexImage3DARB,
+    (GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid * data),
+    (target, level, internalFormat, width, height, depth, border, imagesize, realptr), data)
+#endif
+
+CR_FUNC_SUBIMAGE(TexSubImage1D,
+    (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels),
+    (target, level, xoffset, width, format, type, realptr), pixels)
+
+CR_FUNC_SUBIMAGE(TexSubImage2D,
+    (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels),
+    (target, level, xoffset, yoffset, width, height, format, type, realptr), pixels)
+
+CR_FUNC_SUBIMAGE(TexSubImage3D,
+    (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels),
+    (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, realptr), pixels)
+
+CR_FUNC_IMAGE(TexImage1D,
+    (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
+    (target, level, internalFormat, width, border, format, type, realptr), pixels)
+
+CR_FUNC_IMAGE(TexImage2D,
+    (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
+    (target, level, internalFormat, width, height, border, format, type, realptr), pixels)
+
+CR_FUNC_IMAGE(TexImage3D,
+    (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels),
+    (target, level, internalFormat, width, height, depth, border, format, type, realptr), pixels)
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchTexEnvf( GLenum target, GLenum pname, GLfloat param )
+{
+    crStateTexEnvf( target, pname, param );
+    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
+        CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.TexEnvf( target, pname, param ););
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchTexEnvfv( GLenum target, GLenum pname, const GLfloat * params )
+{
+    crStateTexEnvfv( target, pname, params );
+    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
+        CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.TexEnvfv( target, pname, params ););
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchTexEnvi( GLenum target, GLenum pname, GLint param )
+{
+    crStateTexEnvi( target, pname, param );
+    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
+        CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.TexEnvi( target, pname, param ););
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchTexEnviv( GLenum target, GLenum pname, const GLint * params )
+{
+    crStateTexEnviv( target, pname, params );
+    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
+        CR_GLERR_CHECK(cr_server.head_spu->dispatch_table.TexEnviv( target, pname, params ););
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetTexEnvfv( GLenum target, GLenum pname, GLfloat * params )
+{
+    unsigned int cComponents = 0;
+    GLfloat local_params[4] = {0};
+    (void) params;
+    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
+        cr_server.head_spu->dispatch_table.GetTexEnvfv( target, pname, local_params );
+    else
+        crStateGetTexEnvfv( target, pname, local_params );
+
+    cComponents = RT_MIN(crStateHlpComponentsCount(pname), RT_ELEMENTS(local_params));
+    crServerReturnValue( &(local_params[0]), cComponents*sizeof (GLfloat) );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchGetTexEnviv( GLenum target, GLenum pname, GLint * params )
+{
+    unsigned int cComponents = 0;
+    GLint local_params[4] = {0};
+    (void) params;
+    if (GL_POINT_SPRITE != target && pname != GL_COORD_REPLACE)
+        cr_server.head_spu->dispatch_table.GetTexEnviv( target, pname, local_params );
+    else
+        crStateGetTexEnviv( target, pname, local_params );
+
+    cComponents = RT_MIN(crStateHlpComponentsCount(pname), RT_ELEMENTS(local_params));
+    crServerReturnValue( &(local_params[0]), cComponents*sizeof (GLint) );
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchBindTexture( GLenum target, GLuint texture )
+{
+    crStateBindTexture( target, texture );
+    cr_server.head_spu->dispatch_table.BindTexture(target, crStateGetTextureHWID(texture));
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteTextures( GLsizei n, const GLuint *textures)
+{
+    GLuint *newTextures;
+    GLint i;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchDeleteTextures: parameter 'n' is out of range");
+        return;
+    }
+
+    newTextures = (GLuint *)crAlloc(n * sizeof(GLuint));
+
+    if (!newTextures)
+    {
+        crError("crServerDispatchDeleteTextures: out of memory");
+        return;
+    }
+
+    for (i = 0; i < n; i++)
+    {
+        newTextures[i] = crStateGetTextureHWID(textures[i]);
+    }
+
+//    for (i = 0; i < n; ++i)
+//    {
+//        crDebug("DeleteTexture: %d, pid %d, ctx %d", textures[i], (uint32_t)cr_server.curClient->pid, cr_server.currentCtxInfo->pContext->id);
+//    }
+
+
+    crStateDeleteTextures(n, textures);
+    cr_server.head_spu->dispatch_table.DeleteTextures(n, newTextures);
+    crFree(newTextures);
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchPrioritizeTextures( GLsizei n, const GLuint * textures, const GLclampf * priorities )
+{
+    GLuint *newTextures;
+    GLint i;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchPrioritizeTextures: parameter 'n' is out of range");
+        return;
+    }
+
+    newTextures = (GLuint *)crAlloc(n * sizeof(GLuint));
+
+    if (!newTextures)
+    {
+        crError("crServerDispatchPrioritizeTextures: out of memory");
+        return;
+    }
+
+    crStatePrioritizeTextures(n, textures, priorities);
+
+    for (i = 0; i < n; i++)
+    {
+        newTextures[i] = crStateGetTextureHWID(textures[i]);
+    }
+
+    cr_server.head_spu->dispatch_table.PrioritizeTextures(n, newTextures, priorities);
+    crFree(newTextures);
+}
+
+
+/** @todo will fail for textures loaded from snapshot */
+GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsTexture( GLuint texture )
+{
+    GLboolean retval;
+    retval = cr_server.head_spu->dispatch_table.IsTexture(crStateGetTextureHWID(texture));
+    crServerReturnValue( &retval, sizeof(retval) );
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
+
+
+GLboolean SERVER_DISPATCH_APIENTRY
+crServerDispatchAreTexturesResident(GLsizei n, const GLuint *textures,
+                                    GLboolean *residences)
+{
+    GLboolean retval = GL_FALSE;
+    GLsizei i;
+    GLboolean *res;
+    GLuint *textures2;
+    (void) residences;
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
+    {
+        crError("crServerDispatchAreTexturesResident: parameter 'n' is out of range");
+        return GL_FALSE;
+    }
+
+    res = (GLboolean *)crCalloc(n * sizeof(GLboolean));
+    if (!res)
+    {
+        crError("crServerDispatchAreTexturesResident: out of memory");
+        return GL_FALSE;
+    }
+
+    textures2 = (GLuint *)crAlloc(n * sizeof(GLuint));
+
+    if (!textures2)
+    {
+        crError("crServerDispatchAreTexturesResident: out of memory");
+        crFree(res);
+        return GL_FALSE;
+    }
+
+    for (i = 0; i < n; i++)
+    {
+        textures2[i] = crStateGetTextureHWID(textures[i]);
+    }
+    retval = cr_server.head_spu->dispatch_table.AreTexturesResident(n, textures2, res);
+
+    crFree(textures2);
+
+    crServerReturnValue(res, n * sizeof(GLboolean));
+
+    crFree(res);
+
+    return retval; /* WILL PROBABLY BE IGNORED */
+}
+
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_viewport.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_viewport.c	(revision 78189)
+++ 	(revision )
@@ -1,288 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "server_dispatch.h"
-#include "server.h"
-#include "cr_error.h"
-#include "state/cr_statetypes.h"
-
-
-static const CRmatrix identity_matrix = { 
-	1.0, 0.0, 0.0, 0.0,
-	0.0, 1.0, 0.0, 0.0,
-	0.0, 0.0, 1.0, 0.0,
-	0.0, 0.0, 0.0, 1.0
-};
-
-
-/*
- * Clip the rectangle q against the given image window.
- */
-static void
-crServerViewportClipToWindow( const CRrecti *imagewindow,	CRrecti *q) 
-{
-	if (q->x1 < imagewindow->x1) q->x1 = imagewindow->x1;
-	if (q->x1 > imagewindow->x2) q->x1 = imagewindow->x2;
-
-	if (q->x2 > imagewindow->x2) q->x2 = imagewindow->x2;
-	if (q->x2 < imagewindow->x1) q->x2 = imagewindow->x1;
-	
-	if (q->y1 < imagewindow->y1) q->y1 = imagewindow->y1;
-	if (q->y1 > imagewindow->y2) q->y1 = imagewindow->y2;
-
-	if (q->y2 > imagewindow->y2) q->y2 = imagewindow->y2;
-	if (q->y2 < imagewindow->y1) q->y2 = imagewindow->y1;
-}
-
-
-/*
- * Translate the rectangle q from the image window space to the outputwindow
- * space.
- */
-static void
-crServerConvertToOutput( const CRrecti *imagewindow,
-												 const CRrecti *outputwindow,
-												 CRrecti *q )
-{
-	q->x1 = q->x1 - imagewindow->x1 + outputwindow->x1;
-	q->x2 = q->x2 - imagewindow->x2 + outputwindow->x2;
-	q->y1 = q->y1 - imagewindow->y1 + outputwindow->y1;
-	q->y2 = q->y2 - imagewindow->y2 + outputwindow->y2;
-}
-
-
-/*
- * Compute clipped image window, scissor, viewport and base projection
- * info for each tile in the mural.
- * Need to call this when either the viewport or mural is changed.
- */
-void
-crServerComputeViewportBounds(const CRViewportState *v, CRMuralInfo *mural)
-{
-#if 0
-	static GLuint serialNo = 1;
-	int i;
-
-	for (i = 0; i < mural->numExtents; i++) {
-		CRExtent *extent = &mural->extents[i];
-		CRrecti q;
-
-		/* If the scissor is disabled set it to the whole output.
-		** We might as well use the actual scissorTest rather than
-		** scissorValid - it never gets reset anyway.
-		*/
-		if (!v->scissorTest)
-		{
-			extent->scissorBox = extent->outputwindow;
-		} 
-		else 
-		{
-			q.x1 = v->scissorX;
-			q.x2 = v->scissorX + v->scissorW;
-			q.y1 = v->scissorY;
-			q.y2 = v->scissorY + v->scissorH;
-
-			crServerViewportClipToWindow(&(extent->imagewindow), &q);
-			crServerConvertToOutput(&(extent->imagewindow),
-															&(extent->outputwindow), &q);
-			extent->scissorBox = q;
-		}
-
-		/* if the viewport is not valid,
-		** set it to the entire output.
-		*/
-		if (!v->viewportValid) 
-		{
-			extent->clippedImagewindow = extent->imagewindow;
-			extent->viewport = extent->outputwindow;
-		}
-		else
-		{
-			q.x1 = v->viewportX;
-			q.x2 = v->viewportX + v->viewportW;
-			q.y1 = v->viewportY;
-			q.y2 = v->viewportY + v->viewportH;
-
-			/* This is where the viewport gets clamped to the max size. */
-			crServerViewportClipToWindow(&(extent->imagewindow), &q);
-
-			extent->clippedImagewindow = q;
-
-			crServerConvertToOutput(&(extent->imagewindow),
-															&(extent->outputwindow), &q);
-
-			extent->viewport = q;
-		}
-
-		/*
-		** Now, compute the base projection.
-		*/
-		if (extent->clippedImagewindow.x1 == extent->clippedImagewindow.x2 ||
-				extent->clippedImagewindow.y1 == extent->clippedImagewindow.y2) {
-			/* zero-area extent, use identity matrix (doesn't really matter) */
-			extent->baseProjection = identity_matrix;
-		}
-		else
-		{
-			const int vpx = v->viewportX;
-			const int vpy = v->viewportY;
-			const int vpw = v->viewportW;
-			const int vph = v->viewportH;
-			GLfloat xscale, yscale;
-			GLfloat xtrans, ytrans;
-			CRrectf p;
-
-			/* 
-			 * We need to take account of the current viewport parameters,
-			 * and they are passed to this function as x, y, w, h.
-			 * In the default case (from main.c) we pass the the
-			 * full muralsize of 0, 0, width, height
-			 */
-			p.x1 = (GLfloat) (extent->clippedImagewindow.x1 - vpx) / vpw;
-			p.y1 = (GLfloat) (extent->clippedImagewindow.y1 - vpy) / vph;
-			p.x2 = (GLfloat) (extent->clippedImagewindow.x2 - vpx) / vpw;
-			p.y2 = (GLfloat) (extent->clippedImagewindow.y2 - vpy) / vph;
-
-			/* XXX not sure this clamping is really need anymore
-			 */
-			if (p.x1 < 0.0) { 
-				p.x1 = 0.0;
-				if (p.x2 > 1.0) p.x2 = 1.0;
-			}
-
-			if (p.y1 < 0.0) {
-				p.y1 = 0.0; 
-				if (p.y2 > 1.0) p.y2 = 1.0;
-			}
-
-			/* Rescale [0,1] -> [-1,1] */
-			p.x1 = p.x1 * 2.0f - 1.0f;
-			p.x2 = p.x2 * 2.0f - 1.0f;
-			p.y1 = p.y1 * 2.0f - 1.0f;
-			p.y2 = p.y2 * 2.0f - 1.0f;
-
-			xscale = 2.0f / (p.x2 - p.x1);
-			yscale = 2.0f / (p.y2 - p.y1);
-			xtrans = -(p.x2 + p.x1) / 2.0f;
-			ytrans = -(p.y2 + p.y1) / 2.0f;
-
-			CRASSERT(xscale == xscale); /* NaN test */
-			CRASSERT(yscale == yscale);
-
-			extent->baseProjection = identity_matrix;
-			extent->baseProjection.m00 = xscale;
-			extent->baseProjection.m11 = yscale;
-			extent->baseProjection.m30 = xtrans * xscale;
-			extent->baseProjection.m31 = ytrans * yscale;
-		}
-
-		extent->serialNo = serialNo++;
-	}
-	mural->viewportValidated = GL_TRUE;
-#endif
-}
-
-
-/*
- * Issue the glScissor, glViewport and projection matrix needed for
- * rendering the tile specified by extNum.  We computed the scissor,
- * viewport and projection parameters above in crServerComputeViewportBounds.
- */
-void
-crServerSetOutputBounds( const CRMuralInfo *mural, int extNum )
-{
-#if 0
-	const CRExtent *extent = mural->extents + extNum;
-	CRASSERT(mural->viewportValidated);
-
-	/*
-	 * Serial Number info:
-	 * Everytime we compute new scissor, viewport, projection matrix info for
-	 * a tile, we give that tile a new serial number.
-	 * When we're about to render into a tile, we only update the scissor,
-	 * viewport and projection matrix if the tile's serial number doesn't match
-	 * the current serial number.  This avoids a _LOT_ of redundant calls to
-	 * those three functions.
-	 */
-	if (extent->serialNo != cr_server.currentSerialNo) {
-		cr_server.head_spu->dispatch_table.Scissor(extent->scissorBox.x1,
-																 extent->scissorBox.y1,
-																 extent->scissorBox.x2 - extent->scissorBox.x1,
-																 extent->scissorBox.y2 - extent->scissorBox.y1);
-
-		cr_server.head_spu->dispatch_table.Viewport(extent->viewport.x1,
-																 extent->viewport.y1,
-																 extent->viewport.x2 - extent->viewport.x1,
-																 extent->viewport.y2 - extent->viewport.y1);
-
-		crServerApplyBaseProjection(&(extent->baseProjection));
-		cr_server.currentSerialNo = extent->serialNo;
-	}		
-#endif
-}
-
-
-/*
- * Pre-multiply the current projection matrix with the current client's
- * base projection.  I.e.  P' = b * P.  Note that OpenGL's glMultMatrix
- * POST-multiplies.
- */
-void
-crServerApplyBaseProjection(const CRmatrix *baseProj)
-{
-	const CRmatrix *projMatrix;
-	if (cr_server.projectionOverride) {
-		int eye = crServerGetCurrentEye();
-		projMatrix = &cr_server.projectionMatrix[eye];
-	}
-	else
-		projMatrix = cr_server.curClient->currentCtxInfo->pContext->transform.projectionStack.top;
-
-	cr_server.head_spu->dispatch_table.PushAttrib( GL_TRANSFORM_BIT );
-	cr_server.head_spu->dispatch_table.MatrixMode( GL_PROJECTION );
-	cr_server.head_spu->dispatch_table.LoadMatrixf( (const GLfloat *) baseProj );
-	cr_server.head_spu->dispatch_table.MultMatrixf( cr_server.alignment_matrix );
-	cr_server.head_spu->dispatch_table.MultMatrixf( (const GLfloat *) projMatrix );
-	cr_server.head_spu->dispatch_table.PopAttrib();
-}
-
-
-void
-crServerApplyViewMatrix(const CRmatrix *view)
-{
-	const CRmatrix *modelview = cr_server.curClient->currentCtxInfo->pContext->transform.modelViewStack.top;
-
-	cr_server.head_spu->dispatch_table.PushAttrib( GL_TRANSFORM_BIT );
-	cr_server.head_spu->dispatch_table.MatrixMode( GL_MODELVIEW );
-	cr_server.head_spu->dispatch_table.LoadMatrixf( (const GLfloat *) view );
-	cr_server.head_spu->dispatch_table.MultMatrixf( (const GLfloat *) modelview );
-	cr_server.head_spu->dispatch_table.PopAttrib();
-}
-
-
-/*
- * Called via unpacker module.
- * Note: when there's a tilesort SPU upstream, the viewport dimensions
- * will typically match the mural size.  That is, the viewport dimensions
- * probably won't be the same values that the application issues.
- */
-void SERVER_DISPATCH_APIENTRY crServerDispatchViewport( GLint x, GLint y, GLsizei width, GLsizei height )
-{
-	CRMuralInfo *mural = cr_server.curClient->currentMural;
-	CRContext *ctx = crStateGetCurrent();
-
-	if (ctx->viewport.viewportX != x ||
-			ctx->viewport.viewportY != y ||
-			ctx->viewport.viewportW != width ||
-			ctx->viewport.viewportH != height) {
-		 /* Note -- If there are tiles, this will be overridden in the 
-			* process of decoding the BoundsInfo packet, so no worries. */
-		 crStateViewport( x, y, width, height );
-	}
-
-	/* always dispatch to be safe */
-	cr_server.head_spu->dispatch_table.Viewport( x, y, width, height );
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_viewport.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_viewport.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_viewport.cpp	(revision 78190)
@@ -0,0 +1,288 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "server_dispatch.h"
+#include "server.h"
+#include "cr_error.h"
+#include "state/cr_statetypes.h"
+
+
+static const CRmatrix identity_matrix = { 
+	1.0, 0.0, 0.0, 0.0,
+	0.0, 1.0, 0.0, 0.0,
+	0.0, 0.0, 1.0, 0.0,
+	0.0, 0.0, 0.0, 1.0
+};
+
+
+/*
+ * Clip the rectangle q against the given image window.
+ */
+static void
+crServerViewportClipToWindow( const CRrecti *imagewindow,	CRrecti *q) 
+{
+	if (q->x1 < imagewindow->x1) q->x1 = imagewindow->x1;
+	if (q->x1 > imagewindow->x2) q->x1 = imagewindow->x2;
+
+	if (q->x2 > imagewindow->x2) q->x2 = imagewindow->x2;
+	if (q->x2 < imagewindow->x1) q->x2 = imagewindow->x1;
+	
+	if (q->y1 < imagewindow->y1) q->y1 = imagewindow->y1;
+	if (q->y1 > imagewindow->y2) q->y1 = imagewindow->y2;
+
+	if (q->y2 > imagewindow->y2) q->y2 = imagewindow->y2;
+	if (q->y2 < imagewindow->y1) q->y2 = imagewindow->y1;
+}
+
+
+/*
+ * Translate the rectangle q from the image window space to the outputwindow
+ * space.
+ */
+static void
+crServerConvertToOutput( const CRrecti *imagewindow,
+												 const CRrecti *outputwindow,
+												 CRrecti *q )
+{
+	q->x1 = q->x1 - imagewindow->x1 + outputwindow->x1;
+	q->x2 = q->x2 - imagewindow->x2 + outputwindow->x2;
+	q->y1 = q->y1 - imagewindow->y1 + outputwindow->y1;
+	q->y2 = q->y2 - imagewindow->y2 + outputwindow->y2;
+}
+
+
+/*
+ * Compute clipped image window, scissor, viewport and base projection
+ * info for each tile in the mural.
+ * Need to call this when either the viewport or mural is changed.
+ */
+void
+crServerComputeViewportBounds(const CRViewportState *v, CRMuralInfo *mural)
+{
+#if 0
+	static GLuint serialNo = 1;
+	int i;
+
+	for (i = 0; i < mural->numExtents; i++) {
+		CRExtent *extent = &mural->extents[i];
+		CRrecti q;
+
+		/* If the scissor is disabled set it to the whole output.
+		** We might as well use the actual scissorTest rather than
+		** scissorValid - it never gets reset anyway.
+		*/
+		if (!v->scissorTest)
+		{
+			extent->scissorBox = extent->outputwindow;
+		} 
+		else 
+		{
+			q.x1 = v->scissorX;
+			q.x2 = v->scissorX + v->scissorW;
+			q.y1 = v->scissorY;
+			q.y2 = v->scissorY + v->scissorH;
+
+			crServerViewportClipToWindow(&(extent->imagewindow), &q);
+			crServerConvertToOutput(&(extent->imagewindow),
+															&(extent->outputwindow), &q);
+			extent->scissorBox = q;
+		}
+
+		/* if the viewport is not valid,
+		** set it to the entire output.
+		*/
+		if (!v->viewportValid) 
+		{
+			extent->clippedImagewindow = extent->imagewindow;
+			extent->viewport = extent->outputwindow;
+		}
+		else
+		{
+			q.x1 = v->viewportX;
+			q.x2 = v->viewportX + v->viewportW;
+			q.y1 = v->viewportY;
+			q.y2 = v->viewportY + v->viewportH;
+
+			/* This is where the viewport gets clamped to the max size. */
+			crServerViewportClipToWindow(&(extent->imagewindow), &q);
+
+			extent->clippedImagewindow = q;
+
+			crServerConvertToOutput(&(extent->imagewindow),
+															&(extent->outputwindow), &q);
+
+			extent->viewport = q;
+		}
+
+		/*
+		** Now, compute the base projection.
+		*/
+		if (extent->clippedImagewindow.x1 == extent->clippedImagewindow.x2 ||
+				extent->clippedImagewindow.y1 == extent->clippedImagewindow.y2) {
+			/* zero-area extent, use identity matrix (doesn't really matter) */
+			extent->baseProjection = identity_matrix;
+		}
+		else
+		{
+			const int vpx = v->viewportX;
+			const int vpy = v->viewportY;
+			const int vpw = v->viewportW;
+			const int vph = v->viewportH;
+			GLfloat xscale, yscale;
+			GLfloat xtrans, ytrans;
+			CRrectf p;
+
+			/* 
+			 * We need to take account of the current viewport parameters,
+			 * and they are passed to this function as x, y, w, h.
+			 * In the default case (from main.c) we pass the the
+			 * full muralsize of 0, 0, width, height
+			 */
+			p.x1 = (GLfloat) (extent->clippedImagewindow.x1 - vpx) / vpw;
+			p.y1 = (GLfloat) (extent->clippedImagewindow.y1 - vpy) / vph;
+			p.x2 = (GLfloat) (extent->clippedImagewindow.x2 - vpx) / vpw;
+			p.y2 = (GLfloat) (extent->clippedImagewindow.y2 - vpy) / vph;
+
+			/* XXX not sure this clamping is really need anymore
+			 */
+			if (p.x1 < 0.0) { 
+				p.x1 = 0.0;
+				if (p.x2 > 1.0) p.x2 = 1.0;
+			}
+
+			if (p.y1 < 0.0) {
+				p.y1 = 0.0; 
+				if (p.y2 > 1.0) p.y2 = 1.0;
+			}
+
+			/* Rescale [0,1] -> [-1,1] */
+			p.x1 = p.x1 * 2.0f - 1.0f;
+			p.x2 = p.x2 * 2.0f - 1.0f;
+			p.y1 = p.y1 * 2.0f - 1.0f;
+			p.y2 = p.y2 * 2.0f - 1.0f;
+
+			xscale = 2.0f / (p.x2 - p.x1);
+			yscale = 2.0f / (p.y2 - p.y1);
+			xtrans = -(p.x2 + p.x1) / 2.0f;
+			ytrans = -(p.y2 + p.y1) / 2.0f;
+
+			CRASSERT(xscale == xscale); /* NaN test */
+			CRASSERT(yscale == yscale);
+
+			extent->baseProjection = identity_matrix;
+			extent->baseProjection.m00 = xscale;
+			extent->baseProjection.m11 = yscale;
+			extent->baseProjection.m30 = xtrans * xscale;
+			extent->baseProjection.m31 = ytrans * yscale;
+		}
+
+		extent->serialNo = serialNo++;
+	}
+	mural->viewportValidated = GL_TRUE;
+#endif
+}
+
+
+/*
+ * Issue the glScissor, glViewport and projection matrix needed for
+ * rendering the tile specified by extNum.  We computed the scissor,
+ * viewport and projection parameters above in crServerComputeViewportBounds.
+ */
+void
+crServerSetOutputBounds( const CRMuralInfo *mural, int extNum )
+{
+#if 0
+	const CRExtent *extent = mural->extents + extNum;
+	CRASSERT(mural->viewportValidated);
+
+	/*
+	 * Serial Number info:
+	 * Everytime we compute new scissor, viewport, projection matrix info for
+	 * a tile, we give that tile a new serial number.
+	 * When we're about to render into a tile, we only update the scissor,
+	 * viewport and projection matrix if the tile's serial number doesn't match
+	 * the current serial number.  This avoids a _LOT_ of redundant calls to
+	 * those three functions.
+	 */
+	if (extent->serialNo != cr_server.currentSerialNo) {
+		cr_server.head_spu->dispatch_table.Scissor(extent->scissorBox.x1,
+																 extent->scissorBox.y1,
+																 extent->scissorBox.x2 - extent->scissorBox.x1,
+																 extent->scissorBox.y2 - extent->scissorBox.y1);
+
+		cr_server.head_spu->dispatch_table.Viewport(extent->viewport.x1,
+																 extent->viewport.y1,
+																 extent->viewport.x2 - extent->viewport.x1,
+																 extent->viewport.y2 - extent->viewport.y1);
+
+		crServerApplyBaseProjection(&(extent->baseProjection));
+		cr_server.currentSerialNo = extent->serialNo;
+	}		
+#endif
+}
+
+
+/*
+ * Pre-multiply the current projection matrix with the current client's
+ * base projection.  I.e.  P' = b * P.  Note that OpenGL's glMultMatrix
+ * POST-multiplies.
+ */
+void
+crServerApplyBaseProjection(const CRmatrix *baseProj)
+{
+	const CRmatrix *projMatrix;
+	if (cr_server.projectionOverride) {
+		int eye = crServerGetCurrentEye();
+		projMatrix = &cr_server.projectionMatrix[eye];
+	}
+	else
+		projMatrix = cr_server.curClient->currentCtxInfo->pContext->transform.projectionStack.top;
+
+	cr_server.head_spu->dispatch_table.PushAttrib( GL_TRANSFORM_BIT );
+	cr_server.head_spu->dispatch_table.MatrixMode( GL_PROJECTION );
+	cr_server.head_spu->dispatch_table.LoadMatrixf( (const GLfloat *) baseProj );
+	cr_server.head_spu->dispatch_table.MultMatrixf( cr_server.alignment_matrix );
+	cr_server.head_spu->dispatch_table.MultMatrixf( (const GLfloat *) projMatrix );
+	cr_server.head_spu->dispatch_table.PopAttrib();
+}
+
+
+void
+crServerApplyViewMatrix(const CRmatrix *view)
+{
+	const CRmatrix *modelview = cr_server.curClient->currentCtxInfo->pContext->transform.modelViewStack.top;
+
+	cr_server.head_spu->dispatch_table.PushAttrib( GL_TRANSFORM_BIT );
+	cr_server.head_spu->dispatch_table.MatrixMode( GL_MODELVIEW );
+	cr_server.head_spu->dispatch_table.LoadMatrixf( (const GLfloat *) view );
+	cr_server.head_spu->dispatch_table.MultMatrixf( (const GLfloat *) modelview );
+	cr_server.head_spu->dispatch_table.PopAttrib();
+}
+
+
+/*
+ * Called via unpacker module.
+ * Note: when there's a tilesort SPU upstream, the viewport dimensions
+ * will typically match the mural size.  That is, the viewport dimensions
+ * probably won't be the same values that the application issues.
+ */
+void SERVER_DISPATCH_APIENTRY crServerDispatchViewport( GLint x, GLint y, GLsizei width, GLsizei height )
+{
+	CRMuralInfo *mural = cr_server.curClient->currentMural;
+	CRContext *ctx = crStateGetCurrent();
+
+	if (ctx->viewport.viewportX != x ||
+			ctx->viewport.viewportY != y ||
+			ctx->viewport.viewportW != width ||
+			ctx->viewport.viewportH != height) {
+		 /* Note -- If there are tiles, this will be overridden in the 
+			* process of decoding the BoundsInfo packet, so no worries. */
+		 crStateViewport( x, y, width, height );
+	}
+
+	/* always dispatch to be safe */
+	cr_server.head_spu->dispatch_table.Viewport( x, y, width, height );
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.c	(revision 78189)
+++ 	(revision )
@@ -1,484 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "server.h"
-#include "server_dispatch.h"
-#include "cr_mem.h"
-#include "cr_rand.h"
-#include "cr_string.h"
-
-#include "render/renderspu.h"
-
-GLint SERVER_DISPATCH_APIENTRY
-crServerDispatchWindowCreate(const char *dpyName, GLint visBits)
-{
-    return crServerDispatchWindowCreateEx(dpyName, visBits, -1);
-}
-
-GLint crServerMuralInit(CRMuralInfo *mural, GLboolean fGuestWindow, GLint visBits, GLint preloadWinID)
-{
-    CRMuralInfo *defaultMural;
-    GLint dims[2];
-    GLint windowID = -1;
-    GLint spuWindow = 0;
-    GLint realVisBits = visBits;
-    const char *dpyName = "";
-
-    crMemset(mural, 0, sizeof (*mural));
-
-    if (cr_server.fVisualBitsDefault)
-        realVisBits = cr_server.fVisualBitsDefault;
-
-#ifdef RT_OS_DARWIN
-    if (fGuestWindow)
-    {
-        CRMuralInfo *dummy = crServerGetDummyMural(realVisBits);
-        if (!dummy)
-        {
-            WARN(("crServerGetDummyMural failed"));
-            return -1;
-        }
-        spuWindow = dummy->spuWindow;
-        mural->fIsDummyRefference = GL_TRUE;
-
-        dims[0] = dummy->width;
-        dims[1] = dummy->height;
-    }
-    else
-#endif
-    {
-        /*
-         * Have first SPU make a new window.
-         */
-        spuWindow = cr_server.head_spu->dispatch_table.WindowCreate( dpyName, realVisBits );
-        if (spuWindow < 0) {
-            return spuWindow;
-        }
-        mural->fIsDummyRefference = GL_FALSE;
-
-        /* get initial window size */
-        cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, spuWindow, GL_INT, 2, dims);
-    }
-
-    defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
-    CRASSERT(defaultMural);
-    mural->gX = 0;
-    mural->gY = 0;
-    mural->width = dims[0];
-    mural->height = dims[1];
-
-    mural->spuWindow = spuWindow;
-    mural->screenId = 0;
-    mural->fHasParentWindow = !!cr_server.screen[0].winID;
-    mural->bVisible = !cr_server.bWindowsInitiallyHidden;
-
-    mural->cVisibleRects = 0;
-    mural->pVisibleRects = NULL;
-    mural->bReceivedRects = GL_FALSE;
-
-    /* generate ID for this new window/mural (special-case for file conns) */
-    if (cr_server.curClient && cr_server.curClient->conn->type == CR_FILE)
-        windowID = spuWindow;
-    else
-        windowID = preloadWinID<0 ? (GLint)crHashtableAllocKeys( cr_server.muralTable, 1 ) : preloadWinID;
-
-    mural->CreateInfo.realVisualBits = realVisBits;
-    mural->CreateInfo.requestedVisualBits = visBits;
-    mural->CreateInfo.externalID = windowID;
-    mural->CreateInfo.pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
-
-    CR_STATE_SHAREDOBJ_USAGE_INIT(mural);
-
-    return windowID;
-}
-
-GLint crServerDispatchWindowCreateEx(const char *dpyName, GLint visBits, GLint preloadWinID)
-{
-    CRMuralInfo *mural;
-    GLint windowID = -1;
-
-    NOREF(dpyName);
-
-    if (cr_server.sharedWindows) {
-        int pos, j;
-
-        /* find empty position in my (curclient) windowList */
-        for (pos = 0; pos < CR_MAX_WINDOWS; pos++) {
-            if (cr_server.curClient->windowList[pos] == 0) {
-                break;
-            }
-        }
-        if (pos == CR_MAX_WINDOWS) {
-            crWarning("Too many windows in crserver!");
-            return -1;
-        }
-
-        /* Look if any other client has a window for this slot */
-        for (j = 0; j < cr_server.numClients; j++) {
-            if (cr_server.clients[j]->windowList[pos] != 0) {
-                /* use that client's window */
-                windowID = cr_server.clients[j]->windowList[pos];
-                cr_server.curClient->windowList[pos] = windowID;
-                crServerReturnValue( &windowID, sizeof(windowID) ); /* real return value */
-                crDebug("CRServer: client %p sharing window %d",
-                                cr_server.curClient, windowID);
-                return windowID;
-            }
-        }
-    }
-
-
-    /*
-     * Create a new mural for the new window.
-     */
-    mural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo));
-    if (!mural)
-    {
-        crWarning("crCalloc failed!");
-        return -1;
-    }
-
-    windowID = crServerMuralInit(mural, GL_TRUE, visBits, preloadWinID);
-    if (windowID < 0)
-    {
-        crWarning("crServerMuralInit failed!");
-        crServerReturnValue( &windowID, sizeof(windowID) );
-        crFree(mural);
-        return windowID;
-    }
-
-    crHashtableAdd(cr_server.muralTable, windowID, mural);
-
-    crDebug("CRServer: client %p created new window %d (SPU window %d)",
-                    cr_server.curClient, windowID, mural->spuWindow);
-
-    if (windowID != -1 && !cr_server.bIsInLoadingState) {
-        int pos;
-        for (pos = 0; pos < CR_MAX_WINDOWS; pos++) {
-            if (cr_server.curClient->windowList[pos] == 0) {
-                cr_server.curClient->windowList[pos] = windowID;
-                break;
-            }
-        }
-    }
-
-    /* ensure we have a dummy mural created right away to avoid potential deadlocks on VM shutdown */
-    crServerGetDummyMural(mural->CreateInfo.realVisualBits);
-
-    crServerReturnValue( &windowID, sizeof(windowID) );
-    return windowID;
-}
-
-static int crServerRemoveClientWindow(CRClient *pClient, GLint window)
-{
-    int pos;
-
-    for (pos = 0; pos < CR_MAX_WINDOWS; ++pos)
-    {
-        if (pClient->windowList[pos] == window)
-        {
-            pClient->windowList[pos] = 0;
-            return true;
-        }
-    }
-
-    return false;
-}
-
-void crServerMuralTerm(CRMuralInfo *mural)
-{
-	PCR_BLITTER pBlitter;
-    crServerRedirMuralFBO(mural, false);
-    crServerDeleteMuralFBO(mural);
-
-    if (cr_server.currentMural == mural)
-    {
-        CRMuralInfo *dummyMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
-        /* reset the current context to some dummy values to ensure render spu does not switch to a default "0" context,
-         * which might lead to muralFBO (offscreen rendering) gl entities being created in a scope of that context */
-        cr_server.head_spu->dispatch_table.MakeCurrent(dummyMural->spuWindow, 0, cr_server.MainContextInfo.SpuContext);
-        cr_server.currentWindow = -1;
-        cr_server.currentMural = dummyMural;
-    }
-    else
-    {
-        CRASSERT(cr_server.currentMural != mural);
-    }
-
-    pBlitter = crServerVBoxBlitterGetInitialized();
-    if (pBlitter)
-    {
-    	const CR_BLITTER_WINDOW * pWindow = CrBltMuralGetCurrentInfo(pBlitter);
-    	if (pWindow && pWindow->Base.id == mural->spuWindow)
-    	{
-    		CRMuralInfo *dummy = crServerGetDummyMural(mural->CreateInfo.realVisualBits);
-    		CR_BLITTER_WINDOW DummyInfo;
-    		CRASSERT(dummy);
-    		crServerVBoxBlitterWinInit(&DummyInfo, dummy);
-    		CrBltMuralSetCurrentInfo(pBlitter, &DummyInfo);
-    	}
-    }
-
-    if (!mural->fIsDummyRefference)
-        cr_server.head_spu->dispatch_table.WindowDestroy( mural->spuWindow );
-
-    mural->spuWindow = 0;
-
-    if (mural->pVisibleRects)
-    {
-        crFree(mural->pVisibleRects);
-    }
-
-    if (mural->CreateInfo.pszDpyName)
-        crFree(mural->CreateInfo.pszDpyName);
-
-    crServerRedirMuralFbClear(mural);
-}
-
-static void crServerCleanupCtxMuralRefsCB(unsigned long key, void *data1, void *data2)
-{
-    CRContextInfo *ctxInfo = (CRContextInfo *) data1;
-    CRMuralInfo *mural = (CRMuralInfo *) data2;
-
-    if (ctxInfo->currentMural == mural)
-        ctxInfo->currentMural = NULL;
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchWindowDestroy( GLint window )
-{
-    CRMuralInfo *mural;
-    int32_t client;
-    CRClientNode *pNode;
-    int found=false;
-
-    if (!window)
-    {
-        crWarning("Unexpected attempt to delete default mural, ignored!");
-        return;
-    }
-
-    mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
-    if (!mural) {
-         crWarning("CRServer: invalid window %d passed to WindowDestroy()", window);
-         return;
-    }
-
-    crDebug("CRServer: Destroying window %d (spu window %d)", window, mural->spuWindow);
-
-    crHashtableWalk(cr_server.contextTable, crServerCleanupCtxMuralRefsCB, mural);
-
-    crServerMuralTerm(mural);
-
-    CRASSERT(cr_server.currentWindow != window);
-
-    if (cr_server.curClient)
-    {
-        if (cr_server.curClient->currentMural == mural)
-        {
-            cr_server.curClient->currentMural = NULL;
-            cr_server.curClient->currentWindow = -1;
-        }
-
-        found = crServerRemoveClientWindow(cr_server.curClient, window);
-
-        /*Same as with contexts, some apps destroy it not in a thread where it was created*/
-        if (!found)
-        {
-            for (client=0; client<cr_server.numClients; ++client)
-            {
-                if (cr_server.clients[client]==cr_server.curClient)
-                    continue;
-
-                found = crServerRemoveClientWindow(cr_server.clients[client], window);
-
-                if (found) break;
-            }
-        }
-
-        if (!found)
-        {
-            pNode=cr_server.pCleanupClient;
-
-            while (pNode && !found)
-            {
-                found = crServerRemoveClientWindow(pNode->pClient, window);
-                pNode = pNode->next;
-            }
-        }
-
-        CRASSERT(found);
-    }
-
-    /*Make sure this window isn't active in other clients*/
-    for (client=0; client<cr_server.numClients; ++client)
-    {
-        if (cr_server.clients[client]->currentMural == mural)
-        {
-            cr_server.clients[client]->currentMural = NULL;
-            cr_server.clients[client]->currentWindow = -1;
-        }
-    }
-
-    pNode=cr_server.pCleanupClient;
-    while (pNode)
-    {
-        if (pNode->pClient->currentMural == mural)
-        {
-            pNode->pClient->currentMural = NULL;
-            pNode->pClient->currentWindow = -1;
-        }
-        pNode = pNode->next;
-    }
-
-    crHashtableDelete(cr_server.muralTable, window, crFree);
-
-    crServerCheckAllMuralGeometry(NULL);
-}
-
-GLboolean crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height)
-{
-    if (mural->width == width && mural->height == height)
-        return GL_FALSE;
-
-    mural->width = width;
-    mural->height = height;
-
-    if (cr_server.curClient && cr_server.curClient->currentMural == mural
-            && !mural->fRedirected)
-    {
-        crStateGetCurrent()->buffer.width = mural->width;
-        crStateGetCurrent()->buffer.height = mural->height;
-    }
-
-    crServerCheckAllMuralGeometry(mural);
-
-    return GL_TRUE;
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchWindowSize( GLint window, GLint width, GLint height )
-{
-    CRMuralInfo *mural;
-
-    /*  crDebug("CRServer: Window %d size %d x %d", window, width, height);*/
-    mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
-    if (!mural) {
-#if EXTRA_WARN
-         crWarning("CRServer: invalid window %d passed to WindowSize()", window);
-#endif
-         return;
-    }
-
-    crServerMuralSize(mural, width, height);
-
-    if (cr_server.currentMural == mural)
-    {
-        crServerPerformMakeCurrent( mural, cr_server.currentCtxInfo );
-    }
-}
-
-void crServerMuralPosition(CRMuralInfo *mural, GLint x, GLint y)
-{
-    if (mural->gX == x && mural->gY == y)
-        return;
-
-    mural->gX = x;
-    mural->gY = y;
-
-    crServerCheckAllMuralGeometry(mural);
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchWindowPosition( GLint window, GLint x, GLint y )
-{
-    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
-    if (!mural) {
-#if EXTRA_WARN
-         crWarning("CRServer: invalid window %d passed to WindowPosition()", window);
-#endif
-         return;
-    }
-    crServerMuralPosition(mural, x, y);
-}
-
-void crServerMuralVisibleRegion( CRMuralInfo *mural, GLint cRects, const GLint *pRects )
-{
-    if (mural->pVisibleRects)
-    {
-        crFree(mural->pVisibleRects);
-        mural->pVisibleRects = NULL;
-    }
-
-    mural->cVisibleRects = cRects;
-    mural->bReceivedRects = GL_TRUE;
-    if (cRects)
-    {
-        mural->pVisibleRects = (GLint*) crAlloc(4*sizeof(GLint)*cRects);
-        if (!mural->pVisibleRects)
-        {
-            crError("Out of memory in crServerDispatchWindowVisibleRegion");
-        }
-        crMemcpy(mural->pVisibleRects, pRects, 4*sizeof(GLint)*cRects);
-    }
-
-    crServerCheckAllMuralGeometry(mural);
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchWindowVisibleRegion( GLint window, GLint cRects, const GLint *pRects )
-{
-    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
-    if (!mural) {
-#if EXTRA_WARN
-         crWarning("CRServer: invalid window %d passed to WindowVisibleRegion()", window);
-#endif
-         return;
-    }
-
-    crServerMuralVisibleRegion( mural, cRects, pRects );
-}
-
-void crServerMuralShow( CRMuralInfo *mural, GLint state )
-{
-    if (!mural->bVisible == !state)
-        return;
-
-    mural->bVisible = !!state;
-
-    if (mural->bVisible)
-        crServerCheckMuralGeometry(mural);
-    else
-        crServerCheckAllMuralGeometry(mural);
-}
-
-void SERVER_DISPATCH_APIENTRY
-crServerDispatchWindowShow( GLint window, GLint state )
-{
-    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
-    if (!mural) {
-#if EXTRA_WARN
-         crWarning("CRServer: invalid window %d passed to WindowShow()", window);
-#endif
-         return;
-    }
-
-    crServerMuralShow( mural, state );
-}
-
-GLint
-crServerSPUWindowID(GLint serverWindow)
-{
-    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, serverWindow);
-    if (!mural) {
-#if EXTRA_WARN
-         crWarning("CRServer: invalid window %d passed to crServerSPUWindowID()",
-                             serverWindow);
-#endif
-         return -1;
-    }
-    return mural->spuWindow;
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_window.cpp	(revision 78190)
@@ -0,0 +1,480 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "server.h"
+#include "server_dispatch.h"
+#include "cr_mem.h"
+#include "cr_string.h"
+
+#include "render/renderspu.h"
+
+GLint SERVER_DISPATCH_APIENTRY
+crServerDispatchWindowCreate(const char *dpyName, GLint visBits)
+{
+    return crServerDispatchWindowCreateEx(dpyName, visBits, -1);
+}
+
+GLint crServerMuralInit(CRMuralInfo *mural, GLboolean fGuestWindow, GLint visBits, GLint preloadWinID)
+{
+    CRMuralInfo *defaultMural;
+    GLint dims[2];
+    GLint windowID = -1;
+    GLint spuWindow = 0;
+    GLint realVisBits = visBits;
+    const char *dpyName = "";
+
+    crMemset(mural, 0, sizeof (*mural));
+
+    if (cr_server.fVisualBitsDefault)
+        realVisBits = cr_server.fVisualBitsDefault;
+
+#ifdef RT_OS_DARWIN
+    if (fGuestWindow)
+    {
+        CRMuralInfo *dummy = crServerGetDummyMural(realVisBits);
+        if (!dummy)
+        {
+            WARN(("crServerGetDummyMural failed"));
+            return -1;
+        }
+        spuWindow = dummy->spuWindow;
+        mural->fIsDummyRefference = GL_TRUE;
+
+        dims[0] = dummy->width;
+        dims[1] = dummy->height;
+    }
+    else
+#endif
+    {
+        /*
+         * Have first SPU make a new window.
+         */
+        spuWindow = cr_server.head_spu->dispatch_table.WindowCreate( dpyName, realVisBits );
+        if (spuWindow < 0) {
+            return spuWindow;
+        }
+        mural->fIsDummyRefference = GL_FALSE;
+
+        /* get initial window size */
+        cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, spuWindow, GL_INT, 2, dims);
+    }
+
+    defaultMural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, 0);
+    CRASSERT(defaultMural);
+    mural->gX = 0;
+    mural->gY = 0;
+    mural->width = dims[0];
+    mural->height = dims[1];
+
+    mural->spuWindow = spuWindow;
+    mural->screenId = 0;
+    mural->fHasParentWindow = !!cr_server.screen[0].winID;
+    mural->bVisible = !cr_server.bWindowsInitiallyHidden;
+
+    mural->cVisibleRects = 0;
+    mural->pVisibleRects = NULL;
+    mural->bReceivedRects = GL_FALSE;
+
+    /* generate ID for this new window/mural. */
+    windowID = preloadWinID<0 ? (GLint)crHashtableAllocKeys( cr_server.muralTable, 1 ) : preloadWinID;
+
+    mural->CreateInfo.realVisualBits = realVisBits;
+    mural->CreateInfo.requestedVisualBits = visBits;
+    mural->CreateInfo.externalID = windowID;
+    mural->CreateInfo.pszDpyName = dpyName ? crStrdup(dpyName) : NULL;
+
+    CR_STATE_SHAREDOBJ_USAGE_INIT(mural);
+
+    return windowID;
+}
+
+GLint crServerDispatchWindowCreateEx(const char *dpyName, GLint visBits, GLint preloadWinID)
+{
+    CRMuralInfo *mural;
+    GLint windowID = -1;
+
+    NOREF(dpyName);
+
+    if (cr_server.sharedWindows) {
+        int pos, j;
+
+        /* find empty position in my (curclient) windowList */
+        for (pos = 0; pos < CR_MAX_WINDOWS; pos++) {
+            if (cr_server.curClient->windowList[pos] == 0) {
+                break;
+            }
+        }
+        if (pos == CR_MAX_WINDOWS) {
+            crWarning("Too many windows in crserver!");
+            return -1;
+        }
+
+        /* Look if any other client has a window for this slot */
+        for (j = 0; j < cr_server.numClients; j++) {
+            if (cr_server.clients[j]->windowList[pos] != 0) {
+                /* use that client's window */
+                windowID = cr_server.clients[j]->windowList[pos];
+                cr_server.curClient->windowList[pos] = windowID;
+                crServerReturnValue( &windowID, sizeof(windowID) ); /* real return value */
+                crDebug("CRServer: client %p sharing window %d",
+                                cr_server.curClient, windowID);
+                return windowID;
+            }
+        }
+    }
+
+
+    /*
+     * Create a new mural for the new window.
+     */
+    mural = (CRMuralInfo *) crCalloc(sizeof(CRMuralInfo));
+    if (!mural)
+    {
+        crWarning("crCalloc failed!");
+        return -1;
+    }
+
+    windowID = crServerMuralInit(mural, GL_TRUE, visBits, preloadWinID);
+    if (windowID < 0)
+    {
+        crWarning("crServerMuralInit failed!");
+        crServerReturnValue( &windowID, sizeof(windowID) );
+        crFree(mural);
+        return windowID;
+    }
+
+    crHashtableAdd(cr_server.muralTable, windowID, mural);
+
+    crDebug("CRServer: client %p created new window %d (SPU window %d)",
+                    cr_server.curClient, windowID, mural->spuWindow);
+
+    if (windowID != -1 && !cr_server.bIsInLoadingState) {
+        int pos;
+        for (pos = 0; pos < CR_MAX_WINDOWS; pos++) {
+            if (cr_server.curClient->windowList[pos] == 0) {
+                cr_server.curClient->windowList[pos] = windowID;
+                break;
+            }
+        }
+    }
+
+    /* ensure we have a dummy mural created right away to avoid potential deadlocks on VM shutdown */
+    crServerGetDummyMural(mural->CreateInfo.realVisualBits);
+
+    crServerReturnValue( &windowID, sizeof(windowID) );
+    return windowID;
+}
+
+static int crServerRemoveClientWindow(CRClient *pClient, GLint window)
+{
+    int pos;
+
+    for (pos = 0; pos < CR_MAX_WINDOWS; ++pos)
+    {
+        if (pClient->windowList[pos] == window)
+        {
+            pClient->windowList[pos] = 0;
+            return true;
+        }
+    }
+
+    return false;
+}
+
+void crServerMuralTerm(CRMuralInfo *mural)
+{
+	PCR_BLITTER pBlitter;
+    crServerRedirMuralFBO(mural, false);
+    crServerDeleteMuralFBO(mural);
+
+    if (cr_server.currentMural == mural)
+    {
+        CRMuralInfo *dummyMural = crServerGetDummyMural(cr_server.MainContextInfo.CreateInfo.realVisualBits);
+        /* reset the current context to some dummy values to ensure render spu does not switch to a default "0" context,
+         * which might lead to muralFBO (offscreen rendering) gl entities being created in a scope of that context */
+        cr_server.head_spu->dispatch_table.MakeCurrent(dummyMural->spuWindow, 0, cr_server.MainContextInfo.SpuContext);
+        cr_server.currentWindow = -1;
+        cr_server.currentMural = dummyMural;
+    }
+    else
+    {
+        CRASSERT(cr_server.currentMural != mural);
+    }
+
+    pBlitter = crServerVBoxBlitterGetInitialized();
+    if (pBlitter)
+    {
+    	const CR_BLITTER_WINDOW * pWindow = CrBltMuralGetCurrentInfo(pBlitter);
+    	if (pWindow && pWindow->Base.id == mural->spuWindow)
+    	{
+    		CRMuralInfo *dummy = crServerGetDummyMural(mural->CreateInfo.realVisualBits);
+    		CR_BLITTER_WINDOW DummyInfo;
+    		CRASSERT(dummy);
+    		crServerVBoxBlitterWinInit(&DummyInfo, dummy);
+    		CrBltMuralSetCurrentInfo(pBlitter, &DummyInfo);
+    	}
+    }
+
+    if (!mural->fIsDummyRefference)
+        cr_server.head_spu->dispatch_table.WindowDestroy( mural->spuWindow );
+
+    mural->spuWindow = 0;
+
+    if (mural->pVisibleRects)
+    {
+        crFree(mural->pVisibleRects);
+    }
+
+    if (mural->CreateInfo.pszDpyName)
+        crFree(mural->CreateInfo.pszDpyName);
+
+    crServerRedirMuralFbClear(mural);
+}
+
+static void crServerCleanupCtxMuralRefsCB(unsigned long key, void *data1, void *data2)
+{
+    CRContextInfo *ctxInfo = (CRContextInfo *) data1;
+    CRMuralInfo *mural = (CRMuralInfo *) data2;
+
+    if (ctxInfo->currentMural == mural)
+        ctxInfo->currentMural = NULL;
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchWindowDestroy( GLint window )
+{
+    CRMuralInfo *mural;
+    int32_t client;
+    CRClientNode *pNode;
+    int found=false;
+
+    if (!window)
+    {
+        crWarning("Unexpected attempt to delete default mural, ignored!");
+        return;
+    }
+
+    mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
+    if (!mural) {
+         crWarning("CRServer: invalid window %d passed to WindowDestroy()", window);
+         return;
+    }
+
+    crDebug("CRServer: Destroying window %d (spu window %d)", window, mural->spuWindow);
+
+    crHashtableWalk(cr_server.contextTable, crServerCleanupCtxMuralRefsCB, mural);
+
+    crServerMuralTerm(mural);
+
+    CRASSERT(cr_server.currentWindow != window);
+
+    if (cr_server.curClient)
+    {
+        if (cr_server.curClient->currentMural == mural)
+        {
+            cr_server.curClient->currentMural = NULL;
+            cr_server.curClient->currentWindow = -1;
+        }
+
+        found = crServerRemoveClientWindow(cr_server.curClient, window);
+
+        /*Same as with contexts, some apps destroy it not in a thread where it was created*/
+        if (!found)
+        {
+            for (client=0; client<cr_server.numClients; ++client)
+            {
+                if (cr_server.clients[client]==cr_server.curClient)
+                    continue;
+
+                found = crServerRemoveClientWindow(cr_server.clients[client], window);
+
+                if (found) break;
+            }
+        }
+
+        if (!found)
+        {
+            pNode=cr_server.pCleanupClient;
+
+            while (pNode && !found)
+            {
+                found = crServerRemoveClientWindow(pNode->pClient, window);
+                pNode = pNode->next;
+            }
+        }
+
+        CRASSERT(found);
+    }
+
+    /*Make sure this window isn't active in other clients*/
+    for (client=0; client<cr_server.numClients; ++client)
+    {
+        if (cr_server.clients[client]->currentMural == mural)
+        {
+            cr_server.clients[client]->currentMural = NULL;
+            cr_server.clients[client]->currentWindow = -1;
+        }
+    }
+
+    pNode=cr_server.pCleanupClient;
+    while (pNode)
+    {
+        if (pNode->pClient->currentMural == mural)
+        {
+            pNode->pClient->currentMural = NULL;
+            pNode->pClient->currentWindow = -1;
+        }
+        pNode = pNode->next;
+    }
+
+    crHashtableDelete(cr_server.muralTable, window, crFree);
+
+    crServerCheckAllMuralGeometry(NULL);
+}
+
+GLboolean crServerMuralSize(CRMuralInfo *mural, GLint width, GLint height)
+{
+    if (mural->width == width && mural->height == height)
+        return GL_FALSE;
+
+    mural->width = width;
+    mural->height = height;
+
+    if (cr_server.curClient && cr_server.curClient->currentMural == mural
+            && !mural->fRedirected)
+    {
+        crStateGetCurrent()->buffer.width = mural->width;
+        crStateGetCurrent()->buffer.height = mural->height;
+    }
+
+    crServerCheckAllMuralGeometry(mural);
+
+    return GL_TRUE;
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchWindowSize( GLint window, GLint width, GLint height )
+{
+    CRMuralInfo *mural;
+
+    /*  crDebug("CRServer: Window %d size %d x %d", window, width, height);*/
+    mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
+    if (!mural) {
+#ifdef EXTRA_WARN
+         crWarning("CRServer: invalid window %d passed to WindowSize()", window);
+#endif
+         return;
+    }
+
+    crServerMuralSize(mural, width, height);
+
+    if (cr_server.currentMural == mural)
+    {
+        crServerPerformMakeCurrent( mural, cr_server.currentCtxInfo );
+    }
+}
+
+void crServerMuralPosition(CRMuralInfo *mural, GLint x, GLint y)
+{
+    if (mural->gX == x && mural->gY == y)
+        return;
+
+    mural->gX = x;
+    mural->gY = y;
+
+    crServerCheckAllMuralGeometry(mural);
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchWindowPosition( GLint window, GLint x, GLint y )
+{
+    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
+    if (!mural) {
+#ifdef EXTRA_WARN
+         crWarning("CRServer: invalid window %d passed to WindowPosition()", window);
+#endif
+         return;
+    }
+    crServerMuralPosition(mural, x, y);
+}
+
+void crServerMuralVisibleRegion( CRMuralInfo *mural, GLint cRects, const GLint *pRects )
+{
+    if (mural->pVisibleRects)
+    {
+        crFree(mural->pVisibleRects);
+        mural->pVisibleRects = NULL;
+    }
+
+    mural->cVisibleRects = cRects;
+    mural->bReceivedRects = GL_TRUE;
+    if (cRects)
+    {
+        mural->pVisibleRects = (GLint*) crAlloc(4*sizeof(GLint)*cRects);
+        if (!mural->pVisibleRects)
+        {
+            crError("Out of memory in crServerDispatchWindowVisibleRegion");
+        }
+        crMemcpy(mural->pVisibleRects, pRects, 4*sizeof(GLint)*cRects);
+    }
+
+    crServerCheckAllMuralGeometry(mural);
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchWindowVisibleRegion( GLint window, GLint cRects, const GLint *pRects )
+{
+    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
+    if (!mural) {
+#ifdef EXTRA_WARN
+         crWarning("CRServer: invalid window %d passed to WindowVisibleRegion()", window);
+#endif
+         return;
+    }
+
+    crServerMuralVisibleRegion( mural, cRects, pRects );
+}
+
+void crServerMuralShow( CRMuralInfo *mural, GLint state )
+{
+    if (!mural->bVisible == !state)
+        return;
+
+    mural->bVisible = !!state;
+
+    if (mural->bVisible)
+        crServerCheckMuralGeometry(mural);
+    else
+        crServerCheckAllMuralGeometry(mural);
+}
+
+void SERVER_DISPATCH_APIENTRY
+crServerDispatchWindowShow( GLint window, GLint state )
+{
+    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, window);
+    if (!mural) {
+#ifdef EXTRA_WARN
+         crWarning("CRServer: invalid window %d passed to WindowShow()", window);
+#endif
+         return;
+    }
+
+    crServerMuralShow( mural, state );
+}
+
+GLint
+crServerSPUWindowID(GLint serverWindow)
+{
+    CRMuralInfo *mural = (CRMuralInfo *) crHashtableSearch(cr_server.muralTable, serverWindow);
+    if (!mural) {
+#ifdef EXTRA_WARN
+         crWarning("CRServer: invalid window %d passed to crServerSPUWindowID()",
+                             serverWindow);
+#endif
+         return -1;
+    }
+    return mural->spuWindow;
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_winpos.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_winpos.c	(revision 78189)
+++ 	(revision )
@@ -1,95 +1,0 @@
-
-#include "server_dispatch.h"
-#include "server.h"
-
-
-/**
- * All glWindowPos commands go through here.
- */
-static void crServerWindowPos( GLfloat x, GLfloat y, GLfloat z )
-{
-	crStateWindowPos3fARB(x, y, z);
-	cr_server.head_spu->dispatch_table.WindowPos3fARB(x, y, z);
-}
-
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2dARB( GLdouble x, GLdouble y )
-{
-	crServerWindowPos((GLfloat) x, (GLfloat) y, 0.0F);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2dvARB( const GLdouble * v )
-{
-	crServerWindowPos((GLfloat) v[0], (GLfloat) v[1], 0.0F);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2fARB( GLfloat x, GLfloat y )
-{
-	crServerWindowPos(x, y, 0.0F);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2fvARB( const GLfloat * v )
-{
-	crServerWindowPos(v[0], v[1], 0.0F);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2iARB( GLint x, GLint y )
-{
-	crServerWindowPos((GLfloat)x, (GLfloat)y, 0.0F);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2ivARB( const GLint * v )
-{
-	crServerWindowPos((GLfloat)v[0], (GLfloat)v[1], 0.0F);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2sARB( GLshort x, GLshort y )
-{
-	crServerWindowPos(x, y, 0.0F);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2svARB( const GLshort * v )
-{
-	crServerWindowPos(v[0], v[1], 0.0F);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3dARB( GLdouble x, GLdouble y, GLdouble z )
-{
-	crServerWindowPos((GLfloat) x, (GLfloat) y, (GLfloat) z);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3dvARB( const GLdouble * v )
-{
-	crServerWindowPos((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3fARB( GLfloat x, GLfloat y, GLfloat z )
-{
-	crServerWindowPos(x, y, z);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3fvARB( const GLfloat * v )
-{
-	crServerWindowPos(v[0], v[1], v[2]);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3iARB( GLint x, GLint y, GLint z )
-{
-	crServerWindowPos((GLfloat)x,(GLfloat)y, (GLfloat)z);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3ivARB( const GLint * v )
-{
-	crServerWindowPos((GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3sARB( GLshort x, GLshort y, GLshort z )
-{
-	crServerWindowPos(x, y, z);
-}
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3svARB( const GLshort * v )
-{
-	crServerWindowPos(v[0], v[1], v[2]);
-}
-
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_winpos.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_winpos.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_winpos.cpp	(revision 78190)
@@ -0,0 +1,95 @@
+
+#include "server_dispatch.h"
+#include "server.h"
+
+
+/**
+ * All glWindowPos commands go through here.
+ */
+static void crServerWindowPos( GLfloat x, GLfloat y, GLfloat z )
+{
+	crStateWindowPos3fARB(x, y, z);
+	cr_server.head_spu->dispatch_table.WindowPos3fARB(x, y, z);
+}
+
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2dARB( GLdouble x, GLdouble y )
+{
+	crServerWindowPos((GLfloat) x, (GLfloat) y, 0.0F);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2dvARB( const GLdouble * v )
+{
+	crServerWindowPos((GLfloat) v[0], (GLfloat) v[1], 0.0F);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2fARB( GLfloat x, GLfloat y )
+{
+	crServerWindowPos(x, y, 0.0F);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2fvARB( const GLfloat * v )
+{
+	crServerWindowPos(v[0], v[1], 0.0F);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2iARB( GLint x, GLint y )
+{
+	crServerWindowPos((GLfloat)x, (GLfloat)y, 0.0F);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2ivARB( const GLint * v )
+{
+	crServerWindowPos((GLfloat)v[0], (GLfloat)v[1], 0.0F);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2sARB( GLshort x, GLshort y )
+{
+	crServerWindowPos(x, y, 0.0F);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos2svARB( const GLshort * v )
+{
+	crServerWindowPos(v[0], v[1], 0.0F);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3dARB( GLdouble x, GLdouble y, GLdouble z )
+{
+	crServerWindowPos((GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3dvARB( const GLdouble * v )
+{
+	crServerWindowPos((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3fARB( GLfloat x, GLfloat y, GLfloat z )
+{
+	crServerWindowPos(x, y, z);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3fvARB( const GLfloat * v )
+{
+	crServerWindowPos(v[0], v[1], v[2]);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3iARB( GLint x, GLint y, GLint z )
+{
+	crServerWindowPos((GLfloat)x,(GLfloat)y, (GLfloat)z);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3ivARB( const GLint * v )
+{
+	crServerWindowPos((GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2]);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3sARB( GLshort x, GLshort y, GLshort z )
+{
+	crServerWindowPos(x, y, z);
+}
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWindowPos3svARB( const GLshort * v )
+{
+	crServerWindowPos(v[0], v[1], v[2]);
+}
+
Index: unk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_writeback.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_writeback.c	(revision 78189)
+++ 	(revision )
@@ -1,28 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_mem.h"
-#include "cr_net.h"
-#include "server_dispatch.h"
-#include "server.h"
-
-void SERVER_DISPATCH_APIENTRY crServerDispatchWriteback( GLint *writeback )
-{
-	(void) writeback;
-	crServerWriteback( );
-}
-
-void crServerWriteback(void)
-{
-	CRMessageWriteback *wb = (CRMessageWriteback *) crAlloc( sizeof( *wb ) );
-	wb->header.type = CR_MESSAGE_WRITEBACK;
-	CRDBGPTR_PRINTWB(cr_server.curClient->conn->u32ClientID, &cr_server.writeback_ptr);
-	CRDBGPTR_CHECKNZ(&cr_server.writeback_ptr);
-	crMemcpy( &(wb->writeback_ptr), &(cr_server.writeback_ptr), sizeof( wb->writeback_ptr ) );
-	crNetSend( cr_server.curClient->conn, NULL, wb, sizeof( *wb ) );
-	CRDBGPTR_SETZ(&cr_server.writeback_ptr);
-	crFree( wb );
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_writeback.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_writeback.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_writeback.cpp	(revision 78190)
@@ -0,0 +1,28 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "cr_mem.h"
+#include "cr_net.h"
+#include "server_dispatch.h"
+#include "server.h"
+
+void SERVER_DISPATCH_APIENTRY crServerDispatchWriteback( GLint *writeback )
+{
+	(void) writeback;
+	crServerWriteback( );
+}
+
+void crServerWriteback(void)
+{
+	CRMessageWriteback *wb = (CRMessageWriteback *) crAlloc( sizeof( *wb ) );
+	wb->header.type = CR_MESSAGE_WRITEBACK;
+	CRDBGPTR_PRINTWB(cr_server.curClient->conn->u32ClientID, &cr_server.writeback_ptr);
+	CRDBGPTR_CHECKNZ(&cr_server.writeback_ptr);
+	crMemcpy( &(wb->writeback_ptr), &(cr_server.writeback_ptr), sizeof( wb->writeback_ptr ) );
+	crNetSend( cr_server.curClient->conn, NULL, wb, sizeof( *wb ) );
+	CRDBGPTR_SETZ(&cr_server.writeback_ptr);
+	crFree( wb );
+}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.c	(revision 78190)
@@ -5,10 +5,8 @@
  */
 
-#include "cr_environment.h"
 #include "cr_string.h"
 #include "cr_error.h"
 #include "cr_mem.h"
 #include "cr_spu.h"
-#include "cr_environment.h"
 #include "renderspu.h"
 #include "cr_extstring.h"
@@ -16,4 +14,6 @@
 #include <iprt/asm.h>
 
+#include <stdio.h> /*sprintf*/
+
 uint32_t renderspuContextRelease(ContextInfo *context);
 uint32_t renderspuContextRetain(ContextInfo *context);
@@ -26,24 +26,8 @@
     out.header.type = CR_MESSAGE_OOB;
 
-    if (render_spu.is_swap_master)
-    {
-        int a;
-
-        for (a = 0; a < render_spu.num_swap_clients; a++)
-        {
-            crNetGetMessage( render_spu.swap_conns[a], &in );
-            crNetFree( render_spu.swap_conns[a], in);
-        }
-
-        for (a = 0; a < render_spu.num_swap_clients; a++)
-            crNetSend( render_spu.swap_conns[a], NULL, &out, sizeof(CRMessage));
-    }
-    else
-    {
-        crNetSend( render_spu.swap_conns[0], NULL, &out, sizeof(CRMessage));
-
-        crNetGetMessage( render_spu.swap_conns[0], &in );
-        crNetFree( render_spu.swap_conns[0], in);
-    }
+    crNetSend( render_spu.swap_conns[0], NULL, &out, sizeof(CRMessage));
+
+    crNetGetMessage( render_spu.swap_conns[0], &in );
+    crNetFree( render_spu.swap_conns[0], in);
 }
 
@@ -1361,7 +1345,4 @@
         DrawCursor( render_spu.cursorX, render_spu.cursorY );
 
-    if (render_spu.swap_master_url)
-        DoSync();
-
     renderspu_SystemSwapBuffers( w, flags );
 }
@@ -1570,16 +1551,4 @@
                 switch (render_spu.server->clients[client_num]->conn->type)
                 {
-                    case CR_TCPIP:
-                        crDebug("Render SPU: AcceptClient from %s on %d",
-                            render_spu.server->clients[client_num]->conn->hostname, render_spu.gather_port);
-                        render_spu.gather_conns[client_num] =
-                                crNetAcceptClient("tcpip", NULL, port, 1024*1024,  1);
-                        break;
-
-                    case CR_GM:
-                        render_spu.gather_conns[client_num] =
-                                crNetAcceptClient("gm", NULL, port, 1024*1024,  1);
-                        break;
-
                     default:
                         crError("Render SPU: Unknown Network Type to Open Gather Connection");
@@ -1600,5 +1569,5 @@
                 if (render_spu.gather_conns[client_num])
                 {
-                    crDebug("Render SPU: success! from %s", render_spu.gather_conns[client_num]->hostname);
+                    crDebug("Render SPU: success!");
                 }
             }
@@ -1629,8 +1598,4 @@
          * in SwapBuffers above] is not necessary -- karl
          */
-
-        if (render_spu.swap_master_url)
-            DoSync();
-
         for (client_num=0; client_num< render_spu.server->numClients; client_num++)
             crNetSend(render_spu.gather_conns[client_num], NULL, &pingback,
Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu.h	(revision 78190)
@@ -14,9 +14,5 @@
 #define snprintf _snprintf
 #elif defined(DARWIN)
-# ifndef VBOX_WITH_COCOA_QT
-#  include <AGL/AGL.h>
-# else
-#  include "renderspu_cocoa_helper.h"
-# endif
+# include "renderspu_cocoa_helper.h"
 #define RENDER_APIENTRY
 #else
@@ -47,24 +43,4 @@
 #define MAX_VISUALS 32
 
-#ifdef RT_OS_DARWIN
-# ifndef VBOX_WITH_COCOA_QT
-enum
-{
-    /* Event classes */
-    kEventClassVBox         = 'vbox',
-    /* Event kinds */
-    kEventVBoxShowWindow    = 'swin',
-    kEventVBoxHideWindow    = 'hwin',
-    kEventVBoxMoveWindow    = 'mwin',
-    kEventVBoxResizeWindow  = 'rwin',
-    kEventVBoxDisposeWindow = 'dwin',
-    kEventVBoxUpdateDock    = 'udck',
-    kEventVBoxUpdateContext = 'uctx',
-    kEventVBoxBoundsChanged = 'bchg'
-};
-pascal OSStatus windowEvtHndlr(EventHandlerCallRef myHandler, EventRef event, void* userData);
-# endif
-#endif /* RT_OS_DARWIN */
-
 /**
  * Visual info
@@ -76,7 +52,4 @@
 //    HDC device_context;
 #elif defined(DARWIN)
-# ifndef VBOX_WITH_COCOA_QT
-    WindowRef window;
-# endif
 #elif defined(GLX)
     Display *dpy;
@@ -121,18 +94,7 @@
     HRGN hRgn;
 #elif defined(DARWIN)
-# ifndef VBOX_WITH_COCOA_QT
-    WindowRef window;
-    WindowRef nativeWindow; /**< for render_to_app_window */
-    WindowRef appWindow;
-    EventHandlerUPP event_handler;
-    GLint bufferName;
-    AGLContext dummyContext;
-    RgnHandle hVisibleRegion;
-    /* unsigned long context_ptr; */
-# else
     NativeNSViewRef window;
     NativeNSViewRef nativeWindow; /**< for render_to_app_window */
     NativeNSOpenGLContextRef *currentCtx;
-# endif
 #elif defined(GLX)
     Window window;
@@ -163,9 +125,5 @@
     HGLRC hRC;
 #elif defined(DARWIN)
-# ifndef VBOX_WITH_COCOA_QT
-    AGLContext context;
-# else
     NativeNSOpenGLContextRef context;
-# endif
 #elif defined(GLX)
     GLXContext context;
@@ -288,7 +246,5 @@
     CRHashTable *barrierHash;
 
-    int is_swap_master, num_swap_clients;
-    int swap_mtu;
-    char *swap_master_url;
+    int num_swap_clients;
     CRConnection **swap_conns;
 
@@ -329,5 +285,4 @@
 
 #ifdef RT_OS_DARWIN
-# ifdef VBOX_WITH_COCOA_QT
     PFNDELETE_OBJECT pfnDeleteObject;
     PFNGET_ATTACHED_OBJECTS pfnGetAttachedObjects;
@@ -338,14 +293,4 @@
 
     CR_GLSL_CACHE GlobalShaders;
-# else
-    RgnHandle hRootVisibleRegion;
-    RTSEMFASTMUTEX syncMutex;
-    EventHandlerUPP hParentEventHandler;
-    WindowGroupRef pParentGroup;
-    WindowGroupRef pMasterGroup;
-    GLint currentBufferName;
-    uint64_t uiDockUpdateTS;
-    bool fInit;
-# endif
 #endif /* RT_OS_DARWIN */
     /* If TRUE, render should tell window server to prevent artificial content
Index: unk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c	(revision 78189)
+++ 	(revision )
@@ -1,907 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include <Carbon/Carbon.h>
-#include <AGL/agl.h>
-#include <OpenGL/OpenGL.h>
-
-#include <iprt/time.h>
-#include <iprt/assert.h>
-#include <iprt/semaphore.h>
-
-#include <stdio.h>
-
-#include "cr_environment.h"
-#include "cr_error.h"
-#include "cr_string.h"
-#include "cr_mem.h"
-#include "renderspu.h"
-
-#ifdef __LP64__ /** @todo port to 64-bit darwin. */
-# define renderspuSetWindowContext(w, c) \
-    AssertFailed()
-# define renderspuGetWindowContext(w) \
-    ( (ContextInfo *) GetWRefCon( ((w)->nativeWindow ? (w)->nativeWindow : (w)->window) ) )
-#else
-# define renderspuSetWindowContext(w, c) \
-    ( SetWRefCon( (w), (unsigned long) (c) ) )
-# define renderspuGetWindowContext(w) \
-    ( (ContextInfo *) GetWRefCon( ((w)->nativeWindow ? (w)->nativeWindow : (w)->window) ) )
-#endif
-
-/* Debug macros */
-#ifdef DEBUG_poetzsch
-#define DEBUG_MSG_POETZSCH(text) \
-    printf text
-#else
-#define DEBUG_MSG_POETZSCH(text) \
-    do {} while (0)
-#endif
-
-#define DEBUG_MSG_RESULT(result, text) \
-        crDebug(text" (%d; %s:%d)", (int)(result), __FILE__, __LINE__)
-
-#define CHECK_CARBON_RC(result, text) \
-    if((result) != noErr) \
-        DEBUG_MSG_RESULT(result, text);
-
-#define CHECK_CARBON_RC_RETURN(result, text, ret) \
-    if((result) != noErr) \
-    { \
-        DEBUG_MSG_RESULT(result, text); \
-        return ret; \
-    }
-
-#define CHECK_CARBON_RC_RETURN_VOID(result, text) \
-    CHECK_CARBON_RC_RETURN(result, text,)
-
-#define CHECK_AGL_RC(result, text) \
-    if(!(result)) \
-    { \
-        GLenum error = render_spu.ws.aglGetError(); \
-        DEBUG_MSG_RESULT(result, text); \
-    }
-
-static void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window);
-static void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects);
-
-/* In some case (like compiz which doesn't provide us with clipping regions) we
- * have to make sure that *all* open OpenGL windows are clipped to the main
- * application window. This is done here when called from the event handler
- * which monitor bounding changes of the main window. */
-static void crClipRootHelper(unsigned long key, void *data1, void *data2)
-{
-    /* The window with id zero is the base window, which isn't displayed at
-     * all. So ignore it. */
-    if (key > 0)
-    {
-        /* Fetch the actually window info & the user data */
-        WindowInfo *pWin = (WindowInfo *) data1;
-        /* We need to assign the context with this window */
-        ContextInfo *context = renderspuGetWindowContext(pWin);
-        if (context &&
-            context->context)
-        {
-            RTSemFastMutexRequest(render_spu.syncMutex);
-            GLboolean result = render_spu.ws.aglSetCurrentContext(context->context);
-            CHECK_AGL_RC (result, "Render SPU (crClipRootHelper): SetCurrentContext Failed");
-            if (result)
-            {
-                result = render_spu.ws.aglUpdateContext(context->context);
-                CHECK_AGL_RC (result, "Render SPU (crClipRootHelper): UpdateContext Failed");
-                /* Update the clipping region */
-                renderspu_SystemWindowApplyVisibleRegion(pWin);
-            }
-            RTSemFastMutexRelease(render_spu.syncMutex);
-            /* Make sure that the position is updated relative to the Qt main
-             * view */
-            renderspu_SystemWindowPosition(pWin, pWin->x, pWin->y);
-        }
-    }
-}
-
-/* Window event handler */
-pascal OSStatus
-windowEvtHndlr(EventHandlerCallRef myHandler, EventRef event, void* userData)
-{
-    WindowRef   window = NULL;
-    OSStatus    eventResult = eventNotHandledErr;
-    UInt32      class = GetEventClass (event);
-    UInt32      kind = GetEventKind (event);
-
-    /* If we aren't initialized or even deinitialized already (as on VM
-     * shutdown) do nothing. */
-    if (!render_spu.fInit)
-        return eventNotHandledErr;
-
-    /* Fetch the sender of the event */
-    GetEventParameter(event, kEventParamDirectObject, typeWindowRef,
-                      NULL, sizeof(WindowRef), NULL, &window);
-    switch (class)
-    {
-        case kEventClassVBox:
-        {
-            switch (kind)
-            {
-                case kEventVBoxUpdateContext:
-                {
-#ifndef __LP64__ /** @todo port to 64-bit darwin! Need to check if this event is generated or not (it probably isn't). */
-                    WindowInfo *wi1;
-                    GetEventParameter(event, kEventParamUserData, typeVoidPtr,
-                                      NULL, sizeof(wi1), NULL, &wi1);
-                    ContextInfo *context = renderspuGetWindowContext(wi1);
-                    if (context &&
-                        context->context)
-                    {
-                        AGLContext tmpContext = render_spu.ws.aglGetCurrentContext();
-                        DEBUG_MSG_POETZSCH (("kEventVBoxUpdateContext %x %x\n", wi1, context->context));
-                        RTSemFastMutexRequest(render_spu.syncMutex);
-                        GLboolean result = render_spu.ws.aglSetCurrentContext(context->context);
-                        if (result)
-                        {
-                            result = render_spu.ws.aglUpdateContext(context->context);
-                            CHECK_AGL_RC (result, "Render SPU (windowEvtHndlr): UpdateContext Failed");
-                            renderspu_SystemWindowApplyVisibleRegion(wi1);
-                            /* Reapply the last active context */
-                            if (tmpContext)
-                            {
-                                result = render_spu.ws.aglSetCurrentContext(tmpContext);
-                                CHECK_AGL_RC (result, "Render SPU (windowEvtHndlr): SetCurrentContext Failed");
-                                if (result)
-                                {
-                                    result = render_spu.ws.aglUpdateContext(tmpContext);
-                                    CHECK_AGL_RC (result, "Render SPU (windowEvtHndlr): UpdateContext Failed");
-                                }
-                            }
-                        }
-                        RTSemFastMutexRelease(render_spu.syncMutex);
-                    }
-                    eventResult = noErr;
-#endif
-                    break;
-                }
-                case kEventVBoxBoundsChanged:
-                {
-#ifndef __LP64__ /** @todo port to 64-bit darwin! Need to check if this event is generated or not (it probably isn't). */
-                    HIPoint p;
-                    GetEventParameter(event, kEventParamOrigin, typeHIPoint,
-                                      NULL, sizeof(p), NULL, &p);
-                    HISize s;
-                    GetEventParameter(event, kEventParamDimensions, typeHISize,
-                                      NULL, sizeof(s), NULL, &s);
-                    HIRect r = CGRectMake (0, 0, s.width, s.height);
-                    DEBUG_MSG_POETZSCH (("kEventVBoxBoundsChanged %f %f %f %f\n", p.x, p.y, s.width, s.height));
-                    GLint l[4] = { 0,
-                                   0,
-                                   r.size.width,
-                                   r.size.height };
-                    /* Update the root window clip region */
-                    renderspu_SystemSetRootVisibleRegion(1, l);
-                    /* Temporary save the current active context */
-                    AGLContext tmpContext = render_spu.ws.aglGetCurrentContext();
-                    crHashtableWalk(render_spu.windowTable, crClipRootHelper, NULL);
-                    /* Reapply the last active context */
-                    if (tmpContext)
-                    {
-                        RTSemFastMutexRequest(render_spu.syncMutex);
-                        GLboolean result = render_spu.ws.aglSetCurrentContext(tmpContext);
-                        CHECK_AGL_RC (result, "Render SPU (windowEvtHndlr): SetCurrentContext Failed");
-                        /* Doesn't work with DirectX; Anyway doesn't  */
-/*                        if (result)*/
-/*                        {*/
-/*                            result = render_spu.ws.aglUpdateContext(tmpContext);*/
-/*                            CHECK_AGL_RC (result, "Render SPU (windowEvtHndlr): UpdateContext Failed");*/
-/*                        }*/
-                        RTSemFastMutexRelease(render_spu.syncMutex);
-                    }
-                    eventResult = noErr;
-#endif
-                    break;
-                }
-            };
-            break;
-        }
-        break;
-    };
-
-    return eventResult;
-}
-
-GLboolean
-renderspu_SystemInitVisual(VisualInfo *visual)
-{
-    if(visual->visAttribs & CR_PBUFFER_BIT)
-        crWarning("Render SPU (renderspu_SystemInitVisual): PBuffers not support on Darwin/AGL yet.");
-
-    return GL_TRUE;
-}
-
-GLboolean
-renderspuChoosePixelFormat(ContextInfo *context, AGLPixelFormat *pix)
-{
-    GLbitfield  visAttribs = context->visual->visAttribs;
-    GLint       attribs[32];
-    GLint       ind = 0;
-
-#define ATTR_ADD(s)     ( attribs[ind++] = (s) )
-#define ATTR_ADDV(s,v)  ( ATTR_ADD((s)), ATTR_ADD((v)) )
-
-    CRASSERT(render_spu.ws.aglChoosePixelFormat);
-
-    ATTR_ADD(AGL_RGBA);
-/*  ATTR_ADDV(AGL_RED_SIZE, 1);
-    ATTR_ADDV(AGL_GREEN_SIZE, 1);
-    ATTR_ADDV(AGL_BLUE_SIZE, 1); */
-
-/*  if( render_spu.fullscreen )*/
-/*      ATTR_ADD(AGL_FULLSCREEN);*/
-
-    if( visAttribs & CR_ALPHA_BIT )
-        ATTR_ADDV(AGL_ALPHA_SIZE, 1);
-
-    if( visAttribs & CR_DOUBLE_BIT )
-        ATTR_ADD(AGL_DOUBLEBUFFER);
-
-    if( visAttribs & CR_STEREO_BIT )
-        ATTR_ADD(AGL_STEREO);
-
-    if( visAttribs & CR_DEPTH_BIT )
-        ATTR_ADDV(AGL_DEPTH_SIZE, 1);
-
-    if( visAttribs & CR_STENCIL_BIT )
-        ATTR_ADDV(AGL_STENCIL_SIZE, 1);
-
-    if( visAttribs & CR_ACCUM_BIT ) {
-        ATTR_ADDV(AGL_ACCUM_RED_SIZE, 1);
-        ATTR_ADDV(AGL_ACCUM_GREEN_SIZE, 1);
-        ATTR_ADDV(AGL_ACCUM_BLUE_SIZE, 1);
-        if( visAttribs & CR_ALPHA_BIT )
-            ATTR_ADDV(AGL_ACCUM_ALPHA_SIZE, 1);
-    }
-
-    if( visAttribs & CR_MULTISAMPLE_BIT ) {
-        ATTR_ADDV(AGL_SAMPLE_BUFFERS_ARB, 1);
-        ATTR_ADDV(AGL_SAMPLES_ARB, 4);
-    }
-
-    if( visAttribs & CR_OVERLAY_BIT )
-        ATTR_ADDV(AGL_LEVEL, 1);
-
-    ATTR_ADD(AGL_NONE);
-
-    *pix = render_spu.ws.aglChoosePixelFormat( NULL, 0, attribs );
-
-    return (*pix != NULL);
-}
-
-void
-renderspuDestroyPixelFormat(ContextInfo *context, AGLPixelFormat *pix)
-{
-    render_spu.ws.aglDestroyPixelFormat( *pix );
-    *pix = NULL;
-}
-
-GLboolean
-renderspu_SystemCreateContext(VisualInfo *visual, ContextInfo *context, ContextInfo *sharedContext)
-{
-    AGLPixelFormat pix;
-
-    (void) sharedContext;
-    CRASSERT(visual);
-    CRASSERT(context);
-
-    context->visual = visual;
-
-    if( !renderspuChoosePixelFormat(context, &pix) ) {
-        crError( "Render SPU (renderspu_SystemCreateContext): Unable to create pixel format" );
-        return GL_FALSE;
-    }
-
-    context->context = render_spu.ws.aglCreateContext( pix, NULL );
-    renderspuDestroyPixelFormat( context, &pix );
-
-    if( !context->context ) {
-        crError( "Render SPU (renderspu_SystemCreateContext): Could not create rendering context" );
-        return GL_FALSE;
-    }
-
-    return GL_TRUE;
-}
-
-void
-renderspu_SystemDestroyContext(ContextInfo *context)
-{
-    if(!context)
-        return;
-
-    render_spu.ws.aglSetDrawable(context->context, NULL);
-    render_spu.ws.aglSetCurrentContext(NULL);
-    if(context->context)
-    {
-        render_spu.ws.aglDestroyContext(context->context);
-        context->context = NULL;
-    }
-
-    context->visual = NULL;
-}
-
-void
-renderspuFullscreen(WindowInfo *window, GLboolean fullscreen)
-{
-    /* Real fullscreen isn't supported by VirtualBox */
-}
-
-GLboolean
-renderspuWindowAttachContext(WindowInfo *wi, WindowRef window,
-                             ContextInfo *context)
-{
-    GLboolean result;
-
-    if(!context || !wi)
-        return render_spu.ws.aglSetCurrentContext( NULL );
-
-/*    DEBUG_MSG_POETZSCH (("WindowAttachContext %d\n", wi->BltInfo.Base.id));*/
-
-    /* Flush old context first */
-    if (context->currentWindow->window != window)
-        render_spu.self.Flush();
-    /* If the window buffer name is uninitialized we have to create a new
-     * dummy context. */
-    if (wi->bufferName == -1)
-    {
-        DEBUG_MSG_POETZSCH (("WindowAttachContext: create context %d\n", wi->BltInfo.Base.id));
-        /* Use the same visual bits as those in the context structure */
-        AGLPixelFormat pix;
-        if( !renderspuChoosePixelFormat(context, &pix) )
-        {
-            crError( "Render SPU (renderspuWindowAttachContext): Unable to create pixel format" );
-            return GL_FALSE;
-        }
-        /* Create the dummy context */
-        wi->dummyContext = render_spu.ws.aglCreateContext( pix, NULL );
-        renderspuDestroyPixelFormat( context, &pix );
-        if( !wi->dummyContext )
-        {
-            crError( "Render SPU (renderspuWindowAttachContext): Could not create rendering context" );
-            return GL_FALSE;
-        }
-        AGLDrawable drawable;
-#ifdef __LP64__ /** @todo port to 64-bit darwin. */
-        drawable = NULL;
-#else
-        drawable = (AGLDrawable) GetWindowPort(window);
-#endif
-        /* New global buffer name */
-        wi->bufferName = render_spu.currentBufferName++;
-        /* Set the new buffer name to the dummy context. This enable the
-         * sharing of the same hardware buffer afterwards. */
-        result = render_spu.ws.aglSetInteger(wi->dummyContext, AGL_BUFFER_NAME, &wi->bufferName);
-        CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetInteger Failed");
-        /* Assign the dummy context to the window */
-        result = render_spu.ws.aglSetDrawable(wi->dummyContext, drawable);
-        CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetDrawable Failed");
-    }
-
-    AGLDrawable oldDrawable;
-    AGLDrawable newDrawable;
-
-    oldDrawable = render_spu.ws.aglGetDrawable(context->context);
-#ifdef __LP64__ /** @todo port to 64-bit darwin. */
-    newDrawable = oldDrawable;
-#else
-    newDrawable = (AGLDrawable) GetWindowPort(window);
-#endif
-    RTSemFastMutexRequest(render_spu.syncMutex);
-    /* Only switch the context if the drawable has changed */
-    if (oldDrawable != newDrawable)
-    {
-        /* Reset the current context */
-        result = render_spu.ws.aglSetDrawable(context->context, NULL);
-        CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetDrawable Failed");
-        /* Set the buffer name of the dummy context to the current context
-         * also. After that both share the same hardware buffer. */
-        render_spu.ws.aglSetInteger (context->context, AGL_BUFFER_NAME, &wi->bufferName);
-        CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetInteger Failed");
-        /* Set the new drawable */
-#ifdef __LP64__ /** @todo port to 64-bit darwin. */
-        result = -1;
-#else
-        result = render_spu.ws.aglSetDrawable(context->context, newDrawable);
-#endif
-        CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetDrawable Failed");
-        renderspuSetWindowContext(window, context);
-    }
-    result = render_spu.ws.aglSetCurrentContext(context->context);
-    CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetCurrentContext Failed");
-    result = render_spu.ws.aglUpdateContext(context->context);
-    CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): UpdateContext Failed");
-    RTSemFastMutexRelease(render_spu.syncMutex);
-
-    return result;
-}
-
-GLboolean
-renderspu_SystemCreateWindow(VisualInfo *visual, GLboolean showIt,
-                             WindowInfo *window)
-{
-    return GL_TRUE;
-}
-
-void renderspu_SystemReparentWindow(WindowInfo *)
-{
-    /* stub only */
-}
-
-void
-renderspu_SystemDestroyWindow(WindowInfo *window)
-{
-    CRASSERT(window);
-    CRASSERT(window->visual);
-
-    if(!window->nativeWindow)
-    {
-        EventRef evt;
-        OSStatus status = CreateEvent(NULL, kEventClassVBox, kEventVBoxDisposeWindow, 0, kEventAttributeNone, &evt);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemDestroyWindow): CreateEvent Failed");
-        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemDestroyWindow): SetEventParameter Failed");
-        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemDestroyWindow): PostEventToQueue Failed");
-    }
-
-    /* Delete the dummy context */
-    if(window->dummyContext)
-    {
-        render_spu.ws.aglSetDrawable(window->dummyContext, NULL);
-        render_spu.ws.aglDestroyContext(window->dummyContext);
-        window->dummyContext = NULL;
-    }
-
-    /* Reset some values */
-    window->bufferName = -1;
-    window->visual = NULL;
-    window->window = NULL;
-
-    if (window->hVisibleRegion)
-    {
-        DisposeRgn(window->hVisibleRegion);
-        window->hVisibleRegion = 0;
-    }
-}
-
-void
-renderspu_SystemWindowPosition(WindowInfo *window,
-                               GLint x, GLint y)
-{
-    CRASSERT(window);
-    CRASSERT(window->window);
-
-    OSStatus status = noErr;
-    /* Send a event to the main thread, cause some function of Carbon aren't
-     * thread safe */
-    EventRef evt;
-    status = CreateEvent(NULL, kEventClassVBox, kEventVBoxMoveWindow, 0, kEventAttributeNone, &evt);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): CreateEvent Failed");
-    status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof(window->window), &window->window);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): SetEventParameter Failed");
-    HIPoint p = CGPointMake (x, y);
-    status = SetEventParameter(evt, kEventParamOrigin, typeHIPoint, sizeof (p), &p);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): SetEventParameter Failed");
-    status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): SetEventParameter Failed");
-    status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): PostEventToQueue Failed");
-
-    /* save the new pos */
-    window->x = x;
-    window->y = y;
-}
-
-void
-renderspu_SystemWindowSize(WindowInfo *window, GLint w, GLint h)
-{
-    CRASSERT(window);
-    CRASSERT(window->window);
-
-    OSStatus status = noErr;
-    /* Send a event to the main thread, cause some function of Carbon aren't
-     * thread safe */
-    EventRef evt;
-    status = CreateEvent(NULL, kEventClassVBox, kEventVBoxResizeWindow, 0, kEventAttributeNone, &evt);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): CreateEvent Failed ");
-    status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof(window->window), &window->window);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SetEventParameter Failed");
-    HISize s = CGSizeMake (w, h);
-    status = SetEventParameter(evt, kEventParamDimensions, typeHISize, sizeof (s), &s);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SetEventParameter Failed");
-    status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SetEventParameter Failed");
-    status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SendEventToEventTarget Failed");
-
-    DEBUG_MSG_POETZSCH (("Size %d visible %d\n", window->BltInfo.Base.id, IsWindowVisible (window->window)));
-    /* save the new size */
-    window->BltInfo.width = w;
-    window->BltInfo.height = h;
-}
-
-void
-renderspu_SystemGetWindowGeometry(WindowInfo *window,
-                                  GLint *x, GLint *y,
-                                  GLint *w, GLint *h)
-{
-    CRASSERT(window);
-    CRASSERT(window->window);
-
-    OSStatus status = noErr;
-    Rect r;
-    status = GetWindowBounds(window->window, kWindowStructureRgn, &r);
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemGetWindowGeometry): GetWindowBounds Failed");
-
-    *x = (int) r.left;
-    *y = (int) r.top;
-    *w = (int) (r.right - r.left);
-    *h = (int) (r.bottom - r.top);
-}
-
-void
-renderspu_SystemGetMaxWindowSize(WindowInfo *window,
-                                 GLint *w, GLint *h)
-{
-    CRASSERT(window);
-    CRASSERT(window->window);
-
-    OSStatus status = noErr;
-    HISize s;
-#ifdef __LP64__ /** @todo port to 64-bit darwin. */
-    status = -1;
-#else
-    status = GetWindowResizeLimits (window->window, NULL, &s);
-#endif
-    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemGetMaxWindowSize): GetWindowResizeLimits Failed");
-
-    *w = s.width;
-    *h = s.height;
-}
-
-/* Either show or hide the render SPU's window. */
-void
-renderspu_SystemShowWindow(WindowInfo *window, GLboolean showIt)
-{
-    CRASSERT(window);
-    CRASSERT(window->window);
-
-    if (!IsValidWindowPtr(window->window))
-        return;
-
-    if(showIt)
-    {
-        /* Force moving the win to the right position before we show it */
-        renderspu_SystemWindowPosition (window, window->x, window->y);
-        OSStatus status = noErr;
-        /* Send a event to the main thread, cause some function of Carbon
-         * aren't thread safe */
-        EventRef evt;
-        status = CreateEvent(NULL, kEventClassVBox, kEventVBoxShowWindow, 0, kEventAttributeNone, &evt);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): CreateEvent Failed");
-        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): SetEventParameter Failed");
-        status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowShow): SetEventParameter Failed");
-        //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
-        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): PostEventToQueue Failed");
-    }
-    else
-    {
-        EventRef evt;
-        OSStatus status = CreateEvent(NULL, kEventClassVBox, kEventVBoxHideWindow, 0, kEventAttributeNone, &evt);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): CreateEvent Failed");
-        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): SetEventParameter Failed");
-        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): PostEventToQueue Failed");
-    }
-}
-
-void renderspu_SystemVBoxPresentComposition( WindowInfo *window, const struct VBOXVR_SCR_COMPOSITOR * pCompositor, const struct VBOXVR_SCR_COMPOSITOR_ENTRY *pChangedEntry )
-{
-    renderspuVBoxPresentCompositionGeneric(window, pCompositor, pChangedEntry, 0, false);
-}
-
-void
-renderspu_SystemMakeCurrent(WindowInfo *window, GLint nativeWindow,
-                            ContextInfo *context)
-{
-    Boolean result;
-/*    DEBUG_MSG_POETZSCH (("makecurrent %d: \n", window->BltInfo.Base.id));*/
-
-    CRASSERT(render_spu.ws.aglSetCurrentContext);
-    //crDebug( "renderspu_SystemMakeCurrent( %x, %i, %x )", window, nativeWindow, context );
-
-    nativeWindow = 0;
-
-    if(window && context)
-    {
-        CRASSERT(window->window);
-        CRASSERT(context->context);
-
-        if(window->visual != context->visual)
-        {
-            crDebug("Render SPU (renderspu_SystemMakeCurrent): MakeCurrent visual mismatch (0x%x != 0x%x); remaking window.",
-                    (uint)window->visual->visAttribs, (uint)context->visual->visAttribs);
-            /*
-             * XXX have to revisit this issue!!!
-             *
-             * But for now we destroy the current window
-             * and re-create it with the context's visual abilities
-             */
-            renderspu_SystemDestroyWindow(window);
-            renderspu_SystemCreateWindow(context->visual, window->visible,
-                                         window);
-        }
-
-        /* This is the normal case: rendering to the render SPU's own window */
-        result = renderspuWindowAttachContext(window, window->window,
-                                              context);
-        /* XXX this is a total hack to work around an NVIDIA driver bug */
-        if(render_spu.self.GetFloatv && context->haveWindowPosARB)
-        {
-            GLfloat f[4];
-            render_spu.self.GetFloatv(GL_CURRENT_RASTER_POSITION, f);
-            if (!window->everCurrent || f[1] < 0.0)
-            {
-                crDebug("Render SPU (renderspu_SystemMakeCurrent): Resetting raster pos");
-                render_spu.self.WindowPos2iARB(0, 0);
-            }
-        }
-        /* Reapply the visible regions */
-        renderspu_SystemWindowApplyVisibleRegion(window);
-    }
-    else
-        renderspuWindowAttachContext (0, 0, 0);
-}
-
-void
-renderspu_SystemSwapBuffers(WindowInfo *window, GLint flags)
-{
-    CRASSERT(window);
-    CRASSERT(window->window);
-
-    ContextInfo *context = renderspuGetWindowContext(window);
-
-    if(!context)
-        crError("Render SPU (renderspu_SystemSwapBuffers): SwapBuffers got a null context from the window");
-
-    RTSemFastMutexRequest(render_spu.syncMutex);
-//    DEBUG_MSG_POETZSCH (("Swapped %d context %x visible: %d\n", window->BltInfo.Base.id, context->context, IsWindowVisible (window->window)));
-    if (context->visual &&
-        context->visual->visAttribs & CR_DOUBLE_BIT)
-        render_spu.ws.aglSwapBuffers(context->context);
-    else
-        glFlush();
-    RTSemFastMutexRelease(render_spu.syncMutex);
-
-    /* This method seems called very often. To prevent the dock using all free
-     * resources we update the dock only two times per second. */
-    uint64_t curTS = RTTimeMilliTS();
-    if ((curTS - render_spu.uiDockUpdateTS) > 500)
-    {
-        OSStatus status = noErr;
-        /* Send a event to the main thread, cause some function of Carbon aren't
-         * thread safe */
-        EventRef evt;
-        status = CreateEvent(NULL, kEventClassVBox, kEventVBoxUpdateDock, 0, kEventAttributeNone, &evt);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemSwapBuffers): CreateEvent Failed");
-        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
-        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemSwapBuffers): PostEventToQueue Failed");
-
-        render_spu.uiDockUpdateTS = curTS;
-    }
-}
-
-GLboolean renderspu_SystemWindowNeedEmptyPresent(WindowInfo *window)
-{
-    return GL_FALSE;
-}
-
-void renderspu_SystemWindowVisibleRegion(WindowInfo *window, GLint cRects, const GLint* pRects)
-{
-    CRASSERT(window);
-    CRASSERT(window->window);
-
-    /* Remember any additional clipping stuff e.g. seamless regions */
-    if (window->hVisibleRegion)
-    {
-        DisposeRgn(window->hVisibleRegion);
-        window->hVisibleRegion = 0;
-    }
-
-    if (cRects>0)
-    {
-        int i;
-        /* Create some temporary regions */
-        RgnHandle rgn = NewRgn();
-        SetEmptyRgn (rgn);
-        RgnHandle tmpRgn = NewRgn();
-        for (i=0; i<cRects; ++i)
-        {
-            SetRectRgn (tmpRgn,
-                        pRects[4*i]  , pRects[4*i+1],
-                        pRects[4*i+2], pRects[4*i+3]);
-            //DEBUG_MSG_POETZSCH (("visible rect %d %d %d %d\n", pRects[4*i]  , pRects[4*i+1],
-            //                     pRects[4*i+2], pRects[4*i+3]));
-            UnionRgn (rgn, tmpRgn, rgn);
-        }
-        DisposeRgn (tmpRgn);
-        window->hVisibleRegion = rgn;
-    }
-
-    renderspu_SystemWindowApplyVisibleRegion(window);
-}
-
-static void renderspu_SystemSetRootVisibleRegion(GLint cRects, GLint *pRects)
-{
-    /* Remember the visible region of the root window if there is one */
-    if (render_spu.hRootVisibleRegion)
-    {
-        DisposeRgn(render_spu.hRootVisibleRegion);
-        render_spu.hRootVisibleRegion = 0;
-    }
-
-    if (cRects>0)
-    {
-        int i;
-        render_spu.hRootVisibleRegion = NewRgn();
-        SetEmptyRgn (render_spu.hRootVisibleRegion);
-        RgnHandle tmpRgn = NewRgn();
-        for (i=0; i<cRects; ++i)
-        {
-            SetRectRgn (tmpRgn,
-                        pRects[4*i]  , pRects[4*i+1],
-                        pRects[4*i+2], pRects[4*i+3]);
-            UnionRgn (render_spu.hRootVisibleRegion, tmpRgn, render_spu.hRootVisibleRegion);
-        }
-        DisposeRgn (tmpRgn);
-    }
-}
-
-/*Assumes that all regions are in the guest coordinates system*/
-static void renderspu_SystemWindowApplyVisibleRegion(WindowInfo *window)
-{
-    ContextInfo *c = renderspuGetWindowContext(window);
-    RgnHandle rgn;
-    GLboolean result = true;
-
-    DEBUG_MSG_POETZSCH (("ApplyVisibleRegion %x\n", window));
-
-    if (!c || !c->context) return;
-
-    rgn = NewRgn();
-    SetEmptyRgn(rgn);
-
-    if (render_spu.hRootVisibleRegion)
-    {
-        /* The render_spu.hRootVisibleRegion has coordinates from the root
-         * window. We intersect it with the rect of the OpenGL window we
-         * currently process. */
-        SetRectRgn(rgn,
-                   window->x, window->y,
-                   window->x + window->BltInfo.width,
-                   window->y + window->BltInfo.height);
-        SectRgn(render_spu.hRootVisibleRegion, rgn, rgn);
-        /* Because the clipping is done in the coordinate space of the OpenGL
-         * window we have to remove the x/y position from the newly created
-         * region. */
-        OffsetRgn (rgn, -window->x, -window->y);
-    }
-    else
-    {
-        /* If there is not root clipping region is available, create a base
-         * region with the size of the target window. This covers all
-         * needed/possible space. */
-        SetRectRgn(rgn, 0, 0, window->BltInfo.width, window->BltInfo.height);
-    }
-
-    /* Now intersect the window clipping region with a additional region e.g.
-     * for the seamless mode. */
-    if (window->hVisibleRegion)
-        SectRgn(rgn, window->hVisibleRegion, rgn);
-
-    if (rgn && !EmptyRgn(rgn))
-    {
-        /* Set the clip region to the context */
-        result = render_spu.ws.aglSetInteger(c->context, AGL_CLIP_REGION, (const GLint*)rgn);
-        CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowVisibleRegion): SetInteger Failed");
-        result = render_spu.ws.aglEnable(c->context, AGL_CLIP_REGION);
-        CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowVisibleRegion): Enable Failed");
-    }
-    /* Clear the region structure */
-    DisposeRgn (rgn);
-}
-
-GLboolean
-renderspu_SystemVBoxCreateWindow(VisualInfo *visual, GLboolean showIt,
-                                 WindowInfo *window)
-{
-    CRASSERT(visual);
-    CRASSERT(window);
-
-    WindowAttributes winAttr = kWindowNoShadowAttribute | kWindowCompositingAttribute | kWindowIgnoreClicksAttribute | kWindowStandardHandlerAttribute | kWindowLiveResizeAttribute;
-    WindowClass winClass = kOverlayWindowClass;
-    Rect windowRect;
-    OSStatus status = noErr;
-
-    window->visual = visual;
-    window->nativeWindow = NULL;
-
-    if(window->window && IsValidWindowPtr(window->window))
-    {
-        EventRef evt;
-        status = CreateEvent(NULL, kEventClassVBox, kEventVBoxDisposeWindow, 0, kEventAttributeNone, &evt);
-        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateEvent Failed", false);
-        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
-        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): SetEventParameter Failed", false);
-        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
-        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): PostEventToQueue Failed", false);
-    }
-
-    windowRect.left = window->x;
-    windowRect.top = window->y;
-    windowRect.right = window->x + window->BltInfo.width;
-    windowRect.bottom = window->y + window->BltInfo.height;
-
-    status = CreateNewWindow(winClass, winAttr, &windowRect, &window->window);
-    CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateNewWindow Failed", GL_FALSE);
-
-    /* We set a title for debugging purposes */
-    CFStringRef title_string;
-    title_string = CFStringCreateWithCStringNoCopy(NULL, window->title,
-                                                   kCFStringEncodingMacRoman, NULL);
-    SetWindowTitleWithCFString(window->BltInfo.window, title_string);
-    CFRelease(title_string);
-
-    /* The parent has to be in its own group */
-    WindowRef parent = NULL;
-    if (render_spu_parent_window_id)
-    {
-        parent = HIViewGetWindow ((HIViewRef)render_spu_parent_window_id);
-        SetWindowGroup (parent, render_spu.pParentGroup);
-
-    }
-
-    /* Add the new window to the master group */
-    SetWindowGroup(window->window, render_spu.pMasterGroup);
-
-    /* This will be initialized on the first attempt to attach the global
-     * context to this new window */
-    window->bufferName = -1;
-    window->dummyContext = NULL;
-    window->hVisibleRegion = 0;
-
-    if(showIt)
-        renderspu_SystemShowWindow(window, GL_TRUE);
-
-    crDebug("Render SPU (renderspu_SystemVBoxCreateWindow): actual window (x, y, width, height): %d, %d, %d, %d",
-            window->x, window->y, window->BltInfo.width, window->BltInfo.height);
-
-    return GL_TRUE;
-}
-
-int renderspu_SystemInit()
-{
-    return VINF_SUCCESS;
-}
-
-int renderspu_SystemTerm()
-{
-    return VINF_SUCCESS;
-}
-
-void renderspu_SystemDefaultSharedContextChanged(ContextInfo *fromContext, ContextInfo *toContext)
-{
-
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_config.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_config.c	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_config.c	(revision 78190)
@@ -10,316 +10,11 @@
 #include "cr_mem.h"
 #include "cr_error.h"
-#include "cr_environment.h"
-#include "cr_url.h"
 
-
-static void set_window_geometry( RenderSPU *render_spu, const char *response )
-{
-    int x, y, w, h;
-    CRASSERT(response[0] == '[');
-    sscanf( response, "[ %d, %d, %d, %d ]", &x, &y, &w, &h );
-    render_spu->defaultX = (int) x;
-    render_spu->defaultY = (int) y;
-    render_spu->defaultWidth = (unsigned int) w;
-    render_spu->defaultHeight = (unsigned int) h;
-}
-
-static void set_default_visual( RenderSPU *render_spu, const char *response )
-{
-    if (crStrlen(response) > 0) {
-        if (crStrstr(response, "rgb"))
-                render_spu->default_visual |= CR_RGB_BIT;
-        if (crStrstr(response, "alpha"))
-                render_spu->default_visual |= CR_ALPHA_BIT;
-        if (crStrstr(response, "z") || crStrstr(response, "depth"))
-                render_spu->default_visual |= CR_DEPTH_BIT;
-        if (crStrstr(response, "stencil"))
-                render_spu->default_visual |= CR_STENCIL_BIT;
-        if (crStrstr(response, "accum"))
-                render_spu->default_visual |= CR_ACCUM_BIT;
-        if (crStrstr(response, "stereo"))
-                render_spu->default_visual |= CR_STEREO_BIT;
-        if (crStrstr(response, "multisample"))
-                render_spu->default_visual |= CR_MULTISAMPLE_BIT;
-        if (crStrstr(response, "double"))
-                render_spu->default_visual |= CR_DOUBLE_BIT;
-        if (crStrstr(response, "pbuffer"))
-                render_spu->default_visual |= CR_PBUFFER_BIT;
-    }
-}
-
-static void set_display_string( RenderSPU *render_spu, const char *response )
-{
-    if (!crStrcmp(response, "DEFAULT")) {
-        const char *display = crGetenv("DISPLAY");
-        if (display)
-            crStrncpy(render_spu->display_string,
-                                display,
-                                sizeof(render_spu->display_string));
-        else
-            crStrcpy(render_spu->display_string, ""); /* empty string */
-    }
-    else {
-        crStrncpy(render_spu->display_string,
-                            response,
-                            sizeof(render_spu->display_string));
-    }
-}
-
-static void set_fullscreen( RenderSPU *render_spu, const char *response )
-{
-    sscanf( response, "%d", &(render_spu->fullscreen) );
-}
-
-static void set_on_top( RenderSPU *render_spu, const char *response )
-{
-    sscanf( response, "%d", &(render_spu->ontop) );
-}
-
-static void set_system_gl_path( RenderSPU *render_spu, const char *response )
-{
-    if (crStrlen(response) > 0)
-        crSetenv( "CR_SYSTEM_GL_PATH", response );
-}
-
-static void set_title( RenderSPU *render_spu, const char *response )
-{
-    crFree( render_spu->window_title );
-    render_spu->window_title = crStrdup( response );
-}
-
-#if defined(GLX)
-static void set_try_direct( RenderSPU *render_spu, const char *response )
-{
-    sscanf( response, "%d", &(render_spu->try_direct) );
-}
-
-static void set_force_direct( RenderSPU *render_spu, const char *response )
-{
-    sscanf( response, "%d", &(render_spu->force_direct) );
-}
-#endif /* GLX */
-
-static void render_to_app_window( RenderSPU *render_spu, const char *response )
-{
-    sscanf( response, "%d", &(render_spu->render_to_app_window) );
-}
-
-static void render_to_crut_window( RenderSPU *render_spu, const char *response )
-{
-    sscanf( response, "%d", &(render_spu->render_to_crut_window) );
-}
-
-static void resizable( RenderSPU *render_spu, const char *response )
-{
-    sscanf( response, "%d", &(render_spu->resizable) );
-}
-
-static void set_borderless( RenderSPU *render_spu, const char *response )
-{
-    sscanf( response, "%d", &(render_spu->borderless) );
-}
-
-static void set_cursor( RenderSPU *render_spu, const char *response )
-{
-    sscanf( response, "%d", &(render_spu->drawCursor) );
-}
-
-static void gather_url( RenderSPU *render_spu, const char *response )
-{
-    char protocol[4096], hostname[4096];
-    unsigned short port;
-    
-    if (!crParseURL(response, protocol, hostname, &port, 0))
-    {
-        crError( "Malformed URL: \"%s\"", response );
-    }
-
-    render_spu->gather_port = port;
-}
-
-static void gather_userbuf( RenderSPU *render_spu, const char *response )
-{
-    sscanf( response, "%d", &(render_spu->gather_userbuf_size) );
-}
-
-static void set_lut8( RenderSPU *render_spu, const char *response )
-{
-    int a;  
-    char **lut;
-    
-    if (!response[0]) return;
-
-    lut = crStrSplit(response, ",");
-    if (!lut) return;
-
-    for (a=0; a<256; a++)
-    {
-        render_spu->lut8[0][a]  = crStrToInt(lut[a]);
-        render_spu->lut8[1][a]  = crStrToInt(lut[256+a]);
-        render_spu->lut8[2][a]  = crStrToInt(lut[512+a]);
-    }
-
-    crFreeStrings(lut);
-
-    render_spu->use_lut8 = 1;
-}
-
-static void set_master_url ( RenderSPU *render_spu, char *response )
-{
-    if (response[0])
-        render_spu->swap_master_url = crStrdup( response );
-    else
-        render_spu->swap_master_url = NULL;
-}
-
-static void set_is_master ( RenderSPU *render_spu, char *response )
-{
-    render_spu->is_swap_master = crStrToInt( response );
-}
-
-static void set_num_clients ( RenderSPU *render_spu, char *response )
-{
-    render_spu->num_swap_clients = crStrToInt( response );
-}
-
-static void set_use_osmesa ( RenderSPU *render_spu, char *response )
-{
-    int val = crStrToInt( response );
-#ifdef USE_OSMESA
-    render_spu->use_osmesa = val;
-#else
-    if (val != 0)
-        crError( "renderspu with Conf(use_osmesa, 1) but not compiled with -DUSE_OSMESA");
-#endif
-}
-
-static void set_nv_swap_group( RenderSPU *render_spu, char *response )
-{
-    render_spu->nvSwapGroup = crStrToInt( response );
-    if (render_spu->nvSwapGroup < 0)
-        render_spu->nvSwapGroup = 0;
-}
-
-static void set_ignore_papi( RenderSPU *render_spu, char *response )
-{
-    render_spu->ignore_papi = crStrToInt( response );
-}
-
-static void set_ignore_window_moves( RenderSPU *render_spu, char *response )
-{
-    render_spu->ignore_window_moves = crStrToInt( response );
-}
-
-static void set_pbuffer_size( RenderSPU *render_spu, const char *response )
-{
-    CRASSERT(response[0] == '[');
-    sscanf( response, "[ %d, %d ]",
-                    &render_spu->pbufferWidth, &render_spu->pbufferHeight);
-}
-
-static void set_use_glxchoosevisual( RenderSPU *render_spu, char *response )
-{
-    render_spu->use_glxchoosevisual = crStrToInt( response );
-}
-
-static void set_draw_bbox( RenderSPU *render_spu, char *response )
-{
-    render_spu->draw_bbox = crStrToInt( response );
-}
-
-
-
-/* option, type, nr, default, min, max, title, callback
- */
-SPUOptions renderSPUOptions[] = {
-    { "title", CR_STRING, 1, "Chromium Render SPU", NULL, NULL, 
-        "Window Title", (SPUOptionCB)set_title },
-
-    { "window_geometry", CR_INT, 4, "[0, 0, 256, 256]", "[0, 0, 1, 1]", NULL, 
-        "Default Window Geometry (x,y,w,h)", (SPUOptionCB)set_window_geometry },
-
-    { "fullscreen", CR_BOOL, 1, "0", NULL, NULL, 
-        "Full-screen Window", (SPUOptionCB)set_fullscreen },
-
-    { "resizable", CR_BOOL, 1, "0", NULL, NULL,
-        "Resizable Window", (SPUOptionCB)resizable },
-
-    { "on_top", CR_BOOL, 1, "0", NULL, NULL, 
-        "Display on Top", (SPUOptionCB)set_on_top },
-
-    { "borderless", CR_BOOL, 1, "0", NULL, NULL,
-        "Borderless Window", (SPUOptionCB) set_borderless },
-
-    { "default_visual", CR_STRING, 1, "rgb, double, depth", NULL, NULL,
-        "Default GL Visual", (SPUOptionCB) set_default_visual },
-
-#if defined(GLX)
-    { "try_direct", CR_BOOL, 1, "1", NULL, NULL, 
-        "Try Direct Rendering", (SPUOptionCB)set_try_direct  },
-
-    { "force_direct", CR_BOOL, 1, "0", NULL, NULL, 
-        "Force Direct Rendering", (SPUOptionCB)set_force_direct },
-#endif
-
-    { "render_to_app_window", CR_BOOL, 1, "0", NULL, NULL,
-        "Render to Application window", (SPUOptionCB)render_to_app_window },
-
-    { "render_to_crut_window", CR_BOOL, 1, "0", NULL, NULL,
-        "Render to CRUT window", (SPUOptionCB)render_to_crut_window },
-
-    { "show_cursor", CR_BOOL, 1, "0", NULL, NULL,
-        "Show Software Cursor", (SPUOptionCB) set_cursor },
-
-    { "system_gl_path", CR_STRING, 1, "", NULL, NULL, 
-        "System GL Path", (SPUOptionCB)set_system_gl_path },
-
-    { "display_string", CR_STRING, 1, "DEFAULT", NULL, NULL, 
-        "X Display String", (SPUOptionCB)set_display_string },
-
-    { "gather_url", CR_STRING, 1, "", NULL, NULL,
-        "Gatherer URL", (SPUOptionCB)gather_url},
-
-    { "gather_userbuf_size", CR_INT, 1, "0", NULL, NULL,
-        "Size of Buffer to Allocate for Gathering", (SPUOptionCB)gather_userbuf},
-
-    { "lut8", CR_STRING, 1, "", NULL, NULL,
-        "8 bit RGB LUT", (SPUOptionCB)set_lut8},
-
-    { "swap_master_url", CR_STRING, 1, "", NULL, NULL,
-        "The URL to the master swapper", (SPUOptionCB)set_master_url },
-
-    { "is_swap_master", CR_BOOL, 1, "0", NULL, NULL,
-        "Is this the swap master", (SPUOptionCB)set_is_master },
-
-    { "num_swap_clients", CR_INT, 1, "1", NULL, NULL,
-        "How many swaps to wait on", (SPUOptionCB)set_num_clients },
-
-    { "use_osmesa", CR_BOOL, 1, "0", NULL, NULL,
-        "Use offscreen rendering with Mesa", (SPUOptionCB)set_use_osmesa },
-     
-    { "nv_swap_group", CR_INT, 1, "0", NULL, NULL,
-        "NVIDIA Swap Group Number", (SPUOptionCB) set_nv_swap_group },
-
-    { "ignore_papi", CR_BOOL, 1, "0", NULL, NULL,
-        "Ignore Barrier and Semaphore calls", (SPUOptionCB) set_ignore_papi },
-
-    { "ignore_window_moves", CR_BOOL, 1, "0", NULL, NULL,
-        "Ignore crWindowPosition calls", (SPUOptionCB) set_ignore_window_moves },
-
-    { "pbuffer_size", CR_INT, 2, "[0, 0]", "[0, 0]", NULL,
-        "Maximum PBuffer Size", (SPUOptionCB) set_pbuffer_size },
-
-    { "use_glxchoosevisual", CR_BOOL, 1, "1", NULL, NULL,
-        "Use glXChooseVisual", (SPUOptionCB) set_use_glxchoosevisual },
-
-    { "draw_bbox", CR_BOOL, 1, "0", NULL, NULL,
-        "Draw Bounding Boxes", (SPUOptionCB) set_draw_bbox },
-    { NULL, CR_BOOL, 0, NULL, NULL, NULL, NULL, NULL },
-};
+#include <iprt/env.h>
 
 
 void renderspuSetVBoxConfiguration( RenderSPU *render_spu )
 {
+    const char *display = NULL;
     int a;
 
@@ -332,35 +27,38 @@
     render_spu->use_lut8 = 0;
 
-    set_title(render_spu, "Chromium Render SPU");
-    set_window_geometry(render_spu, "[0, 0, 0, 0]");
-    set_fullscreen(render_spu, "0");
-    resizable(render_spu, "0");
-    set_on_top(render_spu, "1");
-    set_borderless(render_spu, "1");
-    set_default_visual(render_spu, "rgb, double, depth");
+    crFree( render_spu->window_title );
+    render_spu->window_title = crStrdup("Chromium Render SPU");
+    render_spu->defaultX = 0;
+    render_spu->defaultY = 0;
+    render_spu->defaultWidth = 0;
+    render_spu->defaultHeight = 0;
+    render_spu->fullscreen = 0;
+    render_spu->resizable = 0;
+    render_spu->ontop = 1;
+    render_spu->borderless = 1;
+    render_spu->default_visual = CR_RGB_BIT | CR_DOUBLE_BIT | CR_DEPTH_BIT;
 #if defined(GLX)
-    set_try_direct(render_spu, "1");
-    set_force_direct(render_spu, "0");
+    render_spu->try_direct = 1;
+    render_spu->force_direct = 0;
 #endif
-    render_to_app_window(render_spu, "0");
-    render_to_crut_window(render_spu, "0");
-    set_cursor(render_spu, "0");
-    set_system_gl_path(render_spu, "");
-    set_display_string(render_spu, "DEFAULT");
-    gather_url(render_spu, "");
-    gather_userbuf(render_spu, "0");
-    set_lut8(render_spu, "");
-    set_master_url(render_spu, "");
-    set_is_master(render_spu, "0");
-    set_num_clients(render_spu, "1");
-    set_use_osmesa(render_spu, "0");
-    set_nv_swap_group(render_spu, "0");
-    set_ignore_papi(render_spu, "0");
-    set_ignore_window_moves(render_spu, "0");
-    set_pbuffer_size(render_spu, "[0, 0]");
-    set_use_glxchoosevisual(render_spu, "1");
-    set_draw_bbox(render_spu, "0");
+    render_spu->render_to_app_window = 0;
+    render_spu->render_to_crut_window = 0;
+    render_spu->drawCursor = 0;
+    render_spu->gather_userbuf_size = 0;
+    render_spu->use_lut8 = 0;
+    render_spu->num_swap_clients = 1;
+    render_spu->nvSwapGroup = 0;
+    render_spu->ignore_papi = 0;
+    render_spu->ignore_window_moves = 0;
+    render_spu->pbufferWidth = 0;
+    render_spu->pbufferHeight = 0;
+    render_spu->use_glxchoosevisual = 1;
+    render_spu->draw_bbox = 0;
 
-    render_spu->swap_mtu = 1024 * 500;
+    display = RTEnvGet("DISPLAY");
+    if (display)
+        crStrncpy(render_spu->display_string, display, sizeof(render_spu->display_string));
+    else
+        crStrcpy(render_spu->display_string, ""); /* empty string */
 
     /* Some initialization that doesn't really have anything to do
@@ -376,5 +74,5 @@
     /* Config of "render force present main thread" (currently implemented by glx and wgl). */
     {
-        const char *forcePresent = crGetenv("CR_RENDER_FORCE_PRESENT_MAIN_THREAD");
+        const char *forcePresent = RTEnvGet("CR_RENDER_FORCE_PRESENT_MAIN_THREAD");
         if (forcePresent)
             render_spu->force_present_main_thread = crStrToInt(forcePresent) ? 1 : 0;
Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_glx.c	(revision 78190)
@@ -4,9 +4,4 @@
  * See the file LICENSE.txt for information on redistributing this software.
  */
-#if 00 /*TEMPORARY*/
-#include <unistd.h>
-#include "cr_rand.h"
-#endif
-
 #include <GL/glx.h>
 #include <X11/Xlib.h>
@@ -18,5 +13,4 @@
 #include <stdio.h>
 
-#include "cr_environment.h"
 #include "cr_error.h"
 #include "cr_string.h"
@@ -24,5 +18,4 @@
 #include "cr_process.h"
 #include "renderspu.h"
-
 
 /*
@@ -948,20 +941,5 @@
     flags = CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
 
-    /* 
-     * We pass the VNC's desktop windowID via an environment variable.
-     * If we don't find one, we're not on a 3D-capable vncviewer, or
-     * if we do find one, then create the renderspu subwindow as a
-     * child of the vncviewer's desktop window. 
-     *
-     * This is purely for the replicateSPU.
-     *
-     * NOTE: This is crufty, and will do for now. FIXME.
-     */
-    vncWin = crStrToInt( crGetenv("CRVNCWINDOW") );
-    if (vncWin)
-        parent = (Window) vncWin;
-    else
-        parent = RootWindow(dpy, visual->visual->screen);
-
+    parent = RootWindow(dpy, visual->visual->screen);
     if (render_spu_parent_window_id>0)
     {
@@ -1989,17 +1967,4 @@
     CRASSERT(w);
 
-#if 00 /*TEMPORARY - FOR TESTING SWAP LOCK*/
-    if (1) {
-        /* random delay */
-        int k = crRandInt(1000 * 100, 750*1000);
-        static int first = 1;
-        if (first) {
-             crRandAutoSeed();
-             first = 0;
-        }
-        usleep(k);
-    }
-#endif
-
     /* render_to_app_window:
      * w->nativeWindow will only be non-zero if the
Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_init.c	(revision 78190)
@@ -9,8 +9,8 @@
 #include "cr_error.h"
 #include "cr_string.h"
-#include "cr_url.h"
-#include "cr_environment.h"
 #include "renderspu.h"
 #include <stdio.h>
+
+#include <iprt/env.h>
 
 #ifdef RT_OS_DARWIN
@@ -32,38 +32,4 @@
 CRtsd _RenderTSD;
 #endif
-
-static void swapsyncConnect(void)
-{
-    char hostname[4096], protocol[4096];
-    unsigned short port;
-
-    crNetInit(NULL, NULL);
-
-    if (!crParseURL( render_spu.swap_master_url, protocol, hostname,
-                    &port, 9876))
-        crError( "Bad URL: %s", render_spu.swap_master_url );
-
-    if (render_spu.is_swap_master)
-    {
-        int a;
-
-        render_spu.swap_conns = (CRConnection **)crAlloc(
-                        render_spu.num_swap_clients*sizeof(CRConnection *));
-        for (a=0; a<render_spu.num_swap_clients; a++)
-        {
-            render_spu.swap_conns[a] = crNetAcceptClient( protocol, hostname, port,
-                                                        render_spu.swap_mtu, 1);
-        }
-    }
-    else
-    {
-        render_spu.swap_conns = (CRConnection **)crAlloc(sizeof(CRConnection *));
-
-        render_spu.swap_conns[0] = crNetConnectToServer(render_spu.swap_master_url,
-                                    port, render_spu.swap_mtu, 1);
-        if (!render_spu.swap_conns[0])
-            crError("Failed connection");
-    }
-}
 
 #ifdef RT_OS_WINDOWS
@@ -195,8 +161,4 @@
     renderspuSetVBoxConfiguration(&render_spu);
 
-    if (render_spu.swap_master_url)
-        swapsyncConnect();
-
-
     /* Get our special functions. */
     numSpecial = renderspuCreateFunctions( _cr_render_table );
@@ -234,5 +196,5 @@
     render_spu.dummyWindowTable = crAllocHashtable();
 
-    pcpwSetting = crGetenv("CR_RENDER_ENABLE_SINGLE_PRESENT_CONTEXT");
+    pcpwSetting = RTEnvGet("CR_RENDER_ENABLE_SINGLE_PRESENT_CONTEXT");
     if (pcpwSetting)
     {
@@ -271,35 +233,4 @@
     }
 #endif
-
-#ifdef DARWIN
-# ifdef VBOX_WITH_COCOA_QT
-# else /* VBOX_WITH_COCOA_QT */
-    render_spu.hRootVisibleRegion = 0;
-    render_spu.currentBufferName = 1;
-    render_spu.uiDockUpdateTS = 0;
-    /* Create a mutex for synchronizing events from the main Qt thread & this
-       thread */
-    RTSemFastMutexCreate(&render_spu.syncMutex);
-    /* Create our window groups */
-    CreateWindowGroup(kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrSharedActivation | kWindowGroupAttrHideOnCollapse | kWindowGroupAttrFixedLevel, &render_spu.pMasterGroup);
-    CreateWindowGroup(kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrSharedActivation | kWindowGroupAttrHideOnCollapse | kWindowGroupAttrFixedLevel, &render_spu.pParentGroup);
-    /* Make the correct z-layering */
-    SendWindowGroupBehind (render_spu.pParentGroup, render_spu.pMasterGroup);
-    /* and set the gParentGroup as parent for gMasterGroup. */
-    SetWindowGroupParent (render_spu.pMasterGroup, render_spu.pParentGroup);
-    /* Install the event handlers */
-    EventTypeSpec eventList[] =
-    {
-        {kEventClassVBox, kEventVBoxUpdateContext}, /* Update the context after show/size/move events */
-        {kEventClassVBox, kEventVBoxBoundsChanged}  /* Clip/Pos the OpenGL windows when the main window is changed in pos/size */
-    };
-    /* We need to process events from our main window */
-    render_spu.hParentEventHandler = NewEventHandlerUPP(windowEvtHndlr);
-    InstallApplicationEventHandler (render_spu.hParentEventHandler,
-                                    GetEventTypeCount(eventList), eventList,
-                                    NULL, NULL);
-    render_spu.fInit = true;
-# endif /* VBOX_WITH_COCOA_QT */
-#endif /* DARWIN */
 
     rc = renderspuDefaultCtxInit();
@@ -536,22 +467,4 @@
     renderspuCleanupBase(true);
 
-#ifdef RT_OS_DARWIN
-# ifndef VBOX_WITH_COCOA_QT
-    render_spu.fInit = false;
-    DisposeEventHandlerUPP(render_spu.hParentEventHandler);
-    ReleaseWindowGroup(render_spu.pMasterGroup);
-    ReleaseWindowGroup(render_spu.pParentGroup);
-    if (render_spu.hRootVisibleRegion)
-    {
-        DisposeRgn(render_spu.hRootVisibleRegion);
-        render_spu.hRootVisibleRegion = 0;
-    }
-    render_spu.currentBufferName = 1;
-    render_spu.uiDockUpdateTS = 0;
-    RTSemFastMutexDestroy(render_spu.syncMutex);
-# else /* VBOX_WITH_COCOA_QT */
-# endif /* VBOX_WITH_COCOA_QT */
-#endif /* RT_OS_DARWIN */
-
 #ifdef RT_OS_WINDOWS
     if (render_spu.dwWinThreadId)
@@ -600,9 +513,7 @@
 
 
-extern SPUOptions renderSPUOptions[];
-
 int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
          SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
-         SPUOptionsPtr *options, int *flags )
+         int *flags )
 {
     *name = "render";
@@ -611,5 +522,4 @@
     *self = renderSPUSelfDispatch;
     *cleanup = renderSPUCleanup;
-    *options = renderSPUOptions;
     *flags = (SPU_NO_PACKER|SPU_IS_TERMINAL|SPU_MAX_SERVERS_ZERO);
 
Index: /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_wgl.c	(revision 78190)
@@ -13,5 +13,4 @@
 #include <memory.h>
 
-#include "cr_environment.h"
 #include "cr_error.h"
 #include "cr_string.h"
@@ -19,4 +18,5 @@
 #include "cr_mem.h"
 
+#include <iprt/env.h>
 
 /* IAT patcher stuff */
@@ -664,5 +664,5 @@
      */
 #ifdef VBOX_CR_SERVER_FORCE_WGL
-    if (crGetenv( "CR_WGL_DO_NOT_USE_GDI" ) != NULL)
+    if (RTEnvGet( "CR_WGL_DO_NOT_USE_GDI" ) != NULL)
     {
         pixelformat = render_spu.ws.wglChoosePixelFormat( hdc, ppfd );
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.def
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.def	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.def	(revision 78190)
@@ -5,6 +5,4 @@
 EXPORTS
 crUnpack
-crUnpackPush
-crUnpackPop
 crUnpackSetReturnPointer
 crUnpackSetWritebackPointer
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack.py	(revision 78190)
@@ -27,8 +27,7 @@
 DECLEXPORT(const unsigned char *) cr_unpackData = NULL;
 DECLEXPORT(const unsigned char *) cr_unpackDataEnd = NULL;
-SPUDispatchTable cr_unpackDispatch;
-
-static void crUnpackExtend(void);
-static void crUnpackExtendDbg(void);
+
+static void crUnpackExtend(PCrUnpackerState pState);
+static void crUnpackExtendDbg(PCrUnpackerState pState);
 
 #if 0 //def DEBUG_misha
@@ -72,7 +71,7 @@
     argument out of the buffer's operand area."""
     if arg_type == "GLdouble" or arg_type == "GLclampd":
-        retval = "READ_DOUBLE(%d)" % offset
-    else:
-        retval = "READ_DATA(%d, %s)" % (offset, arg_type)
+        retval = "READ_DOUBLE(pState, %d)" % offset
+    else:
+        retval = "READ_DATA(pState, %d, %s)" % (offset, arg_type)
     return retval
 
@@ -83,12 +82,12 @@
     arg_len = apiutil.PacketLength( params )
     if (return_type != 'void'):
-        print('\tSET_RETURN_PTR(%d);' % (arg_len + 8)) # extended opcode plus packet length
+        print('\tSET_RETURN_PTR(pState, %d);' % (arg_len + 8)) # extended opcode plus packet length
     else:
         paramList = [ ('foo', 'void *', 0) ]
-        print('\tSET_RETURN_PTR(%d);' % (arg_len + 8 - apiutil.PacketLength(paramList)))
-
-
-def FindWritebackPointer( return_type, params ):
-    """Emit a SET_WRITEBACK_PTR call."""
+        print('\tSET_RETURN_PTR(pState, %d);' % (arg_len + 8 - apiutil.PacketLength(paramList)))
+
+
+def getWritebackPointerOffset(return_type, params):
+    """Returns the offset of the writeback pointer"""
     arg_len = apiutil.PacketLength( params )
     if return_type != 'void':
@@ -96,5 +95,9 @@
         arg_len += apiutil.PacketLength( paramList )
 
-    print('\tSET_WRITEBACK_PTR(%d);' % (arg_len + 8)) # extended opcode plus packet length
+    return arg_len + 8 # extended opcode plus packet length
+
+def FindWritebackPointer( return_type, params ):
+    """Emit a SET_WRITEBACK_PTR call."""
+    print('\tSET_WRITEBACK_PTR(pState, %d);' % getWritebackPointerOffset(return_type, params))
 
 
@@ -122,5 +125,5 @@
     else:
         print("\t", end="")
-    print("cr_unpackDispatch.%s(%s);" % (func_name, apiutil.MakeCallStringForDispatcher(params)))
+    print("pState->pDispatchTbl->%s(%s);" % (func_name, apiutil.MakeCallStringForDispatcher(params)))
 
 
@@ -134,12 +137,12 @@
     if arg_type == "GLdouble" or arg_type == "GLclampd":
         print("#ifdef CR_UNALIGNED_ACCESS_OKAY")
-        print("\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType))
+        print("\tpState->pDispatchTbl->%s((%s) pState->pbUnpackData);" % (vec_func, vecType))
         print("#else")
         for index in range(0, vecSize):
-            print("\tGLdouble v" + repr(index) + " = READ_DOUBLE(" + repr(index * 8) + ");")
+            print("\tGLdouble v" + repr(index) + " = READ_DOUBLE(pState, " + repr(index * 8) + ");")
         if return_type != "void":
-            print("\t(void) cr_unpackDispatch.%s(" % func_name, end="")
+            print("\t(void) pState->pDispatchTbl->%s(" % func_name, end="")
         else:
-            print("\tcr_unpackDispatch.%s(" % func_name, end="")
+            print("\tpState->pDispatchTbl->%s(" % func_name, end="")
         for index in range(0, vecSize):
             print("v" + repr(index), end="")
@@ -149,5 +152,5 @@
         print("#endif")
     else:
-        print("\tcr_unpackDispatch.%s((%s) cr_unpackData);" % (vec_func, vecType))
+        print("\tpState->pDispatchTbl->%s((%s) pState->pbUnpackData);" % (vec_func, vecType))
 
 
@@ -166,16 +169,12 @@
     params = apiutil.Parameters(func_name)
     return_type = apiutil.ReturnType(func_name)
-    
-    print("static void crUnpack%s(void)" % func_name)
+
+    packet_length = apiutil.PacketLength( params )
+    print("static void crUnpack%s(PCrUnpackerState pState)" % func_name)
     print("{")
-
-    # Verify that the provided buffer length is what we expect.
-    packet_length = apiutil.PacketLength( params )
-    if packet_length > 0:
-        print("\tif(!DATA_POINTER_CHECK(%d))" % packet_length);
-        print("\t{");
-        print("\t\tcrError(\"crUnpack%s: parameters out of range\");" % func_name);
-        print("\t\treturn;");
-        print("\t}");
+    if ("get" in apiutil.Properties(func_name)):
+        print("\tCHECK_BUFFER_SIZE_STATIC(pState, %s);" % getWritebackPointerOffset(return_type, params));
+    elif packet_length != 0:
+        print("\tCHECK_BUFFER_SIZE_STATIC(pState, %s);" % packet_length);
 
     vector_func = apiutil.VectorFunction(func_name)
@@ -185,7 +184,7 @@
         MakeNormalCall( return_type, func_name, params )
     if packet_length == 0:
-        print("\tINCR_DATA_PTR_NO_ARGS( );")
-    else:
-        print("\tINCR_DATA_PTR(%d);" % packet_length)
+        print("\tINCR_DATA_PTR_NO_ARGS(pState);")
+    else:
+        print("\tINCR_DATA_PTR(pState, %d);" % packet_length)
     print("}\n")
 
@@ -195,34 +194,4 @@
 #
 print(""" 
-typedef struct __dispatchNode {
-    const unsigned char *unpackData;
-    struct __dispatchNode *next;
-} DispatchNode;
-
-static DispatchNode *unpackStack = NULL;
-
-static SPUDispatchTable *cr_lastDispatch = NULL;
-
-void crUnpackPush(void)
-{
-    DispatchNode *node = (DispatchNode*)crAlloc( sizeof( *node ) );
-    node->next = unpackStack;
-    unpackStack = node;
-    node->unpackData = cr_unpackData;
-}
-
-void crUnpackPop(void)
-{
-    DispatchNode *node = unpackStack;
-
-    if (!node)
-    {
-        crError( "crUnpackPop called with an empty stack!" );
-    }
-    unpackStack = node->next;
-    cr_unpackData = node->unpackData;
-    crFree( node );
-}
-
 CR_UNPACK_BUFFER_TYPE crUnpackGetBufferType(const void *opcodes, unsigned int num_opcodes)
 {
@@ -249,34 +218,23 @@
 }
 
-void crUnpack( const void *data, const void *data_end, const void *opcodes, 
-        unsigned int num_opcodes, SPUDispatchTable *table )
+void crUnpack(PCrUnpackerState pState)
 {
     unsigned int i;
-    const unsigned char *unpack_opcodes;
-    if (table != cr_lastDispatch)
-    {
-        crSPUCopyDispatchTable( &cr_unpackDispatch, table );
-        cr_lastDispatch = table;
-    }
-
-    unpack_opcodes = (const unsigned char *)opcodes;
-    cr_unpackData = (const unsigned char *)data;
-    cr_unpackDataEnd = (const unsigned char *)data_end;
 
 #if defined(CR_UNPACK_DEBUG_OPCODES) || defined(CR_UNPACK_DEBUG_LAST_OPCODES)
-    crDebug("crUnpack: %d opcodes", num_opcodes);
-#endif
-
-    for (i = 0; i < num_opcodes; i++)
+    crDebug("crUnpack: %d opcodes", pState->cOpcodes);
+#endif
+
+    for (i = 0; i < pState->cOpcodes && RT_SUCCESS(pState->rcUnpack); i++)
     {
     
-        CRDBGPTR_CHECKZ(writeback_ptr);
-        CRDBGPTR_CHECKZ(return_ptr);
+        CRDBGPTR_CHECKZ(pState->pWritebackPtr);
+        CRDBGPTR_CHECKZ(pState->pReturnPtr);
     
-        /*crDebug(\"Unpacking opcode \%d\", *unpack_opcodes);*/
+        /*crDebug(\"Unpacking opcode \%d\", *pState->pbOpcodes);*/
 #ifdef CR_UNPACK_DEBUG_PREV_OPCODES
-        g_VBoxDbgCrPrevOpcode = *unpack_opcodes;
-#endif
-        switch( *unpack_opcodes )
+        g_VBoxDbgCrPrevOpcode = *pState->pbOpcodes;
+#endif
+        switch( *pState->pbOpcodes )
         {""")
 
@@ -295,16 +253,16 @@
                 crDebug("Unpack: %s");
 #endif """ % apiutil.OpcodeName(func_name))
-        print('\t\t\t\tcrUnpack%s(); \n\t\t\t\tbreak;' % func_name)
+        print('\t\t\t\tcrUnpack%s(pState); \n\t\t\t\tbreak;' % func_name)
 
 print("""       
             case CR_EXTEND_OPCODE:
                 #ifdef CR_UNPACK_DEBUG_OPCODES 
-                    crUnpackExtendDbg();
+                    crUnpackExtendDbg(pState);
                 #else
                 # ifdef CR_UNPACK_DEBUG_LAST_OPCODES
-                    if (i==(num_opcodes-1)) crUnpackExtendDbg();
+                    if (i==(num_opcodes-1)) crUnpackExtendDbg(pState);
                     else
                 # endif
-                    crUnpackExtend();
+                    crUnpackExtend(pState);
                 #endif
                 break;
@@ -313,15 +271,14 @@
             case CR_CMDBLOCKFLUSH_OPCODE:
             case CR_NOP_OPCODE:
-                INCR_DATA_PTR_NO_ARGS( );
+                INCR_DATA_PTR_NO_ARGS(pState);
                 break;
             default:
-                crError( "Unknown opcode: %d", *unpack_opcodes );
+                crError( "Unknown opcode: %d", *pState->pbOpcodes );
                 break;
         }
-        
-        CRDBGPTR_CHECKZ(writeback_ptr);
-        CRDBGPTR_CHECKZ(return_ptr);
-        
-        unpack_opcodes--;
+
+        CRDBGPTR_CHECKZ(pState->pWritebackPtr);
+        CRDBGPTR_CHECKZ(pState->pReturnPtr);
+        pState->pbOpcodes--;
     }
 }""")
@@ -336,21 +293,16 @@
             return_type = apiutil.ReturnType(func_name)
             params = apiutil.Parameters(func_name)
-            print('static void crUnpackExtend%s(void)' % func_name)
+            print('static void crUnpackExtend%s(PCrUnpackerState pState)' % func_name)
             print('{')
-
-            # Verify that the provided buffer length is what we expect.
-            packet_length = apiutil.PacketLength( params )
-            if packet_length > 0:
-                print("\tif(!DATA_POINTER_CHECK(%d))" % packet_length);
-                print("\t{");
-                print("\t\tcrError(\"crUnpack%s: parameters out of range\");" % func_name);
-                print("\t\treturn;");
-                print("\t}");
-
+            if ("get" in apiutil.Properties(func_name)):
+                print("\tCHECK_BUFFER_SIZE_STATIC(pState, %s);" % (8 + getWritebackPointerOffset(return_type, params)));
+            else:
+                print("\tCHECK_BUFFER_SIZE_STATIC(pState, %s);" % (8 + apiutil.PacketLength( params )));
             MakeNormalCall( return_type, func_name, params, 8 )
             print('}\n')
 
-print('static void crUnpackExtend(void)')
+print('static void crUnpackExtend(PCrUnpackerState pState)')
 print('{')
+print('\tCHECK_BUFFER_SIZE_STATIC_LAST(pState, 4, GLenum);');
 print('\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' ))
 print('')
@@ -371,5 +323,5 @@
         print('\t\tcase %s:' % apiutil.ExtendedOpcodeName( func_name ))
 #        print('\t\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name )))
-        print('\t\t\tcrUnpackExtend%s( );' % func_name)
+        print('\t\t\tcrUnpackExtend%s(pState);' % func_name)
         print('\t\t\tbreak;')
 
@@ -378,9 +330,10 @@
             break;
     }
-    INCR_VAR_PTR();
+    INCR_VAR_PTR(pState);
 }""")
 
-print('static void crUnpackExtendDbg(void)')
+print('static void crUnpackExtendDbg(PCrUnpackerState pState)')
 print('{')
+print('\tCHECK_BUFFER_SIZE_STATIC_LAST(pState, 4, GLenum);');
 print('\tGLenum extend_opcode = %s;' % ReadData( 4, 'GLenum' ))
 print('')
@@ -402,5 +355,5 @@
         if not apiutil.ExtendedOpcodeName(func_name) in nodebug_extopcodes:
             print('\t\t\tcrDebug("Unpack: %s");' % apiutil.ExtendedOpcodeName( func_name ))
-        print('\t\t\tcrUnpackExtend%s( );' % func_name)
+        print('\t\t\tcrUnpackExtend%s(pState);' % func_name)
         print('\t\t\tbreak;')
 
@@ -409,4 +362,4 @@
             break;
     }
-    INCR_VAR_PTR();
+    INCR_VAR_PTR(pState);
 }""")
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_arrays.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_arrays.c	(revision 78189)
+++ 	(revision )
@@ -1,316 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "cr_error.h"
-#include "unpack_extend.h"
-#include "unpacker.h"
-#include "cr_glstate.h"
-/**
- * \mainpage Unpacker 
- *
- * \section UnpackerIntroduction Introduction
- *
- * Chromium consists of all the top-level files in the cr
- * directory.  The unpacker module basically takes care of API dispatch,
- * and OpenGL state management.
- *
- */
-
-void crUnpackExtendVertexPointer(void)
-{
-    GLint size = READ_DATA( 8, GLint );
-    GLenum type = READ_DATA( 12, GLenum );
-    GLsizei stride = READ_DATA( 16, GLsizei );
-    GLintptrARB pointer = (GLintptrARB) READ_DATA( 20, GLuint );
-    cr_unpackDispatch.VertexPointer( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendTexCoordPointer(void)
-{
-    GLint size = READ_DATA( 8, GLint );
-    GLenum type = READ_DATA( 12, GLenum );
-    GLsizei stride = READ_DATA( 16, GLsizei );
-    GLintptrARB pointer = READ_DATA( 20, GLuint );
-    cr_unpackDispatch.TexCoordPointer( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendNormalPointer(void)
-{
-    GLenum type = READ_DATA( 8, GLenum );
-    GLsizei stride = READ_DATA( 12, GLsizei );
-    GLintptrARB pointer = READ_DATA( 16, GLuint );
-    cr_unpackDispatch.NormalPointer( type, stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendIndexPointer(void)
-{
-    GLenum type = READ_DATA( 8, GLenum );
-    GLsizei stride = READ_DATA( 12, GLsizei );
-    GLintptrARB pointer = READ_DATA( 16, GLuint );
-    cr_unpackDispatch.IndexPointer( type, stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendEdgeFlagPointer(void)
-{
-    GLsizei stride = READ_DATA( 8, GLsizei );
-    GLintptrARB pointer = READ_DATA( 12, GLuint );
-    cr_unpackDispatch.EdgeFlagPointer( stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendColorPointer(void)
-{
-    GLint size = READ_DATA( 8, GLint );
-    GLenum type = READ_DATA( 12, GLenum );
-    GLsizei stride = READ_DATA( 16, GLsizei );
-    GLintptrARB pointer = READ_DATA( 20, GLuint );
-    cr_unpackDispatch.ColorPointer( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendFogCoordPointerEXT(void)
-{
-    GLenum type = READ_DATA( 8, GLenum );
-    GLsizei stride = READ_DATA( 12, GLsizei );
-    GLintptrARB pointer = READ_DATA( 16, GLuint );
-    cr_unpackDispatch.FogCoordPointerEXT( type, stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendSecondaryColorPointerEXT(void)
-{
-    GLint size = READ_DATA( 8, GLint );
-    GLenum type = READ_DATA( 12, GLenum );
-    GLsizei stride = READ_DATA( 16, GLsizei );
-    GLintptrARB pointer = READ_DATA( 20, GLuint );
-    cr_unpackDispatch.SecondaryColorPointerEXT( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendVertexAttribPointerARB(void)
-{
-    GLuint index = READ_DATA( 8, GLuint);
-    GLint size = READ_DATA( 12, GLint );
-    GLenum type = READ_DATA( 16, GLenum );
-    GLboolean normalized = READ_DATA( 20, GLboolean );
-    GLsizei stride = READ_DATA( 24, GLsizei );
-    GLintptrARB pointer = READ_DATA( 28, GLuint );
-    cr_unpackDispatch.VertexAttribPointerARB( index, size, type, normalized, stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendVertexAttribPointerNV(void)
-{
-    GLuint index = READ_DATA( 8, GLuint);
-    GLint size = READ_DATA( 12, GLint );
-    GLenum type = READ_DATA( 16, GLenum );
-    GLsizei stride = READ_DATA( 20, GLsizei );
-    GLintptrARB pointer = READ_DATA( 24, GLuint );
-    cr_unpackDispatch.VertexAttribPointerNV( index, size, type, stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendInterleavedArrays(void)
-{
-    GLenum format = READ_DATA( 8, GLenum );
-    GLsizei stride = READ_DATA( 12, GLsizei );
-    GLintptrARB pointer = READ_DATA( 16, GLuint );
-    cr_unpackDispatch.InterleavedArrays( format, stride, (void *) pointer, false /*fRealPtr*/ );
-}
-
-void crUnpackExtendDrawElements(void)
-{
-    GLenum mode         = READ_DATA( 8, GLenum );
-    GLsizei count       = READ_DATA( 12, GLsizei );
-    GLenum type         = READ_DATA( 16, GLenum );
-    GLintptrARB indices = READ_DATA( 20, GLuint );
-    void * indexptr;
-#ifdef CR_ARB_vertex_buffer_object
-    GLboolean hasidxdata = READ_DATA(24, GLint);
-    indexptr = hasidxdata ? DATA_POINTER(28, void) : (void*)indices;
-#else
-    indexptr = DATA_POINTER(24, void);
-#endif
-    cr_unpackDispatch.DrawElements(mode, count, type, indexptr);
-}
-
-void crUnpackExtendDrawRangeElements(void)
-{
-    GLenum mode         = READ_DATA( 8, GLenum );
-    GLuint start        = READ_DATA( 12, GLuint );
-    GLuint end          = READ_DATA( 16, GLuint );
-    GLsizei count       = READ_DATA( 20, GLsizei );
-    GLenum type         = READ_DATA( 24, GLenum );
-    GLintptrARB indices = READ_DATA( 28, GLuint );
-    void * indexptr;
-#ifdef CR_ARB_vertex_buffer_object
-    GLboolean hasidxdata = READ_DATA(32, GLint);
-    indexptr = hasidxdata ? DATA_POINTER(36, void) : (void*)indices;
-#else
-    indexptr = DATA_POINTER(32, void);
-#endif
-    cr_unpackDispatch.DrawRangeElements(mode, start, end, count, type, indexptr);
-}
-
-void crUnpackMultiDrawArraysEXT(void)
-{
-    crError( "Can't decode MultiDrawArraysEXT" );
-}
-
-void crUnpackMultiDrawElementsEXT(void)
-{
-    crError( "Can't decode MultiDrawElementsEXT" );
-}
-
-static void crUnpackSetClientPointerByIndex(int index, GLint size, 
-                                            GLenum type, GLboolean normalized,
-                                            GLsizei stride, const GLvoid *pointer, CRClientState *c, int fRealPtr)
-{
-    /*crDebug("crUnpackSetClientPointerByIndex: %i(s=%i, t=0x%x, n=%i, str=%i) -> %p", index, size, type, normalized, stride, pointer);*/
-
-    if (index<7)
-    {
-        switch (index)
-        {
-            case 0:
-                cr_unpackDispatch.VertexPointer(size, type, stride, pointer, fRealPtr);
-                break;
-            case 1:
-                cr_unpackDispatch.ColorPointer(size, type, stride, pointer, fRealPtr);
-                break;
-            case 2:
-                cr_unpackDispatch.FogCoordPointerEXT(type, stride, pointer, fRealPtr);
-                break;
-            case 3:
-                cr_unpackDispatch.SecondaryColorPointerEXT(size, type, stride, pointer, fRealPtr);
-                break;
-            case 4:
-                cr_unpackDispatch.EdgeFlagPointer(stride, pointer, fRealPtr);
-                break;
-            case 5:
-                cr_unpackDispatch.IndexPointer(type, stride, pointer, fRealPtr);
-                break;
-            case 6:
-                cr_unpackDispatch.NormalPointer(type, stride, pointer, fRealPtr);
-                break;
-        }
-    }
-    else if (index<(7+CR_MAX_TEXTURE_UNITS))
-    {
-        int curTexUnit = c->curClientTextureUnit;
-        if ((index-7)!=curTexUnit)
-        {
-            cr_unpackDispatch.ClientActiveTextureARB(GL_TEXTURE0_ARB+index-7);
-        }
-        cr_unpackDispatch.TexCoordPointer(size, type, stride, pointer, fRealPtr);
-        if ((index-7)!=curTexUnit)
-        {
-            cr_unpackDispatch.ClientActiveTextureARB(GL_TEXTURE0_ARB+curTexUnit);
-        }
-    }
-    else
-    {
-        cr_unpackDispatch.VertexAttribPointerARB(index-7-CR_MAX_TEXTURE_UNITS,
-                                                 size, type, normalized, stride, pointer, fRealPtr);
-    }
-}
-
-void crUnpackExtendLockArraysEXT(void)
-{
-    GLint first    = READ_DATA(sizeof(int) + 4, GLint);
-    GLint count    = READ_DATA(sizeof(int) + 8, GLint);
-    int numenabled = READ_DATA(sizeof(int) + 12, int);
-
-    CRContext *g = crStateGetCurrent();
-    CRClientState *c = &g->client;
-    CRClientPointer *cp;
-    int i, index, offset;
-    unsigned char *data;
-    
-    if (first < 0 || count <= 0 || first >= INT32_MAX - count)
-    {
-        crError("crUnpackExtendLockArraysEXT: first(%i) count(%i), parameters out of range", first, count);
-        return;
-    }
-
-    if (numenabled <= 0 || numenabled >= CRSTATECLIENT_MAX_VERTEXARRAYS)
-    {
-        crError("crUnpackExtendLockArraysEXT: numenabled(%i), parameter out of range", numenabled);
-        return;
-    }
-
-    offset = 2 * sizeof(int) + 12;
-
-    /*crDebug("crUnpackExtendLockArraysEXT(%i, %i) ne=%i", first, count, numenabled);*/
-
-    for (i = 0; i < numenabled; ++i)
-    {
-        index = READ_DATA(offset, int);
-        offset += sizeof(int);
-
-        cp = crStateGetClientPointerByIndex(index, &c->array);
-
-        CRASSERT(cp && cp->enabled && (!cp->buffer || !cp->buffer->id));
-
-        if (cp && cp->bytesPerIndex > 0)
-        {
-            if (first + count >= INT32_MAX / cp->bytesPerIndex)
-            {
-                crError("crUnpackExtendLockArraysEXT: first(%i) count(%i) bpi(%i), parameters out of range", first, count, cp->bytesPerIndex);
-                return;
-            }
-
-            data = crAlloc((first + count) * cp->bytesPerIndex);
-
-            if (data)
-            {
-                crMemcpy(data + first * cp->bytesPerIndex, DATA_POINTER(offset, GLvoid), count * cp->bytesPerIndex);
-                /*crDebug("crUnpackExtendLockArraysEXT: old cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
-                        index, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
-                crUnpackSetClientPointerByIndex(index, cp->size, cp->type, cp->normalized, 0, data, c, 1 /*fRealPtr*/);
-                /*crDebug("crUnpackExtendLockArraysEXT: new cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
-                        index, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
-            }
-            else
-            {
-                crError("crUnpackExtendLockArraysEXT: crAlloc failed");
-                return;
-            }
-        }
-        else
-        {
-            crError("crUnpackExtendLockArraysEXT: wrong CRClientState %i", index);
-            return;
-        }
-
-        offset += count * cp->bytesPerIndex;
-    }
-
-    cr_unpackDispatch.LockArraysEXT(first, count);
-}
-
-void crUnpackExtendUnlockArraysEXT(void)
-{
-    int i;
-    CRContext *g = crStateGetCurrent();
-    CRClientState *c = &g->client;
-    CRClientPointer *cp;
-
-    /*crDebug("crUnpackExtendUnlockArraysEXT");*/
-
-    cr_unpackDispatch.UnlockArraysEXT();
-
-    for (i=0; i<CRSTATECLIENT_MAX_VERTEXARRAYS; ++i)
-    {
-        cp = crStateGetClientPointerByIndex(i, &c->array);
-        if (cp->enabled)
-        {
-            /*crDebug("crUnpackExtendUnlockArraysEXT: old cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
-                    i, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
-            unsigned char *prevPtr = cp->prevPtr;
-            int fPrevRealPtr = cp->fPrevRealPtr;
-            cp->prevPtr = NULL;
-            cp->fPrevRealPtr = 0;
-            crUnpackSetClientPointerByIndex(i, cp->size, cp->type, cp->normalized, cp->prevStride, prevPtr, c, fPrevRealPtr);
-            /*crDebug("crUnpackExtendUnlockArraysEXT: new cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
-                    i, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
-        }
-    }
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_arrays.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_arrays.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_arrays.cpp	(revision 78190)
@@ -0,0 +1,400 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "cr_error.h"
+#include "unpack_extend.h"
+#include "unpacker.h"
+#include "cr_glstate.h"
+/**
+ * \mainpage Unpacker 
+ *
+ * \section UnpackerIntroduction Introduction
+ *
+ * Chromium consists of all the top-level files in the cr
+ * directory.  The unpacker module basically takes care of API dispatch,
+ * and OpenGL state management.
+ *
+ */
+
+void crUnpackExtendVertexPointer(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 20 + sizeof(GLuint) );
+
+    GLint size = READ_DATA(pState, 8, GLint );
+    GLenum type = READ_DATA(pState, 12, GLenum );
+    GLsizei stride = READ_DATA(pState, 16, GLsizei );
+    GLintptrARB pointer = (GLintptrARB) READ_DATA(pState, 20, GLuint );
+    pState->pDispatchTbl->VertexPointer( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendTexCoordPointer(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 20 + sizeof(GLuint) );
+
+    GLint size = READ_DATA(pState, 8, GLint );
+    GLenum type = READ_DATA(pState, 12, GLenum );
+    GLsizei stride = READ_DATA(pState, 16, GLsizei );
+    GLintptrARB pointer = READ_DATA(pState, 20, GLuint );
+    pState->pDispatchTbl->TexCoordPointer( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendNormalPointer(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 16 + sizeof(GLuint) );
+
+    GLenum type = READ_DATA(pState, 8, GLenum );
+    GLsizei stride = READ_DATA(pState, 12, GLsizei );
+    GLintptrARB pointer = READ_DATA(pState, 16, GLuint );
+    pState->pDispatchTbl->NormalPointer( type, stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendIndexPointer(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 16 + sizeof(GLuint) );
+
+    GLenum type = READ_DATA(pState, 8, GLenum );
+    GLsizei stride = READ_DATA(pState, 12, GLsizei );
+    GLintptrARB pointer = READ_DATA(pState, 16, GLuint );
+    pState->pDispatchTbl->IndexPointer( type, stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendEdgeFlagPointer(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 12 + sizeof(GLuint) );
+
+    GLsizei stride = READ_DATA(pState, 8, GLsizei );
+    GLintptrARB pointer = READ_DATA(pState, 12, GLuint );
+    pState->pDispatchTbl->EdgeFlagPointer( stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendColorPointer(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 20 + sizeof(GLuint) );
+
+    GLint size = READ_DATA(pState, 8, GLint );
+    GLenum type = READ_DATA(pState, 12, GLenum );
+    GLsizei stride = READ_DATA(pState, 16, GLsizei );
+    GLintptrARB pointer = READ_DATA(pState, 20, GLuint );
+    pState->pDispatchTbl->ColorPointer( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendFogCoordPointerEXT(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 16 + sizeof(GLuint) );
+
+    GLenum type = READ_DATA(pState, 8, GLenum );
+    GLsizei stride = READ_DATA(pState, 12, GLsizei );
+    GLintptrARB pointer = READ_DATA(pState, 16, GLuint );
+    pState->pDispatchTbl->FogCoordPointerEXT( type, stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendSecondaryColorPointerEXT(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 20 + sizeof(GLuint) );
+
+    GLint size = READ_DATA(pState, 8, GLint );
+    GLenum type = READ_DATA(pState, 12, GLenum );
+    GLsizei stride = READ_DATA(pState, 16, GLsizei );
+    GLintptrARB pointer = READ_DATA(pState, 20, GLuint );
+    pState->pDispatchTbl->SecondaryColorPointerEXT( size, type, stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendVertexAttribPointerARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 28 + sizeof(GLuint) );
+
+    GLuint index = READ_DATA(pState, 8, GLuint);
+    GLint size = READ_DATA(pState, 12, GLint );
+    GLenum type = READ_DATA(pState, 16, GLenum );
+    GLboolean normalized = READ_DATA(pState, 20, GLboolean );
+    GLsizei stride = READ_DATA(pState, 24, GLsizei );
+    GLintptrARB pointer = READ_DATA(pState, 28, GLuint );
+    pState->pDispatchTbl->VertexAttribPointerARB( index, size, type, normalized, stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendVertexAttribPointerNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 24 + sizeof(GLuint) );
+
+    GLuint index = READ_DATA(pState, 8, GLuint);
+    GLint size = READ_DATA(pState, 12, GLint );
+    GLenum type = READ_DATA(pState, 16, GLenum );
+    GLsizei stride = READ_DATA(pState, 20, GLsizei );
+    GLintptrARB pointer = READ_DATA(pState, 24, GLuint );
+    pState->pDispatchTbl->VertexAttribPointerNV( index, size, type, stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendInterleavedArrays(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 16 + sizeof(GLuint) );
+
+    GLenum format = READ_DATA(pState, 8, GLenum );
+    GLsizei stride = READ_DATA(pState, 12, GLsizei );
+    GLintptrARB pointer = READ_DATA(pState, 16, GLuint );
+    pState->pDispatchTbl->InterleavedArrays( format, stride, (void *) pointer, false /*fRealPtr*/ );
+}
+
+void crUnpackExtendDrawElements(PCrUnpackerState pState)
+{
+#ifdef CR_ARB_vertex_buffer_object
+    CHECK_BUFFER_SIZE_STATIC(pState, 28);
+#else
+    CHECK_BUFFER_SIZE_STATIC(pState, 24);
+#endif
+
+    GLenum mode         = READ_DATA(pState, 8, GLenum );
+    GLsizei count       = READ_DATA(pState, 12, GLsizei );
+    GLenum type         = READ_DATA(pState, 16, GLenum );
+    GLintptrARB indices = READ_DATA(pState, 20, GLuint );
+    void * indexptr;
+
+    size_t cbElem = 0;
+    switch (type)
+    {
+        case GL_UNSIGNED_BYTE:
+            cbElem = sizeof(GLubyte);
+            break;
+        case GL_UNSIGNED_SHORT:
+            cbElem = sizeof(GLubyte);
+            break;
+        case GL_UNSIGNED_INT:
+            cbElem = sizeof(GLubyte);
+            break;
+        default:
+            crError("crUnpackExtendDrawElements: Invalid type (%#x) passed!\n", type);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+#ifdef CR_ARB_vertex_buffer_object
+    GLboolean hasidxdata = READ_DATA(pState, 24, GLint);
+    indexptr = hasidxdata ? DATA_POINTER(pState, 28, void) : (void*)indices;
+    if (hasidxdata)
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_SZ_LAST(pState, indexptr, count, cbElem);
+#else
+    indexptr = DATA_POINTER(pState, 24, void);
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_SZ_LAST(pState, indexptr, count, cbElem);
+#endif
+    pState->pDispatchTbl->DrawElements(mode, count, type, indexptr);
+}
+
+void crUnpackExtendDrawRangeElements(PCrUnpackerState pState)
+{
+#ifdef CR_ARB_vertex_buffer_object
+    CHECK_BUFFER_SIZE_STATIC(pState, 36);
+#else
+    CHECK_BUFFER_SIZE_STATIC(pState, 32);
+#endif
+
+    GLenum mode         = READ_DATA(pState, 8, GLenum );
+    GLuint start        = READ_DATA(pState, 12, GLuint );
+    GLuint end          = READ_DATA(pState, 16, GLuint );
+    GLsizei count       = READ_DATA(pState, 20, GLsizei );
+    GLenum type         = READ_DATA(pState, 24, GLenum );
+    GLintptrARB indices = READ_DATA(pState, 28, GLuint );
+    void * indexptr;
+
+    size_t cbElem = 0;
+    switch (type)
+    {
+        case GL_UNSIGNED_BYTE:
+            cbElem = sizeof(GLubyte);
+            break;
+        case GL_UNSIGNED_SHORT:
+            cbElem = sizeof(GLubyte);
+            break;
+        case GL_UNSIGNED_INT:
+            cbElem = sizeof(GLubyte);
+            break;
+        default:
+            crError("crUnpackExtendDrawElements: Invalid type (%#x) passed!\n", type);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+#ifdef CR_ARB_vertex_buffer_object
+    GLboolean hasidxdata = READ_DATA(pState, 32, GLint);
+    indexptr = hasidxdata ? DATA_POINTER(pState, 36, void) : (void*)indices;
+    if (hasidxdata)
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_SZ_LAST(pState, indexptr, count, cbElem);
+#else
+    indexptr = DATA_POINTER(pState, 32, void);
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_SZ_LAST(pState, indexptr, count, cbElem);
+#endif
+
+    pState->pDispatchTbl->DrawRangeElements(mode, start, end, count, type, indexptr);
+}
+
+void crUnpackMultiDrawArraysEXT(PCrUnpackerState pState)
+{
+    RT_NOREF(pState);
+    crError( "Can't decode MultiDrawArraysEXT" );
+}
+
+void crUnpackMultiDrawElementsEXT(PCrUnpackerState pState)
+{
+    RT_NOREF(pState);
+    crError( "Can't decode MultiDrawElementsEXT" );
+}
+
+static void crUnpackSetClientPointerByIndex(PCrUnpackerState pState, int index, GLint size, 
+                                            GLenum type, GLboolean normalized,
+                                            GLsizei stride, const GLvoid *pointer, CRClientState *c, int fRealPtr)
+{
+    /*crDebug("crUnpackSetClientPointerByIndex: %i(s=%i, t=0x%x, n=%i, str=%i) -> %p", index, size, type, normalized, stride, pointer);*/
+
+    if (index<7)
+    {
+        switch (index)
+        {
+            case 0:
+                pState->pDispatchTbl->VertexPointer(size, type, stride, pointer, fRealPtr);
+                break;
+            case 1:
+                pState->pDispatchTbl->ColorPointer(size, type, stride, pointer, fRealPtr);
+                break;
+            case 2:
+                pState->pDispatchTbl->FogCoordPointerEXT(type, stride, pointer, fRealPtr);
+                break;
+            case 3:
+                pState->pDispatchTbl->SecondaryColorPointerEXT(size, type, stride, pointer, fRealPtr);
+                break;
+            case 4:
+                pState->pDispatchTbl->EdgeFlagPointer(stride, pointer, fRealPtr);
+                break;
+            case 5:
+                pState->pDispatchTbl->IndexPointer(type, stride, pointer, fRealPtr);
+                break;
+            case 6:
+                pState->pDispatchTbl->NormalPointer(type, stride, pointer, fRealPtr);
+                break;
+        }
+    }
+    else if (index<(7+CR_MAX_TEXTURE_UNITS))
+    {
+        int curTexUnit = c->curClientTextureUnit;
+        if ((index-7)!=curTexUnit)
+        {
+            pState->pDispatchTbl->ClientActiveTextureARB(GL_TEXTURE0_ARB+index-7);
+        }
+        pState->pDispatchTbl->TexCoordPointer(size, type, stride, pointer, fRealPtr);
+        if ((index-7)!=curTexUnit)
+        {
+            pState->pDispatchTbl->ClientActiveTextureARB(GL_TEXTURE0_ARB+curTexUnit);
+        }
+    }
+    else
+    {
+        pState->pDispatchTbl->VertexAttribPointerARB(index-7-CR_MAX_TEXTURE_UNITS,
+                                                 size, type, normalized, stride, pointer, fRealPtr);
+    }
+}
+
+void crUnpackExtendLockArraysEXT(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, sizeof(int) + 12 + sizeof(int));
+
+    GLint first    = READ_DATA(pState, sizeof(int) + 4, GLint);
+    GLint count    = READ_DATA(pState, sizeof(int) + 8, GLint);
+    int numenabled = READ_DATA(pState, sizeof(int) + 12, int);
+
+    CRContext *g = crStateGetCurrent();
+    CRClientState *c = &g->client;
+    CRClientPointer *cp;
+    int i, index, offset;
+    uint8_t *data;
+
+    if (first < 0 || count <= 0 || first >= INT32_MAX - count)
+    {
+        crError("crUnpackExtendLockArraysEXT: first(%i) count(%i), parameters out of range", first, count);
+        return;
+    }
+
+    if (numenabled <= 0 || numenabled >= CRSTATECLIENT_MAX_VERTEXARRAYS)
+    {
+        crError("crUnpackExtendLockArraysEXT: numenabled(%i), parameter out of range", numenabled);
+        return;
+    }
+
+    offset = 2 * sizeof(int) + 12;
+
+    /*crDebug("crUnpackExtendLockArraysEXT(%i, %i) ne=%i", first, count, numenabled);*/
+
+    for (i = 0; i < numenabled; ++i)
+    {
+        CHECK_BUFFER_SIZE_STATIC_LAST(pState, offset, int);
+        index = READ_DATA(pState, offset, int);
+        offset += sizeof(int);
+
+        cp = crStateGetClientPointerByIndex(index, &c->array);
+
+        CRASSERT(cp && cp->enabled && (!cp->buffer || !cp->buffer->id));
+
+        if (cp && cp->bytesPerIndex > 0)
+        {
+            if (first + count >= INT32_MAX / cp->bytesPerIndex)
+            {
+                crError("crUnpackExtendLockArraysEXT: first(%i) count(%i) bpi(%i), parameters out of range", first, count, cp->bytesPerIndex);
+                return;
+            }
+
+            data = (uint8_t *)crAlloc((first + count) * cp->bytesPerIndex);
+
+            if (data)
+            {
+                crMemcpy(data + first * cp->bytesPerIndex, DATA_POINTER(pState, offset, GLvoid), count * cp->bytesPerIndex);
+                /*crDebug("crUnpackExtendLockArraysEXT: old cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
+                        index, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
+                crUnpackSetClientPointerByIndex(pState, index, cp->size, cp->type, cp->normalized, 0, data, c, 1);
+                /*crDebug("crUnpackExtendLockArraysEXT: new cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
+                        index, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
+            }
+            else
+            {
+                crError("crUnpackExtendLockArraysEXT: crAlloc failed");
+                return;
+            }
+        }
+        else
+        {
+            crError("crUnpackExtendLockArraysEXT: wrong CRClientState %i", index);
+            return;
+        }
+
+        offset += count * cp->bytesPerIndex;
+    }
+
+    pState->pDispatchTbl->LockArraysEXT(first, count);
+}
+
+void crUnpackExtendUnlockArraysEXT(PCrUnpackerState pState)
+{
+    int i;
+    CRContext *g = crStateGetCurrent();
+    CRClientState *c = &g->client;
+    CRClientPointer *cp;
+
+    /*crDebug("crUnpackExtendUnlockArraysEXT");*/
+
+    pState->pDispatchTbl->UnlockArraysEXT();
+
+    for (i=0; i<CRSTATECLIENT_MAX_VERTEXARRAYS; ++i)
+    {
+        cp = crStateGetClientPointerByIndex(i, &c->array);
+        if (cp->enabled)
+        {
+            /*crDebug("crUnpackExtendUnlockArraysEXT: old cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
+                    i, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
+            unsigned char *prevPtr = cp->prevPtr;
+            int fPrevRealPtr = cp->fPrevRealPtr;
+            cp->prevPtr = NULL;
+            cp->fPrevRealPtr = 0;
+
+            crUnpackSetClientPointerByIndex(pState, i, cp->size, cp->type, cp->normalized, cp->prevStride, prevPtr, c, fPrevRealPtr);
+            /*crDebug("crUnpackExtendUnlockArraysEXT: new cp(%i): en/l=%i(%i) p=%p size=%i type=0x%x n=%i str=%i pp=%p pstr=%i",
+                    i, cp->enabled, cp->locked, cp->p, cp->size, cp->type, cp->normalized, cp->stride, cp->prevPtr, cp->prevStride);*/
+        }
+    }
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bounds.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bounds.c	(revision 78189)
+++ 	(revision )
@@ -1,27 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "state/cr_statetypes.h"
-
-void crUnpackBoundsInfoCR( void  )
-{
-	CRrecti bounds;
-	GLint len;
-	GLuint num_opcodes;
-	GLbyte *payload;
-	
-	len = READ_DATA( 0, GLint );
-	bounds.x1 = READ_DATA( 4, GLint );
-	bounds.y1 = READ_DATA( 8, GLint );
-	bounds.x2 = READ_DATA( 12, GLint );
-	bounds.y2 = READ_DATA( 16, GLint );
-	num_opcodes = READ_DATA( 20, GLuint );
-	payload = DATA_POINTER( 24, GLbyte );
-
-	cr_unpackDispatch.BoundsInfoCR( &bounds, payload, len, num_opcodes );
-	INCR_VAR_PTR();
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bounds.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bounds.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bounds.cpp	(revision 78190)
@@ -0,0 +1,29 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "state/cr_statetypes.h"
+
+void crUnpackBoundsInfoCR(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 24 + sizeof(GLbyte));
+
+	CRrecti bounds;
+	GLint len;
+	GLuint num_opcodes;
+	GLbyte *payload;
+
+	len = READ_DATA(pState, 0, GLint );
+	bounds.x1 = READ_DATA(pState, 4, GLint );
+	bounds.y1 = READ_DATA(pState, 8, GLint );
+	bounds.x2 = READ_DATA(pState, 12, GLint );
+	bounds.y2 = READ_DATA(pState, 16, GLint );
+	num_opcodes = READ_DATA(pState, 20, GLuint );
+	payload = DATA_POINTER(pState, 24, GLbyte );
+
+	pState->pDispatchTbl->BoundsInfoCR( &bounds, payload, len, num_opcodes );
+	INCR_VAR_PTR(pState);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bufferobject.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bufferobject.c	(revision 78189)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "cr_mem.h"
-#include "cr_error.h"
-
-
-void crUnpackExtendGetBufferSubDataARB( void )
-{
-    GLenum target = READ_DATA( 8, GLenum );
-    GLintptrARB offset = READ_DATA( 12, GLuint );
-    GLsizeiptrARB size = READ_DATA( 16, GLuint );
-
-    SET_RETURN_PTR( 20 );
-    SET_WRITEBACK_PTR( 28 );
-
-    cr_unpackDispatch.GetBufferSubDataARB( target, offset, size, NULL );
-}
-
-
-void crUnpackExtendBufferDataARB( void )
-{
-    GLenum target      = READ_DATA(sizeof(int) + 4, GLenum);
-    GLsizeiptrARB size = READ_DATA(sizeof(int) + 8, GLuint);
-    GLenum usage       = READ_DATA(sizeof(int) + 12, GLenum);
-    GLboolean hasdata  = READ_DATA(sizeof(int) + 16, GLint);
-    GLvoid *data       = DATA_POINTER(sizeof(int) + 20, GLvoid);
-
-    cr_unpackDispatch.BufferDataARB(target, size, hasdata ? data:NULL, usage);
-}
-
-
-void crUnpackExtendBufferSubDataARB( void )
-{
-    GLenum target = READ_DATA( sizeof(int) + 4, GLenum );
-    GLintptrARB offset = READ_DATA( sizeof(int) + 8, GLuint );
-    GLsizeiptrARB size = READ_DATA( sizeof(int) + 12, GLuint );
-    GLvoid *data = DATA_POINTER( sizeof(int) + 16, GLvoid );
-
-    cr_unpackDispatch.BufferSubDataARB( target, offset, size, data );
-}
-
-
-void crUnpackExtendDeleteBuffersARB(void)
-{
-    GLsizei n = READ_DATA( 8, GLsizei );
-    const GLuint *buffers = DATA_POINTER( 12, GLuint );
-    cr_unpackDispatch.DeleteBuffersARB( n, buffers );
-}
-
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bufferobject.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bufferobject.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_bufferobject.cpp	(revision 78190)
@@ -0,0 +1,67 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "cr_mem.h"
+#include "cr_error.h"
+
+
+void crUnpackExtendGetBufferSubDataARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 28 + sizeof(CRNetworkPointer));
+
+    GLenum target = READ_DATA(pState, 8, GLenum );
+    GLintptrARB offset = READ_DATA(pState, 12, GLuint );
+    GLsizeiptrARB size = READ_DATA(pState, 16, GLuint );
+
+    SET_RETURN_PTR(pState, 20);
+    SET_WRITEBACK_PTR(pState, 28);
+
+    pState->pDispatchTbl->GetBufferSubDataARB( target, offset, size, NULL );
+}
+
+
+void crUnpackExtendBufferDataARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, sizeof(int) + 20);
+
+    GLenum target      = READ_DATA(pState, sizeof(int) + 4, GLenum);
+    GLsizeiptrARB size = READ_DATA(pState, sizeof(int) + 8, GLuint);
+    GLenum usage       = READ_DATA(pState, sizeof(int) + 12, GLenum);
+    GLboolean hasdata  = READ_DATA(pState, sizeof(int) + 16, GLint);
+    GLvoid *data       = DATA_POINTER(pState, sizeof(int) + 20, GLvoid);
+
+    if (hasdata)
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, data, size, GLubyte);
+    pState->pDispatchTbl->BufferDataARB(target, size, hasdata ? data:NULL, usage);
+}
+
+
+void crUnpackExtendBufferSubDataARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, sizeof(int) + 16);
+
+    GLenum target = READ_DATA(pState, sizeof(int) + 4, GLenum );
+    GLintptrARB offset = READ_DATA(pState, sizeof(int) + 8, GLuint );
+    GLsizeiptrARB size = READ_DATA(pState, sizeof(int) + 12, GLuint );
+    GLvoid *data = DATA_POINTER(pState, sizeof(int) + 16, GLvoid );
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, data, size, GLubyte);
+    pState->pDispatchTbl->BufferSubDataARB( target, offset, size, data );
+}
+
+
+void crUnpackExtendDeleteBuffersARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 8 + sizeof(GLsizei));
+
+    GLsizei n = READ_DATA(pState, 8, GLsizei );
+    const GLuint *buffers = DATA_POINTER(pState, 12, GLuint );
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, buffers, n, GLuint);
+    pState->pDispatchTbl->DeleteBuffersARB( n, buffers );
+}
+
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_calllists.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_calllists.c	(revision 78189)
+++ 	(revision )
@@ -1,17 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-
-void crUnpackCallLists( void  )
-{
-	GLint n = READ_DATA( sizeof( int ) + 0, GLint );
-	GLenum type = READ_DATA( sizeof( int ) + 4, GLenum );
-	GLvoid *lists = DATA_POINTER( sizeof( int ) + 8, GLvoid );
-
-	cr_unpackDispatch.CallLists( n, type, lists );
-	INCR_VAR_PTR();
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_calllists.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_calllists.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_calllists.cpp	(revision 78190)
@@ -0,0 +1,57 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+
+void crUnpackCallLists(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4, GLenum);
+
+    GLint n = READ_DATA(pState, sizeof( int ) + 0, GLint );
+    GLenum type = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLvoid *lists = DATA_POINTER(pState, sizeof( int ) + 8, GLvoid );
+
+    switch (type)
+    {
+        case GL_BYTE:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, lists, n, GLbyte);
+            break;
+        case GL_UNSIGNED_BYTE:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, lists, n, GLubyte);
+            break;
+        case GL_SHORT:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, lists, n, GLshort);
+            break;
+        case GL_UNSIGNED_SHORT:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, lists, n, GLushort);
+            break;
+        case GL_INT:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, lists, n, GLint);
+            break;
+        case GL_UNSIGNED_INT:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, lists, n, GLuint);
+            break;
+        case GL_FLOAT:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, lists, n, GLfloat);
+            break;
+        case GL_2_BYTES:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, lists, 2 * n, GLbyte);
+            break;
+        case GL_3_BYTES:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, lists, 3 * n, GLbyte);
+            break;
+        case GL_4_BYTES:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, lists, 4 * n, GLbyte);
+            break;
+        default:
+            crError("crUnpackCallLists: Invalid type (%#x) passed!\n", type);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    pState->pDispatchTbl->CallLists( n, type, lists );
+    INCR_VAR_PTR(pState);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_clipplane.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_clipplane.c	(revision 78189)
+++ 	(revision )
@@ -1,19 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "cr_mem.h"
-#include "unpack_extend.h"
-
-void crUnpackClipPlane( void  )
-{
-	GLenum plane = READ_DATA( 0, GLenum );
-	GLdouble equation[4];
-	crMemcpy( equation, DATA_POINTER( 4, GLdouble ), sizeof(equation) );
-
-	cr_unpackDispatch.ClipPlane( plane, equation );
-	INCR_DATA_PTR( sizeof( GLenum ) + 4*sizeof( GLdouble ));
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_clipplane.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_clipplane.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_clipplane.cpp	(revision 78190)
@@ -0,0 +1,21 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "cr_mem.h"
+#include "unpack_extend.h"
+
+void crUnpackClipPlane(PCrUnpackerState pState)
+{
+	GLdouble equation[4];
+    CHECK_BUFFER_SIZE_STATIC(pState, 4 + sizeof(equation));
+
+	GLenum plane = READ_DATA(pState, 0, GLenum );
+	crMemcpy( equation, DATA_POINTER(pState, 4, GLdouble ), sizeof(equation) );
+
+	pState->pDispatchTbl->ClipPlane( plane, equation );
+	INCR_DATA_PTR(pState, sizeof( GLenum ) + 4*sizeof( GLdouble ));
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_context.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_context.c	(revision 78189)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "cr_mem.h"
-
-/* XXX duplicated in pack_context.c */
-#define DISPLAY_NAME_LEN 256
-
-#define READ_BYTES( dest, offset, len ) \
-    crMemcpy( dest, (cr_unpackData + (offset)), len )
-
-void crUnpackExtendCreateContext( void )
-{
-	char dpyName[DISPLAY_NAME_LEN];
-	GLint visBits = READ_DATA( DISPLAY_NAME_LEN + 8, GLint );
-	GLint shareCtx = READ_DATA( DISPLAY_NAME_LEN + 12, GLint );
-	GLint retVal;
-
-	READ_BYTES( dpyName, 8, DISPLAY_NAME_LEN );
-	dpyName[DISPLAY_NAME_LEN - 1] = 0; /* NULL-terminate, just in case */
-
-	SET_RETURN_PTR( DISPLAY_NAME_LEN + 16 );
-	SET_WRITEBACK_PTR( DISPLAY_NAME_LEN + 24 );
-	retVal = cr_unpackDispatch.CreateContext( dpyName, visBits, shareCtx );
-	(void) retVal;
-}
-
-void crUnpackExtendWindowCreate(void)
-{
-	char dpyName[DISPLAY_NAME_LEN];
-	GLint visBits = READ_DATA( DISPLAY_NAME_LEN + 8, GLint );
-	GLint retVal;
-
-	READ_BYTES( dpyName, 8, DISPLAY_NAME_LEN );
-	dpyName[DISPLAY_NAME_LEN - 1] = 0; /* NULL-terminate, just in case */
-
-	SET_RETURN_PTR( DISPLAY_NAME_LEN + 12 );
-	SET_WRITEBACK_PTR( DISPLAY_NAME_LEN + 20 );
-	retVal = cr_unpackDispatch.WindowCreate( dpyName, visBits );
-	(void) retVal;
-}
-
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_context.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_context.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_context.cpp	(revision 78190)
@@ -0,0 +1,50 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "cr_mem.h"
+
+/* XXX duplicated in pack_context.c */
+#define DISPLAY_NAME_LEN 256
+
+#define READ_BYTES(a_pState, dest, offset, len ) \
+    crMemcpy( dest, ((a_pState)->pbUnpackData + (offset)), len )
+
+void crUnpackExtendCreateContext(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24 + DISPLAY_NAME_LEN, sizeof(CRNetworkPointer));
+
+	char dpyName[DISPLAY_NAME_LEN];
+	GLint visBits = READ_DATA(pState, DISPLAY_NAME_LEN + 8, GLint );
+	GLint shareCtx = READ_DATA(pState, DISPLAY_NAME_LEN + 12, GLint );
+	GLint retVal;
+
+	READ_BYTES(pState, dpyName, 8, DISPLAY_NAME_LEN );
+	dpyName[DISPLAY_NAME_LEN - 1] = 0; /* NULL-terminate, just in case */
+
+	SET_RETURN_PTR(pState, DISPLAY_NAME_LEN + 16 );
+	SET_WRITEBACK_PTR(pState, DISPLAY_NAME_LEN + 24 );
+	retVal = pState->pDispatchTbl->CreateContext( dpyName, visBits, shareCtx );
+	(void) retVal;
+}
+
+void crUnpackExtendWindowCreate(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 20 + DISPLAY_NAME_LEN, sizeof(CRNetworkPointer));
+
+	char dpyName[DISPLAY_NAME_LEN];
+	GLint visBits = READ_DATA(pState, DISPLAY_NAME_LEN + 8, GLint );
+	GLint retVal;
+
+	READ_BYTES(pState, dpyName, 8, DISPLAY_NAME_LEN );
+	dpyName[DISPLAY_NAME_LEN - 1] = 0; /* NULL-terminate, just in case */
+
+	SET_RETURN_PTR(pState, DISPLAY_NAME_LEN + 12 );
+	SET_WRITEBACK_PTR(pState, DISPLAY_NAME_LEN + 20 );
+	retVal = pState->pDispatchTbl->WindowCreate( dpyName, visBits );
+	(void) retVal;
+}
+
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_drawpixels.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_drawpixels.c	(revision 78189)
+++ 	(revision )
@@ -1,94 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "cr_error.h"
-
-#include "state/cr_bufferobject.h"
-
-void crUnpackDrawPixels( void )
-{
-    GLsizei width  = READ_DATA( sizeof( int ) + 0, GLsizei );
-    GLsizei height = READ_DATA( sizeof( int ) + 4, GLsizei );
-    GLenum format  = READ_DATA( sizeof( int ) + 8, GLenum );
-    GLenum type    = READ_DATA( sizeof( int ) + 12, GLenum );
-    GLint noimagedata = READ_DATA( sizeof( int ) + 16, GLint );
-    GLvoid *pixels;
-
-    if (noimagedata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
-        return;
-
-    if (noimagedata)
-        pixels = (void*) (uintptr_t) READ_DATA( sizeof( int ) + 20, GLint);
-    else
-        pixels = DATA_POINTER( sizeof( int ) + 24, GLvoid );
-
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-    cr_unpackDispatch.DrawPixels( width, height, format, type, pixels );
-
-    INCR_VAR_PTR( );
-}
-
-void crUnpackBitmap( void )
-{   
-    GLsizei width   = READ_DATA( sizeof( int ) + 0, GLsizei );
-    GLsizei height  = READ_DATA( sizeof( int ) + 4, GLsizei );
-    GLfloat xorig   = READ_DATA( sizeof( int ) + 8, GLfloat );
-    GLfloat yorig   = READ_DATA( sizeof( int ) + 12, GLfloat );
-    GLfloat xmove   = READ_DATA( sizeof( int ) + 16, GLfloat );
-    GLfloat ymove   = READ_DATA( sizeof( int ) + 20, GLfloat );
-    GLuint noimagedata = READ_DATA( sizeof( int ) + 24, GLuint );
-    GLubyte *bitmap;
-
-    if (noimagedata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
-        return;
-
-    if (noimagedata)
-        bitmap = (void*) (uintptr_t) READ_DATA(sizeof(int) + 28, GLint);
-    else
-        bitmap = DATA_POINTER( sizeof(int) + 32, GLubyte );
-
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-    cr_unpackDispatch.Bitmap( width, height, xorig, yorig, xmove, ymove, bitmap );
-
-    INCR_VAR_PTR( );
-}
-
-/*
- * ZPixCR  - compressed DrawPixels
- */
-void crUnpackExtendZPixCR( void )
-{
-    GLsizei width   = READ_DATA(   8, GLsizei );
-    GLsizei height  = READ_DATA(  12, GLsizei );
-    GLenum  format  = READ_DATA(  16, GLenum );
-    GLenum  type    = READ_DATA(  20, GLenum );
-    GLenum  ztype   = READ_DATA(  24, GLenum );
-    GLint   zparm   = READ_DATA(  28, GLuint );
-    GLint   length  = READ_DATA(  32, GLint );
-    GLvoid  *pixels = DATA_POINTER(  36, GLvoid );
-
-/*XXX JAG 
-  crDebug("UnpackZPixCR: w = %d, h = %d, len = %d",
-                                 width,  height, length);
-*/
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-    cr_unpackDispatch.ZPixCR( width, height, format, type, ztype, zparm, length, pixels );
-
-    /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_drawpixels.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_drawpixels.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_drawpixels.cpp	(revision 78190)
@@ -0,0 +1,119 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "cr_error.h"
+#include "cr_pixeldata.h"
+
+#include "state/cr_bufferobject.h"
+
+void crUnpackDrawPixels(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 20, GLint);
+
+    GLsizei width  = READ_DATA(pState, sizeof( int ) + 0, GLsizei );
+    GLsizei height = READ_DATA(pState, sizeof( int ) + 4, GLsizei );
+    GLenum format  = READ_DATA(pState, sizeof( int ) + 8, GLenum );
+    GLenum type    = READ_DATA(pState, sizeof( int ) + 12, GLenum );
+    GLint noimagedata = READ_DATA(pState, sizeof( int ) + 16, GLint );
+    GLvoid *pixels;
+
+    if (noimagedata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
+        return;
+
+    if (noimagedata)
+        pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof( int ) + 20, GLint);
+    else
+    {
+        size_t cbImg = crImageSize( format, type, width, height );
+        if (RT_UNLIKELY(cbImg == 0))
+        {
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+        }
+
+        pixels = DATA_POINTER(pState, sizeof( int ) + 24, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
+    }
+
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+
+    pState->pDispatchTbl->DrawPixels( width, height, format, type, pixels );
+
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackBitmap(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 28, GLint);
+
+    GLsizei width   = READ_DATA(pState, sizeof( int ) + 0, GLsizei );
+    GLsizei height  = READ_DATA(pState,sizeof( int ) + 4, GLsizei );
+    GLfloat xorig   = READ_DATA(pState, sizeof( int ) + 8, GLfloat );
+    GLfloat yorig   = READ_DATA(pState, sizeof( int ) + 12, GLfloat );
+    GLfloat xmove   = READ_DATA(pState, sizeof( int ) + 16, GLfloat );
+    GLfloat ymove   = READ_DATA(pState, sizeof( int ) + 20, GLfloat );
+    GLuint noimagedata = READ_DATA(pState, sizeof( int ) + 24, GLuint );
+    GLubyte *bitmap;
+
+    if (noimagedata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
+        return;
+
+    if (noimagedata)
+        bitmap = (GLubyte *) (uintptr_t) READ_DATA(pState,sizeof(int) + 28, GLint);
+    else
+    {
+        /* Each pixel is one bit => 8 pixels per byte. */
+        size_t cbImg = crImageSize(GL_COLOR_INDEX, GL_BITMAP, width, height);
+        if (RT_UNLIKELY(cbImg == 0))
+        {
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+        }
+
+        bitmap = DATA_POINTER(pState, sizeof(int) + 32, GLubyte );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, bitmap, cbImg, GLubyte);
+    }
+
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+
+    pState->pDispatchTbl->Bitmap( width, height, xorig, yorig, xmove, ymove, bitmap );
+
+    INCR_VAR_PTR(pState);
+}
+
+/*
+ * ZPixCR  - compressed DrawPixels
+ */
+void crUnpackExtendZPixCR(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 32, GLint);
+
+    GLsizei width   = READ_DATA(pState,   8, GLsizei );
+    GLsizei height  = READ_DATA(pState,  12, GLsizei );
+    GLenum  format  = READ_DATA(pState,  16, GLenum );
+    GLenum  type    = READ_DATA(pState,  20, GLenum );
+    GLenum  ztype   = READ_DATA(pState,  24, GLenum );
+    GLint   zparm   = READ_DATA(pState,  28, GLuint );
+    GLint   length  = READ_DATA(pState,  32, GLint );
+    GLvoid  *pixels = DATA_POINTER(pState,  36, GLvoid );
+
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, length, GLubyte);
+    pState->pDispatchTbl->ZPixCR( width, height, format, type, ztype, zparm, length, pixels );
+
+    /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */
+}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_extend.py	(revision 78190)
@@ -18,4 +18,6 @@
 #define UNPACK_EXTEND_H 1
 
+#include "cr_unpack.h"
+
 #ifdef __cplusplus
 extern "C" {
@@ -30,7 +32,7 @@
 for func_name in apiutil.AllSpecials( "unpacker" ):
 	if "extpack" in apiutil.ChromiumProps(func_name):
-		print('extern void crUnpackExtend%s(void);' % func_name)
+		print('extern void crUnpackExtend%s(PCrUnpackerState pState);' % func_name)
 	else:
-		print('extern void crUnpack%s(void);' % func_name)
+		print('extern void crUnpack%s(PCrUnpackerState pState);' % func_name)
 
 print("""
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fence.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fence.c	(revision 78189)
+++ 	(revision )
@@ -1,10 +1,0 @@
-
-#include "unpacker.h"
-
-void crUnpackExtendDeleteFencesNV(void)
-{
-	GLsizei n = READ_DATA( 8, GLsizei );
-	const GLuint *fences = DATA_POINTER( 12, GLuint );
-	cr_unpackDispatch.DeleteFencesNV( n, fences );
-}
-
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fence.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fence.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fence.cpp	(revision 78190)
@@ -0,0 +1,14 @@
+
+#include "unpacker.h"
+
+void crUnpackExtendDeleteFencesNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLuint);
+    GLsizei n = READ_DATA(pState, 8, GLsizei );
+    const GLuint *fences = DATA_POINTER(pState, 12, GLuint );
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, fences, n, GLuint);
+
+    pState->pDispatchTbl->DeleteFencesNV( n, fences );
+}
+
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fog.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fog.c	(revision 78189)
+++ 	(revision )
@@ -1,25 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-
-void crUnpackFogfv( void  )
-{
-	GLenum pname = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLfloat *params = DATA_POINTER( sizeof( int ) + 4, GLfloat );
-
-	cr_unpackDispatch.Fogfv( pname, params );
-	INCR_VAR_PTR();
-}
-
-void crUnpackFogiv( void  )
-{
-	GLenum pname = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLint *params = DATA_POINTER( sizeof( int ) + 4, GLint );
-
-	cr_unpackDispatch.Fogiv( pname, params );
-	INCR_VAR_PTR();
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fog.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fog.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_fog.cpp	(revision 78190)
@@ -0,0 +1,46 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+
+void crUnpackFogfv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLfloat);
+
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 4, GLfloat );
+
+    /*
+     * GL_FOG_COLOR requires 4 elements values while all others require only
+     * 1 element.
+     */
+    if (pname == GL_FOG_COLOR)
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLfloat);
+    else
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLfloat);
+
+    pState->pDispatchTbl->Fogfv( pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackFogiv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLint);
+    GLenum pname = READ_DATA(pState,  sizeof( int ) + 0, GLenum );
+    GLint *params = DATA_POINTER(pState,  sizeof( int ) + 4, GLint );
+
+    /*
+     * GL_FOG_COLOR requires 4 elements values while all others require only
+     * 1 element.
+     */
+    if (pname == GL_FOG_COLOR)
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLint);
+    else
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLint);
+
+    pState->pDispatchTbl->Fogiv( pname, params );
+    INCR_VAR_PTR(pState);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_framebuffer.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_framebuffer.c	(revision 78189)
+++ 	(revision )
@@ -1,37 +1,0 @@
-/* $Id$ */
-/** @file
- * VBox OpenGL: EXT_framebuffer_object
- */
-
-/*
- * Copyright (C) 2009-2019 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#include "unpacker.h"
-#include "cr_error.h"
-#include "cr_protocol.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-#include "cr_version.h"
-
-void crUnpackExtendDeleteFramebuffersEXT(void)
-{
-    GLsizei n = READ_DATA( 8, GLsizei );
-    const GLuint *buffers = DATA_POINTER( 12, GLuint );
-    cr_unpackDispatch.DeleteFramebuffersEXT( n, buffers );
-}
-
-void crUnpackExtendDeleteRenderbuffersEXT(void)
-{
-    GLsizei n = READ_DATA( 8, GLsizei );
-    const GLuint *buffers = DATA_POINTER( 12, GLuint );
-    cr_unpackDispatch.DeleteRenderbuffersEXT( n, buffers );
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_framebuffer.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_framebuffer.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_framebuffer.cpp	(revision 78190)
@@ -0,0 +1,45 @@
+/* $Id$ */
+/** @file
+ * VBox OpenGL: EXT_framebuffer_object
+ */
+
+/*
+ * Copyright (C) 2009-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include "unpacker.h"
+#include "cr_error.h"
+#include "cr_protocol.h"
+#include "cr_mem.h"
+#include "cr_string.h"
+#include "cr_version.h"
+
+void crUnpackExtendDeleteFramebuffersEXT(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLsizei);
+
+    GLsizei n = READ_DATA(pState, 8, GLsizei );
+    const GLuint *buffers = DATA_POINTER(pState, 12, GLuint );
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, buffers, n, GLuint);
+    pState->pDispatchTbl->DeleteFramebuffersEXT( n, buffers );
+}
+
+void crUnpackExtendDeleteRenderbuffersEXT(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLsizei);
+
+    GLsizei n = READ_DATA(pState, 8, GLsizei );
+    const GLuint *buffers = DATA_POINTER(pState, 12, GLuint );
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, buffers, n, GLuint);
+    pState->pDispatchTbl->DeleteRenderbuffersEXT( n, buffers );
+}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py	(revision 78189)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_header.py	(revision 78190)
@@ -22,9 +22,11 @@
 print("""#ifndef CR_UNPACKFUNCTIONS_H
 #define CR_UNPACKFUNCTIONS_H
+
+#include "cr_unpack.h"
 """)
 
 for func_name in sorted(gl_mapping.keys()):
 	( return_type, arg_names, arg_types ) = gl_mapping[func_name]
-	print('void crUnpack%s();' %( func_name ))
-print('void crUnpackExtend();')
+	print('void crUnpack%s(PCrUnpackerState pState);' %( func_name ))
+print('void crUnpackExtend(PCrUnpackerState pState);')
 print('\n#endif /* CR_UNPACKFUNCTIONS_H */')
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_lights.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_lights.c	(revision 78189)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-
-void crUnpackLightfv( void  )
-{
-	GLenum light = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-	GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat );
-
-	cr_unpackDispatch.Lightfv( light, pname, params );
-	INCR_VAR_PTR();
-}
-
-void crUnpackLightiv( void  )
-{
-	GLenum light = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-	GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint );
-
-	cr_unpackDispatch.Lightiv( light, pname, params );
-	INCR_VAR_PTR();
-}
-
-void crUnpackLightModelfv( void  )
-{
-	GLenum pname = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLfloat *params = DATA_POINTER( sizeof( int ) + 4, GLfloat );
-
-	cr_unpackDispatch.LightModelfv( pname, params );
-	INCR_VAR_PTR();
-}
-
-void crUnpackLightModeliv( void  )
-{
-	GLenum pname = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLint *params = DATA_POINTER( sizeof( int ) + 4, GLint );
-
-	cr_unpackDispatch.LightModeliv( pname, params );
-	INCR_VAR_PTR();
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_lights.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_lights.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_lights.cpp	(revision 78190)
@@ -0,0 +1,129 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+
+void crUnpackLightfv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum light = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 8, GLfloat );
+
+    switch (pname)
+    {
+        case GL_AMBIENT:
+        case GL_DIFFUSE:
+        case GL_SPECULAR:
+        case GL_POSITION:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLfloat);
+            break;
+        case GL_SPOT_DIRECTION:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 3, GLfloat);
+            break;
+        case GL_SPOT_EXPONENT:
+        case GL_SPOT_CUTOFF:
+        case GL_CONSTANT_ATTENUATION:
+        case GL_LINEAR_ATTENUATION:
+        case GL_QUADRATIC_ATTENUATION:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLfloat);
+            break;
+        default:
+            crError("crUnpackLightfv: Invalid pname (%#x) passed!\n", pname);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    pState->pDispatchTbl->Lightfv( light, pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackLightiv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum light = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLint *params = DATA_POINTER(pState, sizeof( int ) + 8, GLint );
+
+    switch (pname)
+    {
+        case GL_AMBIENT:
+        case GL_DIFFUSE:
+        case GL_SPECULAR:
+        case GL_POSITION:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLint);
+            break;
+        case GL_SPOT_DIRECTION:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 3, GLint);
+            break;
+        case GL_SPOT_EXPONENT:
+        case GL_SPOT_CUTOFF:
+        case GL_CONSTANT_ATTENUATION:
+        case GL_LINEAR_ATTENUATION:
+        case GL_QUADRATIC_ATTENUATION:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLint);
+            break;
+        default:
+            crError("crUnpackLightfv: Invalid pname (%#x) passed!\n", pname);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    pState->pDispatchTbl->Lightiv( light, pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackLightModelfv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 0, GLenum);
+
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 4, GLfloat );
+
+    switch (pname)
+    {
+        case GL_LIGHT_MODEL_AMBIENT:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLfloat);
+            break;
+        case GL_LIGHT_MODEL_TWO_SIDE:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLfloat);
+            break;
+        default:
+            crError("crUnpackLightfv: Invalid pname (%#x) passed!\n", pname);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    pState->pDispatchTbl->LightModelfv( pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackLightModeliv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 0, GLenum);
+
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLint *params = DATA_POINTER(pState, sizeof( int ) + 4, GLint );
+
+    switch (pname)
+    {
+        case GL_LIGHT_MODEL_AMBIENT:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLint);
+            break;
+        case GL_LIGHT_MODEL_TWO_SIDE:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLint);
+            break;
+        default:
+            crError("crUnpackLightfv: Invalid pname (%#x) passed!\n", pname);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    pState->pDispatchTbl->LightModeliv( pname, params );
+    INCR_VAR_PTR(pState);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.c	(revision 78189)
+++ 	(revision )
@@ -1,138 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "cr_error.h"
-#include "cr_mem.h"
-#include "state/cr_limits.h"
-
-
-void crUnpackMap2d(void)
-{
-    GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
-    GLdouble u1 = READ_DOUBLE(sizeof(int) + 4);
-    GLdouble u2 = READ_DOUBLE(sizeof(int) + 12);
-    GLint ustride = READ_DATA(sizeof(int) + 20, GLint);
-    GLint uorder = READ_DATA(sizeof(int) + 24, GLint);
-    GLdouble v1 = READ_DOUBLE(sizeof(int) + 28);
-    GLdouble v2 = READ_DOUBLE(sizeof(int) + 36);
-    GLint vstride = READ_DATA(sizeof(int) + 44, GLint);
-    GLint vorder = READ_DATA(sizeof(int) + 48, GLint);
-    GLdouble *points = DATA_POINTER(sizeof(int) + 52, GLdouble);
-    GLint cbMax;
-
-    if (uorder < 1 || uorder > CR_MAX_EVAL_ORDER ||
-        vorder < 1 || vorder > CR_MAX_EVAL_ORDER ||
-        ustride < 1 || ustride > INT32_MAX / (ssize_t)sizeof(double) / uorder / 8 ||
-        vstride < 1 || vstride > INT32_MAX / (ssize_t)sizeof(double) / vorder / 8 )
-    {
-        crError("crUnpackMap2d: parameters out of range");
-        return;
-    }
-
-    cbMax = (ustride * uorder + vstride * vorder) * sizeof(double);
-    if (!DATA_POINTER_CHECK(cbMax))
-    {
-        crError("crUnpackMap2d: parameters out of range");
-        return;
-    }
-
-    cr_unpackDispatch.Map2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
-
-    INCR_VAR_PTR();
-}
-
-void crUnpackMap2f(void)
-{
-    GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
-    GLfloat u1 = READ_DATA(sizeof(int) + 4, GLfloat);
-    GLfloat u2 = READ_DATA(sizeof(int) + 8, GLfloat);
-    GLint ustride = READ_DATA(sizeof(int) + 12, GLint);
-    GLint uorder = READ_DATA(sizeof(int) + 16, GLint);
-    GLfloat v1 = READ_DATA(sizeof(int) + 20, GLfloat);
-    GLfloat v2 = READ_DATA(sizeof(int) + 24, GLfloat);
-    GLint vstride = READ_DATA(sizeof(int) + 28, GLint);
-    GLint vorder = READ_DATA(sizeof(int) + 32, GLint);
-    GLfloat *points = DATA_POINTER(sizeof(int) + 36, GLfloat);
-    GLint cbMax;
-
-    if (uorder < 1 || uorder > CR_MAX_EVAL_ORDER ||
-        vorder < 1 || vorder > CR_MAX_EVAL_ORDER ||
-        ustride < 1 || ustride > INT32_MAX / (ssize_t)sizeof(float) / uorder / 8 ||
-        vstride < 1 || vstride > INT32_MAX / (ssize_t)sizeof(float) / vorder / 8)
-    {
-        crError("crUnpackMap2d: parameters out of range");
-        return;
-    }
-
-    cbMax = (ustride * uorder + vstride * vorder) * sizeof(float);
-    if (!DATA_POINTER_CHECK(cbMax))
-    {
-        crError("crUnpackMap2f: parameters out of range");
-        return;
-    }
-
-    cr_unpackDispatch.Map2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
-
-    INCR_VAR_PTR();
-}
-
-void crUnpackMap1d(void)
-{
-    GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
-    GLdouble u1 = READ_DOUBLE(sizeof(int) + 4);
-    GLdouble u2 = READ_DOUBLE(sizeof(int) + 12);
-    GLint stride = READ_DATA(sizeof(int) + 20, GLint);
-    GLint order = READ_DATA(sizeof(int) + 24, GLint);
-    GLdouble *points = DATA_POINTER(sizeof(int) + 28, GLdouble);
-    GLint cbMax;
-
-    if (order < 1 || order > CR_MAX_EVAL_ORDER ||
-        stride < 1 || stride > INT32_MAX / (ssize_t)sizeof(double) / order / 8)
-    {
-        crError("crUnpackMap1d: parameters out of range");
-        return;
-    }
-
-    cbMax = stride * order * sizeof(double);
-    if (!DATA_POINTER_CHECK(cbMax))
-    {
-        crError("crUnpackMap1d: parameters out of range");
-        return;
-    }
-
-    cr_unpackDispatch.Map1d(target, u1, u2, stride, order, points);
-
-    INCR_VAR_PTR();
-}
-
-void crUnpackMap1f(void)
-{
-    GLenum target = READ_DATA(sizeof(int) + 0, GLenum);
-    GLfloat u1 = READ_DATA(sizeof(int) + 4, GLfloat);
-    GLfloat u2 = READ_DATA(sizeof(int) + 8, GLfloat);
-    GLint stride = READ_DATA(sizeof(int) + 12, GLint);
-    GLint order = READ_DATA(sizeof(int) + 16, GLint);
-    GLfloat *points = DATA_POINTER(sizeof(int) + 20, GLfloat);
-    GLint cbMax;
-
-    if (order < 1 || order > CR_MAX_EVAL_ORDER ||
-        stride < 1 || stride > INT32_MAX / (ssize_t)sizeof(float) / order / 8)
-    {
-        crError("crUnpackMap1f: parameters out of range");
-        return;
-    }
-
-    cbMax = stride * order * sizeof(float);
-    if (!DATA_POINTER_CHECK(cbMax))
-    {
-        crError("crUnpackMap1f: parameters out of range");
-        return;
-    }
-
-    cr_unpackDispatch.Map1f(target, u1, u2, stride, order, points);
-    INCR_VAR_PTR();
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_map.cpp	(revision 78190)
@@ -0,0 +1,146 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "cr_error.h"
+#include "cr_mem.h"
+#include "state/cr_limits.h"
+
+
+void crUnpackMap2d(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 48, GLint);
+
+    GLenum target = READ_DATA(pState, sizeof(int) + 0, GLenum);
+    GLdouble u1 = READ_DOUBLE(pState, sizeof(int) + 4);
+    GLdouble u2 = READ_DOUBLE(pState, sizeof(int) + 12);
+    GLint ustride = READ_DATA(pState, sizeof(int) + 20, GLint);
+    GLint uorder = READ_DATA(pState, sizeof(int) + 24, GLint);
+    GLdouble v1 = READ_DOUBLE(pState, sizeof(int) + 28);
+    GLdouble v2 = READ_DOUBLE(pState, sizeof(int) + 36);
+    GLint vstride = READ_DATA(pState, sizeof(int) + 44, GLint);
+    GLint vorder = READ_DATA(pState, sizeof(int) + 48, GLint);
+    GLdouble *points = DATA_POINTER(pState, sizeof(int) + 52, GLdouble);
+    GLint cbMax;
+
+    if (uorder < 1 || uorder > CR_MAX_EVAL_ORDER ||
+        vorder < 1 || vorder > CR_MAX_EVAL_ORDER ||
+        ustride < 1 || ustride > INT32_MAX / (ssize_t)sizeof(double) / uorder / 8 ||
+        vstride < 1 || vstride > INT32_MAX / (ssize_t)sizeof(double) / vorder / 8 )
+    {
+        crError("crUnpackMap2d: parameters out of range");
+        return;
+    }
+
+    cbMax = (ustride * uorder + vstride * vorder) * sizeof(double);
+    if (!DATA_POINTER_CHECK(pState, cbMax))
+    {
+        crError("crUnpackMap2d: parameters out of range");
+        return;
+    }
+
+    pState->pDispatchTbl->Map2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
+
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackMap2f(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 32, GLint);
+
+    GLenum target = READ_DATA(pState, sizeof(int) + 0, GLenum);
+    GLfloat u1 = READ_DATA(pState, sizeof(int) + 4, GLfloat);
+    GLfloat u2 = READ_DATA(pState, sizeof(int) + 8, GLfloat);
+    GLint ustride = READ_DATA(pState, sizeof(int) + 12, GLint);
+    GLint uorder = READ_DATA(pState, sizeof(int) + 16, GLint);
+    GLfloat v1 = READ_DATA(pState, sizeof(int) + 20, GLfloat);
+    GLfloat v2 = READ_DATA(pState, sizeof(int) + 24, GLfloat);
+    GLint vstride = READ_DATA(pState, sizeof(int) + 28, GLint);
+    GLint vorder = READ_DATA(pState, sizeof(int) + 32, GLint);
+    GLfloat *points = DATA_POINTER(pState, sizeof(int) + 36, GLfloat);
+    GLint cbMax;
+
+    if (uorder < 1 || uorder > CR_MAX_EVAL_ORDER ||
+        vorder < 1 || vorder > CR_MAX_EVAL_ORDER ||
+        ustride < 1 || ustride > INT32_MAX / (ssize_t)sizeof(float) / uorder / 8 ||
+        vstride < 1 || vstride > INT32_MAX / (ssize_t)sizeof(float) / vorder / 8)
+    {
+        crError("crUnpackMap2d: parameters out of range");
+        return;
+    }
+
+    cbMax = (ustride * uorder + vstride * vorder) * sizeof(float);
+    if (!DATA_POINTER_CHECK(pState, cbMax))
+    {
+        crError("crUnpackMap2f: parameters out of range");
+        return;
+    }
+
+    pState->pDispatchTbl->Map2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
+
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackMap1d(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 24, GLint);
+
+    GLenum target = READ_DATA(pState, sizeof(int) + 0, GLenum);
+    GLdouble u1 = READ_DOUBLE(pState, sizeof(int) + 4);
+    GLdouble u2 = READ_DOUBLE(pState, sizeof(int) + 12);
+    GLint stride = READ_DATA(pState, sizeof(int) + 20, GLint);
+    GLint order = READ_DATA(pState, sizeof(int) + 24, GLint);
+    GLdouble *points = DATA_POINTER(pState, sizeof(int) + 28, GLdouble);
+    GLint cbMax;
+
+    if (order < 1 || order > CR_MAX_EVAL_ORDER ||
+        stride < 1 || stride > INT32_MAX / (ssize_t)sizeof(double) / order / 8)
+    {
+        crError("crUnpackMap1d: parameters out of range");
+        return;
+    }
+
+    cbMax = stride * order * sizeof(double);
+    if (!DATA_POINTER_CHECK(pState, cbMax))
+    {
+        crError("crUnpackMap1d: parameters out of range");
+        return;
+    }
+
+    pState->pDispatchTbl->Map1d(target, u1, u2, stride, order, points);
+
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackMap1f(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 16, GLint);
+
+    GLenum target = READ_DATA(pState, sizeof(int) + 0, GLenum);
+    GLfloat u1 = READ_DATA(pState, sizeof(int) + 4, GLfloat);
+    GLfloat u2 = READ_DATA(pState, sizeof(int) + 8, GLfloat);
+    GLint stride = READ_DATA(pState, sizeof(int) + 12, GLint);
+    GLint order = READ_DATA(pState, sizeof(int) + 16, GLint);
+    GLfloat *points = DATA_POINTER(pState, sizeof(int) + 20, GLfloat);
+    GLint cbMax;
+
+    if (order < 1 || order > CR_MAX_EVAL_ORDER ||
+        stride < 1 || stride > INT32_MAX / (ssize_t)sizeof(float) / order / 8)
+    {
+        crError("crUnpackMap1f: parameters out of range");
+        return;
+    }
+
+    cbMax = stride * order * sizeof(float);
+    if (!DATA_POINTER_CHECK(pState, cbMax))
+    {
+        crError("crUnpackMap1f: parameters out of range");
+        return;
+    }
+
+    pState->pDispatchTbl->Map1f(target, u1, u2, stride, order, points);
+    INCR_VAR_PTR(pState);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_materials.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_materials.c	(revision 78189)
+++ 	(revision )
@@ -1,27 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-
-void crUnpackMaterialfv( void  )
-{
-	GLenum face = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-	GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat );
-
-	cr_unpackDispatch.Materialfv( face, pname, params );
-	INCR_VAR_PTR();
-}
-
-void crUnpackMaterialiv( void  )
-{
-	GLenum face = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-	GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint );
-
-	cr_unpackDispatch.Materialiv( face, pname, params );
-	INCR_VAR_PTR();
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_materials.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_materials.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_materials.cpp	(revision 78190)
@@ -0,0 +1,73 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+
+void crUnpackMaterialfv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum face = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 8, GLfloat );
+
+    switch (pname)
+    {
+        case GL_AMBIENT:
+        case GL_DIFFUSE:
+        case GL_SPECULAR:
+        case GL_EMISSION:
+        case GL_AMBIENT_AND_DIFFUSE:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLfloat);
+            break;
+        case GL_SHININESS:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLfloat);
+            break;
+        case GL_COLOR_INDEXES:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 3, GLfloat);
+            break;
+        default:
+            crError("crUnpackMaterialfv: Invalid pname (%#x) passed!\n", pname);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    pState->pDispatchTbl->Materialfv( face, pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackMaterialiv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum face = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLint *params = DATA_POINTER(pState, sizeof( int ) + 8, GLint );
+
+    switch (pname)
+    {
+        case GL_AMBIENT:
+        case GL_DIFFUSE:
+        case GL_SPECULAR:
+        case GL_EMISSION:
+        case GL_AMBIENT_AND_DIFFUSE:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLint);
+            break;
+        case GL_SHININESS:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLint);
+            break;
+        case GL_COLOR_INDEXES:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 3, GLint);
+            break;
+        default:
+            crError("crUnpackMaterialfv: Invalid pname (%#x) passed!\n", pname);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    pState->pDispatchTbl->Materialiv( face, pname, params );
+    INCR_VAR_PTR(pState);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_matrices.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_matrices.c	(revision 78189)
+++ 	(revision )
@@ -1,72 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "cr_mem.h"
-
-void crUnpackMultMatrixd( void  )
-{
-	GLdouble m[16];
-	crMemcpy( m, DATA_POINTER( 0, GLdouble ), sizeof(m) );
-
-	cr_unpackDispatch.MultMatrixd( m );
-	INCR_DATA_PTR( 16*sizeof( GLdouble ) );
-}
-
-void crUnpackMultMatrixf( void  )
-{
-	GLfloat *m = DATA_POINTER( 0, GLfloat );
-
-	cr_unpackDispatch.MultMatrixf( m );
-	INCR_DATA_PTR( 16*sizeof( GLfloat ) );
-}
-
-void crUnpackLoadMatrixd( void  )
-{
-	GLdouble m[16];
-	crMemcpy( m, DATA_POINTER( 0, GLdouble ), sizeof(m) );
-
-	cr_unpackDispatch.LoadMatrixd( m );
-	INCR_DATA_PTR( 16*sizeof( GLdouble ) );
-}
-
-void crUnpackLoadMatrixf( void  )
-{
-	GLfloat *m = DATA_POINTER( 0, GLfloat );
-
-	cr_unpackDispatch.LoadMatrixf( m );
-	INCR_DATA_PTR( 16*sizeof( GLfloat ) );
-}
-
-void crUnpackExtendMultTransposeMatrixdARB( void  )
-{
-	GLdouble m[16];
-	crMemcpy( m, DATA_POINTER( 8, GLdouble ), sizeof(m) );
-
-	cr_unpackDispatch.MultTransposeMatrixdARB( m );
-}
-
-void crUnpackExtendMultTransposeMatrixfARB( void  )
-{
-	GLfloat *m = DATA_POINTER( 8, GLfloat );
-
-	cr_unpackDispatch.MultTransposeMatrixfARB( m );
-}
-
-void crUnpackExtendLoadTransposeMatrixdARB( void  )
-{
-	GLdouble m[16];
-	crMemcpy( m, DATA_POINTER( 8, GLdouble ), sizeof(m) );
-
-	cr_unpackDispatch.LoadTransposeMatrixdARB( m );
-}
-
-void crUnpackExtendLoadTransposeMatrixfARB( void  )
-{
-	GLfloat *m = DATA_POINTER( 8, GLfloat );
-
-	cr_unpackDispatch.LoadTransposeMatrixfARB( m );
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_matrices.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_matrices.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_matrices.cpp	(revision 78190)
@@ -0,0 +1,82 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "cr_mem.h"
+
+void crUnpackMultMatrixd(PCrUnpackerState pState)
+{
+	GLdouble m[16];
+    CHECK_BUFFER_SIZE_STATIC(pState, sizeof(m));
+	crMemcpy( m, DATA_POINTER(pState, 0, GLdouble ), sizeof(m) );
+
+	pState->pDispatchTbl->MultMatrixd( m );
+	INCR_DATA_PTR(pState, 16*sizeof( GLdouble ) );
+}
+
+void crUnpackMultMatrixf(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 16 * sizeof(GLfloat));
+
+	GLfloat *m = DATA_POINTER(pState, 0, GLfloat );
+
+	pState->pDispatchTbl->MultMatrixf( m );
+	INCR_DATA_PTR(pState, 16*sizeof( GLfloat ) );
+}
+
+void crUnpackLoadMatrixd(PCrUnpackerState pState)
+{
+	GLdouble m[16];
+    CHECK_BUFFER_SIZE_STATIC(pState, sizeof(m));
+	crMemcpy( m, DATA_POINTER(pState, 0, GLdouble ), sizeof(m) );
+
+	pState->pDispatchTbl->LoadMatrixd( m );
+	INCR_DATA_PTR(pState, 16*sizeof( GLdouble ) );
+}
+
+void crUnpackLoadMatrixf(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 16 * sizeof(GLfloat));
+
+	GLfloat *m = DATA_POINTER(pState, 0, GLfloat );
+
+	pState->pDispatchTbl->LoadMatrixf( m );
+	INCR_DATA_PTR(pState, 16*sizeof( GLfloat ) );
+}
+
+void crUnpackExtendMultTransposeMatrixdARB(PCrUnpackerState pState)
+{
+	GLdouble m[16];
+    CHECK_BUFFER_SIZE_STATIC(pState, 8 + sizeof(m));
+	crMemcpy( m, DATA_POINTER(pState, 8, GLdouble ), sizeof(m) );
+
+	pState->pDispatchTbl->MultTransposeMatrixdARB( m );
+}
+
+void crUnpackExtendMultTransposeMatrixfARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 8 + 16 * sizeof(GLfloat));
+	GLfloat *m = DATA_POINTER(pState, 8, GLfloat );
+
+	pState->pDispatchTbl->MultTransposeMatrixfARB( m );
+}
+
+void crUnpackExtendLoadTransposeMatrixdARB(PCrUnpackerState pState)
+{
+	GLdouble m[16];
+    CHECK_BUFFER_SIZE_STATIC(pState, 8 + sizeof(m));
+	crMemcpy( m, DATA_POINTER(pState, 8, GLdouble ), sizeof(m) );
+
+	pState->pDispatchTbl->LoadTransposeMatrixdARB( m );
+}
+
+void crUnpackExtendLoadTransposeMatrixfARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 8 + 16 * sizeof(GLfloat));
+	GLfloat *m = DATA_POINTER(pState, 8, GLfloat );
+
+	pState->pDispatchTbl->LoadTransposeMatrixfARB( m );
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_misc.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_misc.c	(revision 78189)
+++ 	(revision )
@@ -1,101 +1,0 @@
-/*
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-
-void crUnpackExtendChromiumParametervCR( void  )
-{
-    GLenum target = READ_DATA( 8, GLenum );
-    GLenum type = READ_DATA( 12, GLenum );
-    GLsizei count = READ_DATA( 16, GLsizei );
-    GLvoid *values = DATA_POINTER( 20, GLvoid );
-
-    cr_unpackDispatch.ChromiumParametervCR(target, type, count, values);
-
-
-    /*
-    INCR_VAR_PTR();
-    */
-}
-
-void crUnpackExtendDeleteQueriesARB(void)
-{
-    GLsizei n = READ_DATA( 8, GLsizei );
-    const GLuint *ids = DATA_POINTER(12, GLuint);
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLint) / 4 || !DATA_POINTER_CHECK(12 + n * sizeof(GLuint)))
-    {
-        crError("crUnpackExtendDeleteQueriesARB: parameter 'n' is out of range");
-        return;
-    }
-
-    cr_unpackDispatch.DeleteQueriesARB(n, ids);
-}
-
-void crUnpackExtendGetPolygonStipple(void)
-{
-    GLubyte *mask;
-
-    SET_RETURN_PTR( 8 );
-    SET_WRITEBACK_PTR( 16 );
-    mask = DATA_POINTER(8, GLubyte);
-
-    cr_unpackDispatch.GetPolygonStipple( mask );
-}
-
-void crUnpackExtendGetPixelMapfv(void)
-{
-    GLenum map = READ_DATA( 8, GLenum );
-    GLfloat *values;
-
-    SET_RETURN_PTR( 12 );
-    SET_WRITEBACK_PTR( 20 );
-    values = DATA_POINTER(12, GLfloat);
-
-    cr_unpackDispatch.GetPixelMapfv( map, values );
-}
-
-void crUnpackExtendGetPixelMapuiv(void)
-{
-    GLenum map = READ_DATA( 8, GLenum );
-    GLuint *values;
-
-    SET_RETURN_PTR( 12 );
-    SET_WRITEBACK_PTR( 20 );
-    values = DATA_POINTER(12, GLuint);
-
-    cr_unpackDispatch.GetPixelMapuiv( map, values );
-}
-
-void crUnpackExtendGetPixelMapusv(void)
-{
-    GLenum map = READ_DATA( 8, GLenum );
-    GLushort *values;
-
-    SET_RETURN_PTR( 12 );
-    SET_WRITEBACK_PTR( 20 );
-    values = DATA_POINTER(12, GLushort);
-
-    cr_unpackDispatch.GetPixelMapusv( map, values );
-}
-
-void crUnpackExtendVBoxTexPresent(void)
-{
-    GLuint texture = READ_DATA( 8, GLuint );
-    GLuint cfg = READ_DATA( 12, GLuint );
-    GLint xPos = READ_DATA( 16, GLint );
-    GLint yPos = READ_DATA( 20, GLint );
-    GLint cRects = READ_DATA( 24, GLint );
-    GLint *pRects = (GLint *)DATA_POINTER( 28, GLvoid );
-
-    if (cRects <= 0 || cRects >= INT32_MAX / sizeof(GLint) / 8 || !DATA_POINTER_CHECK(28 + 4 * cRects * sizeof(GLint)))
-    {
-        crError("crUnpackExtendVBoxTexPresent: parameter 'cRects' is out of range");
-        return;
-    }
-
-    cr_unpackDispatch.VBoxTexPresent( texture, cfg, xPos, yPos, cRects, pRects );
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_misc.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_misc.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_misc.cpp	(revision 78190)
@@ -0,0 +1,146 @@
+/*
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+
+void crUnpackExtendChromiumParametervCR(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLsizei);
+
+    GLenum target = READ_DATA(pState, 8, GLenum );
+    GLenum type = READ_DATA(pState, 12, GLenum );
+    GLsizei count = READ_DATA(pState, 16, GLsizei );
+    GLvoid *values = DATA_POINTER(pState, 20, GLvoid );
+
+    size_t cbValue = 0;
+    switch (type)
+    {
+        case GL_BYTE:
+        case GL_UNSIGNED_BYTE:
+            cbValue = sizeof(GLbyte);
+            break;
+        case GL_SHORT:
+        case GL_UNSIGNED_SHORT:
+            cbValue = sizeof(GLshort);
+            break;
+        case GL_INT:
+        case GL_UNSIGNED_INT:
+            cbValue = sizeof(GLint);
+            break;
+        case GL_FLOAT:
+            cbValue = sizeof(GLfloat);
+            break;
+        case GL_DOUBLE:
+            cbValue = sizeof(GLdouble);
+            break;
+        default:
+            crError("crUnpackExtendChromiumParametervCR: Invalid type (%#x) passed!\n", type);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_SZ_LAST(pState, values, count, cbValue);
+    pState->pDispatchTbl->ChromiumParametervCR(target, type, count, values);
+}
+
+void crUnpackExtendDeleteQueriesARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLsizei);
+
+    GLsizei n = READ_DATA(pState, 8, GLsizei );
+    const GLuint *ids = DATA_POINTER(pState, 12, GLuint);
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLint) / 4 || !DATA_POINTER_CHECK(pState, 12 + n * sizeof(GLuint)))
+    {
+        crError("crUnpackExtendDeleteQueriesARB: parameter 'n' is out of range");
+        return;
+    }
+
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, ids, n, GLuint);
+    pState->pDispatchTbl->DeleteQueriesARB(n, ids);
+}
+
+void crUnpackExtendGetPolygonStipple(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, CRNetworkPointer);
+
+    SET_RETURN_PTR(pState, 8 );
+    SET_WRITEBACK_PTR(pState, 16 );
+    GLubyte *mask = DATA_POINTER(pState, 8, GLubyte);
+
+    /*
+     * This method will write to the set writeback buffer and not to the mask argument, the mask argument is only used
+     * for GL_PIXEL_PACK_BUFFER_ARB contexts where it denotes an offset (GLint) which was already enclosed in the
+     * buffer verification.
+     */
+    pState->pDispatchTbl->GetPolygonStipple( mask );
+}
+
+void crUnpackExtendGetPixelMapfv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 20, CRNetworkPointer);
+
+    GLenum map = READ_DATA(pState, 8, GLenum );
+
+    SET_RETURN_PTR(pState, 12 );
+    SET_WRITEBACK_PTR(pState, 20 );
+    GLfloat *values = DATA_POINTER(pState, 12, GLfloat);
+
+    /* see crUnpackExtendGetPolygonStipple() for verification notes. */
+    pState->pDispatchTbl->GetPixelMapfv( map, values );
+}
+
+void crUnpackExtendGetPixelMapuiv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 20, CRNetworkPointer);
+
+    GLenum map = READ_DATA(pState, 8, GLenum );
+    GLuint *values;
+
+    SET_RETURN_PTR(pState, 12 );
+    SET_WRITEBACK_PTR(pState, 20 );
+    values = DATA_POINTER(pState, 12, GLuint);
+
+    /* see crUnpackExtendGetPolygonStipple() for verification notes. */
+    pState->pDispatchTbl->GetPixelMapuiv( map, values );
+}
+
+void crUnpackExtendGetPixelMapusv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 20, CRNetworkPointer);
+
+    GLenum map = READ_DATA(pState, 8, GLenum );
+    GLushort *values;
+
+    SET_RETURN_PTR(pState, 12 );
+    SET_WRITEBACK_PTR(pState, 20 );
+    values = DATA_POINTER(pState, 12, GLushort);
+
+    /* see crUnpackExtendGetPolygonStipple() for verification notes. */
+    pState->pDispatchTbl->GetPixelMapusv( map, values );
+}
+
+void crUnpackExtendVBoxTexPresent(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, GLint);
+
+    GLuint texture = READ_DATA(pState, 8, GLuint );
+    GLuint cfg = READ_DATA(pState, 12, GLuint );
+    GLint xPos = READ_DATA(pState, 16, GLint );
+    GLint yPos = READ_DATA(pState, 20, GLint );
+    GLint cRects = READ_DATA(pState, 24, GLint );
+    GLint *pRects = (GLint *)DATA_POINTER(pState, 28, GLvoid );
+
+    if (cRects <= 0 || cRects >= INT32_MAX / sizeof(GLint) / 8 || !DATA_POINTER_CHECK(pState, 28 + 4 * cRects * sizeof(GLint)))
+    {
+        crError("crUnpackExtendVBoxTexPresent: parameter 'cRects' is out of range");
+        return;
+    }
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pRects, cRects * 4, GLint); /* Each rect as 4 points. */
+    pState->pDispatchTbl->VBoxTexPresent( texture, cfg, xPos, yPos, cRects, pRects );
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_pixelmap.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_pixelmap.c	(revision 78189)
+++ 	(revision )
@@ -1,65 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "state/cr_bufferobject.h"
-
-void crUnpackPixelMapfv( void  )
-{
-    GLenum map = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLsizei mapsize = READ_DATA( sizeof( int ) + 4, GLsizei );
-    int nodata = READ_DATA( sizeof(int) + 8, int);
-    GLfloat *values;
-
-    if (nodata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
-        return;
-
-    if (nodata)
-        values = (GLfloat*) (uintptr_t) READ_DATA(sizeof(int) + 12, GLint);
-    else
-        values = DATA_POINTER( sizeof( int ) + 16, GLfloat );
-
-    cr_unpackDispatch.PixelMapfv( map, mapsize, values );
-    INCR_VAR_PTR();
-}
-
-void crUnpackPixelMapuiv( void  )
-{
-    GLenum map = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLsizei mapsize = READ_DATA( sizeof( int ) + 4, GLsizei );
-    int nodata = READ_DATA( sizeof(int) + 8, int);
-    GLuint *values;
-
-    if (nodata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
-        return;
-
-    if (nodata)
-        values = (GLuint*) (uintptr_t) READ_DATA(sizeof(int) + 12, GLint);
-    else
-        values = DATA_POINTER( sizeof( int ) + 16, GLuint );
-        
-    cr_unpackDispatch.PixelMapuiv( map, mapsize, values );
-    INCR_VAR_PTR();
-}
-
-void crUnpackPixelMapusv( void  )
-{
-    GLenum map = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLsizei mapsize = READ_DATA( sizeof( int ) + 4, GLsizei );
-    int nodata = READ_DATA( sizeof(int) + 8, int);
-    GLushort *values;
-
-    if (nodata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
-        return;
-
-    if (nodata)
-        values = (GLushort*) (uintptr_t) READ_DATA(sizeof(int) + 12, GLint);
-    else
-        values = DATA_POINTER( sizeof( int ) + 16, GLushort );
-
-    cr_unpackDispatch.PixelMapusv( map, mapsize, values );
-    INCR_VAR_PTR();
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_pixelmap.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_pixelmap.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_pixelmap.cpp	(revision 78190)
@@ -0,0 +1,89 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "state/cr_bufferobject.h"
+
+void crUnpackPixelMapfv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, int);
+
+    GLenum map = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLsizei mapsize = READ_DATA(pState, sizeof( int ) + 4, GLsizei );
+    int nodata = READ_DATA(pState, sizeof(int) + 8, int);
+    GLfloat *values;
+
+    if (nodata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
+        return;
+
+    if (nodata)
+    {
+        /* This is valid, see glPixelMap description for GL_PIXEL_UNPACK_BUFFER values is treated as a byte offset. */
+        values = (GLfloat*) (uintptr_t) READ_DATA(pState,sizeof(int) + 12, GLint);
+    }
+    else
+    {
+        values = DATA_POINTER(pState, sizeof( int ) + 16, GLfloat );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, values, mapsize, GLfloat);
+    }
+
+    pState->pDispatchTbl->PixelMapfv( map, mapsize, values );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackPixelMapuiv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, int);
+
+    GLenum map = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLsizei mapsize = READ_DATA(pState, sizeof( int ) + 4, GLsizei );
+    int nodata = READ_DATA(pState, sizeof(int) + 8, int);
+    GLuint *values;
+
+    if (nodata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
+        return;
+
+    if (nodata)
+    {
+        /* This is valid, see glPixelMap description for GL_PIXEL_UNPACK_BUFFER values is treated as a byte offset. */
+        values = (GLuint*) (uintptr_t) READ_DATA(pState,sizeof(int) + 12, GLint);
+    }
+    else
+    {
+        values = DATA_POINTER(pState, sizeof( int ) + 16, GLuint );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, values, mapsize, GLuint);
+    }
+
+    pState->pDispatchTbl->PixelMapuiv( map, mapsize, values );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackPixelMapusv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, int);
+
+    GLenum map = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLsizei mapsize = READ_DATA(pState, sizeof( int ) + 4, GLsizei );
+    int nodata = READ_DATA(pState, sizeof(int) + 8, int);
+    GLushort *values;
+
+    if (nodata && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
+        return;
+
+    if (nodata)
+    {
+        /* This is valid, see glPixelMap description for GL_PIXEL_UNPACK_BUFFER values is treated as a byte offset. */
+        values = (GLushort*) (uintptr_t) READ_DATA(pState, sizeof(int) + 12, GLint);
+    }
+    else
+    {
+        values = DATA_POINTER(pState, sizeof( int ) + 16, GLushort );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, values, mapsize, GLushort);
+    }
+
+    pState->pDispatchTbl->PixelMapusv( map, mapsize, values );
+    INCR_VAR_PTR(pState);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_point.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_point.c	(revision 78189)
+++ 	(revision )
@@ -1,24 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-
-void crUnpackExtendPointParameterfvARB( void  )
-{
-	GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-	GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat );
-	cr_unpackDispatch.PointParameterfvARB( pname, params );
-}
-
-#if 1
-void crUnpackExtendPointParameteriv( void  )
-{
-	GLenum pname = READ_DATA( sizeof( int ) + 0, GLenum );
-	GLint *params = DATA_POINTER( sizeof( int ) + 4, GLint );
-
-	cr_unpackDispatch.PointParameteriv( pname, params );
-}
-#endif
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_point.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_point.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_point.cpp	(revision 78190)
@@ -0,0 +1,30 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+
+void crUnpackExtendPointParameterfvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 8, GLfloat );
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLfloat);
+    pState->pDispatchTbl->PointParameterfvARB( pname, params );
+}
+
+void crUnpackExtendPointParameteriv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 0, GLenum);
+
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLint *params = DATA_POINTER(pState, sizeof( int ) + 4, GLint );
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLint);
+    pState->pDispatchTbl->PointParameteriv( pname, params );
+}
+
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.c	(revision 78189)
+++ 	(revision )
@@ -1,386 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "cr_error.h"
-#include "cr_protocol.h"
-#include "cr_mem.h"
-#include "cr_version.h"
-
-
-void crUnpackExtendProgramParameter4dvNV(void)
-{
-	GLenum target = READ_DATA(8, GLenum);
-	GLuint index = READ_DATA(12, GLuint);
-	GLdouble params[4];
-	params[0] = READ_DOUBLE(16);
-	params[1] = READ_DOUBLE(24);
-	params[2] = READ_DOUBLE(32);
-	params[3] = READ_DOUBLE(40);
-	cr_unpackDispatch.ProgramParameter4dvNV(target, index, params);
-}
-
-
-void crUnpackExtendProgramParameter4fvNV(void)
-{
-	GLenum target = READ_DATA(8, GLenum);
-	GLuint index = READ_DATA(12, GLuint);
-	GLfloat params[4];
-	params[0] = READ_DATA(16, GLfloat);
-	params[1] = READ_DATA(20, GLfloat);
-	params[2] = READ_DATA(24, GLfloat);
-	params[3] = READ_DATA(28, GLfloat);
-	cr_unpackDispatch.ProgramParameter4fvNV(target, index, params);
-}
-
-
-void crUnpackExtendProgramParameters4dvNV(void)
-{
-	GLenum target = READ_DATA(8, GLenum);
-	GLuint index = READ_DATA(12, GLuint);
-	GLuint num = READ_DATA(16, GLuint);
-    GLdouble *params;
-
-    if (num <= 0 || num >= INT32_MAX / (4 * sizeof(GLdouble)))
-    {
-        crError("crUnpackExtendProgramParameters4dvNV: parameter 'num' is out of range");
-        return;
-    }
-
-    params = (GLdouble *)crAlloc(num * 4 * sizeof(GLdouble));
-
-	if (params) {
-		GLuint i;
-		for (i = 0; i < 4 * num; i++) {
-            params[i] = READ_DATA(20 + i * sizeof(GLdouble), GLdouble);
-		}
-		cr_unpackDispatch.ProgramParameters4dvNV(target, index, num, params);
-		crFree(params);
-	}
-}
-
-
-void crUnpackExtendProgramParameters4fvNV(void)
-{
-	GLenum target = READ_DATA(8, GLenum);
-	GLuint index = READ_DATA(12, GLuint);
-	GLuint num = READ_DATA(16, GLuint);
-    GLfloat *params;
-
-    if (num <= 0 || num >= INT32_MAX / (4 * sizeof(GLfloat)))
-    {
-        crError("crUnpackExtendProgramParameters4fvNV: parameter 'num' is out of range");
-        return;
-    }
-
-    params = (GLfloat *)crAlloc(num * 4 * sizeof(GLfloat));
-
-	if (params) {
-		GLuint i;
-		for (i = 0; i < 4 * num; i++) {
-            params[i] = READ_DATA(20 + i * sizeof(GLfloat), GLfloat);
-		}
-		cr_unpackDispatch.ProgramParameters4fvNV(target, index, num, params);
-		crFree(params);
-	}
-}
-
-
-void crUnpackExtendAreProgramsResidentNV(void)
-{
-    GLsizei n = READ_DATA(8, GLsizei);
-    const GLuint *programs = DATA_POINTER(12, const GLuint);
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint) / 4 || !DATA_POINTER_CHECK(20 + n * sizeof(GLuint)))
-    {
-        crError("crUnpackExtendAreProgramsResidentNV: %d is out of range", n);
-        return;
-    }
-
-    SET_RETURN_PTR(12 + n * sizeof(GLuint));
-    SET_WRITEBACK_PTR(20 + n * sizeof(GLuint));
-    (void) cr_unpackDispatch.AreProgramsResidentNV(n, programs, NULL);
-}
-
-
-void crUnpackExtendLoadProgramNV(void)
-{
-	GLenum target = READ_DATA(8, GLenum);
-	GLuint id = READ_DATA(12, GLuint);
-	GLsizei len = READ_DATA(16, GLsizei);
-	GLvoid *program = DATA_POINTER(20, GLvoid);
-	cr_unpackDispatch.LoadProgramNV(target, id, len, program);
-}
-
-
-void crUnpackExtendExecuteProgramNV(void)
-{
-	GLenum target = READ_DATA(8, GLenum);
-	GLuint id = READ_DATA(12, GLuint);
-	GLfloat params[4];
-	params[0] = READ_DATA(16, GLfloat);
-	params[1] = READ_DATA(20, GLfloat);
-	params[2] = READ_DATA(24, GLfloat);
-	params[3] = READ_DATA(28, GLfloat);
-	cr_unpackDispatch.ExecuteProgramNV(target, id, params);
-}
-
-void crUnpackExtendRequestResidentProgramsNV(void)
-{
-	GLsizei n = READ_DATA(8, GLsizei);
-	crError("RequestResidentProgramsNV needs to be special cased!");
-	cr_unpackDispatch.RequestResidentProgramsNV(n, NULL);
-}
-
-
-void crUnpackExtendProgramLocalParameter4fvARB(void)
-{
-	GLenum target = READ_DATA(8, GLenum);
-	GLuint index = READ_DATA(12, GLuint);
-	GLfloat params[4];
-	params[0] = READ_DATA(16, GLfloat);
-	params[1] = READ_DATA(20, GLfloat);
-	params[2] = READ_DATA(24, GLfloat);
-	params[3] = READ_DATA(28, GLfloat);
-	cr_unpackDispatch.ProgramLocalParameter4fvARB(target, index, params);
-}
-
-
-void crUnpackExtendProgramLocalParameter4dvARB(void)
-{
-	GLenum target = READ_DATA(8, GLenum);
-	GLuint index = READ_DATA(12, GLuint);
-	GLdouble params[4];
-	params[0] = READ_DOUBLE(16);
-	params[1] = READ_DOUBLE(24);
-	params[2] = READ_DOUBLE(32);
-	params[3] = READ_DOUBLE(40);
-	cr_unpackDispatch.ProgramLocalParameter4dvARB(target, index, params);
-}
-
-
-
-void crUnpackExtendProgramNamedParameter4dvNV(void)
-{
-	GLuint id = READ_DATA(8, GLuint);
-	GLsizei len = READ_DATA(12, GLsizei);
-	GLdouble params[4];
-	GLubyte *name = crAlloc(len);
-	params[0] = READ_DOUBLE(16);
-	params[1] = READ_DOUBLE(24);
-	params[2] = READ_DOUBLE(32);
-	params[3] = READ_DOUBLE(40);
-	crMemcpy(name, DATA_POINTER(48, GLubyte), len);
-	cr_unpackDispatch.ProgramNamedParameter4dvNV(id, len, name, params);
-}
-
-void crUnpackExtendProgramNamedParameter4dNV(void)
-{
-	GLuint id = READ_DATA(8, GLuint);
-	GLsizei len = READ_DATA(12, GLsizei);
-	GLdouble params[4];
-	GLubyte *name = crAlloc (len);
-	params[0] = READ_DOUBLE(16);
-	params[1] = READ_DOUBLE(24);
-	params[2] = READ_DOUBLE(32);
-	params[3] = READ_DOUBLE(40);
-	crMemcpy(name, DATA_POINTER(48, GLubyte), len);
-	cr_unpackDispatch.ProgramNamedParameter4dNV(id, len, name, params[0], params[1], params[2], params[3]);
-}
-
-void crUnpackExtendProgramNamedParameter4fNV(void)
-{
-	GLenum id = READ_DATA(8, GLuint);
-	GLsizei len = READ_DATA(12, GLsizei);
-	GLfloat params[4];
-	GLubyte *name = crAlloc(len);
-	params[0] = READ_DATA(16, GLfloat);
-	params[1] = READ_DATA(20, GLfloat);
-	params[2] = READ_DATA(24, GLfloat);
-	params[3] = READ_DATA(28, GLfloat);
-	crMemcpy(name, DATA_POINTER(32,  GLubyte), len);
-	cr_unpackDispatch.ProgramNamedParameter4fNV(id, len, name, params[0], params[1], params[2], params[3]);
-}
-
-void crUnpackExtendProgramNamedParameter4fvNV(void)
-{
-	GLenum id = READ_DATA(8, GLuint);
-	GLsizei len = READ_DATA(12, GLsizei);
-	GLfloat params[4];
-	GLubyte *name = crAlloc(len);
-	params[0] = READ_DATA(16, GLfloat);
-	params[1] = READ_DATA(20, GLfloat);
-	params[2] = READ_DATA(24, GLfloat);
-	params[3] = READ_DATA(28, GLfloat);
-	crMemcpy(name, DATA_POINTER(32, GLubyte), len);
-	cr_unpackDispatch.ProgramNamedParameter4fvNV(id, len, name, params);
-}
-
-void crUnpackExtendGetProgramNamedParameterdvNV(void)
-{
-    GLuint id = READ_DATA(8, GLuint);
-    GLsizei len = READ_DATA(12, GLsizei);
-    const GLubyte *name = DATA_POINTER(16, GLubyte);
-
-    if (len <= 0 || len >= INT32_MAX / 4 || !DATA_POINTER_CHECK(16 + len + 8))
-    {
-        crError("crUnpackExtendGetProgramNamedParameterdvNV: len %d is out of range", len);
-        return;
-    }
-
-    SET_RETURN_PTR(16+len);
-    SET_WRITEBACK_PTR(16+len+8);
-    cr_unpackDispatch.GetProgramNamedParameterdvNV(id, len, name, NULL);
-}
-
-void crUnpackExtendGetProgramNamedParameterfvNV(void)
-{
-    GLuint id = READ_DATA(8, GLuint);
-    GLsizei len = READ_DATA(12, GLsizei);
-    const GLubyte *name = DATA_POINTER(16, GLubyte);
-
-    if (len <= 0 || len >= INT32_MAX / 4 || !DATA_POINTER_CHECK(16 + len + 8))
-    {
-        crError("crUnpackExtendGetProgramNamedParameterfvNV: len %d is out of range", len);
-        return;
-    }
-
-    SET_RETURN_PTR(16+len);
-    SET_WRITEBACK_PTR(16+len+8);
-    cr_unpackDispatch.GetProgramNamedParameterfvNV(id, len, name, NULL);
-}
-
-void crUnpackExtendProgramStringARB(void)
-{ 
-      GLenum target = READ_DATA(8, GLenum);
-      GLenum format = READ_DATA(12, GLuint);
-      GLsizei len = READ_DATA(16, GLsizei);
-      GLvoid *program = DATA_POINTER(20, GLvoid);
-      cr_unpackDispatch.ProgramStringARB(target, format, len, program);
-}
-
-void crUnpackExtendGetProgramStringARB(void)
-{
-}
-
-void crUnpackExtendProgramEnvParameter4dvARB(void)
-{
-	GLenum target = READ_DATA(8, GLenum);
-	GLuint index = READ_DATA(12, GLuint);
-	GLdouble params[4];
-	params[0] = READ_DOUBLE(16);
-	params[1] = READ_DOUBLE(24);
-	params[2] = READ_DOUBLE(32);
-	params[3] = READ_DOUBLE(40);
-	cr_unpackDispatch.ProgramEnvParameter4dvARB(target, index, params);
-}
-
-void crUnpackExtendProgramEnvParameter4fvARB(void)
-{
-	GLenum target = READ_DATA(8, GLenum);
-	GLuint index = READ_DATA(12, GLuint);
-	GLfloat params[4];
-	params[0] = READ_DATA(16, GLfloat);
-	params[1] = READ_DATA(20, GLfloat);
-	params[2] = READ_DATA(24, GLfloat);
-	params[3] = READ_DATA(28, GLfloat);
-	cr_unpackDispatch.ProgramEnvParameter4fvARB(target, index, params);
-}
-
-void crUnpackExtendDeleteProgramsARB(void)
-{
-	GLsizei n = READ_DATA(8, GLsizei);
-	const GLuint *programs = DATA_POINTER(12, GLuint);
-	cr_unpackDispatch.DeleteProgramsARB(n, programs);
-}
-
-void crUnpackVertexAttrib4NbvARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLbyte *v = DATA_POINTER(4, const GLbyte);
-	cr_unpackDispatch.VertexAttrib4NbvARB(index, v);
-	INCR_DATA_PTR(8);
-}
-
-void crUnpackVertexAttrib4NivARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLint *v = DATA_POINTER(4, const GLint);
-	cr_unpackDispatch.VertexAttrib4NivARB(index, v);
-	INCR_DATA_PTR(20);
-}
-
-void crUnpackVertexAttrib4NsvARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLshort *v = DATA_POINTER(4, const GLshort);
-	cr_unpackDispatch.VertexAttrib4NsvARB(index, v);
-	INCR_DATA_PTR(12);
-}
-
-void crUnpackVertexAttrib4NubvARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLubyte *v = DATA_POINTER(4, const GLubyte);
-	cr_unpackDispatch.VertexAttrib4NubvARB(index, v);
-	INCR_DATA_PTR(8);
-}
-
-void crUnpackVertexAttrib4NuivARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLuint *v = DATA_POINTER(4, const GLuint);
-	cr_unpackDispatch.VertexAttrib4NuivARB(index, v);
-	INCR_DATA_PTR(20);
-}
-
-void crUnpackVertexAttrib4NusvARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLushort *v = DATA_POINTER(4, const GLushort);
-	cr_unpackDispatch.VertexAttrib4NusvARB(index, v);
-	INCR_DATA_PTR(12);
-}
-
-void crUnpackVertexAttrib4bvARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLbyte *v = DATA_POINTER(4, const GLbyte);
-	cr_unpackDispatch.VertexAttrib4bvARB(index, v);
-	INCR_DATA_PTR(8);
-}
-
-void crUnpackVertexAttrib4ivARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLint *v = DATA_POINTER(4, const GLint);
-	cr_unpackDispatch.VertexAttrib4ivARB(index, v);
-	INCR_DATA_PTR(20);
-}
-
-void crUnpackVertexAttrib4ubvARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLubyte *v = DATA_POINTER(4, const GLubyte);
-	cr_unpackDispatch.VertexAttrib4ubvARB(index, v);
-	INCR_DATA_PTR(8);
-}
-
-void crUnpackVertexAttrib4uivARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLuint *v = DATA_POINTER(4, const GLuint);
-	cr_unpackDispatch.VertexAttrib4uivARB(index, v);
-	INCR_DATA_PTR(20);
-}
-
-void crUnpackVertexAttrib4usvARB(void)
-{
-	GLuint index = READ_DATA(0, GLuint);
-	const GLushort *v = DATA_POINTER(4, const GLushort);
-	cr_unpackDispatch.VertexAttrib4usvARB(index, v);
-	INCR_DATA_PTR(12);
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_program.cpp	(revision 78190)
@@ -0,0 +1,456 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "cr_error.h"
+#include "cr_protocol.h"
+#include "cr_mem.h"
+#include "cr_version.h"
+
+
+void crUnpackExtendProgramParameter4dvNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 40, GLdouble);
+
+	GLenum target = READ_DATA(pState, 8, GLenum);
+	GLuint index = READ_DATA(pState, 12, GLuint);
+	GLdouble params[4];
+	params[0] = READ_DOUBLE(pState, 16);
+	params[1] = READ_DOUBLE(pState, 24);
+	params[2] = READ_DOUBLE(pState, 32);
+	params[3] = READ_DOUBLE(pState, 40);
+	pState->pDispatchTbl->ProgramParameter4dvNV(target, index, params);
+}
+
+
+void crUnpackExtendProgramParameter4fvNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, GLfloat);
+
+	GLenum target = READ_DATA(pState, 8, GLenum);
+	GLuint index = READ_DATA(pState, 12, GLuint);
+	GLfloat params[4];
+	params[0] = READ_DATA(pState, 16, GLfloat);
+	params[1] = READ_DATA(pState, 20, GLfloat);
+	params[2] = READ_DATA(pState, 24, GLfloat);
+	params[3] = READ_DATA(pState, 28, GLfloat);
+	pState->pDispatchTbl->ProgramParameter4fvNV(target, index, params);
+}
+
+
+void crUnpackExtendProgramParameters4dvNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLuint);
+
+    GLenum target = READ_DATA(pState, 8, GLenum);
+    GLuint index = READ_DATA(pState, 12, GLuint);
+    GLuint num = READ_DATA(pState, 16, GLuint);
+
+    if (num <= 0 || num >= INT32_MAX / (4 * sizeof(GLdouble)))
+    {
+        crError("crUnpackExtendProgramParameters4dvNV: parameter 'num' is out of range");
+        pState->rcUnpack = VERR_INVALID_PARAMETER;
+        return;
+    }
+
+    GLdouble *params = DATA_POINTER(pState, 20, GLdouble);
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4 * num, GLdouble);
+
+    pState->pDispatchTbl->ProgramParameters4dvNV(target, index, num, params);
+}
+
+
+void crUnpackExtendProgramParameters4fvNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLuint);
+
+    GLenum target = READ_DATA(pState, 8, GLenum);
+    GLuint index = READ_DATA(pState, 12, GLuint);
+    GLuint num = READ_DATA(pState, 16, GLuint);
+
+    if (num <= 0 || num >= INT32_MAX / (4 * sizeof(GLfloat)))
+    {
+        crError("crUnpackExtendProgramParameters4fvNV: parameter 'num' is out of range");
+        pState->rcUnpack = VERR_INVALID_PARAMETER;
+        return;
+    }
+
+    GLfloat *params = DATA_POINTER(pState, 20, GLfloat);
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4 * num, GLfloat);
+
+    pState->pDispatchTbl->ProgramParameters4fvNV(target, index, num, params);
+}
+
+
+void crUnpackExtendAreProgramsResidentNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLsizei);
+    GLsizei n = READ_DATA(pState, 8, GLsizei);
+    const GLuint *programs = DATA_POINTER(pState, 12, const GLuint);
+
+    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint) / 4 || !DATA_POINTER_CHECK(pState, 20 + n * sizeof(GLuint)))
+    {
+        crError("crUnpackExtendAreProgramsResidentNV: %d is out of range", n);
+        pState->rcUnpack = VERR_INVALID_PARAMETER;
+        return;
+    }
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, programs, n, GLuint);
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 20 + n * sizeof(GLuint), CRNetworkPointer);
+
+    SET_RETURN_PTR(pState, 12 + n * sizeof(GLuint));
+    SET_WRITEBACK_PTR(pState, 20 + n * sizeof(GLuint));
+    (void) pState->pDispatchTbl->AreProgramsResidentNV(n, programs, NULL);
+}
+
+
+void crUnpackExtendLoadProgramNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLsizei);
+
+    GLenum target = READ_DATA(pState, 8, GLenum);
+    GLuint id = READ_DATA(pState, 12, GLuint);
+    GLsizei len = READ_DATA(pState, 16, GLsizei);
+
+    GLvoid *program = DATA_POINTER(pState, 20, GLvoid);
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, program, len, GLubyte);
+    pState->pDispatchTbl->LoadProgramNV(target, id, len, (GLubyte *)program);
+}
+
+
+void crUnpackExtendExecuteProgramNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 20, GLfloat);
+
+	GLenum target = READ_DATA(pState, 8, GLenum);
+	GLuint id = READ_DATA(pState, 12, GLuint);
+	GLfloat params[4];
+	params[0] = READ_DATA(pState, 16, GLfloat);
+	params[1] = READ_DATA(pState, 20, GLfloat);
+	params[2] = READ_DATA(pState, 24, GLfloat);
+	params[3] = READ_DATA(pState, 28, GLfloat);
+	pState->pDispatchTbl->ExecuteProgramNV(target, id, params);
+}
+
+void crUnpackExtendRequestResidentProgramsNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLsizei);
+
+	GLsizei n = READ_DATA(pState, 8, GLsizei);
+	crError("RequestResidentProgramsNV needs to be special cased!");
+	pState->pDispatchTbl->RequestResidentProgramsNV(n, NULL);
+}
+
+
+void crUnpackExtendProgramLocalParameter4fvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, GLfloat);
+
+	GLenum target = READ_DATA(pState, 8, GLenum);
+	GLuint index = READ_DATA(pState, 12, GLuint);
+	GLfloat params[4];
+	params[0] = READ_DATA(pState, 16, GLfloat);
+	params[1] = READ_DATA(pState, 20, GLfloat);
+	params[2] = READ_DATA(pState, 24, GLfloat);
+	params[3] = READ_DATA(pState, 28, GLfloat);
+	pState->pDispatchTbl->ProgramLocalParameter4fvARB(target, index, params);
+}
+
+
+void crUnpackExtendProgramLocalParameter4dvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 40, GLdouble);
+
+	GLenum target = READ_DATA(pState, 8, GLenum);
+	GLuint index = READ_DATA(pState, 12, GLuint);
+	GLdouble params[4];
+	params[0] = READ_DOUBLE(pState, 16);
+	params[1] = READ_DOUBLE(pState, 24);
+	params[2] = READ_DOUBLE(pState, 32);
+	params[3] = READ_DOUBLE(pState, 40);
+	pState->pDispatchTbl->ProgramLocalParameter4dvARB(target, index, params);
+}
+
+
+
+void crUnpackExtendProgramNamedParameter4dvNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 40, GLdouble);
+
+    GLuint id = READ_DATA(pState, 8, GLuint);
+    GLsizei len = READ_DATA(pState, 12, GLsizei);
+    GLdouble *params = DATA_POINTER(pState, 16, GLdouble);
+    GLubyte *name = DATA_POINTER(pState, 48, GLubyte);
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
+    pState->pDispatchTbl->ProgramNamedParameter4dvNV(id, len, name, params);
+}
+
+void crUnpackExtendProgramNamedParameter4dNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 40, GLdouble);
+
+    GLuint id = READ_DATA(pState, 8, GLuint);
+    GLsizei len = READ_DATA(pState, 12, GLsizei);
+    GLdouble params[4];
+    params[0] = READ_DOUBLE(pState, 16);
+    params[1] = READ_DOUBLE(pState, 24);
+    params[2] = READ_DOUBLE(pState, 32);
+    params[3] = READ_DOUBLE(pState, 40);
+
+    GLubyte *name = DATA_POINTER(pState, 48, GLubyte);
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
+    pState->pDispatchTbl->ProgramNamedParameter4dNV(id, len, name, params[0], params[1], params[2], params[3]);
+}
+
+void crUnpackExtendProgramNamedParameter4fNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, GLfloat);
+
+    GLenum id = READ_DATA(pState, 8, GLuint);
+    GLsizei len = READ_DATA(pState, 12, GLsizei);
+    GLfloat params[4];
+    params[0] = READ_DATA(pState, 16, GLfloat);
+    params[1] = READ_DATA(pState, 20, GLfloat);
+    params[2] = READ_DATA(pState, 24, GLfloat);
+    params[3] = READ_DATA(pState, 28, GLfloat);
+
+    GLubyte *name = DATA_POINTER(pState, 32, GLubyte);
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
+    pState->pDispatchTbl->ProgramNamedParameter4fNV(id, len, name, params[0], params[1], params[2], params[3]);
+}
+
+void crUnpackExtendProgramNamedParameter4fvNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, GLfloat);
+
+    GLenum id = READ_DATA(pState, 8, GLuint);
+    GLsizei len = READ_DATA(pState, 12, GLsizei);
+    GLfloat *params = DATA_POINTER(pState, 16, GLfloat);
+    GLubyte *name = DATA_POINTER(pState, 32, GLubyte);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
+    pState->pDispatchTbl->ProgramNamedParameter4fvNV(id, len, name, params);
+}
+
+void crUnpackExtendGetProgramNamedParameterdvNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
+
+    GLuint id = READ_DATA(pState, 8, GLuint);
+    GLsizei len = READ_DATA(pState, 12, GLsizei);
+    const GLubyte *name = DATA_POINTER(pState, 16, GLubyte);
+
+    if (len <= 0 || len >= INT32_MAX / 4)
+    {
+        crError("crUnpackExtendGetProgramNamedParameterdvNV: len %d is out of range", len);
+        pState->rcUnpack = VERR_INVALID_PARAMETER;
+        return;
+    }
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 16 + len + sizeof(CRNetworkPointer), CRNetworkPointer);
+
+    SET_RETURN_PTR(pState, 16+len);
+    SET_WRITEBACK_PTR(pState, 16+len+8);
+    pState->pDispatchTbl->GetProgramNamedParameterdvNV(id, len, name, NULL);
+}
+
+void crUnpackExtendGetProgramNamedParameterfvNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
+
+    GLuint id = READ_DATA(pState, 8, GLuint);
+    GLsizei len = READ_DATA(pState, 12, GLsizei);
+    const GLubyte *name = DATA_POINTER(pState, 16, GLubyte);
+
+    if (len <= 0 || len >= INT32_MAX / 4)
+    {
+        crError("crUnpackExtendGetProgramNamedParameterfvNV: len %d is out of range", len);
+        pState->rcUnpack = VERR_INVALID_PARAMETER;
+        return;
+    }
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, name, len, GLubyte);
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 16 + len + sizeof(CRNetworkPointer), CRNetworkPointer);
+    SET_RETURN_PTR(pState, 16+len);
+    SET_WRITEBACK_PTR(pState, 16+len+8);
+    pState->pDispatchTbl->GetProgramNamedParameterfvNV(id, len, name, NULL);
+}
+
+void crUnpackExtendProgramStringARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLsizei);
+
+    GLenum target = READ_DATA(pState, 8, GLenum);
+    GLenum format = READ_DATA(pState, 12, GLuint);
+    GLsizei len = READ_DATA(pState, 16, GLsizei);
+    GLvoid *program = DATA_POINTER(pState, 20, GLvoid);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, program, len, GLubyte);
+    pState->pDispatchTbl->ProgramStringARB(target, format, len, program);
+}
+
+void crUnpackExtendGetProgramStringARB(PCrUnpackerState pState)
+{
+}
+
+void crUnpackExtendProgramEnvParameter4dvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 40, GLdouble);
+
+	GLenum target = READ_DATA(pState, 8, GLenum);
+	GLuint index = READ_DATA(pState, 12, GLuint);
+	GLdouble params[4];
+	params[0] = READ_DOUBLE(pState, 16);
+	params[1] = READ_DOUBLE(pState, 24);
+	params[2] = READ_DOUBLE(pState, 32);
+	params[3] = READ_DOUBLE(pState, 40);
+	pState->pDispatchTbl->ProgramEnvParameter4dvARB(target, index, params);
+}
+
+void crUnpackExtendProgramEnvParameter4fvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, GLfloat);
+
+	GLenum target = READ_DATA(pState, 8, GLenum);
+	GLuint index = READ_DATA(pState, 12, GLuint);
+	GLfloat params[4];
+	params[0] = READ_DATA(pState, 16, GLfloat);
+	params[1] = READ_DATA(pState, 20, GLfloat);
+	params[2] = READ_DATA(pState, 24, GLfloat);
+	params[3] = READ_DATA(pState, 28, GLfloat);
+	pState->pDispatchTbl->ProgramEnvParameter4fvARB(target, index, params);
+}
+
+void crUnpackExtendDeleteProgramsARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLsizei);
+
+    GLsizei n = READ_DATA(pState, 8, GLsizei);
+    const GLuint *programs = DATA_POINTER(pState, 12, GLuint);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, programs, n, GLuint);
+    pState->pDispatchTbl->DeleteProgramsARB(n, programs);
+}
+
+void crUnpackVertexAttrib4NbvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 8);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLbyte *v = DATA_POINTER(pState, 4, const GLbyte);
+
+    pState->pDispatchTbl->VertexAttrib4NbvARB(index, v);
+    INCR_DATA_PTR(pState, 8);
+}
+
+void crUnpackVertexAttrib4NivARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 20);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLint *v = DATA_POINTER(pState, 4, const GLint);
+
+    pState->pDispatchTbl->VertexAttrib4NivARB(index, v);
+    INCR_DATA_PTR(pState, 20);
+}
+
+void crUnpackVertexAttrib4NsvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 12);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLshort *v = DATA_POINTER(pState, 4, const GLshort);
+
+    pState->pDispatchTbl->VertexAttrib4NsvARB(index, v);
+    INCR_DATA_PTR(pState, 12);
+}
+
+void crUnpackVertexAttrib4NubvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 8);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLubyte *v = DATA_POINTER(pState, 4, const GLubyte);
+
+    pState->pDispatchTbl->VertexAttrib4NubvARB(index, v);
+    INCR_DATA_PTR(pState, 8);
+}
+
+void crUnpackVertexAttrib4NuivARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 20);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLuint *v = DATA_POINTER(pState, 4, const GLuint);
+
+    pState->pDispatchTbl->VertexAttrib4NuivARB(index, v);
+    INCR_DATA_PTR(pState, 20);
+}
+
+void crUnpackVertexAttrib4NusvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 12);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLushort *v = DATA_POINTER(pState, 4, const GLushort);
+
+    pState->pDispatchTbl->VertexAttrib4NusvARB(index, v);
+    INCR_DATA_PTR(pState, 12);
+}
+
+void crUnpackVertexAttrib4bvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 8);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLbyte *v = DATA_POINTER(pState, 4, const GLbyte);
+
+    pState->pDispatchTbl->VertexAttrib4bvARB(index, v);
+    INCR_DATA_PTR(pState, 8);
+}
+
+void crUnpackVertexAttrib4ivARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 20);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLint *v = DATA_POINTER(pState, 4, const GLint);
+
+    pState->pDispatchTbl->VertexAttrib4ivARB(index, v);
+    INCR_DATA_PTR(pState, 20);
+}
+
+void crUnpackVertexAttrib4ubvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 8);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLubyte *v = DATA_POINTER(pState, 4, const GLubyte);
+
+    pState->pDispatchTbl->VertexAttrib4ubvARB(index, v);
+    INCR_DATA_PTR(pState, 8);
+}
+
+void crUnpackVertexAttrib4uivARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 20);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLuint *v = DATA_POINTER(pState, 4, const GLuint);
+
+    pState->pDispatchTbl->VertexAttrib4uivARB(index, v);
+    INCR_DATA_PTR(pState, 20);
+}
+
+void crUnpackVertexAttrib4usvARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC(pState, 12);
+
+    GLuint index = READ_DATA(pState, 0, GLuint);
+    const GLushort *v = DATA_POINTER(pState, 4, const GLushort);
+
+    pState->pDispatchTbl->VertexAttrib4usvARB(index, v);
+    INCR_DATA_PTR(pState, 12);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_readpixels.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_readpixels.c	(revision 78189)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "cr_pixeldata.h"
-#include "cr_mem.h"
-
-void crUnpackReadPixels( void )
-{
-	GLint x        = READ_DATA( 0, GLint );
-	GLint y        = READ_DATA( 4, GLint );
-	GLsizei width  = READ_DATA( 8, GLsizei );
-	GLsizei height = READ_DATA( 12, GLsizei );
-	GLenum format  = READ_DATA( 16, GLenum );
-	GLenum type    = READ_DATA( 20, GLenum );
-	GLint stride   = READ_DATA( 24, GLint );
-	GLint alignment     = READ_DATA( 28, GLint );
-	GLint skipRows      = READ_DATA( 32, GLint );
-	GLint skipPixels    = READ_DATA( 36, GLint );
-	GLint bytes_per_row = READ_DATA( 40, GLint );
-	GLint rowLength     = READ_DATA( 44, GLint );
-	GLvoid *pixels;
-
-	/* point <pixels> at the 8-byte network pointer */
-	pixels = DATA_POINTER( 48, GLvoid );
-
-	(void) stride;
-	(void) bytes_per_row;
-	(void) alignment;
-	(void) skipRows;
-	(void) skipPixels;
-	(void) rowLength;
-
-	/* we always pack densely on the server side! */
-	cr_unpackDispatch.PixelStorei( GL_PACK_ROW_LENGTH, 0 );
-	cr_unpackDispatch.PixelStorei( GL_PACK_SKIP_PIXELS, 0 );
-	cr_unpackDispatch.PixelStorei( GL_PACK_SKIP_ROWS, 0 );
-	cr_unpackDispatch.PixelStorei( GL_PACK_ALIGNMENT, 1 );
-
-	cr_unpackDispatch.ReadPixels( x, y, width, height, format, type, pixels);
-
-	INCR_DATA_PTR(48+sizeof(CRNetworkPointer));
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_readpixels.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_readpixels.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_readpixels.cpp	(revision 78190)
@@ -0,0 +1,47 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "cr_pixeldata.h"
+#include "cr_mem.h"
+
+void crUnpackReadPixels(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 48, CRNetworkPointer);
+
+    GLint x        = READ_DATA(pState,  0, GLint );
+    GLint y        = READ_DATA(pState,  4, GLint );
+    GLsizei width  = READ_DATA(pState,  8, GLsizei );
+    GLsizei height = READ_DATA(pState,  12, GLsizei );
+    GLenum format  = READ_DATA(pState,  16, GLenum );
+    GLenum type    = READ_DATA(pState,  20, GLenum );
+    GLint stride   = READ_DATA(pState,  24, GLint );
+    GLint alignment     = READ_DATA(pState,  28, GLint );
+    GLint skipRows      = READ_DATA(pState,  32, GLint );
+    GLint skipPixels    = READ_DATA(pState,  36, GLint );
+    GLint bytes_per_row = READ_DATA(pState,  40, GLint );
+    GLint rowLength     = READ_DATA(pState,  44, GLint );
+
+    /* point <pixels> at the 8-byte network pointer where the result will be written to. */
+    GLvoid *pixels = DATA_POINTER(pState,  48, GLvoid );
+
+    (void) stride;
+    (void) bytes_per_row;
+    (void) alignment;
+    (void) skipRows;
+    (void) skipPixels;
+    (void) rowLength;
+
+    /* we always pack densely on the server side! */
+    pState->pDispatchTbl->PixelStorei( GL_PACK_ROW_LENGTH, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_PACK_SKIP_PIXELS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_PACK_SKIP_ROWS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_PACK_ALIGNMENT, 1 );
+
+    pState->pDispatchTbl->ReadPixels( x, y, width, height, format, type, pixels);
+
+    INCR_DATA_PTR(pState, 48+sizeof(CRNetworkPointer));
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_regcombiner.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_regcombiner.c	(revision 78189)
+++ 	(revision )
@@ -1,35 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-
-void crUnpackExtendCombinerParameterfvNV( void  )
-{
-	GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-	GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat );
-
-	cr_unpackDispatch.CombinerParameterfvNV( pname, params );
-        /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */
-}
-
-void crUnpackExtendCombinerParameterivNV( void  )
-{
-	GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-	GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint );
-
-	cr_unpackDispatch.CombinerParameterivNV( pname, params );
-        /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */
-}
-
-void crUnpackExtendCombinerStageParameterfvNV( void  )
-{
-	GLenum stage = READ_DATA( sizeof( int ) + 4, GLenum );
-	GLenum pname = READ_DATA( sizeof( int ) + 8, GLenum );
-	GLfloat *params = DATA_POINTER( sizeof( int ) + 12, GLfloat );
-
-	cr_unpackDispatch.CombinerStageParameterfvNV( stage, pname, params );
-        /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_regcombiner.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_regcombiner.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_regcombiner.cpp	(revision 78190)
@@ -0,0 +1,85 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+
+void crUnpackExtendCombinerParameterfvNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, GLfloat);
+
+    GLenum pname = READ_DATA(pState,  sizeof( int ) + 4, GLenum );
+    GLfloat *params = DATA_POINTER(pState,  sizeof( int ) + 8, GLfloat );
+
+    switch (pname)
+    {
+        case GL_CONSTANT_COLOR0_NV:
+        case GL_CONSTANT_COLOR1_NV:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLfloat);
+            break;
+        case GL_NUM_GENERAL_COMBINERS_NV:
+        case GL_COLOR_SUM_CLAMP_NV:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLfloat);
+            break;
+        default:
+            crError("crUnpackExtendCombinerParameterfvNV: Invalid pname (%#x) passed!\n", pname);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    pState->pDispatchTbl->CombinerParameterfvNV( pname, params );
+    /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */
+}
+
+void crUnpackExtendCombinerParameterivNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, GLint);
+
+    GLenum pname = READ_DATA(pState,  sizeof( int ) + 4, GLenum );
+    GLint *params = DATA_POINTER(pState,  sizeof( int ) + 8, GLint );
+
+    switch (pname)
+    {
+        case GL_CONSTANT_COLOR0_NV:
+        case GL_CONSTANT_COLOR1_NV:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLint);
+            break;
+        case GL_NUM_GENERAL_COMBINERS_NV:
+        case GL_COLOR_SUM_CLAMP_NV:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 1, GLint);
+            break;
+        default:
+            crError("crUnpackExtendCombinerParameterivNV: Invalid pname (%#x) passed!\n", pname);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    pState->pDispatchTbl->CombinerParameterivNV( pname, params );
+    /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */
+}
+
+void crUnpackExtendCombinerStageParameterfvNV(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, GLenum);
+
+    GLenum stage = READ_DATA(pState,  sizeof( int ) + 4, GLenum );
+    GLenum pname = READ_DATA(pState,  sizeof( int ) + 8, GLenum );
+    GLfloat *params = DATA_POINTER(pState,  sizeof( int ) + 12, GLfloat );
+
+    switch (pname)
+    {
+        case GL_CONSTANT_COLOR0_NV:
+        case GL_CONSTANT_COLOR1_NV:
+            CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, 4, GLint);
+            break;
+        default:
+            crError("crUnpackExtendCombinerStageParameterfvNV: Invalid pname (%#x) passed!\n", pname);
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+    }
+
+    pState->pDispatchTbl->CombinerStageParameterfvNV( stage, pname, params );
+    /* Don't call INCR_VAR_PTR(); - it's done in crUnpackExtend() */
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_shaders.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_shaders.c	(revision 78189)
+++ 	(revision )
@@ -1,398 +1,0 @@
-/* $Id$ */
-/** @file
- * VBox OpenGL DRI driver functions
- */
-
-/*
- * Copyright (C) 2009-2019 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#include "unpacker.h"
-#include "cr_error.h"
-#include "cr_protocol.h"
-#include "cr_mem.h"
-#include "cr_string.h"
-#include "cr_version.h"
-
-void crUnpackExtendBindAttribLocation(void)
-{
-    GLuint program   = READ_DATA(8, GLuint);
-    GLuint index     = READ_DATA(12, GLuint);
-    const char *name = DATA_POINTER(16, const char);
-
-    cr_unpackDispatch.BindAttribLocation(program, index, name);
-}
-
-void crUnpackExtendShaderSource(void)
-{
-    GLint *length = NULL;
-    GLuint shader = READ_DATA(8, GLuint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    GLint hasNonLocalLen = READ_DATA(16, GLsizei);
-    GLint *pLocalLength = DATA_POINTER(20, GLint);
-    char **ppStrings = NULL;
-    GLsizei i, j, jUpTo;
-    int pos, pos_check;
-
-    if (count <= 0 || count >= INT32_MAX / sizeof(GLint) / 8)
-    {
-        crError("crUnpackExtendShaderSource: count %u is out of range", count);
-        return;
-    }
-
-    pos = 20 + count * sizeof(*pLocalLength);
-
-    if (!DATA_POINTER_CHECK(pos))
-    {
-        crError("crUnpackExtendShaderSource: pos %d is out of range", pos);
-        return;
-    }
-
-    if (hasNonLocalLen > 0)
-    {
-        length = DATA_POINTER(pos, GLint);
-        pos += count * sizeof(*length);
-    }
-
-    if (!DATA_POINTER_CHECK(pos))
-    {
-        crError("crUnpackExtendShaderSource: pos %d is out of range", pos);
-        return;
-    }
-
-    pos_check = pos;
-
-    for (i = 0; i < count; ++i)
-    {
-        if (pLocalLength[i] <= 0 || pos_check >= INT32_MAX - pLocalLength[i])
-        {
-            crError("crUnpackExtendShaderSource: pos %d is out of range", pos_check);
-            return;
-        }
-
-        pos_check += pLocalLength[i];
-
-        if (!DATA_POINTER_CHECK(pos_check))
-        {
-            crError("crUnpackExtendShaderSource: pos %d is out of range", pos_check);
-            return;
-        }
-    }
-
-    ppStrings = crAlloc(count * sizeof(char*));
-    if (!ppStrings) return;
-
-    for (i = 0; i < count; ++i)
-    {
-        ppStrings[i] = DATA_POINTER(pos, char);
-        pos += pLocalLength[i];
-        if (!length)
-        {
-            pLocalLength[i] -= 1;
-        }
-
-        Assert(pLocalLength[i] > 0);
-        jUpTo = i == count -1 ? pLocalLength[i] - 1 : pLocalLength[i];
-        for (j = 0; j < jUpTo; ++j)
-        {
-            char *pString = ppStrings[i];
-
-            if (pString[j] == '\0')
-            {
-                Assert(j == jUpTo - 1);
-                pString[j] = '\n';
-            }
-        }
-    }
-
-//    cr_unpackDispatch.ShaderSource(shader, count, ppStrings, length ? length : pLocalLength);
-    cr_unpackDispatch.ShaderSource(shader, 1, (const char**)ppStrings, 0);
-
-    crFree(ppStrings);
-}
-
-void crUnpackExtendUniform1fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    const GLfloat *value = DATA_POINTER(16, const GLfloat);
-    cr_unpackDispatch.Uniform1fv(location, count, value);
-}
-
-void crUnpackExtendUniform1iv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    const GLint *value = DATA_POINTER(16, const GLint);
-    cr_unpackDispatch.Uniform1iv(location, count, value);
-}
-
-void crUnpackExtendUniform2fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    const GLfloat *value = DATA_POINTER(16, const GLfloat);
-    cr_unpackDispatch.Uniform2fv(location, count, value);
-}
-
-void crUnpackExtendUniform2iv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    const GLint *value = DATA_POINTER(16, const GLint);
-    cr_unpackDispatch.Uniform2iv(location, count, value);
-}
-
-void crUnpackExtendUniform3fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    const GLfloat *value = DATA_POINTER(16, const GLfloat);
-    cr_unpackDispatch.Uniform3fv(location, count, value);
-}
-
-void crUnpackExtendUniform3iv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    const GLint *value = DATA_POINTER(16, const GLint);
-    cr_unpackDispatch.Uniform3iv(location, count, value);
-}
-
-void crUnpackExtendUniform4fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    const GLfloat *value = DATA_POINTER(16, const GLfloat);
-    cr_unpackDispatch.Uniform4fv(location, count, value);
-}
-
-void crUnpackExtendUniform4iv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    const GLint *value = DATA_POINTER(16, const GLint);
-    cr_unpackDispatch.Uniform4iv(location, count, value);
-}
-
-void crUnpackExtendUniformMatrix2fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    GLboolean transpose = READ_DATA(16, GLboolean);
-    const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
-    cr_unpackDispatch.UniformMatrix2fv(location, count, transpose, value);
-}
-
-void crUnpackExtendUniformMatrix3fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    GLboolean transpose = READ_DATA(16, GLboolean);
-    const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
-    cr_unpackDispatch.UniformMatrix3fv(location, count, transpose, value);
-}
-
-void crUnpackExtendUniformMatrix4fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    GLboolean transpose = READ_DATA(16, GLboolean);
-    const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
-    cr_unpackDispatch.UniformMatrix4fv(location, count, transpose, value);
-}
-
-void crUnpackExtendUniformMatrix2x3fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    GLboolean transpose = READ_DATA(16, GLboolean);
-    const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
-    cr_unpackDispatch.UniformMatrix2x3fv(location, count, transpose, value);
-}
-
-void crUnpackExtendUniformMatrix3x2fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    GLboolean transpose = READ_DATA(16, GLboolean);
-    const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
-    cr_unpackDispatch.UniformMatrix3x2fv(location, count, transpose, value);
-}
-
-void crUnpackExtendUniformMatrix2x4fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    GLboolean transpose = READ_DATA(16, GLboolean);
-    const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
-    cr_unpackDispatch.UniformMatrix2x4fv(location, count, transpose, value);
-}
-
-void crUnpackExtendUniformMatrix4x2fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    GLboolean transpose = READ_DATA(16, GLboolean);
-    const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
-    cr_unpackDispatch.UniformMatrix4x2fv(location, count, transpose, value);
-}
-
-void crUnpackExtendUniformMatrix3x4fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    GLboolean transpose = READ_DATA(16, GLboolean);
-    const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
-    cr_unpackDispatch.UniformMatrix3x4fv(location, count, transpose, value);
-}
-
-void crUnpackExtendUniformMatrix4x3fv(void)
-{
-    GLint location = READ_DATA(8, GLint);
-    GLsizei count = READ_DATA(12, GLsizei);
-    GLboolean transpose = READ_DATA(16, GLboolean);
-    const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
-    cr_unpackDispatch.UniformMatrix4x3fv(location, count, transpose, value);
-}
-
-void crUnpackExtendDrawBuffers(void)
-{
-    GLsizei n = READ_DATA(8, GLsizei);
-    const GLenum *bufs = DATA_POINTER(8+sizeof(GLsizei), const GLenum);
-    cr_unpackDispatch.DrawBuffers(n, bufs);
-}
-
-void crUnpackExtendGetActiveAttrib(void)
-{
-    GLuint program = READ_DATA(8, GLuint);
-    GLuint index = READ_DATA(12, GLuint);
-    GLsizei bufSize = READ_DATA(16, GLsizei);
-    SET_RETURN_PTR(20);
-    SET_WRITEBACK_PTR(28);
-    cr_unpackDispatch.GetActiveAttrib(program, index, bufSize, NULL, NULL, NULL, NULL);
-}
-
-void crUnpackExtendGetActiveUniform(void)
-{
-    GLuint program = READ_DATA(8, GLuint);
-    GLuint index = READ_DATA(12, GLuint);
-    GLsizei bufSize = READ_DATA(16, GLsizei);
-    SET_RETURN_PTR(20);
-    SET_WRITEBACK_PTR(28);
-    cr_unpackDispatch.GetActiveUniform(program, index, bufSize, NULL, NULL, NULL, NULL);
-}
-
-void crUnpackExtendGetAttachedShaders(void)
-{
-    GLuint program = READ_DATA(8, GLuint);
-    GLsizei maxCount = READ_DATA(12, GLsizei);
-    SET_RETURN_PTR(16);
-    SET_WRITEBACK_PTR(24);
-    cr_unpackDispatch.GetAttachedShaders(program, maxCount, NULL, NULL);
-}
-
-void crUnpackExtendGetAttachedObjectsARB(void)
-{
-        VBoxGLhandleARB containerObj = READ_DATA(8, VBoxGLhandleARB);
-        GLsizei maxCount = READ_DATA(12, GLsizei);
-        SET_RETURN_PTR(16);
-        SET_WRITEBACK_PTR(24);
-        cr_unpackDispatch.GetAttachedObjectsARB(containerObj, maxCount, NULL, NULL);
-}
-
-void crUnpackExtendGetInfoLogARB(void)
-{
-        VBoxGLhandleARB obj = READ_DATA(8, VBoxGLhandleARB);
-        GLsizei maxLength = READ_DATA(12, GLsizei);
-        SET_RETURN_PTR(16);
-        SET_WRITEBACK_PTR(24);
-        cr_unpackDispatch.GetInfoLogARB(obj, maxLength, NULL, NULL);
-}
-
-void crUnpackExtendGetProgramInfoLog(void)
-{
-    GLuint program = READ_DATA(8, GLuint);
-    GLsizei bufSize = READ_DATA(12, GLsizei);
-    SET_RETURN_PTR(16);
-    SET_WRITEBACK_PTR(24);
-    cr_unpackDispatch.GetProgramInfoLog(program, bufSize, NULL, NULL);
-}
-
-void crUnpackExtendGetShaderInfoLog(void)
-{
-    GLuint shader = READ_DATA(8, GLuint);
-    GLsizei bufSize = READ_DATA(12, GLsizei);
-    SET_RETURN_PTR(16);
-    SET_WRITEBACK_PTR(24);
-    cr_unpackDispatch.GetShaderInfoLog(shader, bufSize, NULL, NULL);
-}
-
-void crUnpackExtendGetShaderSource(void)
-{
-    GLuint shader = READ_DATA(8, GLuint);
-    GLsizei bufSize = READ_DATA(12, GLsizei);
-    SET_RETURN_PTR(16);
-    SET_WRITEBACK_PTR(24);
-    cr_unpackDispatch.GetShaderSource(shader, bufSize, NULL, NULL);
-}
-
-void crUnpackExtendGetAttribLocation(void)
-{
-    int packet_length = READ_DATA(0, int);
-    GLuint program = READ_DATA(8, GLuint);
-    const char *name = DATA_POINTER(12, const char);
-
-    if (!DATA_POINTER_CHECK(packet_length))
-    {
-        crError("crUnpackExtendGetAttribLocation: packet_length is out of range");
-        return;
-    }
-
-    SET_RETURN_PTR(packet_length-16);
-    SET_WRITEBACK_PTR(packet_length-8);
-    cr_unpackDispatch.GetAttribLocation(program, name);
-}
-
-void crUnpackExtendGetUniformLocation(void)
-{
-    int packet_length = READ_DATA(0, int);
-    GLuint program = READ_DATA(8, GLuint);
-    const char *name = DATA_POINTER(12, const char);
-
-    if (!DATA_POINTER_CHECK(packet_length))
-    {
-        crError("crUnpackExtendGetUniformLocation: packet_length is out of range");
-        return;
-    }
-
-    SET_RETURN_PTR(packet_length-16);
-    SET_WRITEBACK_PTR(packet_length-8);
-    cr_unpackDispatch.GetUniformLocation(program, name);
-}
-
-void crUnpackExtendGetUniformsLocations(void)
-{
-        GLuint program = READ_DATA(8, GLuint);
-        GLsizei maxcbData = READ_DATA(12, GLsizei);
-        SET_RETURN_PTR(16);
-        SET_WRITEBACK_PTR(24);
-        cr_unpackDispatch.GetUniformsLocations(program, maxcbData, NULL, NULL);
-}
-
-void crUnpackExtendGetAttribsLocations(void)
-{
-    GLuint program = READ_DATA(8, GLuint);
-    GLsizei maxcbData = READ_DATA(12, GLsizei);
-    SET_RETURN_PTR(16);
-    SET_WRITEBACK_PTR(24);
-    cr_unpackDispatch.GetAttribsLocations(program, maxcbData, NULL, NULL);
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_shaders.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_shaders.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_shaders.cpp	(revision 78190)
@@ -0,0 +1,508 @@
+/* $Id$ */
+/** @file
+ * VBox OpenGL DRI driver functions
+ */
+
+/*
+ * Copyright (C) 2009-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include "unpacker.h"
+#include "cr_error.h"
+#include "cr_protocol.h"
+#include "cr_mem.h"
+#include "cr_string.h"
+#include "cr_version.h"
+
+void crUnpackExtendBindAttribLocation(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLuint);
+
+    GLuint program   = READ_DATA(pState, 8, GLuint);
+    GLuint index     = READ_DATA(pState, 12, GLuint);
+    const char *name = DATA_POINTER(pState, 16, const char);
+
+    CHECK_STRING_FROM_PTR_UPDATE_NO_SZ(pState, name);
+    pState->pDispatchTbl->BindAttribLocation(program, index, name);
+}
+
+void crUnpackExtendShaderSource(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLsizei);
+
+    GLint *length = NULL;
+    GLuint shader = READ_DATA(pState, 8, GLuint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    GLint hasNonLocalLen = READ_DATA(pState, 16, GLsizei);
+    GLint *pLocalLength = DATA_POINTER(pState, 20, GLint);
+    char **ppStrings = NULL;
+    GLsizei i, j, jUpTo;
+    int pos, pos_check;
+
+    if (count <= 0 || count >= INT32_MAX / sizeof(GLint) / 8)
+    {
+        crError("crUnpackExtendShaderSource: count %u is out of range", count);
+        return;
+    }
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pLocalLength, count, GLint);
+
+    /** @todo More verification required here. */
+    pos = 20 + count * sizeof(*pLocalLength);
+
+    if (!DATA_POINTER_CHECK(pState, pos))
+    {
+        crError("crUnpackExtendShaderSource: pos %d is out of range", pos);
+        return;
+    }
+
+    if (hasNonLocalLen > 0)
+    {
+        length = DATA_POINTER(pState, pos, GLint);
+        pos += count * sizeof(*length);
+    }
+
+    pos_check = pos;
+
+    if (!DATA_POINTER_CHECK(pState, pos_check))
+    {
+        crError("crUnpackExtendShaderSource: pos %d is out of range", pos);
+        return;
+    }
+
+    pos_check = pos;
+
+    for (i = 0; i < count; ++i)
+    {
+        if (pLocalLength[i] <= 0 || pos_check >= INT32_MAX - pLocalLength[i] || !DATA_POINTER_CHECK(pState, pos_check))
+        {
+            crError("crUnpackExtendShaderSource: pos %d is out of range", pos_check);
+            return;
+        }
+
+        pos_check += pLocalLength[i];
+
+        if (!DATA_POINTER_CHECK(pState, pos_check))
+        {
+            crError("crUnpackExtendShaderSource: pos %d is out of range", pos_check);
+            return;
+        }
+    }
+
+    ppStrings = (char **)crAlloc(count * sizeof(char*));
+    if (!ppStrings) return;
+
+    for (i = 0; i < count; ++i)
+    {
+        CHECK_BUFFER_SIZE_STATIC_UPDATE(pState, pos); /** @todo Free ppStrings on error. */
+        ppStrings[i] = DATA_POINTER(pState, pos, char);
+        pos += pLocalLength[i];
+        if (!length)
+        {
+            pLocalLength[i] -= 1;
+        }
+
+        Assert(pLocalLength[i] > 0);
+        jUpTo = i == count -1 ? pLocalLength[i] - 1 : pLocalLength[i];
+        for (j = 0; j < jUpTo; ++j)
+        {
+            char *pString = ppStrings[i];
+
+            if (pString[j] == '\0')
+            {
+                Assert(j == jUpTo - 1);
+                pString[j] = '\n';
+            }
+        }
+    }
+
+//    pState->pDispatchTbl->ShaderSource(shader, count, ppStrings, length ? length : pLocalLength);
+    pState->pDispatchTbl->ShaderSource(shader, 1, (const char**)ppStrings, 0);
+
+    crFree(ppStrings);
+}
+
+void crUnpackExtendUniform1fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    const GLfloat *value = DATA_POINTER(pState, 16, const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count, GLfloat);
+    pState->pDispatchTbl->Uniform1fv(location, count, value);
+}
+
+void crUnpackExtendUniform1iv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    const GLint *value = DATA_POINTER(pState, 16, const GLint);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count, GLint);
+    pState->pDispatchTbl->Uniform1iv(location, count, value);
+}
+
+void crUnpackExtendUniform2fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    const GLfloat *value = DATA_POINTER(pState, 16, const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 2, GLfloat);
+    pState->pDispatchTbl->Uniform2fv(location, count, value);
+}
+
+void crUnpackExtendUniform2iv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    const GLint *value = DATA_POINTER(pState, 16, const GLint);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 2, GLint);
+    pState->pDispatchTbl->Uniform2iv(location, count, value);
+}
+
+void crUnpackExtendUniform3fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    const GLfloat *value = DATA_POINTER(pState, 16, const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 3, GLfloat);
+    pState->pDispatchTbl->Uniform3fv(location, count, value);
+}
+
+void crUnpackExtendUniform3iv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    const GLint *value = DATA_POINTER(pState, 16, const GLint);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 3, GLint);
+    pState->pDispatchTbl->Uniform3iv(location, count, value);
+}
+
+void crUnpackExtendUniform4fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    const GLfloat *value = DATA_POINTER(pState, 16, const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 4, GLfloat);
+    pState->pDispatchTbl->Uniform4fv(location, count, value);
+}
+
+void crUnpackExtendUniform4iv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLsizei);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    const GLint *value = DATA_POINTER(pState, 16, const GLint);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 4, GLint);
+    pState->pDispatchTbl->Uniform4iv(location, count, value);
+}
+
+void crUnpackExtendUniformMatrix2fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLboolean);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    GLboolean transpose = READ_DATA(pState, 16, GLboolean);
+    const GLfloat *value = DATA_POINTER(pState, 16+sizeof(GLboolean), const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 2 * 2, GLfloat);
+    pState->pDispatchTbl->UniformMatrix2fv(location, count, transpose, value);
+}
+
+void crUnpackExtendUniformMatrix3fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLboolean);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    GLboolean transpose = READ_DATA(pState, 16, GLboolean);
+    const GLfloat *value = DATA_POINTER(pState, 16+sizeof(GLboolean), const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 3 * 3, GLfloat);
+    pState->pDispatchTbl->UniformMatrix3fv(location, count, transpose, value);
+}
+
+void crUnpackExtendUniformMatrix4fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLboolean);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    GLboolean transpose = READ_DATA(pState, 16, GLboolean);
+    const GLfloat *value = DATA_POINTER(pState, 16+sizeof(GLboolean), const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 4 * 4, GLfloat);
+    pState->pDispatchTbl->UniformMatrix4fv(location, count, transpose, value);
+}
+
+void crUnpackExtendUniformMatrix2x3fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLboolean);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    GLboolean transpose = READ_DATA(pState, 16, GLboolean);
+    const GLfloat *value = DATA_POINTER(pState, 16+sizeof(GLboolean), const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 2 * 3, GLfloat);
+    pState->pDispatchTbl->UniformMatrix2x3fv(location, count, transpose, value);
+}
+
+void crUnpackExtendUniformMatrix3x2fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLboolean);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    GLboolean transpose = READ_DATA(pState, 16, GLboolean);
+    const GLfloat *value = DATA_POINTER(pState, 16+sizeof(GLboolean), const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 3 * 2, GLfloat);
+    pState->pDispatchTbl->UniformMatrix3x2fv(location, count, transpose, value);
+}
+
+void crUnpackExtendUniformMatrix2x4fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLboolean);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    GLboolean transpose = READ_DATA(pState, 16, GLboolean);
+    const GLfloat *value = DATA_POINTER(pState, 16+sizeof(GLboolean), const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 2 * 4, GLfloat);
+    pState->pDispatchTbl->UniformMatrix2x4fv(location, count, transpose, value);
+}
+
+void crUnpackExtendUniformMatrix4x2fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLboolean);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    GLboolean transpose = READ_DATA(pState, 16, GLboolean);
+    const GLfloat *value = DATA_POINTER(pState, 16+sizeof(GLboolean), const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 4 * 2, GLfloat);
+    pState->pDispatchTbl->UniformMatrix4x2fv(location, count, transpose, value);
+}
+
+void crUnpackExtendUniformMatrix3x4fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLboolean);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    GLboolean transpose = READ_DATA(pState, 16, GLboolean);
+    const GLfloat *value = DATA_POINTER(pState, 16+sizeof(GLboolean), const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 3 * 4, GLfloat);
+    pState->pDispatchTbl->UniformMatrix3x4fv(location, count, transpose, value);
+}
+
+void crUnpackExtendUniformMatrix4x3fv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 16, GLboolean);
+
+    GLint location = READ_DATA(pState, 8, GLint);
+    GLsizei count = READ_DATA(pState, 12, GLsizei);
+    GLboolean transpose = READ_DATA(pState, 16, GLboolean);
+    const GLfloat *value = DATA_POINTER(pState, 16+sizeof(GLboolean), const GLfloat);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, value, count * 4 * 3, GLfloat);
+    pState->pDispatchTbl->UniformMatrix4x3fv(location, count, transpose, value);
+}
+
+void crUnpackExtendDrawBuffers(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLsizei);
+
+    GLsizei n = READ_DATA(pState, 8, GLsizei);
+    const GLenum *bufs = DATA_POINTER(pState, 8+sizeof(GLsizei), const GLenum);
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, bufs, n, GLenum);
+    pState->pDispatchTbl->DrawBuffers(n, bufs);
+}
+
+void crUnpackExtendGetActiveAttrib(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, CRNetworkPointer);
+
+    GLuint program = READ_DATA(pState, 8, GLuint);
+    GLuint index = READ_DATA(pState, 12, GLuint);
+    GLsizei bufSize = READ_DATA(pState, 16, GLsizei);
+    SET_RETURN_PTR(pState, 20);
+    SET_WRITEBACK_PTR(pState, 28);
+    pState->pDispatchTbl->GetActiveAttrib(program, index, bufSize, NULL, NULL, NULL, NULL);
+}
+
+void crUnpackExtendGetActiveUniform(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 28, CRNetworkPointer);
+
+    GLuint program = READ_DATA(pState, 8, GLuint);
+    GLuint index = READ_DATA(pState, 12, GLuint);
+    GLsizei bufSize = READ_DATA(pState, 16, GLsizei);
+    SET_RETURN_PTR(pState, 20);
+    SET_WRITEBACK_PTR(pState, 28);
+    pState->pDispatchTbl->GetActiveUniform(program, index, bufSize, NULL, NULL, NULL, NULL);
+}
+
+void crUnpackExtendGetAttachedShaders(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, CRNetworkPointer);
+
+    GLuint program = READ_DATA(pState, 8, GLuint);
+    GLsizei maxCount = READ_DATA(pState, 12, GLsizei);
+    SET_RETURN_PTR(pState, 16);
+    SET_WRITEBACK_PTR(pState, 24);
+    pState->pDispatchTbl->GetAttachedShaders(program, maxCount, NULL, NULL);
+}
+
+void crUnpackExtendGetAttachedObjectsARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, CRNetworkPointer);
+
+    VBoxGLhandleARB containerObj = READ_DATA(pState, 8, VBoxGLhandleARB);
+    GLsizei maxCount = READ_DATA(pState, 12, GLsizei);
+    SET_RETURN_PTR(pState, 16);
+    SET_WRITEBACK_PTR(pState, 24);
+    pState->pDispatchTbl->GetAttachedObjectsARB(containerObj, maxCount, NULL, NULL);
+}
+
+void crUnpackExtendGetInfoLogARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, CRNetworkPointer);
+
+    VBoxGLhandleARB obj = READ_DATA(pState, 8, VBoxGLhandleARB);
+    GLsizei maxLength = READ_DATA(pState, 12, GLsizei);
+    SET_RETURN_PTR(pState, 16);
+    SET_WRITEBACK_PTR(pState, 24);
+    pState->pDispatchTbl->GetInfoLogARB(obj, maxLength, NULL, NULL);
+}
+
+void crUnpackExtendGetProgramInfoLog(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, CRNetworkPointer);
+
+    GLuint program = READ_DATA(pState, 8, GLuint);
+    GLsizei bufSize = READ_DATA(pState, 12, GLsizei);
+    SET_RETURN_PTR(pState, 16);
+    SET_WRITEBACK_PTR(pState, 24);
+    pState->pDispatchTbl->GetProgramInfoLog(program, bufSize, NULL, NULL);
+}
+
+void crUnpackExtendGetShaderInfoLog(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, CRNetworkPointer);
+
+    GLuint shader = READ_DATA(pState, 8, GLuint);
+    GLsizei bufSize = READ_DATA(pState, 12, GLsizei);
+    SET_RETURN_PTR(pState, 16);
+    SET_WRITEBACK_PTR(pState, 24);
+    pState->pDispatchTbl->GetShaderInfoLog(shader, bufSize, NULL, NULL);
+}
+
+void crUnpackExtendGetShaderSource(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, CRNetworkPointer);
+
+    GLuint shader = READ_DATA(pState, 8, GLuint);
+    GLsizei bufSize = READ_DATA(pState, 12, GLsizei);
+    SET_RETURN_PTR(pState, 16);
+    SET_WRITEBACK_PTR(pState, 24);
+    pState->pDispatchTbl->GetShaderSource(shader, bufSize, NULL, NULL);
+}
+
+void crUnpackExtendGetAttribLocation(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLuint);
+
+    int packet_length = READ_DATA(pState, 0, int);
+    GLuint program = READ_DATA(pState, 8, GLuint);
+    const char *name = DATA_POINTER(pState, 12, const char);
+
+    size_t cchStr = CHECK_STRING_FROM_PTR_UPDATE_NO_RETURN(pState, name);
+    if (RT_UNLIKELY(cchStr == SIZE_MAX || packet_length != cchStr + 2 * sizeof(CRNetworkPointer)))
+    {
+        crError("crUnpackExtendGetAttribLocation: packet_length is corrupt");
+        return;
+    }
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE(pState, packet_length);
+    SET_RETURN_PTR(pState, packet_length-16);
+    SET_WRITEBACK_PTR(pState, packet_length-8);
+    pState->pDispatchTbl->GetAttribLocation(program, name);
+}
+
+void crUnpackExtendGetUniformLocation(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, GLuint);
+
+    int packet_length = READ_DATA(pState, 0, int);
+    GLuint program = READ_DATA(pState, 8, GLuint);
+    const char *name = DATA_POINTER(pState, 12, const char);
+
+    size_t cchStr = CHECK_STRING_FROM_PTR_UPDATE_NO_RETURN(pState, name);
+    if (RT_UNLIKELY(cchStr == SIZE_MAX || packet_length != cchStr + 2 * sizeof(CRNetworkPointer)))
+    {
+        crError("crUnpackExtendGetUniformLocation: packet_length is corrupt");
+        return;
+    }
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE(pState, packet_length);
+    SET_RETURN_PTR(pState, packet_length-16);
+    SET_WRITEBACK_PTR(pState, packet_length-8);
+    pState->pDispatchTbl->GetUniformLocation(program, name);
+}
+
+void crUnpackExtendGetUniformsLocations(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, CRNetworkPointer);
+
+    GLuint program = READ_DATA(pState, 8, GLuint);
+    GLsizei maxcbData = READ_DATA(pState, 12, GLsizei);
+    SET_RETURN_PTR(pState, 16);
+    SET_WRITEBACK_PTR(pState, 24);
+    pState->pDispatchTbl->GetUniformsLocations(program, maxcbData, NULL, NULL);
+}
+
+void crUnpackExtendGetAttribsLocations(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, CRNetworkPointer);
+
+    GLuint program = READ_DATA(pState, 8, GLuint);
+    GLsizei maxcbData = READ_DATA(pState, 12, GLsizei);
+    SET_RETURN_PTR(pState, 16);
+    SET_WRITEBACK_PTR(pState, 24);
+    pState->pDispatchTbl->GetAttribsLocations(program, maxcbData, NULL, NULL);
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_stipple.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_stipple.c	(revision 78189)
+++ 	(revision )
@@ -1,27 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-
-void crUnpackPolygonStipple( void  )
-{
-    int nodata = READ_DATA(0, int);
-
-    if (nodata)
-    {
-        crError("crUnpackPolygonStipple: GL_PIXEL_UNPACK_BUFFER is not supported");
-        INCR_DATA_PTR(8);
-    }
-    else
-    {
-        GLubyte *mask;
-
-        mask = DATA_POINTER(4, GLubyte);
-        cr_unpackDispatch.PolygonStipple(mask);
-        // Stipple mask consists of 32 * 32 bits
-        INCR_DATA_PTR(4 + 32 * 32 / 8);
-    }
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_stipple.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_stipple.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_stipple.cpp	(revision 78190)
@@ -0,0 +1,30 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+
+void crUnpackPolygonStipple(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 0, int);
+
+    int nodata = READ_DATA(pState, 0, int);
+
+    if (nodata)
+    {
+        crError("crUnpackPolygonStipple: GL_PIXEL_UNPACK_BUFFER is not supported");
+        INCR_DATA_PTR(pState, 8);
+    }
+    else
+    {
+        /* The mask is represented as a 32x32 array of 1bit color (32x4 bytes). */
+        GLubyte *mask = DATA_POINTER(pState, 4, GLubyte);
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, mask, 32 * (32 / 8), GLubyte);
+
+        pState->pDispatchTbl->PolygonStipple(mask);
+        // Stipple mask consists of 32 * 32 bits
+        INCR_DATA_PTR(pState, 4 + 32 * 32 / 8);
+    }
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_texture.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_texture.c	(revision 78189)
+++ 	(revision )
@@ -1,507 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "cr_error.h"
-#include "cr_protocol.h"
-#include "cr_mem.h"
-#include "cr_version.h"
- 
-#if defined( GL_EXT_texture3D ) 
-void crUnpackTexImage3DEXT( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLint level = READ_DATA( sizeof( int ) + 4, GLint );
-    GLenum internalformat = READ_DATA( sizeof( int ) + 8, GLint );
-    GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei );
-    GLsizei height = READ_DATA( sizeof( int ) + 16, GLsizei );
-    GLsizei depth = READ_DATA( sizeof( int ) + 20, GLsizei );
-    GLint border = READ_DATA( sizeof( int ) + 24, GLint );
-    GLenum format = READ_DATA( sizeof( int ) + 28, GLenum );
-    GLenum type = READ_DATA( sizeof( int ) + 32, GLenum );
-    int noimagedata = READ_DATA( sizeof( int ) + 36, int );
-    GLvoid *pixels;
-
-    /*If there's no imagedata send, it's either that passed pointer was NULL or
-      there was GL_PIXEL_UNPACK_BUFFER_ARB bound, in both cases 4bytes of passed
-      pointer would convert to either NULL or offset in the bound buffer.
-     */
-    if ( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+40, GLint);
-    else
-        pixels = DATA_POINTER( sizeof( int ) + 44, GLvoid );
-
-    cr_unpackDispatch.TexImage3DEXT(target, level, internalformat, width,
-                                    height, depth, border, format, type,
-                                    pixels);
-    INCR_VAR_PTR();
-}
-#endif /* GL_EXT_texture3D */
-
-#if defined( CR_OPENGL_VERSION_1_2 )
-void crUnpackTexImage3D( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLint level = READ_DATA( sizeof( int ) + 4, GLint );
-    GLint internalformat = READ_DATA( sizeof( int ) + 8, GLint );
-    GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei );
-    GLsizei height = READ_DATA( sizeof( int ) + 16, GLsizei );
-    GLsizei depth = READ_DATA( sizeof( int ) + 20, GLsizei );
-    GLint border = READ_DATA( sizeof( int ) + 24, GLint );
-    GLenum format = READ_DATA( sizeof( int ) + 28, GLenum );
-    GLenum type = READ_DATA( sizeof( int ) + 32, GLenum );
-    int noimagedata = READ_DATA( sizeof( int ) + 36, int );
-    GLvoid *pixels;
-    
-    if ( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+40, GLint);
-    else
-        pixels = DATA_POINTER( sizeof( int ) + 44, GLvoid );
-    
-    cr_unpackDispatch.TexImage3D( target, level, internalformat, width, height,
-                                  depth, border, format, type, pixels );
-    INCR_VAR_PTR();
-}
-#endif /* CR_OPENGL_VERSION_1_2 */
-
-void crUnpackTexImage2D( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLint level = READ_DATA( sizeof( int ) + 4, GLint );
-    GLint internalformat = READ_DATA( sizeof( int ) + 8, GLint );
-    GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei );
-    GLsizei height = READ_DATA( sizeof( int ) + 16, GLsizei );
-    GLint border = READ_DATA( sizeof( int ) + 20, GLint );
-    GLenum format = READ_DATA( sizeof( int ) + 24, GLenum );
-    GLenum type = READ_DATA( sizeof( int ) + 28, GLenum );
-    int noimagedata = READ_DATA( sizeof( int ) + 32, int );
-    GLvoid *pixels;
-
-    if ( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+36, GLint);
-    else 
-        pixels = DATA_POINTER( sizeof( int ) + 40, GLvoid );
-
-    cr_unpackDispatch.TexImage2D( target, level, internalformat, width, height,
-                          border, format, type, pixels );
-    INCR_VAR_PTR();
-}
-
-void crUnpackTexImage1D( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLint level = READ_DATA( sizeof( int ) + 4, GLint );
-    GLint internalformat = READ_DATA( sizeof( int ) + 8, GLint );
-    GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei );
-    GLint border = READ_DATA( sizeof( int ) + 16, GLint );
-    GLenum format = READ_DATA( sizeof( int ) + 20, GLenum );
-    GLenum type = READ_DATA( sizeof( int ) + 24, GLenum );
-    int noimagedata = READ_DATA( sizeof( int ) + 28, int );
-    GLvoid *pixels;
-
-    if ( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+32, GLint);
-    else 
-        pixels = DATA_POINTER( sizeof( int ) + 36, GLvoid );
-
-    cr_unpackDispatch.TexImage1D( target, level, internalformat, width, border,
-                          format, type, pixels );
-    INCR_VAR_PTR();
-}
-
-void crUnpackDeleteTextures( void )
-{
-    GLsizei n = READ_DATA( sizeof( int ) + 0, GLsizei );
-    GLuint *textures = DATA_POINTER( sizeof( int ) + 4, GLuint );
-
-    cr_unpackDispatch.DeleteTextures( n, textures );
-    INCR_VAR_PTR();
-}
-
-
-void crUnpackPrioritizeTextures( void )
-{
-    GLsizei n = READ_DATA( sizeof( int ) + 0, GLsizei );
-    GLuint *textures = DATA_POINTER( sizeof( int ) + 4, GLuint );
-    GLclampf *priorities = DATA_POINTER( sizeof( int ) + 4 + n*sizeof( GLuint ),
-                                         GLclampf );
-
-    cr_unpackDispatch.PrioritizeTextures( n, textures, priorities );
-    INCR_VAR_PTR();
-}
-
-void crUnpackTexParameterfv( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-    GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat );
-
-    cr_unpackDispatch.TexParameterfv( target, pname, params );
-    INCR_VAR_PTR();
-}
-
-void crUnpackTexParameteriv( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-    GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint );
-
-    cr_unpackDispatch.TexParameteriv( target, pname, params );
-    INCR_VAR_PTR();
-}
-
-void crUnpackTexParameterf( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-    GLfloat param = READ_DATA( sizeof( int ) + 8, GLfloat );
-
-    cr_unpackDispatch.TexParameterf( target, pname, param );
-    INCR_VAR_PTR();
-}
-
-void crUnpackTexParameteri( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-    GLint param = READ_DATA( sizeof( int ) + 8, GLint );
-
-    cr_unpackDispatch.TexParameteri( target, pname, param );
-    INCR_VAR_PTR();
-}
-
-#if defined(CR_OPENGL_VERSION_1_2)
-void crUnpackTexSubImage3D( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLint level = READ_DATA( sizeof( int ) + 4, GLint );
-    GLint xoffset = READ_DATA( sizeof( int ) + 8, GLint );
-    GLint yoffset = READ_DATA( sizeof( int ) + 12, GLint );
-    GLint zoffset = READ_DATA( sizeof( int ) + 16, GLint );
-    GLsizei width = READ_DATA( sizeof( int ) + 20, GLsizei );
-    GLsizei height = READ_DATA( sizeof( int ) + 24, GLsizei );
-    GLsizei depth = READ_DATA( sizeof( int ) + 28, GLsizei );
-    GLenum format = READ_DATA( sizeof( int ) + 32, GLenum );
-    GLenum type = READ_DATA( sizeof( int ) + 36, GLenum );
-    int noimagedata = READ_DATA( sizeof( int ) + 40, int );
-    GLvoid *pixels;
-
-    if ( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+44, GLint);
-    else 
-        pixels = DATA_POINTER( sizeof( int ) + 48, GLvoid );
-
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-    cr_unpackDispatch.TexSubImage3D(target, level, xoffset, yoffset, zoffset,
-                                    width, height, depth, format, type, pixels);
-    INCR_VAR_PTR();
-}
-#endif /* CR_OPENGL_VERSION_1_2 */
-
-void crUnpackTexSubImage2D( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLint level = READ_DATA( sizeof( int ) + 4, GLint );
-    GLint xoffset = READ_DATA( sizeof( int ) + 8, GLint );
-    GLint yoffset = READ_DATA( sizeof( int ) + 12, GLint );
-    GLsizei width = READ_DATA( sizeof( int ) + 16, GLsizei );
-    GLsizei height = READ_DATA( sizeof( int ) + 20, GLsizei );
-    GLenum format = READ_DATA( sizeof( int ) + 24, GLenum );
-    GLenum type = READ_DATA( sizeof( int ) + 28, GLenum );
-    int noimagedata = READ_DATA( sizeof( int ) + 32, int );
-    GLvoid *pixels;
-
-    if ( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+36, GLint);
-    else 
-        pixels = DATA_POINTER( sizeof( int ) + 40, GLvoid );
-
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-    cr_unpackDispatch.TexSubImage2D( target, level, xoffset, yoffset, width,
-                                     height, format, type, pixels );
-    INCR_VAR_PTR();
-}
-
-void crUnpackTexSubImage1D( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLint level = READ_DATA( sizeof( int ) + 4, GLint );
-    GLint xoffset = READ_DATA( sizeof( int ) + 8, GLint );
-    GLsizei width = READ_DATA( sizeof( int ) + 12, GLsizei );
-    GLenum format = READ_DATA( sizeof( int ) + 16, GLenum );
-    GLenum type = READ_DATA( sizeof( int ) + 20, GLenum );
-    int noimagedata = READ_DATA( sizeof( int ) + 24, int );
-    GLvoid *pixels;
-
-    if ( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(sizeof(int)+28, GLint);
-    else 
-        pixels = DATA_POINTER( sizeof( int ) + 32, GLvoid );
-
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
-    cr_unpackDispatch.PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
-
-    cr_unpackDispatch.TexSubImage1D( target, level, xoffset, width, format,
-                                     type, pixels );
-    INCR_VAR_PTR();
-}
-
-
-void crUnpackTexEnvfv( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-    GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat );
-
-    cr_unpackDispatch.TexEnvfv( target, pname, params );
-    INCR_VAR_PTR();
-}
-
-void crUnpackTexEnviv( void )
-{
-    GLenum target = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-    GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint );
-
-    cr_unpackDispatch.TexEnviv( target, pname, params );
-    INCR_VAR_PTR();
-}
-
-#define DATA_POINTER_DOUBLE( offset )
-
-void crUnpackTexGendv( void )
-{
-    GLenum coord = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-    GLdouble params[4];
-    unsigned int n_param = READ_DATA( 0, int ) - ( sizeof(int) + 8 );
-
-    if (n_param > sizeof(params))
-    {
-        crError("crUnpackTexGendv: n_param=%d, expected <= %d\n", n_param,
-            (unsigned int)sizeof(params));
-        return;
-    }
-
-    crMemcpy( params, DATA_POINTER( sizeof( int ) + 8, GLdouble ), n_param );
-
-    cr_unpackDispatch.TexGendv( coord, pname, params );
-    INCR_VAR_PTR();
-}
-
-void crUnpackTexGenfv( void )
-{
-    GLenum coord = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-    GLfloat *params = DATA_POINTER( sizeof( int ) + 8, GLfloat );
-
-    cr_unpackDispatch.TexGenfv( coord, pname, params );
-    INCR_VAR_PTR();
-}
-
-void crUnpackTexGeniv( void )
-{
-    GLenum coord = READ_DATA( sizeof( int ) + 0, GLenum );
-    GLenum pname = READ_DATA( sizeof( int ) + 4, GLenum );
-    GLint *params = DATA_POINTER( sizeof( int ) + 8, GLint );
-
-    cr_unpackDispatch.TexGeniv( coord, pname, params );
-    INCR_VAR_PTR();
-}
-
-void crUnpackExtendAreTexturesResident( void )
-{
-    GLsizei n = READ_DATA( 8, GLsizei );
-    const GLuint *textures = DATA_POINTER( 12, const GLuint );
-
-    if (n <= 0 || n >= INT32_MAX / sizeof(GLuint) / 4 || !DATA_POINTER_CHECK(20 + n * sizeof(GLuint)))
-    {
-        crError("crUnpackExtendAreTexturesResident: %d is out of range", n);
-        return;
-    }
-
-    SET_RETURN_PTR(12 + n * sizeof(GLuint));
-    SET_WRITEBACK_PTR(20 + n * sizeof(GLuint));
-    (void) cr_unpackDispatch.AreTexturesResident( n, textures, NULL );
-}
-
-
-void crUnpackExtendCompressedTexImage3DARB( void )
-{
-    GLenum  target         = READ_DATA( 4 + sizeof(int) +  0, GLenum );
-    GLint   level          = READ_DATA( 4 + sizeof(int) +  4, GLint );
-    GLenum  internalformat = READ_DATA( 4 + sizeof(int) +  8, GLenum );
-    GLsizei width          = READ_DATA( 4 + sizeof(int) + 12, GLsizei );
-    GLsizei height         = READ_DATA( 4 + sizeof(int) + 16, GLsizei );
-    GLsizei depth          = READ_DATA( 4 + sizeof(int) + 20, GLsizei );
-    GLint   border         = READ_DATA( 4 + sizeof(int) + 24, GLint );
-    GLsizei imagesize      = READ_DATA( 4 + sizeof(int) + 28, GLsizei );
-    int     noimagedata        = READ_DATA( 4 + sizeof(int) + 32, int );
-    GLvoid  *pixels;
-
-    if( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+36, GLint);
-    else
-        pixels = DATA_POINTER( 4 + sizeof(int) + 40, GLvoid );
-
-    cr_unpackDispatch.CompressedTexImage3DARB(target, level, internalformat,
-                                              width, height, depth, border,
-                                              imagesize, pixels);
-}
-
-
-void crUnpackExtendCompressedTexImage2DARB( void )
-{
-    GLenum target =         READ_DATA( 4 + sizeof( int ) + 0, GLenum );
-    GLint level =           READ_DATA( 4 + sizeof( int ) + 4, GLint );
-    GLenum internalformat = READ_DATA( 4 + sizeof( int ) + 8, GLenum );
-    GLsizei width =         READ_DATA( 4 + sizeof( int ) + 12, GLsizei );
-    GLsizei height =        READ_DATA( 4 + sizeof( int ) + 16, GLsizei );
-    GLint border =          READ_DATA( 4 + sizeof( int ) + 20, GLint );
-    GLsizei imagesize =     READ_DATA( 4 + sizeof( int ) + 24, GLsizei );
-    int noimagedata =           READ_DATA( 4 + sizeof( int ) + 28, int );
-    GLvoid *pixels;
-
-    if ( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+32, GLint);
-    else
-        pixels = DATA_POINTER( 4 + sizeof( int ) + 36, GLvoid );
-
-    cr_unpackDispatch.CompressedTexImage2DARB( target, level, internalformat,
-                                               width, height, border, imagesize,
-                                               pixels );
-}
-
-
-void crUnpackExtendCompressedTexImage1DARB( void )
-{
-    GLenum  target         = READ_DATA( 4 + sizeof(int) +  0, GLenum );
-    GLint   level          = READ_DATA( 4 + sizeof(int) +  4, GLint );
-    GLenum  internalformat = READ_DATA( 4 + sizeof(int) +  8, GLenum );
-    GLsizei width          = READ_DATA( 4 + sizeof(int) + 12, GLsizei );
-    GLint   border         = READ_DATA( 4 + sizeof(int) + 16, GLint );
-    GLsizei imagesize      = READ_DATA( 4 + sizeof(int) + 20, GLsizei );
-    int     noimagedata        = READ_DATA( 4 + sizeof(int) + 24, int );
-    GLvoid  *pixels;
-
-    if( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+28, GLint);
-    else
-        pixels = DATA_POINTER( 4 + sizeof(int) + 32, GLvoid );
-
-    cr_unpackDispatch.CompressedTexImage1DARB(target, level, internalformat,
-                                              width, border, imagesize, pixels);
-}
-
-
-void crUnpackExtendCompressedTexSubImage3DARB( void )
-{
-    GLenum  target    = READ_DATA( 4 + sizeof(int) +  0, GLenum );
-    GLint   level     = READ_DATA( 4 + sizeof(int) +  4, GLint );
-    GLint   xoffset   = READ_DATA( 4 + sizeof(int) +  8, GLint );
-    GLint   yoffset   = READ_DATA( 4 + sizeof(int) + 12, GLint );
-    GLint   zoffset   = READ_DATA( 4 + sizeof(int) + 16, GLint );
-    GLsizei width     = READ_DATA( 4 + sizeof(int) + 20, GLsizei );
-    GLsizei height    = READ_DATA( 4 + sizeof(int) + 24, GLsizei );
-    GLsizei depth     = READ_DATA( 4 + sizeof(int) + 28, GLsizei );
-    GLenum  format    = READ_DATA( 4 + sizeof(int) + 32, GLenum );
-    GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 36, GLsizei );
-    int     noimagedata   = READ_DATA( 4 + sizeof(int) + 40, int );
-    GLvoid  *pixels;
-
-    if( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+44, GLint);
-    else
-        pixels = DATA_POINTER( 4 + sizeof(int) + 48, GLvoid );
-
-    cr_unpackDispatch.CompressedTexSubImage3DARB(target, level, xoffset,
-                                                 yoffset, zoffset, width,
-                                                 height, depth, format,
-                                                 imagesize, pixels);
-}
-
-
-void crUnpackExtendCompressedTexSubImage2DARB( void )
-{
-    GLenum  target    = READ_DATA( 4 + sizeof(int) +  0, GLenum );
-    GLint   level     = READ_DATA( 4 + sizeof(int) +  4, GLint );
-    GLint   xoffset   = READ_DATA( 4 + sizeof(int) +  8, GLint );
-    GLint   yoffset   = READ_DATA( 4 + sizeof(int) + 12, GLint );
-    GLsizei width     = READ_DATA( 4 + sizeof(int) + 16, GLsizei );
-    GLsizei height    = READ_DATA( 4 + sizeof(int) + 20, GLsizei );
-    GLenum  format    = READ_DATA( 4 + sizeof(int) + 24, GLenum );
-    GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 28, GLsizei );
-    int     noimagedata   = READ_DATA( 4 + sizeof(int) + 32, int );
-    GLvoid  *pixels;
-
-    if( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+36, GLint);
-    else
-        pixels = DATA_POINTER( 4 + sizeof(int) + 40, GLvoid );
-
-    cr_unpackDispatch.CompressedTexSubImage2DARB(target, level, xoffset,
-                                                 yoffset, width, height,
-                                                 format, imagesize, pixels);
-}
-
-
-void crUnpackExtendCompressedTexSubImage1DARB( void )
-{
-    GLenum  target    = READ_DATA( 4 + sizeof(int) +  0, GLenum );
-    GLint   level     = READ_DATA( 4 + sizeof(int) +  4, GLint );
-    GLint   xoffset   = READ_DATA( 4 + sizeof(int) +  8, GLint );
-    GLsizei width     = READ_DATA( 4 + sizeof(int) + 12, GLsizei );
-    GLenum  format    = READ_DATA( 4 + sizeof(int) + 16, GLenum );
-    GLsizei imagesize = READ_DATA( 4 + sizeof(int) + 20, GLsizei );
-    int     noimagedata   = READ_DATA( 4 + sizeof(int) + 24, int );
-    GLvoid  *pixels;
-
-    if( noimagedata )
-        pixels = (void*) (uintptr_t) READ_DATA(4+sizeof(int)+28, GLint);
-    else
-        pixels = DATA_POINTER( 4 + sizeof(int) + 32, GLvoid );
-
-    cr_unpackDispatch.CompressedTexSubImage1DARB(target, level, xoffset, width,
-                                                 format, imagesize, pixels);
-}
-
-void crUnpackExtendGetTexImage(void)
-{
-    GLenum target = READ_DATA( 8, GLenum );
-    GLint level   = READ_DATA( 12, GLint );
-    GLenum format = READ_DATA( 16, GLenum );
-    GLenum type   = READ_DATA( 20, GLenum );
-    GLvoid *pixels;
-
-    SET_RETURN_PTR(24);
-    SET_WRITEBACK_PTR(32);
-    pixels = DATA_POINTER(24, GLvoid);
-
-    cr_unpackDispatch.GetTexImage(target, level, format, type, pixels);
-}
-
-void crUnpackExtendGetCompressedTexImageARB(void)
-{
-    GLenum target = READ_DATA( 8, GLenum );
-    GLint level   = READ_DATA( 12, GLint );
-    GLvoid *img;
-
-    SET_RETURN_PTR( 16 );
-    SET_WRITEBACK_PTR( 24 );
-    img = DATA_POINTER(16, GLvoid);
-
-    cr_unpackDispatch.GetCompressedTexImageARB( target, level, img );
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_texture.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_texture.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_texture.cpp	(revision 78190)
@@ -0,0 +1,737 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "cr_error.h"
+#include "cr_pixeldata.h"
+#include "cr_protocol.h"
+#include "cr_mem.h"
+#include "cr_version.h"
+ 
+#if defined( GL_EXT_texture3D ) 
+void crUnpackTexImage3DEXT(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 36, int);
+
+    GLenum target = READ_DATA(pState,  sizeof( int ) + 0, GLenum );
+    GLint level = READ_DATA(pState,  sizeof( int ) + 4, GLint );
+    GLenum internalformat = READ_DATA(pState,  sizeof( int ) + 8, GLint );
+    GLsizei width = READ_DATA(pState,  sizeof( int ) + 12, GLsizei );
+    GLsizei height = READ_DATA(pState,  sizeof( int ) + 16, GLsizei );
+    GLsizei depth = READ_DATA(pState,  sizeof( int ) + 20, GLsizei );
+    GLint border = READ_DATA(pState,  sizeof( int ) + 24, GLint );
+    GLenum format = READ_DATA(pState,  sizeof( int ) + 28, GLenum );
+    GLenum type = READ_DATA(pState,  sizeof( int ) + 32, GLenum );
+    int noimagedata = READ_DATA(pState,  sizeof( int ) + 36, int );
+    GLvoid *pixels;
+
+    /*If there's no imagedata send, it's either that passed pointer was NULL or
+      there was GL_PIXEL_UNPACK_BUFFER_ARB bound, in both cases 4bytes of passed
+      pointer would convert to either NULL or offset in the bound buffer.
+     */
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+40, GLint);
+    if ( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+40, GLint);
+    else
+    {
+        size_t cbImg = crImageSize(format, type, width, height);
+        if (RT_UNLIKELY(cbImg == 0))
+        {
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+        }
+        pixels = DATA_POINTER(pState,  sizeof( int ) + 44, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
+    }
+
+    pState->pDispatchTbl->TexImage3DEXT(target, level, internalformat, width,
+                                    height, depth, border, format, type,
+                                    pixels);
+    INCR_VAR_PTR(pState);
+}
+#endif /* GL_EXT_texture3D */
+
+#if defined( CR_OPENGL_VERSION_1_2 )
+void crUnpackTexImage3D(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 36, int);
+
+    GLenum target = READ_DATA(pState,  sizeof( int ) + 0, GLenum );
+    GLint level = READ_DATA(pState,  sizeof( int ) + 4, GLint );
+    GLint internalformat = READ_DATA(pState,  sizeof( int ) + 8, GLint );
+    GLsizei width = READ_DATA(pState,  sizeof( int ) + 12, GLsizei );
+    GLsizei height = READ_DATA(pState,  sizeof( int ) + 16, GLsizei );
+    GLsizei depth = READ_DATA(pState,  sizeof( int ) + 20, GLsizei );
+    GLint border = READ_DATA(pState,  sizeof( int ) + 24, GLint );
+    GLenum format = READ_DATA(pState,  sizeof( int ) + 28, GLenum );
+    GLenum type = READ_DATA(pState,  sizeof( int ) + 32, GLenum );
+    int noimagedata = READ_DATA(pState,  sizeof( int ) + 36, int );
+    GLvoid *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+40, GLint);
+    if ( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+40, GLint);
+    else
+    {
+        size_t cbImg = crImageSize(format, type, width, height);
+        if (RT_UNLIKELY(cbImg == 0))
+        {
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+        }
+        pixels = DATA_POINTER(pState,  sizeof( int ) + 44, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
+    }
+
+    pState->pDispatchTbl->TexImage3D( target, level, internalformat, width, height,
+                                  depth, border, format, type, pixels );
+    INCR_VAR_PTR(pState);
+}
+#endif /* CR_OPENGL_VERSION_1_2 */
+
+void crUnpackTexImage2D(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 32, int);
+
+    GLenum target = READ_DATA(pState,  sizeof( int ) + 0, GLenum );
+    GLint level = READ_DATA(pState,  sizeof( int ) + 4, GLint );
+    GLint internalformat = READ_DATA(pState,  sizeof( int ) + 8, GLint );
+    GLsizei width = READ_DATA(pState, sizeof( int ) + 12, GLsizei );
+    GLsizei height = READ_DATA(pState, sizeof( int ) + 16, GLsizei );
+    GLint border = READ_DATA(pState, sizeof( int ) + 20, GLint );
+    GLenum format = READ_DATA(pState, sizeof( int ) + 24, GLenum );
+    GLenum type = READ_DATA(pState, sizeof( int ) + 28, GLenum );
+    int noimagedata = READ_DATA(pState, sizeof( int ) + 32, int );
+    GLvoid *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+36, GLint);
+    if ( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+36, GLint);
+    else
+    {
+        size_t cbImg = crImageSize(format, type, width, height);
+        if (RT_UNLIKELY(cbImg == 0))
+        {
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+        }
+        pixels = DATA_POINTER(pState,  sizeof( int ) + 40, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
+    }
+
+    pState->pDispatchTbl->TexImage2D( target, level, internalformat, width, height,
+                          border, format, type, pixels );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackTexImage1D(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 28, int);
+
+    GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
+    GLint internalformat = READ_DATA(pState, sizeof( int ) + 8, GLint );
+    GLsizei width = READ_DATA(pState, sizeof( int ) + 12, GLsizei );
+    GLint border = READ_DATA(pState, sizeof( int ) + 16, GLint );
+    GLenum format = READ_DATA(pState, sizeof( int ) + 20, GLenum );
+    GLenum type = READ_DATA(pState, sizeof( int ) + 24, GLenum );
+    int noimagedata = READ_DATA(pState, sizeof( int ) + 28, int );
+    GLvoid *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+32, GLint);
+    if ( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+32, GLint);
+    else
+    {
+        size_t cbImg = crImageSize(format, type, width, 1);
+        if (RT_UNLIKELY(cbImg == 0))
+        {
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+        }
+        pixels = DATA_POINTER(pState,  sizeof( int ) + 36, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
+    }
+
+    pState->pDispatchTbl->TexImage1D(target, level, internalformat, width, border,
+                                     format, type, pixels );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackDeleteTextures(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 0, GLsizei);
+
+    GLsizei n = READ_DATA(pState, sizeof( int ) + 0, GLsizei );
+    GLuint *textures = DATA_POINTER(pState, sizeof( int ) + 4, GLuint );
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, textures, n, GLuint);
+    pState->pDispatchTbl->DeleteTextures( n, textures );
+    INCR_VAR_PTR(pState);
+}
+
+
+void crUnpackPrioritizeTextures(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 0, GLsizei);
+
+    GLsizei n = READ_DATA(pState, sizeof( int ) + 0, GLsizei );
+    GLuint *textures = DATA_POINTER(pState, sizeof( int ) + 4, GLuint );
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, textures, n, GLuint);
+
+    GLclampf *priorities = DATA_POINTER(pState, sizeof( int ) + 4 + n*sizeof( GLuint ),
+                                         GLclampf );
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, priorities, n, GLclampf);
+
+    pState->pDispatchTbl->PrioritizeTextures( n, textures, priorities );
+    INCR_VAR_PTR(pState);
+}
+
+static size_t crGetTexParameterParamsFromPname(GLenum pname)
+{
+    int cParams = 0;
+
+    switch (pname)
+    {
+        case GL_TEXTURE_MIN_FILTER:
+        case GL_TEXTURE_MAG_FILTER:
+        case GL_TEXTURE_WRAP_R:
+        case GL_TEXTURE_WRAP_S:
+        case GL_TEXTURE_WRAP_T:
+        case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+        case GL_TEXTURE_MIN_LOD:
+        case GL_TEXTURE_MAX_LOD:
+        case GL_TEXTURE_BASE_LEVEL:
+        case GL_TEXTURE_MAX_LEVEL:
+#ifdef CR_ARB_shadow
+        case GL_TEXTURE_COMPARE_MODE_ARB:
+        case GL_TEXTURE_COMPARE_FUNC_ARB:
+#endif
+#ifdef GL_TEXTURE_PRIORITY
+        case GL_TEXTURE_PRIORITY:
+#endif
+#ifdef CR_ARB_shadow_ambient
+        case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
+#endif
+#ifdef CR_ARB_depth_texture
+        case GL_DEPTH_TEXTURE_MODE_ARB:
+#endif
+#ifdef CR_SGIS_generate_mipmap
+        case GL_GENERATE_MIPMAP_SGIS:
+#endif
+            cParams = 1;
+            break;
+        case GL_TEXTURE_BORDER_COLOR:
+            cParams = 4;
+            break;
+        default:
+            break; /* Error, handled in caller. */
+    }
+
+    return cParams;
+}
+
+void crUnpackTexParameterfv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 8, GLfloat );
+
+    size_t cParams = crGetTexParameterParamsFromPname(pname);
+    if (RT_UNLIKELY(cParams == 0))
+    {
+        pState->rcUnpack = VERR_INVALID_PARAMETER;
+        return;
+    }
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLfloat);
+    pState->pDispatchTbl->TexParameterfv( target, pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackTexParameteriv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLint *params = DATA_POINTER(pState, sizeof( int ) + 8, GLint );
+
+    size_t cParams = crGetTexParameterParamsFromPname(pname);
+    if (RT_UNLIKELY(cParams == 0))
+    {
+        pState->rcUnpack = VERR_INVALID_PARAMETER;
+        return;
+    }
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLint);
+    pState->pDispatchTbl->TexParameteriv( target, pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackTexParameterf(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, GLfloat);
+
+    GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLfloat param = READ_DATA(pState, sizeof( int ) + 8, GLfloat );
+
+    pState->pDispatchTbl->TexParameterf( target, pname, param );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackTexParameteri(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, GLint);
+
+    GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLint param = READ_DATA(pState, sizeof( int ) + 8, GLint );
+
+    pState->pDispatchTbl->TexParameteri( target, pname, param );
+    INCR_VAR_PTR(pState);
+}
+
+#if defined(CR_OPENGL_VERSION_1_2)
+void crUnpackTexSubImage3D(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 40, int);
+
+    GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
+    GLint xoffset = READ_DATA(pState, sizeof( int ) + 8, GLint );
+    GLint yoffset = READ_DATA(pState, sizeof( int ) + 12, GLint );
+    GLint zoffset = READ_DATA(pState, sizeof( int ) + 16, GLint );
+    GLsizei width = READ_DATA(pState, sizeof( int ) + 20, GLsizei );
+    GLsizei height = READ_DATA(pState, sizeof( int ) + 24, GLsizei );
+    GLsizei depth = READ_DATA(pState, sizeof( int ) + 28, GLsizei );
+    GLenum format = READ_DATA(pState, sizeof( int ) + 32, GLenum );
+    GLenum type = READ_DATA(pState, sizeof( int ) + 36, GLenum );
+    int noimagedata = READ_DATA(pState, sizeof( int ) + 40, int );
+    GLvoid *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+44, GLint);
+    if ( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+44, GLint);
+    else
+    {
+        size_t cbImg = crImageSize(format, type, width, height);
+        if (RT_UNLIKELY(cbImg == 0))
+        {
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+        }
+        pixels = DATA_POINTER(pState, sizeof( int ) + 48, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
+    }
+
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+
+    pState->pDispatchTbl->TexSubImage3D(target, level, xoffset, yoffset, zoffset,
+                                    width, height, depth, format, type, pixels);
+    INCR_VAR_PTR(pState);
+}
+#endif /* CR_OPENGL_VERSION_1_2 */
+
+void crUnpackTexSubImage2D(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 32, int);
+
+    GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
+    GLint xoffset = READ_DATA(pState, sizeof( int ) + 8, GLint );
+    GLint yoffset = READ_DATA(pState, sizeof( int ) + 12, GLint );
+    GLsizei width = READ_DATA(pState, sizeof( int ) + 16, GLsizei );
+    GLsizei height = READ_DATA(pState, sizeof( int ) + 20, GLsizei );
+    GLenum format = READ_DATA(pState, sizeof( int ) + 24, GLenum );
+    GLenum type = READ_DATA(pState, sizeof( int ) + 28, GLenum );
+    int noimagedata = READ_DATA(pState, sizeof( int ) + 32, int );
+    GLvoid *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+36, GLint);
+    if ( noimagedata )
+    {
+        CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+36, GLint);
+        pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+36, GLint);
+    }
+    else
+    {
+        size_t cbImg = crImageSize(format, type, width, height);
+        if (RT_UNLIKELY(cbImg == 0))
+        {
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+        }
+        pixels = DATA_POINTER(pState, sizeof( int ) + 40, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
+    }
+
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+
+    pState->pDispatchTbl->TexSubImage2D( target, level, xoffset, yoffset, width,
+                                     height, format, type, pixels );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackTexSubImage1D(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 24, int);
+
+    GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLint level = READ_DATA(pState, sizeof( int ) + 4, GLint );
+    GLint xoffset = READ_DATA(pState, sizeof( int ) + 8, GLint );
+    GLsizei width = READ_DATA(pState, sizeof( int ) + 12, GLsizei );
+    GLenum format = READ_DATA(pState, sizeof( int ) + 16, GLenum );
+    GLenum type = READ_DATA(pState, sizeof( int ) + 20, GLenum );
+    int noimagedata = READ_DATA(pState, sizeof( int ) + 24, int );
+    GLvoid *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, sizeof(int)+28, GLint);
+    if ( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, sizeof(int)+28, GLint);
+    else
+    {
+        size_t cbImg = crImageSize(format, type, width, 1);
+        if (RT_UNLIKELY(cbImg == 0))
+        {
+            pState->rcUnpack = VERR_INVALID_PARAMETER;
+            return;
+        }
+        pixels = DATA_POINTER(pState, sizeof( int ) + 32, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, cbImg, GLubyte);
+    }
+
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
+    pState->pDispatchTbl->PixelStorei( GL_UNPACK_ALIGNMENT, 1 );
+
+    pState->pDispatchTbl->TexSubImage1D( target, level, xoffset, width, format,
+                                     type, pixels );
+    INCR_VAR_PTR(pState);
+}
+
+
+void crUnpackTexEnvfv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 8, GLfloat );
+
+    size_t cParams = 1;
+    if (pname == GL_TEXTURE_ENV_COLOR)
+        cParams = 4;
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLfloat);
+    pState->pDispatchTbl->TexEnvfv( target, pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackTexEnviv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum target = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLint *params = DATA_POINTER(pState, sizeof( int ) + 8, GLint );
+
+    size_t cParams = 1;
+    if (pname == GL_TEXTURE_ENV_COLOR)
+        cParams = 4;
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLint);
+    pState->pDispatchTbl->TexEnviv( target, pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackTexGendv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum coord = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLdouble *params = DATA_POINTER(pState, sizeof( int ) + 8, GLdouble );
+
+    size_t cParams = 1;
+    if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE)
+        cParams = 4;
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLdouble);
+    pState->pDispatchTbl->TexGendv( coord, pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackTexGenfv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum coord = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLfloat *params = DATA_POINTER(pState, sizeof( int ) + 8, GLfloat );
+
+    size_t cParams = 1;
+    if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE)
+        cParams = 4;
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLfloat);
+    pState->pDispatchTbl->TexGenfv( coord, pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackTexGeniv(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 4, GLenum);
+
+    GLenum coord = READ_DATA(pState, sizeof( int ) + 0, GLenum );
+    GLenum pname = READ_DATA(pState, sizeof( int ) + 4, GLenum );
+    GLint *params = DATA_POINTER(pState, sizeof( int ) + 8, GLint );
+
+    size_t cParams = 1;
+    if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE)
+        cParams = 4;
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, params, cParams, GLint);
+    pState->pDispatchTbl->TexGeniv( coord, pname, params );
+    INCR_VAR_PTR(pState);
+}
+
+void crUnpackExtendAreTexturesResident(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, sizeof(int) + 8, GLsizei);
+
+    GLsizei n = READ_DATA(pState, 8, GLsizei );
+    const GLuint *textures = DATA_POINTER(pState, 12, const GLuint );
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, textures, n, GLuint);
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 20 + n * sizeof(GLuint), CRNetworkPointer);
+    SET_RETURN_PTR(pState, 12 + n * sizeof(GLuint));
+    SET_WRITEBACK_PTR(pState, 20 + n * sizeof(GLuint));
+    (void) pState->pDispatchTbl->AreTexturesResident( n, textures, NULL );
+}
+
+
+void crUnpackExtendCompressedTexImage3DARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 32, int);
+
+    GLenum  target         = READ_DATA(pState, 4 + sizeof(int) +  0, GLenum );
+    GLint   level          = READ_DATA(pState, 4 + sizeof(int) +  4, GLint );
+    GLenum  internalformat = READ_DATA(pState, 4 + sizeof(int) +  8, GLenum );
+    GLsizei width          = READ_DATA(pState, 4 + sizeof(int) + 12, GLsizei );
+    GLsizei height         = READ_DATA(pState, 4 + sizeof(int) + 16, GLsizei );
+    GLsizei depth          = READ_DATA(pState, 4 + sizeof(int) + 20, GLsizei );
+    GLint   border         = READ_DATA(pState, 4 + sizeof(int) + 24, GLint );
+    GLsizei imagesize      = READ_DATA(pState, 4 + sizeof(int) + 28, GLsizei );
+    int     noimagedata        = READ_DATA(pState, 4 + sizeof(int) + 32, int );
+    GLvoid  *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+36, GLint);
+    if( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+36, GLint);
+    else
+    {
+        pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 40, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
+    }
+
+    pState->pDispatchTbl->CompressedTexImage3DARB(target, level, internalformat,
+                                              width, height, depth, border,
+                                              imagesize, pixels);
+}
+
+
+void crUnpackExtendCompressedTexImage2DARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 28, int);
+
+    GLenum target =         READ_DATA(pState, 4 + sizeof( int ) + 0, GLenum );
+    GLint level =           READ_DATA(pState, 4 + sizeof( int ) + 4, GLint );
+    GLenum internalformat = READ_DATA(pState, 4 + sizeof( int ) + 8, GLenum );
+    GLsizei width =         READ_DATA(pState, 4 + sizeof( int ) + 12, GLsizei );
+    GLsizei height =        READ_DATA(pState, 4 + sizeof( int ) + 16, GLsizei );
+    GLint border =          READ_DATA(pState, 4 + sizeof( int ) + 20, GLint );
+    GLsizei imagesize =     READ_DATA(pState, 4 + sizeof( int ) + 24, GLsizei );
+    int noimagedata =           READ_DATA(pState, 4 + sizeof( int ) + 28, int );
+    GLvoid *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+32, GLint);
+    if ( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+32, GLint);
+    else
+    {
+        pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 36, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
+    }
+
+    pState->pDispatchTbl->CompressedTexImage2DARB( target, level, internalformat,
+                                               width, height, border, imagesize,
+                                               pixels );
+}
+
+
+void crUnpackExtendCompressedTexImage1DARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 24, int);
+
+    GLenum  target         = READ_DATA(pState, 4 + sizeof(int) +  0, GLenum );
+    GLint   level          = READ_DATA(pState, 4 + sizeof(int) +  4, GLint );
+    GLenum  internalformat = READ_DATA(pState, 4 + sizeof(int) +  8, GLenum );
+    GLsizei width          = READ_DATA(pState, 4 + sizeof(int) + 12, GLsizei );
+    GLint   border         = READ_DATA(pState, 4 + sizeof(int) + 16, GLint );
+    GLsizei imagesize      = READ_DATA(pState, 4 + sizeof(int) + 20, GLsizei );
+    int     noimagedata        = READ_DATA(pState, 4 + sizeof(int) + 24, int );
+    GLvoid  *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+28, GLint);
+    if( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+28, GLint);
+    else
+    {
+        pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 32, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
+    }
+
+    pState->pDispatchTbl->CompressedTexImage1DARB(target, level, internalformat,
+                                              width, border, imagesize, pixels);
+}
+
+
+void crUnpackExtendCompressedTexSubImage3DARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 40, int);
+
+    GLenum  target    = READ_DATA(pState, 4 + sizeof(int) +  0, GLenum );
+    GLint   level     = READ_DATA(pState, 4 + sizeof(int) +  4, GLint );
+    GLint   xoffset   = READ_DATA(pState, 4 + sizeof(int) +  8, GLint );
+    GLint   yoffset   = READ_DATA(pState, 4 + sizeof(int) + 12, GLint );
+    GLint   zoffset   = READ_DATA(pState, 4 + sizeof(int) + 16, GLint );
+    GLsizei width     = READ_DATA(pState, 4 + sizeof(int) + 20, GLsizei );
+    GLsizei height    = READ_DATA(pState, 4 + sizeof(int) + 24, GLsizei );
+    GLsizei depth     = READ_DATA(pState, 4 + sizeof(int) + 28, GLsizei );
+    GLenum  format    = READ_DATA(pState, 4 + sizeof(int) + 32, GLenum );
+    GLsizei imagesize = READ_DATA(pState, 4 + sizeof(int) + 36, GLsizei );
+    int     noimagedata   = READ_DATA(pState, 4 + sizeof(int) + 40, int );
+    GLvoid  *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+44, GLint);
+    if( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+44, GLint);
+    else
+    {
+        pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 48, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
+    }
+
+    pState->pDispatchTbl->CompressedTexSubImage3DARB(target, level, xoffset,
+                                                 yoffset, zoffset, width,
+                                                 height, depth, format,
+                                                 imagesize, pixels);
+}
+
+
+void crUnpackExtendCompressedTexSubImage2DARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 32, int);
+
+    GLenum  target    = READ_DATA(pState, 4 + sizeof(int) +  0, GLenum );
+    GLint   level     = READ_DATA(pState, 4 + sizeof(int) +  4, GLint );
+    GLint   xoffset   = READ_DATA(pState, 4 + sizeof(int) +  8, GLint );
+    GLint   yoffset   = READ_DATA(pState, 4 + sizeof(int) + 12, GLint );
+    GLsizei width     = READ_DATA(pState, 4 + sizeof(int) + 16, GLsizei );
+    GLsizei height    = READ_DATA(pState, 4 + sizeof(int) + 20, GLsizei );
+    GLenum  format    = READ_DATA(pState, 4 + sizeof(int) + 24, GLenum );
+    GLsizei imagesize = READ_DATA(pState, 4 + sizeof(int) + 28, GLsizei );
+    int     noimagedata   = READ_DATA(pState, 4 + sizeof(int) + 32, int );
+    GLvoid  *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+36, GLint);
+    if( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+36, GLint);
+    else
+    {
+        pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 40, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
+    }
+
+    pState->pDispatchTbl->CompressedTexSubImage2DARB(target, level, xoffset,
+                                                 yoffset, width, height,
+                                                 format, imagesize, pixels);
+}
+
+
+void crUnpackExtendCompressedTexSubImage1DARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 4 + sizeof(int) + 24, int);
+
+    GLenum  target    = READ_DATA(pState, 4 + sizeof(int) +  0, GLenum );
+    GLint   level     = READ_DATA(pState, 4 + sizeof(int) +  4, GLint );
+    GLint   xoffset   = READ_DATA(pState, 4 + sizeof(int) +  8, GLint );
+    GLsizei width     = READ_DATA(pState, 4 + sizeof(int) + 12, GLsizei );
+    GLenum  format    = READ_DATA(pState, 4 + sizeof(int) + 16, GLenum );
+    GLsizei imagesize = READ_DATA(pState, 4 + sizeof(int) + 20, GLsizei );
+    int     noimagedata   = READ_DATA(pState, 4 + sizeof(int) + 24, int );
+    GLvoid  *pixels;
+
+    CHECK_BUFFER_SIZE_STATIC_UPDATE_LAST(pState, 4 + sizeof(int)+28, GLint);
+    if( noimagedata )
+        pixels = (void*) (uintptr_t) READ_DATA(pState, 4+sizeof(int)+28, GLint);
+    else
+    {
+        pixels = DATA_POINTER(pState, 4 + sizeof( int ) + 32, GLvoid );
+        CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pixels, imagesize, GLubyte);
+    }
+
+    pState->pDispatchTbl->CompressedTexSubImage1DARB(target, level, xoffset, width,
+                                                 format, imagesize, pixels);
+}
+
+void crUnpackExtendGetTexImage(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 32, CRNetworkPointer);
+
+    GLenum target = READ_DATA(pState, 8, GLenum );
+    GLint level   = READ_DATA(pState, 12, GLint );
+    GLenum format = READ_DATA(pState, 16, GLenum );
+    GLenum type   = READ_DATA(pState, 20, GLenum );
+    GLvoid *pixels;
+
+    SET_RETURN_PTR(pState, 24);
+    SET_WRITEBACK_PTR(pState, 32);
+    pixels = DATA_POINTER(pState, 24, GLvoid); /* Used for PBO offset. */
+
+    /*
+     * pixels is not written to, see crServerDispatchGetTexImage(). It is only used as an offset
+     * The data is returned in the writeback pointer set above.
+     */
+    pState->pDispatchTbl->GetTexImage(target, level, format, type, pixels);
+}
+
+void crUnpackExtendGetCompressedTexImageARB(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 24, CRNetworkPointer);
+
+    GLenum target = READ_DATA(pState, 8, GLenum );
+    GLint level   = READ_DATA(pState, 12, GLint );
+    GLvoid *img;
+
+    SET_RETURN_PTR(pState, 16 );
+    SET_WRITEBACK_PTR(pState, 24 );
+    img = DATA_POINTER(pState, 16, GLvoid); /* Used for PBO offset. */
+
+    /* see crUnpackExtendGetTexImage() for explanations regarding verification. */
+    pState->pDispatchTbl->GetCompressedTexImageARB( target, level, img );
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_visibleregion.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_visibleregion.c	(revision 78189)
+++ 	(revision )
@@ -1,37 +1,0 @@
-/* $Id$ */
-/** @file
- * VBox Packing VisibleRegion information
- */
-
-/*
- * Copyright (C) 2008-2019 Oracle Corporation
- *
- * This file is part of VirtualBox Open Source Edition (OSE), as
- * available from http://www.virtualbox.org. This file is free software;
- * you can redistribute it and/or modify it under the terms of the GNU
- * General Public License (GPL) as published by the Free Software
- * Foundation, in version 2 as it comes in the "COPYING" file of the
- * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
- * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
- */
-
-#include "unpacker.h"
-#include "cr_error.h"
-#include "cr_protocol.h"
-#include "cr_mem.h"
-#include "cr_version.h"
-
-void crUnpackExtendWindowVisibleRegion( void )
-{
-    GLint window = READ_DATA( 8, GLint );
-    GLint cRects = READ_DATA( 12, GLint );
-    GLvoid *pRects = DATA_POINTER( 16, GLvoid );
-
-    if (cRects <= 0 || cRects >= INT32_MAX / sizeof(GLint) / 8 || !DATA_POINTER_CHECK(16 + 4 * cRects * sizeof(GLint)))
-    {
-        crError("crUnpackExtendWindowVisibleRegion: parameter 'cRects' is out of range");
-        return;
-    }
-
-    cr_unpackDispatch.WindowVisibleRegion( window, cRects, pRects );
-}
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_visibleregion.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_visibleregion.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_visibleregion.cpp	(revision 78190)
@@ -0,0 +1,41 @@
+/* $Id$ */
+/** @file
+ * VBox Packing VisibleRegion information
+ */
+
+/*
+ * Copyright (C) 2008-2019 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+
+#include "unpacker.h"
+#include "cr_error.h"
+#include "cr_protocol.h"
+#include "cr_mem.h"
+#include "cr_version.h"
+
+void crUnpackExtendWindowVisibleRegion(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 12, GLint);
+
+    GLint window = READ_DATA(pState, 8, GLint );
+    GLint cRects = READ_DATA(pState, 12, GLint );
+    GLvoid *pRects = DATA_POINTER(pState, 16, GLvoid );
+
+    if (cRects <= 0 || cRects >= INT32_MAX / sizeof(GLint) / 8)
+    {
+        crError("crUnpackExtendWindowVisibleRegion: parameter 'cRects' is out of range");
+        return;
+    }
+
+    CHECK_ARRAY_SIZE_FROM_PTR_UPDATE_LAST(pState, pRects, cRects * 4, GLint);
+
+    pState->pDispatchTbl->WindowVisibleRegion( window, cRects, (GLint *)pRects );
+}
Index: unk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_writeback.c
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_writeback.c	(revision 78189)
+++ 	(revision )
@@ -1,35 +1,0 @@
-/* Copyright (c) 2001, Stanford University
- * All rights reserved
- *
- * See the file LICENSE.txt for information on redistributing this software.
- */
-
-#include "unpacker.h"
-#include "cr_error.h"
-#include <stdio.h>
-
-CRNetworkPointer *return_ptr = NULL, *writeback_ptr = NULL;
-
-void crUnpackSetReturnPointer( CRNetworkPointer *ret )
-{
-	return_ptr = ret;
-}
-
-void crUnpackSetWritebackPointer( CRNetworkPointer *wri )
-{
-	writeback_ptr = wri;
-}
-
-void crUnpackExtendWriteback(void)
-{
-	/* This copies the unpack buffer's CRNetworkPointer to writeback_ptr */
-	SET_WRITEBACK_PTR( 8 );
-	cr_unpackDispatch.Writeback( NULL );
-}
-
-#if 0
-void crUnpackWriteback(void)
-{
-	crError( "crUnpackWriteback should never be called" );
-}
-#endif
Index: /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_writeback.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_writeback.cpp	(revision 78190)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_writeback.cpp	(revision 78190)
@@ -0,0 +1,25 @@
+/* Copyright (c) 2001, Stanford University
+ * All rights reserved
+ *
+ * See the file LICENSE.txt for information on redistributing this software.
+ */
+
+#include "unpacker.h"
+#include "cr_error.h"
+#include <stdio.h>
+
+void crUnpackExtendWriteback(PCrUnpackerState pState)
+{
+    CHECK_BUFFER_SIZE_STATIC_LAST(pState, 8, CRNetworkPointer);
+
+	/* This copies the unpack buffer's CRNetworkPointer to writeback_ptr */
+	SET_WRITEBACK_PTR(pState, 8 );
+	pState->pDispatchTbl->Writeback( NULL );
+}
+
+#if 0
+void crUnpackWriteback(void)
+{
+	crError( "crUnpackWriteback should never be called" );
+}
+#endif
