Index: /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp	(revision 54788)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp	(revision 54789)
@@ -847,5 +847,5 @@
     PVMSVGA3DCONTEXT       *papContexts;
     uint32_t                cSurfaces;
-    PVMSVGA3DSURFACE        paSurface;
+    PVMSVGA3DSURFACE       *papSurfaces;
 #ifdef DEBUG_GFX_WINDOW_TEST_CONTEXT
     uint32_t                idTestContext;
@@ -900,5 +900,5 @@
     SSMFIELD_ENTRY_IGN_HCPTR(       VMSVGA3DSTATE, papContexts),
     SSMFIELD_ENTRY(                 VMSVGA3DSTATE, cSurfaces),
-    SSMFIELD_ENTRY_IGN_HCPTR(       VMSVGA3DSTATE, paSurface),
+    SSMFIELD_ENTRY_IGN_HCPTR(       VMSVGA3DSTATE, papSurfaces),
     SSMFIELD_ENTRY_TERM()
 };
@@ -1825,6 +1825,6 @@
     for (uint32_t i = 0; i < pState->cSurfaces; i++)
     {
-        if (pState->paSurface[i].id != SVGA3D_INVALID_ID)
-            vmsvga3dSurfaceDestroy(pThis, pState->paSurface[i].id);
+        if (pState->papSurfaces[i]->id != SVGA3D_INVALID_ID)
+            vmsvga3dSurfaceDestroy(pThis, pState->papSurfaces[i]->id);
     }
 
@@ -2627,18 +2627,23 @@
     if (sid >= pState->cSurfaces)
     {
-        void *pvNew = RTMemRealloc(pState->paSurface, sizeof(VMSVGA3DSURFACE) * (sid + 1));
+        /* Grow the array. */
+        uint32_t cNew = RT_ALIGN(sid + 15, 16);
+        void *pvNew = RTMemRealloc(pState->papSurfaces, sizeof(pState->papSurfaces[0]) * cNew);
         AssertReturn(pvNew, VERR_NO_MEMORY);
-        pState->paSurface = (PVMSVGA3DSURFACE)pvNew;
-        memset(&pState->paSurface[pState->cSurfaces], 0, sizeof(VMSVGA3DSURFACE) * (sid + 1 - pState->cSurfaces));
-        for (uint32_t i = pState->cSurfaces; i < sid + 1; i++)
-            pState->paSurface[i].id = SVGA3D_INVALID_ID;
-
-        pState->cSurfaces = sid + 1;
-    }
+        pState->papSurfaces = (PVMSVGA3DSURFACE *)pvNew;
+        while (pState->cSurfaces < cNew)
+        {
+            pSurface = (PVMSVGA3DSURFACE)RTMemAllocZ(sizeof(*pSurface));
+            AssertReturn(pSurface, VERR_NO_MEMORY);
+            pSurface->id = SVGA3D_INVALID_ID;
+            pState->papSurfaces[pState->cSurfaces++] = pSurface;
+        }
+    }
+    pSurface = pState->papSurfaces[sid];
+
     /* If one already exists with this id, then destroy it now. */
-    if (pState->paSurface[sid].id != SVGA3D_INVALID_ID)
+    if (pSurface->id != SVGA3D_INVALID_ID)
         vmsvga3dSurfaceDestroy(pThis, sid);
 
-    pSurface = &pState->paSurface[sid];
     memset(pSurface, 0, sizeof(*pSurface));
     pSurface->id                    = sid;
@@ -2804,7 +2809,7 @@
 
     if (    sid < pState->cSurfaces
-        &&  pState->paSurface[sid].id == sid)
-    {
-        PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid];
+        &&  pState->papSurfaces[sid]->id == sid)
+    {
+        PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
         PVMSVGA3DCONTEXT pContext;
 
@@ -2926,7 +2931,7 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(sidSrc < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sidSrc < pState->cSurfaces && pState->paSurface[sidSrc].id == sidSrc, VERR_INVALID_PARAMETER);
+    AssertReturn(sidSrc < pState->cSurfaces && pState->papSurfaces[sidSrc]->id == sidSrc, VERR_INVALID_PARAMETER);
     AssertReturn(sidDest < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sidDest < pState->cSurfaces && pState->paSurface[sidDest].id == sidDest, VERR_INVALID_PARAMETER);
+    AssertReturn(sidDest < pState->cSurfaces && pState->papSurfaces[sidDest]->id == sidDest, VERR_INVALID_PARAMETER);
 
     for (uint32_t i = 0; i < cCopyBoxes; i++)
@@ -3170,10 +3175,10 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(sidSrc < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sidSrc < pState->cSurfaces && pState->paSurface[sidSrc].id == sidSrc, VERR_INVALID_PARAMETER);
+    AssertReturn(sidSrc < pState->cSurfaces && pState->papSurfaces[sidSrc]->id == sidSrc, VERR_INVALID_PARAMETER);
     AssertReturn(sidDest < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sidDest < pState->cSurfaces && pState->paSurface[sidDest].id == sidDest, VERR_INVALID_PARAMETER);
-
-    pSurfaceSrc  = &pState->paSurface[sidSrc];
-    pSurfaceDest = &pState->paSurface[sidDest];
+    AssertReturn(sidDest < pState->cSurfaces && pState->papSurfaces[sidDest]->id == sidDest, VERR_INVALID_PARAMETER);
+
+    pSurfaceSrc  = pState->papSurfaces[sidSrc];
+    pSurfaceDest = pState->papSurfaces[sidDest];
     AssertReturn(pSurfaceSrc->faces[0].numMipLevels > src.mipmap, VERR_INVALID_PARAMETER);
     AssertReturn(pSurfaceDest->faces[0].numMipLevels > dest.mipmap, VERR_INVALID_PARAMETER);
@@ -3395,7 +3400,7 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sid < pState->cSurfaces && pState->paSurface[sid].id == sid, VERR_INVALID_PARAMETER);
-
-    pSurface = &pState->paSurface[sid];
+    AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
+
+    pSurface = pState->papSurfaces[sid];
     AssertReturn(pSurface->faces[0].numMipLevels > host.mipmap, VERR_INVALID_PARAMETER);
     pMipLevel = &pSurface->pMipmapLevels[host.mipmap];
@@ -3808,7 +3813,7 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sid < pState->cSurfaces && pState->paSurface[sid].id == sid, VERR_INVALID_PARAMETER);
-
-    pSurface = &pState->paSurface[sid];
+    AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
+
+    pSurface = pState->papSurfaces[sid];
 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX
     AssertReturn(pSurface->idAssociatedContext != SVGA3D_INVALID_ID, VERR_INTERNAL_ERROR);
@@ -3887,7 +3892,7 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sid < pState->cSurfaces && pState->paSurface[sid].id == sid, VERR_INVALID_PARAMETER);
-
-    pSurface = &pState->paSurface[sid];
+    AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
+
+    pSurface = pState->papSurfaces[sid];
 #ifndef VMSVGA3D_OGL_WITH_SHARED_CTX
     AssertReturn(pSurface->idAssociatedContext != SVGA3D_INVALID_ID, VERR_INTERNAL_ERROR);
@@ -4553,5 +4558,5 @@
         for (uint32_t sid = 0; sid < pState->cSurfaces; sid++)
         {
-            PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid];
+            PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
             if (    pSurface->idAssociatedContext == cid
                 &&  pSurface->id == sid)
@@ -5813,6 +5818,6 @@
 
     AssertReturn(target.sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(target.sid < pState->cSurfaces && pState->paSurface[target.sid].id == target.sid, VERR_INVALID_PARAMETER);
-    pRenderTarget = &pState->paSurface[target.sid];
+    AssertReturn(target.sid < pState->cSurfaces && pState->papSurfaces[target.sid]->id == target.sid, VERR_INVALID_PARAMETER);
+    pRenderTarget = pState->papSurfaces[target.sid];
 
     switch (type)
@@ -6187,7 +6192,7 @@
 
                 AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-                AssertReturn(sid < pState->cSurfaces && pState->paSurface[sid].id == sid, VERR_INVALID_PARAMETER);
-
-                PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid];
+                AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
+
+                PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
 
                 Log(("SVGA3D_TS_BIND_TEXTURE: stage %d, texture surface id=%x (%d,%d) replacing=%x\n",
@@ -6940,7 +6945,7 @@
 
     AssertReturn(sidVertex < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sidVertex < pState->cSurfaces && pState->paSurface[sidVertex].id == sidVertex, VERR_INVALID_PARAMETER);
-
-    pVertexSurface = &pState->paSurface[sidVertex];
+    AssertReturn(sidVertex < pState->cSurfaces && pState->papSurfaces[sidVertex]->id == sidVertex, VERR_INVALID_PARAMETER);
+
+    pVertexSurface = pState->papSurfaces[sidVertex];
     Log(("vmsvga3dDrawPrimitives: vertex surface %x\n", sidVertex));
 
@@ -7203,5 +7208,5 @@
         if (pContext->sidRenderTarget != SVGA_ID_INVALID)
         {
-            PVMSVGA3DSURFACE pRenderTarget = &pState->paSurface[pContext->sidRenderTarget];
+            PVMSVGA3DSURFACE pRenderTarget = pState->papSurfaces[pContext->sidRenderTarget];
             rtHeight = pRenderTarget->pMipmapLevels[0].size.height;
         }
@@ -7254,12 +7259,12 @@
             if (    sidIndex >= SVGA3D_MAX_SURFACE_IDS
                 ||  sidIndex >= pState->cSurfaces
-                ||  pState->paSurface[sidIndex].id != sidIndex)
+                ||  pState->papSurfaces[sidIndex]->id != sidIndex)
             {
                 Assert(sidIndex < SVGA3D_MAX_SURFACE_IDS);
-                Assert(sidIndex < pState->cSurfaces && pState->paSurface[sidIndex].id == sidIndex);
+                Assert(sidIndex < pState->cSurfaces && pState->papSurfaces[sidIndex]->id == sidIndex);
                 rc = VERR_INVALID_PARAMETER;
                 goto internal_error;
             }
-            pIndexSurface = &pState->paSurface[sidIndex];
+            pIndexSurface = pState->papSurfaces[sidIndex];
             Log(("vmsvga3dDrawPrimitives: index surface %x\n", sidIndex));
 
@@ -7389,10 +7394,10 @@
             {
                 PVMSVGA3DSURFACE pTexture;
-                pTexture = &pState->paSurface[pContext->aSidActiveTexture[activeTextureUnit - GL_TEXTURE0]];
+                pTexture = pState->papSurfaces[pContext->aSidActiveTexture[activeTextureUnit - GL_TEXTURE0]];
 
                 AssertMsg(pTexture->oglId.texture == (GLuint)activeTexture, ("%x vs %x unit %d - %d\n", pTexture->oglId.texture, activeTexture, i, activeTextureUnit - GL_TEXTURE0));
             }
 # else
-            PVMSVGA3DSURFACE pTexture = &pState->paSurface[pContext->aSidActiveTexture[i]];
+            PVMSVGA3DSURFACE pTexture = pState->papSurfaces[pContext->aSidActiveTexture[i]];
             AssertMsg(pTexture->id == pContext->aSidActiveTexture[i], ("%x vs %x\n", pTexture->id == pContext->aSidActiveTexture[i]));
             AssertMsg(pTexture->oglId.texture == (GLuint)activeTexture,
Index: /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.h
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.h	(revision 54788)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-shared.h	(revision 54789)
@@ -207,5 +207,5 @@
             }
 
-            PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid];
+            PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
             Assert(pSurface->id == sid);
 
@@ -436,5 +436,5 @@
     for (uint32_t sid = 0; sid < pState->cSurfaces; sid++)
     {
-        PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid];
+        PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
 
         /* Save the id first. */
Index: /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp	(revision 54788)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp	(revision 54789)
@@ -343,10 +343,12 @@
     RTSEMEVENT              WndRequestSem;
 
-    /** The size of papContexts  */
+    /** The size of papContexts. */
     uint32_t                cContexts;
+    /** The size of papSurfaces. */
     uint32_t                cSurfaces;
     /** Contexts indexed by ID.  Grown as needed. */
     PVMSVGA3DCONTEXT       *papContexts;
-    PVMSVGA3DSURFACE        paSurface;
+    /** Surfaces indexed by ID.  Grown as needed. */
+    PVMSVGA3DSURFACE       *papSurfaces;
 
     bool                    fSupportedSurfaceINTZ;
@@ -369,5 +371,5 @@
     SSMFIELD_ENTRY(                 VMSVGA3DSTATE, cSurfaces),
     SSMFIELD_ENTRY_IGN_HCPTR(       VMSVGA3DSTATE, papContexts),
-    SSMFIELD_ENTRY_IGN_HCPTR(       VMSVGA3DSTATE, paSurface),
+    SSMFIELD_ENTRY_IGN_HCPTR(       VMSVGA3DSTATE, papSurfaces),
     SSMFIELD_ENTRY_IGNORE(          VMSVGA3DSTATE, fSupportedSurfaceINTZ),
     SSMFIELD_ENTRY_IGNORE(          VMSVGA3DSTATE, fSupportedSurfaceNULL),
@@ -595,6 +597,6 @@
     for (uint32_t i = 0; i < pState->cSurfaces; i++)
     {
-        if (pState->paSurface[i].id != SVGA3D_INVALID_ID)
-            vmsvga3dSurfaceDestroy(pThis, pState->paSurface[i].id);
+        if (pState->papSurfaces[i]->id != SVGA3D_INVALID_ID)
+            vmsvga3dSurfaceDestroy(pThis, pState->papSurfaces[i]->id);
     }
 
@@ -1400,18 +1402,23 @@
     if (sid >= pState->cSurfaces)
     {
-        void *pvNew = RTMemRealloc(pState->paSurface, sizeof(VMSVGA3DSURFACE) * (sid + 1));
+        /* Grow the array. */
+        uint32_t cNew = RT_ALIGN(sid + 15, 16);
+        void *pvNew = RTMemRealloc(pState->papSurfaces, sizeof(pState->papSurfaces[0]) * cNew);
         AssertReturn(pvNew, VERR_NO_MEMORY);
-        pState->paSurface = (PVMSVGA3DSURFACE)pvNew;
-        memset(&pState->paSurface[pState->cSurfaces], 0, sizeof(VMSVGA3DSURFACE) * (sid + 1 - pState->cSurfaces));
-        for (uint32_t i = pState->cSurfaces; i < sid + 1; i++)
-            pState->paSurface[i].id = SVGA3D_INVALID_ID;
-
-        pState->cSurfaces = sid + 1;
-    }
+        pState->papSurfaces = (PVMSVGA3DSURFACE *)pvNew;
+        while (pState->cSurfaces < cNew)
+        {
+            pSurface = (PVMSVGA3DSURFACE)RTMemAllocZ(sizeof(*pSurface));
+            AssertReturn(pSurface, VERR_NO_MEMORY);
+            pSurface->id = SVGA3D_INVALID_ID;
+            pState->papSurfaces[pState->cSurfaces++] = pSurface;
+        }
+    }
+    pSurface = pState->papSurfaces[sid];
+
     /* If one already exists with this id, then destroy it now. */
-    if (pState->paSurface[sid].id != SVGA3D_INVALID_ID)
+    if (pSurface->id != SVGA3D_INVALID_ID)
         vmsvga3dSurfaceDestroy(pThis, sid);
 
-    pSurface = &pState->paSurface[sid];
     memset(pSurface, 0, sizeof(*pSurface));
     pSurface->id                    = sid;
@@ -1611,7 +1618,7 @@
 
     if (    sid < pState->cSurfaces
-        &&  pState->paSurface[sid].id == sid)
-    {
-        PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid];
+        &&  pState->papSurfaces[sid]->id == sid)
+    {
+        PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
 
         Log(("vmsvga3dSurfaceDestroy id %x\n", sid));
@@ -1751,9 +1758,9 @@
 {
     PVMSVGA3DSTATE   pState = (PVMSVGA3DSTATE)pThis->svga.p3dState;
-    PVMSVGA3DSURFACE pSurface  = &pState->paSurface[sid];
+    PVMSVGA3DSURFACE pSurface  = pState->papSurfaces[sid];
     HRESULT          hr;
 
     AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sid < pState->cSurfaces && pState->paSurface[sid].id == sid, VERR_INVALID_PARAMETER);
+    AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
 
     /* Nothing to do if this surface hasn't been shared. */
@@ -1820,10 +1827,10 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(sidSrc < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sidSrc < pState->cSurfaces && pState->paSurface[sidSrc].id == sidSrc, VERR_INVALID_PARAMETER);
+    AssertReturn(sidSrc < pState->cSurfaces && pState->papSurfaces[sidSrc]->id == sidSrc, VERR_INVALID_PARAMETER);
     AssertReturn(sidDest < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sidDest < pState->cSurfaces && pState->paSurface[sidDest].id == sidDest, VERR_INVALID_PARAMETER);
-
-    pSurfaceSrc  = &pState->paSurface[sidSrc];
-    pSurfaceDest = &pState->paSurface[sidDest];
+    AssertReturn(sidDest < pState->cSurfaces && pState->papSurfaces[sidDest]->id == sidDest, VERR_INVALID_PARAMETER);
+
+    pSurfaceSrc  = pState->papSurfaces[sidSrc];
+    pSurfaceDest = pState->papSurfaces[sidDest];
 
     AssertReturn(pSurfaceSrc->faces[0].numMipLevels > src.mipmap, VERR_INVALID_PARAMETER);
@@ -2196,10 +2203,10 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(sidSrc < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sidSrc < pState->cSurfaces && pState->paSurface[sidSrc].id == sidSrc, VERR_INVALID_PARAMETER);
+    AssertReturn(sidSrc < pState->cSurfaces && pState->papSurfaces[sidSrc]->id == sidSrc, VERR_INVALID_PARAMETER);
     AssertReturn(sidDest < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sidDest < pState->cSurfaces && pState->paSurface[sidDest].id == sidDest, VERR_INVALID_PARAMETER);
-
-    pSurfaceSrc  = &pState->paSurface[sidSrc];
-    pSurfaceDest = &pState->paSurface[sidDest];
+    AssertReturn(sidDest < pState->cSurfaces && pState->papSurfaces[sidDest]->id == sidDest, VERR_INVALID_PARAMETER);
+
+    pSurfaceSrc  = pState->papSurfaces[sidSrc];
+    pSurfaceDest = pState->papSurfaces[sidDest];
     AssertReturn(pSurfaceSrc->faces[0].numMipLevels > src.mipmap, VERR_INVALID_PARAMETER);
     AssertReturn(pSurfaceDest->faces[0].numMipLevels > dest.mipmap, VERR_INVALID_PARAMETER);
@@ -2323,7 +2330,7 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sid < pState->cSurfaces && pState->paSurface[sid].id == sid, VERR_INVALID_PARAMETER);
-
-    pSurface = &pState->paSurface[sid];
+    AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
+
+    pSurface = pState->papSurfaces[sid];
     AssertReturn(pSurface->faces[0].numMipLevels > host.mipmap, VERR_INVALID_PARAMETER);
     pMipLevel = &pSurface->pMipmapLevels[host.mipmap];
@@ -2687,7 +2694,7 @@
             uint32_t            sid = src.sid;
             AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-            AssertReturn(sid < pState->cSurfaces && pState->paSurface[sid].id == sid, VERR_INVALID_PARAMETER);
-
-            pSurface = &pState->paSurface[sid];
+            AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
+
+            pSurface = pState->papSurfaces[sid];
             uint32_t            cid;
 
@@ -2730,7 +2737,7 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sid < pState->cSurfaces && pState->paSurface[sid].id == sid, VERR_INVALID_PARAMETER);
-
-    pSurface = &pState->paSurface[sid];
+    AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
+
+    pSurface = pState->papSurfaces[sid];
     AssertReturn(pSurface->idAssociatedContext != SVGA3D_INVALID_ID, VERR_INTERNAL_ERROR);
 
@@ -2794,7 +2801,7 @@
     AssertReturn(pState, VERR_NO_MEMORY);
     AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(sid < pState->cSurfaces && pState->paSurface[sid].id == sid, VERR_INVALID_PARAMETER);
-
-    pSurface = &pState->paSurface[sid];
+    AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
+
+    pSurface = pState->papSurfaces[sid];
     AssertReturn(pSurface->idAssociatedContext != SVGA3D_INVALID_ID, VERR_INTERNAL_ERROR);
 
@@ -3049,5 +3056,5 @@
         for (uint32_t sid = 0; sid < pState->cSurfaces; sid++)
         {
-            PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid];
+            PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
             if (    pSurface->id == sid
                 &&  pSurface->idAssociatedContext == cid)
@@ -3196,5 +3203,5 @@
             for (uint32_t sid = 0; sid < pState->cSurfaces; sid++)
             {
-                PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid];
+                PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
                 if (    pSurface->id == sid
                     &&  pSurface->idAssociatedContext == cid
@@ -4335,6 +4342,6 @@
 
     AssertReturn(target.sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-    AssertReturn(target.sid < pState->cSurfaces && pState->paSurface[target.sid].id == target.sid, VERR_INVALID_PARAMETER);
-    pRenderTarget = &pState->paSurface[target.sid];
+    AssertReturn(target.sid < pState->cSurfaces && pState->papSurfaces[target.sid]->id == target.sid, VERR_INVALID_PARAMETER);
+    pRenderTarget = pState->papSurfaces[target.sid];
 
     switch (type)
@@ -4822,7 +4829,7 @@
 
                 AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-                AssertReturn(sid < pState->cSurfaces && pState->paSurface[sid].id == sid, VERR_INVALID_PARAMETER);
-
-                PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid];
+                AssertReturn(sid < pState->cSurfaces && pState->papSurfaces[sid]->id == sid, VERR_INVALID_PARAMETER);
+
+                PVMSVGA3DSURFACE pSurface = pState->papSurfaces[sid];
 
                 Log(("SVGA3D_TS_BIND_TEXTURE: stage %d, texture surface id=%x (%d,%d)\n", currentStage, pTextureState[i].value, pSurface->pMipmapLevels[0].size.width, pSurface->pMipmapLevels[0].size.height));
@@ -5295,7 +5302,7 @@
 
         AssertReturn(sidVertex < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
-        AssertReturn(sidVertex < pState->cSurfaces && pState->paSurface[sidVertex].id == sidVertex, VERR_INVALID_PARAMETER);
-
-        pVertexSurface = &pState->paSurface[sidVertex];
+        AssertReturn(sidVertex < pState->cSurfaces && pState->papSurfaces[sidVertex]->id == sidVertex, VERR_INVALID_PARAMETER);
+
+        pVertexSurface = pState->papSurfaces[sidVertex];
         Log(("vmsvga3dDrawPrimitives: vertex surface %x stream %d\n", sidVertex, idStream));
         Log(("vmsvga3dDrawPrimitives: type=%s (%d) method=%s (%d) usage=%s (%d) usageIndex=%d stride=%d offset=%d\n", vmsvgaDeclType2String(pVertexDecl[iVertex].identity.type), pVertexDecl[iVertex].identity.type, vmsvgaDeclMethod2String(pVertexDecl[iVertex].identity.method), pVertexDecl[iVertex].identity.method, vmsvgaDeclUsage2String(pVertexDecl[iVertex].identity.usage), pVertexDecl[iVertex].identity.usage, pVertexDecl[iVertex].identity.usageIndex, pVertexDecl[iVertex].array.stride, pVertexDecl[iVertex].array.offset));
@@ -5367,5 +5374,5 @@
     unsigned         strideVertex = pVertexDecl[0].array.stride;
 
-    pVertexSurface = &pState->paSurface[sidVertex];
+    pVertexSurface = pState->papSurfaces[sidVertex];
 
     Log(("vmsvga3dDrawPrimitives: SetStreamSource %d min offset=%d stride=%d\n", idStream, uVertexMinOffset, strideVertex));
@@ -5505,12 +5512,12 @@
             if (    sidIndex >= SVGA3D_MAX_SURFACE_IDS
                 ||  sidIndex >= pState->cSurfaces
-                ||  pState->paSurface[sidIndex].id != sidIndex)
+                ||  pState->papSurfaces[sidIndex]->id != sidIndex)
             {
                 Assert(sidIndex < SVGA3D_MAX_SURFACE_IDS);
-                Assert(sidIndex < pState->cSurfaces && pState->paSurface[sidIndex].id == sidIndex);
+                Assert(sidIndex < pState->cSurfaces && pState->papSurfaces[sidIndex]->id == sidIndex);
                 rc = VERR_INVALID_PARAMETER;
                 goto internal_error;
             }
-            pIndexSurface = &pState->paSurface[sidIndex];
+            pIndexSurface = pState->papSurfaces[sidIndex];
             Log(("vmsvga3dDrawPrimitives: index surface %x\n", sidIndex));
 
@@ -5567,5 +5574,5 @@
         unsigned         strideVertex = pVertexDecl[0].array.stride;
 
-        pVertexSurface = &pState->paSurface[sidVertex];
+        pVertexSurface = pState->papSurfaces[sidVertex];
 
         if (!pIndexSurface)
